Class: Cosmos::TlmExtractor::MyListWidget

Inherits:
Qt::ListWidget show all
Defined in:
lib/cosmos/tools/tlm_extractor/tlm_extractor.rb

Instance Method Summary collapse

Methods inherited from Qt::ListWidget

#clearItems, #each

Instance Method Details

#keyPressEvent(event) ⇒ Object



39
40
41
42
43
44
45
46
47
# File 'lib/cosmos/tools/tlm_extractor/tlm_extractor.rb', line 39

def keyPressEvent(event)
  case event.key
  when Qt::Key_Delete, Qt::Key_Backspace
    remove_selected_items()
  when Qt::Key_Return, Qt::Key_Enter
    emit enterKeyPressed(currentRow())
  end
  super(event)
end

#remove_selected_itemsObject



49
50
51
52
53
54
55
# File 'lib/cosmos/tools/tlm_extractor/tlm_extractor.rb', line 49

def remove_selected_items
  indexes = selected_items()
  indexes.reverse.each do |index|
    item = takeItem(index)
    item.dispose if item
  end
end

#selected_itemsObject

Returns an array with the indexes of the selected items



58
59
60
61
62
63
64
65
66
# File 'lib/cosmos/tools/tlm_extractor/tlm_extractor.rb', line 58

def selected_items
  selected = []
  index = 0
  self.each do |list_item|
    selected << index if list_item.selected?
    index += 1
  end
  selected
end