Class: SearchTable
Defined Under Namespace
Instance Method Summary collapse
- #addPackage(row, gem) ⇒ Object
- #currentGem ⇒ Object
- #gem(item) ⇒ Object
- #gemAtRow(row) ⇒ Object
-
#initialize ⇒ SearchTable
constructor
A new instance of SearchTable.
- #updateGemList(gemList) ⇒ Object
Constructor Details
#initialize ⇒ SearchTable
Returns a new instance of SearchTable.
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/searchwin.rb', line 20 def initialize super(0,3) self.windowTitle = i18n('Search Result') setHorizontalHeaderLabels(['name', 'version', 'downloads']) self.horizontalHeader.stretchLastSection = true self.selectionBehavior = Qt::AbstractItemView::SelectRows self.selectionMode = Qt::AbstractItemView::SingleSelection self.alternatingRowColors = true self.sortingEnabled = true sortByColumn(0, Qt::AscendingOrder) @gems = {} end |
Instance Method Details
#addPackage(row, gem) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/searchwin.rb', line 34 def addPackage(row, gem) nameItem = Item.new(gem.package) @gems[nameItem] = gem # 0 column item is hash key. setItem( row, 0, nameItem ) setItem( row, 1, Item.new(gem.version) ) setItem( row, 2, NumItem.new(gem.downloads.to_s) ) end |
#currentGem ⇒ Object
63 64 65 |
# File 'lib/searchwin.rb', line 63 def currentGem gemAtRow(currentRow) end |
#gem(item) ⇒ Object
55 56 57 |
# File 'lib/searchwin.rb', line 55 def gem(item) gemAtRow(item.row) end |
#gemAtRow(row) ⇒ Object
59 60 61 |
# File 'lib/searchwin.rb', line 59 def gemAtRow(row) @gems[item(row,0)] # use 0 column item as hash key. end |
#updateGemList(gemList) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/searchwin.rb', line 42 def updateGemList(gemList) sortFlag = self.sortingEnabled self.sortingEnabled = false clearContents self.rowCount = gemList.length gemList.each_with_index do |g,r| addPackage(r, g) end self.sortingEnabled = sortFlag end |