Class: Qt::ListWidget
Direct Known Subclasses
Instance Method Summary collapse
-
#clearItems ⇒ Object
Helper method to remove all items from a ListWidget.
- #each ⇒ Object
- #remove_selected_items ⇒ Object
Instance Method Details
#clearItems ⇒ Object
Helper method to remove all items from a ListWidget
560 561 562 563 564 |
# File 'lib/cosmos/gui/qt.rb', line 560 def clearItems (0...count).each do takeItem(0).dispose end end |
#each ⇒ Object
566 567 568 569 570 |
# File 'lib/cosmos/gui/qt.rb', line 566 def each (0...count).each do |index| yield self.item(index) end end |
#remove_selected_items ⇒ Object
572 573 574 575 576 577 578 579 |
# File 'lib/cosmos/gui/qt.rb', line 572 def remove_selected_items # Take the selected items and call row on each to get an array of the item indexes # Sort that array because selectedItems is returned in the order selected, not numerical order # Reverse this array of indices so we remove the last item first, # this allows all the indexes to remain constant # Call takeItem of each of the indices and then dispose the resulting ListWidgetItem that is returned selectedItems.map {|x| row(x)}.sort.reverse.each { |index| takeItem(index).dispose } end |