From: Hans F. <fu...@us...> - 2004-06-30 14:34:17
|
Update of /cvsroot/neelix/neelix/view/qt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5558/view/qt Modified Files: mw.ui qt.rb Log Message: Can delete ingredients. Still working on proper add ingredient. It adds now, but just to the end of the list. I'd like it to add to after the current item. More important would be allowing reordering, then adding to the end isn't such a big deal. Both require the swapping idiom which is currently broken I think. See the bug on the bug tracker. http://sourceforge.net/tracker/index.php?func=detail&aid=982778&group_id=93954&atid=606159 Index: mw.ui =================================================================== RCS file: /cvsroot/neelix/neelix/view/qt/mw.ui,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- mw.ui 29 Jun 2004 14:24:07 -0000 1.6 +++ mw.ui 30 Jun 2004 14:34:06 -0000 1.7 @@ -9,7 +9,7 @@ <x>0</x> <y>0</y> <width>747</width> - <height>537</height> + <height>540</height> </rect> </property> <property name="caption"> Index: qt.rb =================================================================== RCS file: /cvsroot/neelix/neelix/view/qt/qt.rb,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- qt.rb 29 Jun 2004 14:24:07 -0000 1.6 +++ qt.rb 30 Jun 2004 14:34:06 -0000 1.7 @@ -7,10 +7,13 @@ end class Neelix - def postinitialize + def postinitialize(app) + @app = app build_shelf @counterStack.enabled = false @shelf.currentItem = @shelf.firstChild + @ingredients_table.rowMovingEnabled = false + @ingredients_table.columnMovingEnabled = false shelf_currentChanged end def build_shelf @@ -47,7 +50,8 @@ @yields_entry.text = r.yields @ingredients_table.numRows = r.ingredients.size - r.ingredients.each_with_index do |ing,j| + r.ingredients.sort.each_with_index do |ing,j| + puts "#{ing}, #{j}" @ingredients_table.setText(j,0,ing.quantity.to_s) @ingredients_table.setText(j,1,ing.measure.to_s) @ingredients_table.setText(j,2,ing.food.to_s) @@ -68,7 +72,6 @@ # fileNew # fileOpen # fileSaveAs - # editAdd_Ingredient # exit def fileExit @@ -117,10 +120,30 @@ @recipe_entry.setFocus @recipe_entry.selectAll end + # assumption: @shelf.currentItem.data === Recipe + def editAdd_Ingredient + r = @shelf.currentItem.data + m = Presenter::findCreateMeasure("") + f = Presenter::findCreateFood("") + i = $replicator.create('ingredient', + {'recipe_id',r.id, 'quantity','', 'measure_id',m.id, + 'food_id',f.id, 'modifier',nil}) + + refresh_recipe(r) + end def editDelete i = @shelf.currentItem d = i.data + if @app.focusWidget == @ingredients_table + return if @ingredients_table.numRows < 1 + r = d + row = @ingredients_table.currentRow + Presenter::deleteIngredient(r,row) + refresh_recipe(r) + return + end + case d when Cookbook Presenter::deleteCookbook(d) @@ -214,15 +237,16 @@ text = @ingredients_table.text(row,col) case col when 0 # quantity - recipe.ingredients[row].quantity = text + recipe.ingredients.sort[row].quantity = text when 1 # measure - recipe.ingredients[row].measure = Presenter::findCreateMeasure(text) + recipe.ingredients.sort[row].measure = Presenter::findCreateMeasure(text) when 2 # food - recipe.ingredients[row].food = Presenter::findCreateFood(text) + recipe.ingredients.sort[row].food = Presenter::findCreateFood(text) when 3 # modifier - recipe.ingredients[row].modifier = text + recipe.ingredients.sort[row].modifier = text end adjust_columns + refresh_recipe(recipe) end def directions_changed() @shelf.currentItem.data.directions = @directions_edit.text @@ -234,7 +258,7 @@ a = Qt::Application.new(ARGV) w = Neelix.new -w.postinitialize +w.postinitialize(a) w.resize(800,600) # run |