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
598 599 600 601 602 |
# File 'lib/cosmos/gui/qt.rb', line 598 def clearItems (0...count).each do takeItem(0).dispose end end |
#each ⇒ Object
604 605 606 607 608 |
# File 'lib/cosmos/gui/qt.rb', line 604 def each (0...count).each do |index| yield self.item(index) end end |
#remove_selected_items ⇒ Object
610 611 612 613 614 615 616 617 |
# File 'lib/cosmos/gui/qt.rb', line 610 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 |