From: Hans F. <fu...@us...> - 2004-06-25 04:27:27
|
Update of /cvsroot/neelix/neelix/view/qt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9681/view/qt Modified Files: mw.ui qt.rb Log Message: Adding stuff (except ingredient) works Index: mw.ui =================================================================== RCS file: /cvsroot/neelix/neelix/view/qt/mw.ui,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- mw.ui 25 Jun 2004 02:45:31 -0000 1.4 +++ mw.ui 25 Jun 2004 04:27:18 -0000 1.5 @@ -9,7 +9,7 @@ <x>0</x> <y>0</y> <width>747</width> - <height>528</height> + <height>531</height> </rect> </property> <property name="caption"> @@ -339,6 +339,14 @@ <separator/> <action name="fileExitAction"/> </item> + <item text="&Edit" name="unnamed"> + <action name="editAdd_CookbookAction"/> + <action name="editAdd_CategoryAction"/> + <action name="editAdd_RecipeAction"/> + <action name="editAdd_IngredientAction"/> + <separator/> + <action name="editDeleteAction"/> + </item> <item text="&Help" name="helpMenu"> <action name="helpAboutAction"/> </item> @@ -422,6 +430,58 @@ <string></string> </property> </action> + <action> + <property name="name"> + <cstring>editAdd_CookbookAction</cstring> + </property> + <property name="text"> + <string>Add C&ookbook</string> + </property> + </action> + <action> + <property name="name"> + <cstring>editAdd_CategoryAction</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Add C&ategory</string> + </property> + </action> + <action> + <property name="name"> + <cstring>editAdd_RecipeAction</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Add &Recipe</string> + </property> + </action> + <action> + <property name="name"> + <cstring>editAdd_IngredientAction</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>Add &Ingredient</string> + </property> + </action> + <action> + <property name="name"> + <cstring>editDeleteAction</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>&Delete</string> + </property> + </action> </actions> <images> <image name="image0"> @@ -513,6 +573,42 @@ <receiver>Neelix</receiver> <slot>ingredient_changed(int,int)</slot> </connection> + <connection> + <sender>editDeleteAction</sender> + <signal>activated()</signal> + <receiver>Neelix</receiver> + <slot>editDelete()</slot> + </connection> + <connection> + <sender>editAdd_CookbookAction</sender> + <signal>activated()</signal> + <receiver>Neelix</receiver> + <slot>editAdd_Cookbook()</slot> + </connection> + <connection> + <sender>editAdd_CategoryAction</sender> + <signal>activated()</signal> + <receiver>Neelix</receiver> + <slot>editAdd_Category()</slot> + </connection> + <connection> + <sender>editAdd_RecipeAction</sender> + <signal>activated()</signal> + <receiver>Neelix</receiver> + <slot>editAdd_Recipe()</slot> + </connection> + <connection> + <sender>editAdd_IngredientAction</sender> + <signal>activated()</signal> + <receiver>Neelix</receiver> + <slot>editAdd_Ingredient()</slot> + </connection> + <connection> + <sender>fileNewAction</sender> + <signal>activated()</signal> + <receiver>Neelix</receiver> + <slot>fileNew()</slot> + </connection> </connections> <tabstops> <tabstop>shelf</tabstop> @@ -537,8 +633,14 @@ <slot>yields_changed(const QString&)</slot> <slot>directions_changed()</slot> <slot>note_changed(const QString&)</slot> - <slot>author_changed(const QString &)</slot> + <slot>editDelete()</slot> <slot>note_changed()</slot> + <slot>editAdd_Category()</slot> + <slot>editAdd_Cookbook()</slot> + <slot>editAdd_Ingredient()</slot> + <slot>editAdd_Recipe()</slot> + <slot>author_changed(const QString&)</slot> + <slot>fileNew()</slot> </slots> <layoutdefaults spacing="6" margin="11"/> </UI> Index: qt.rb =================================================================== RCS file: /cvsroot/neelix/neelix/view/qt/qt.rb,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- qt.rb 25 Jun 2004 02:45:31 -0000 1.4 +++ qt.rb 25 Jun 2004 04:27:18 -0000 1.5 @@ -9,6 +9,7 @@ class Neelix def postinitialize build_shelf + @counterStack.enabled = false @shelf.currentItem = @shelf.firstChild end def build_shelf @@ -62,9 +63,59 @@ end end + # TODO + # fileNew + # fileOpen + # fileSaveAs + # editAdd_Ingredient + # editDelete + def fileExit $qApp.quit end + def editAdd_Cookbook + c = $replicator.create('cookbook',{'name',"New Cookbook"}) + # FIXME hmm, next 4 lines are duplicate code from build_shelf. + # what we really want is a synctree function like in the abandoned fxruby + # code + i = Qt::ListViewItem.new(@shelf,c.name) + i.data = c + i.open = true + i.setRenameEnabled(0,true) + @shelf.currentItem = i + i.startRename(0) + end + # assumption: @shelf.currentItem.data === Cookbook + def editAdd_Category + o = @shelf.currentItem.data + a = $replicator.create('category', + {'cookbook_id',o.id,'name',"New Category"}) + # FIXME hmm, next 4 lines are duplicate code from build_shelf. + # what we really want is a synctree function like in the abandoned fxruby + # code + i = Qt::ListViewItem.new(@shelf.currentItem,a.name) + i.data = a + i.open = true + i.setRenameEnabled(0,true) + @shelf.currentItem = i + i.startRename(0) + end + # assumption: @shelf.currentItem.data === Category + def editAdd_Recipe + a = @shelf.currentItem.data + r = $replicator.create('recipe', {'name',"New Recipe"}) + a.recipes << r + # FIXME hmm, next 4 lines are duplicate code from build_shelf. + # what we really want is a synctree function like in the abandoned fxruby + # code + i = Qt::ListViewItem.new(@shelf.currentItem,r.name) + i.data = r + i.open = true + i.setRenameEnabled(0,true) + @shelf.currentItem = i + @recipe_entry.setFocus + @recipe_entry.selectAll + end def helpAbout AboutDialog.new.exec end @@ -72,13 +123,31 @@ def shelf_currentChanged i = @shelf.currentItem.data self.counter_currentItem = i + + # counterStack enabled or disabled? + # enable/disable menu items case i when Cookbook @counterStack.enabled = false + + @editAdd_CookbookAction.enabled = true + @editAdd_CategoryAction.enabled = true + @editAdd_RecipeAction.enabled = false + @editAdd_IngredientAction.enabled = false when Category @counterStack.enabled = false + + @editAdd_CookbookAction.enabled = true + @editAdd_CategoryAction.enabled = false + @editAdd_RecipeAction.enabled = true + @editAdd_IngredientAction.enabled = false when Recipe @counterStack.enabled = true + + @editAdd_CookbookAction.enabled = true + @editAdd_CategoryAction.enabled = false + @editAdd_RecipeAction.enabled = false + @editAdd_IngredientAction.enabled = true end end def shelf_item_renamed(item,col,text) |