More Mengen
August 24th, 2007 Pekk
Today I worked some more on MenGen, The Menu Generator program I’ve been working on for school. After trying to implement some features and callback (or as QT calls them, “slot”) routines I took a pass over my code. Seeing as it was very messy and the lines of code showed a lot of repetition I decided to make some functions.
Here’s some stuff I added today:
- MG_ERR_ID_EXISTS macro — This macro displays a QMessageBox::critical() message. Saying that the ID you’ve entered in the ID box for your new item is already in use, and you must change it. It also changes the background color of the ID text field to a light red (#FAA) and sets focus to it, to make this more apparent to the user that they must change it. I had to use it in several spots so I wanted to insure that I would be able quickly change the message if needed.
- txtID_enter(void) slot function — I added this function, and altered the enter slot functions of the other text fields, to make sure that when you hit the enter key in one field, it will tab to the next automatically. Hitting enter in the bottom box inserts the data by calling the new addItem() function (which was also added today) and focus is set back to the top, so holding down enter will spin you in a loop between the text fields.
- addItem() private function — two of these were added, one to overload the other. Unfortunately for now I don’t know any other way of doing this, so this function’s exact contents exist twice. Since this functions first parameter is its parent object, I had to make one function to support a QTreeWidget* parent and one to support a QTreeWidgetItem parent.
- The addItem() function also adds new IDs to the Style Target combo box.
- The removeItem() function now searches and removes any IDs contained in the selected tree widget pending deletion, and removes it from the Style Target combo box.
- Updated the titlebar caption for the GUI. It no longer says “MainWindow”
I’ve actually added stuff since my last post about Mengen but I forgot to blog it, so for now I’ll say that currently you can add items to the list of Menu items, and remove them, add child nodes and the remove function will delete the nodes recursively (if you select “yes” to a prompt asking to delete children). Selecting an item in the list causes the information to be tossed back into the text fields where you may edit and “update” the entries.
During my last MenGen session I tried to create a generateXHTML() routine which will generate all of the XHTML for the entire tree structure (giving only XHTML which is used for the list items and links, etc…) but I was getting some bus errors, which I’m still unable to resolve. I also created an xmlLine() routine which assists the generateXHTML() by actually generating the XHTML with the right information; it is now generateXHTML()’s responsibility to traverse the tree structure and call xmlLine() on each node.
At present I’m going to work around the bus error bug, ignoring it, until Monday comes and I consult with my professor at school for some assistance on the matter.
That’s really all that’s new so far… So I’ll post some screenshots
Posted in MenGen, Programming | No Comments »