From: Hans F. <fu...@us...> - 2004-07-02 17:39:36
|
Update of /cvsroot/neelix/neelix/view/qt In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25218/view/qt Modified Files: qt.rb Log Message: Everything seems to be working with one exception. There's a bug regarding moving ingredients that I haven't pinned down yet. Sometimes the ingredient goes off into limbo (in the db, but not on screen, so you have to restart), but other times it doesn't. Once that bug is fixed, we're ready to clean up and package it 0.1.0! Index: qt.rb =================================================================== RCS file: /cvsroot/neelix/neelix/view/qt/qt.rb,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- qt.rb 30 Jun 2004 14:34:06 -0000 1.7 +++ qt.rb 2 Jul 2004 17:39:28 -0000 1.8 @@ -7,13 +7,21 @@ end class Neelix + slots 'ingredient_moved(int,int,int)' + def postinitialize(app) @app = app - build_shelf + @counterStack.enabled = false - @shelf.currentItem = @shelf.firstChild - @ingredients_table.rowMovingEnabled = false + + @ingredients_table.rowMovingEnabled = true @ingredients_table.columnMovingEnabled = false + Qt::Object.connect( + @ingredients_table.verticalHeader, SIGNAL("indexChange(int,int,int)"), + self, SLOT("ingredient_moved(int,int,int)")) + + build_shelf + @shelf.currentItem = @shelf.firstChild shelf_currentChanged end def build_shelf @@ -51,7 +59,6 @@ @ingredients_table.numRows = r.ingredients.size 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) @@ -126,8 +133,10 @@ m = Presenter::findCreateMeasure("") f = Presenter::findCreateFood("") i = $replicator.create('ingredient', - {'recipe_id',r.id, 'quantity','', 'measure_id',m.id, + {'recipe_id',r.id, 'quantity',nil, 'measure_id',m.id, 'food_id',f.id, 'modifier',nil}) + r.ingredients.insert(@ingredients_table.currentRow+1, i) + r.ingredients.pop refresh_recipe(r) end @@ -220,6 +229,21 @@ end end + # assumption: @shelf.currentItem.data === Recipe + def ingredient_moved(section,fromIndex,toIndex) + r = @shelf.currentItem.data + + ary = r.ingredients + puts "from #{fromIndex} to #{toIndex}" + + if toIndex >= ary.size + ary << ary.delete_at(fromIndex) + else + ary.insert(toIndex, ary.delete_at(fromIndex)) + end + puts r.ingredients + end + def recipename_changed(text) @shelf.currentItem.data.name = text end |