Class: Cosmos::PacketLogFrame
- Inherits:
-
Qt::Widget
- Object
- Qt::Base
- Qt::Widget
- Cosmos::PacketLogFrame
- Defined in:
- lib/cosmos/gui/widgets/packet_log_frame.rb
Instance Attribute Summary collapse
-
#change_callback ⇒ Object
Callback called when something changes.
-
#output_filename_filter ⇒ Object
Output filename filter.
-
#packet_log_reader ⇒ Object
readonly
Log reader to use.
-
#time_end ⇒ Object
End time of packets to process.
-
#time_start ⇒ Object
Start time of packets to process.
Instance Method Summary collapse
-
#filenames ⇒ Object
Returns the chosen filenames.
-
#initialize(parent, log_directory, packet_log_reader, initial_filenames = [], initial_output_filename = nil, show_output_filename = false, show_time = true, show_log_reader = true, input_filename_filter = Cosmos::BIN_FILE_PATTERN, output_filename_filter = Cosmos::BIN_FILE_PATTERN) ⇒ PacketLogFrame
constructor
A new instance of PacketLogFrame.
-
#output_filename ⇒ Object
Return the output filename.
-
#output_filename=(new_output_filename) ⇒ Object
Set the output filename.
- #select_output_dir ⇒ Object
- #select_output_file ⇒ Object
Constructor Details
#initialize(parent, log_directory, packet_log_reader, initial_filenames = [], initial_output_filename = nil, show_output_filename = false, show_time = true, show_log_reader = true, input_filename_filter = Cosmos::BIN_FILE_PATTERN, output_filename_filter = Cosmos::BIN_FILE_PATTERN) ⇒ PacketLogFrame
Returns a new instance of PacketLogFrame.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/cosmos/gui/widgets/packet_log_frame.rb', line 34 def initialize(parent, log_directory, packet_log_reader, initial_filenames = [], initial_output_filename = nil, show_output_filename = false, show_time = true, show_log_reader = true, input_filename_filter = Cosmos::BIN_FILE_PATTERN, output_filename_filter = Cosmos::BIN_FILE_PATTERN) super(parent) @output_select = :FILE @input_filename_filter = input_filename_filter @output_filename_filter = output_filename_filter @log_directory = log_directory if initial_output_filename @output_directory = File.dirname(initial_output_filename) else @output_directory = log_directory.clone end @packet_log_reader = packet_log_reader @time_start = nil @time_end = nil @change_callback = nil @layout = Qt::GridLayout.new @layout.setContentsMargins(0,0,0,0) row = 0 # Chooser for Log Files label = Qt::Label.new('Log Files:') @layout.addWidget(label, row, 0, 1, 2) @browse_button = Qt::PushButton.new('Browse...') @browse_button.connect(SIGNAL('clicked()')) { () } @layout.addWidget(@browse_button, row, 2) @remove_button = Qt::PushButton.new('Remove') @remove_button.connect(SIGNAL('clicked()')) { () } @layout.addWidget(@remove_button, row, 3) row += 1 @filenames = Qt::ListWidget.new(self) @filenames.setSelectionMode(Qt::AbstractItemView::ExtendedSelection) @filenames.setSortingEnabled(true) initial_filenames.each {|filename| @filenames.addItem(filename)} @filenames.setMinimumHeight(90) @layout.addWidget(@filenames, row, 0, 3, 4) row += 3 if show_output_filename @output_filename_label = Qt::Label.new('Output File:') @layout.addWidget(@output_filename_label, row, 0) @output_filename = Qt::LineEdit.new(initial_output_filename.to_s) @output_filename.setMinimumWidth(340) @output_filename.setReadOnly(true) @layout.addWidget(@output_filename, row, 1, 1, 2) @output_filename_select_button = Qt::PushButton.new('Select') @output_filename_select_button.connect(SIGNAL('clicked()')) { () } @layout.addWidget(@output_filename_select_button, row, 3) row += 1 end @time_start_field = Qt::LineEdit.new('N/A') @time_end_field = Qt::LineEdit.new('N/A') if show_time %w(Start End).each do |time| time_label = Qt::Label.new("Time Period #{time}:") @layout.addWidget(time_label, row, 0) if time == 'Start' time_field = @time_start_field else time_field = @time_end_field end time_field.setMinimumWidth(340) time_field.setReadOnly(true) @layout.addWidget(time_field, row, 1) = Qt::PushButton.new('Clear') .connect(SIGNAL('clicked()')) { (time, time_field) } @layout.addWidget(, row, 2) = Qt::PushButton.new('Select') .connect(SIGNAL('clicked()')) { (time, time_field) } @layout.addWidget(, row, 3) row += 1 end end if show_log_reader @packet_log_reader = PacketLogReader.new unless @packet_log_reader # Chooser or label for log reader label = Qt::Label.new('Packet Log Reader:') @layout.addWidget(label, row, 0) @packet_log_reader_field = Qt::LineEdit.new(@packet_log_reader.class.to_s) @packet_log_reader_field.setMinimumWidth(340) @packet_log_reader_field.setReadOnly(true) @layout.addWidget(@packet_log_reader_field, row, 1, 1, 2) = Qt::PushButton.new('Select') .connect(SIGNAL('clicked()')) { () } @layout.addWidget(, row, 3) row += 1 end setLayout(@layout) end |
Instance Attribute Details
#change_callback ⇒ Object
Callback called when something changes
32 33 34 |
# File 'lib/cosmos/gui/widgets/packet_log_frame.rb', line 32 def change_callback @change_callback end |
#output_filename_filter ⇒ Object
Output filename filter
29 30 31 |
# File 'lib/cosmos/gui/widgets/packet_log_frame.rb', line 29 def output_filename_filter @output_filename_filter end |
#packet_log_reader ⇒ Object (readonly)
Log reader to use
26 27 28 |
# File 'lib/cosmos/gui/widgets/packet_log_frame.rb', line 26 def packet_log_reader @packet_log_reader end |
#time_end ⇒ Object
End time of packets to process
23 24 25 |
# File 'lib/cosmos/gui/widgets/packet_log_frame.rb', line 23 def time_end @time_end end |
#time_start ⇒ Object
Start time of packets to process
20 21 22 |
# File 'lib/cosmos/gui/widgets/packet_log_frame.rb', line 20 def time_start @time_start end |
Instance Method Details
#filenames ⇒ Object
Returns the chosen filenames
141 142 143 144 145 |
# File 'lib/cosmos/gui/widgets/packet_log_frame.rb', line 141 def filenames filename_array = [] @filenames.each {|list_item| filename_array << list_item.text} filename_array end |
#output_filename ⇒ Object
Return the output filename
148 149 150 |
# File 'lib/cosmos/gui/widgets/packet_log_frame.rb', line 148 def output_filename @output_filename.text end |
#output_filename=(new_output_filename) ⇒ Object
Set the output filename
153 154 155 |
# File 'lib/cosmos/gui/widgets/packet_log_frame.rb', line 153 def output_filename= (new_output_filename) @output_filename.setText(new_output_filename.to_s) end |
#select_output_dir ⇒ Object
162 163 164 165 |
# File 'lib/cosmos/gui/widgets/packet_log_frame.rb', line 162 def select_output_dir @output_filename_label.text = 'Output Dir:' @output_select = :DIR end |
#select_output_file ⇒ Object
157 158 159 160 |
# File 'lib/cosmos/gui/widgets/packet_log_frame.rb', line 157 def select_output_file @output_filename_label.text = 'Output File:' @output_select = :FILE end |