Update of /cvsroot/neelix/neelix/view/qt
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31674
Added Files:
qt.rb
Log Message:
Dear me, this is a rather important file to have in CVS isn't it?
--- NEW FILE: qt.rb ---
require 'view/qt/mw.rb'
require 'view/qt/aboutdialog.rb'
class Qt::ListViewItem
attr_accessor :data
end
class Neelix
def postinitialize
build_shelf
@shelf.currentItem = @shelf.firstChild
end
def helpAbout
AboutDialog.new.exec
end
def fileExit
$qApp.quit
end
def build_shelf
$replicator.cookbooks.each do |cookbook|
i = Qt::ListViewItem.new(@shelf,cookbook.name)
i.data = cookbook
i.open = true
i.setRenameEnabled(0,true)
cookbook.categories.each do |category|
j = Qt::ListViewItem.new(i,category.name)
j.data = category
j.open = true
j.setRenameEnabled(0,true)
category.recipes.each do |recipe|
k = Qt::ListViewItem.new(j,recipe.name)
k.data = recipe
k.setRenameEnabled(0,true)
end
end
end
end
def shelf_currentChanged
i = @shelf.currentItem.data
self.counter_currentItem = i
case i
when Cookbook
@counterStack.enabled = false
when Category
@counterStack.enabled = false
when Recipe
@counterStack.enabled = true
end
end
def counter_currentItem=(i)
case i
when Cookbook
when Category
when Recipe
refresh_recipe(i)
end
end
def adjust_columns
@ingredients_table.numCols.times do |j|
@ingredients_table.adjustColumn(j)
end
end
def shelf_item_renamed(item,col,text)
data = item.data
data.name = text
case data
when Recipe
@recipe_entry.text = text
end
end
def refresh_recipe(r)
@recipe_entry.text = r.name
@author_entry.text = r.author
@tottime_entry.text = r.tottime
@yields_entry.text = r.yields
@ingredients_table.numRows = r.ingredients.size
r.ingredients.each_with_index do |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)
@ingredients_table.setText(j,3,ing.modifier.to_s)
end
adjust_columns
@directions_edit.text = r.directions
@note_edit.text = r.note
end
end
a = Qt::Application.new(ARGV)
w = Neelix.new
w.postinitialize
w.resize(800,600)
# run
a.mainWidget = w
w.show
a.exec
|