Class: Cosmos::PacketLogFrame
- Defined in:
- lib/cosmos/gui/widgets/packet_log_frame.rb
Overview
Widget which displays a button to browse for log files. Files are listed and can be removed. Buttons exist to display start and stop time choosers which apply to all files in the list. The widget can also show a button which allows the user to change the Cosmos log file reader class.
Instance Attribute Summary collapse
-
#change_callback ⇒ #call
Callback called when something changes.
-
#output_filename_filter ⇒ String
Output filename filter.
-
#packet_log_reader ⇒ PacketLogReader
readonly
Log reader class to use.
-
#time_end ⇒ Time
End time of packets to process.
-
#time_start ⇒ Time
Start time of packets to process.
Instance Method Summary collapse
-
#filenames ⇒ Array<String>
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, multiple_file_select = true) ⇒ PacketLogFrame
constructor
A new instance of PacketLogFrame.
-
#output_filename ⇒ String
The output filename.
- #output_filename=(output_filename) ⇒ Object
-
#select_output_dir ⇒ Object
Change the output selection to select a directory (not a file).
-
#select_output_file ⇒ Object
Change the output selection to select a file (not a directory).
- #show_log_fields(show_fields) ⇒ 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, multiple_file_select = true) ⇒ PacketLogFrame
Returns a new instance of PacketLogFrame.
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 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/cosmos/gui/widgets/packet_log_frame.rb', line 70 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, multiple_file_select = true) super(parent) @output_select = :FILE @input_filename_filter = input_filename_filter @output_filename_filter = output_filename_filter @multiple_file_select = multiple_file_select @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 @log_files_label = Qt::Label.new('Log Files:') @layout.addWidget(@log_files_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 = PacketLogFrameListWidget.new(self) @filenames.setSelectionMode(Qt::AbstractItemView::ExtendedSelection) @filenames.setSortingEnabled(true) @filenames.delete_callback = method(:handle_remove_button) 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 # Declare these regardless of if show_time is set so getters and setters work @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 @packet_log_reader_label = Qt::Label.new('Packet Log Reader:') @layout.addWidget(@packet_log_reader_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) @plr_select_button = Qt::PushButton.new('Select') @plr_select_button.connect(SIGNAL('clicked()')) { () } @layout.addWidget(@plr_select_button, row, 3) row += 1 end setLayout(@layout) end |
Instance Attribute Details
#change_callback ⇒ #call
Returns Callback called when something changes. Called with the item that was changed as a symbol. The possible values are :INPUT_FILES, :OUTPUT_FILE, :OUTPUT_DIR, :TIME_START, :TIME_END, :LOG_READER.
47 48 49 |
# File 'lib/cosmos/gui/widgets/packet_log_frame.rb', line 47 def change_callback @change_callback end |
#output_filename_filter ⇒ String
Returns Output filename filter. Must conform to the syntax as described in the Qt::FileDialog class.
42 43 44 |
# File 'lib/cosmos/gui/widgets/packet_log_frame.rb', line 42 def output_filename_filter @output_filename_filter end |
#packet_log_reader ⇒ PacketLogReader (readonly)
Returns Log reader class to use.
39 40 41 |
# File 'lib/cosmos/gui/widgets/packet_log_frame.rb', line 39 def packet_log_reader @packet_log_reader end |
#time_end ⇒ Time
Returns End time of packets to process.
37 38 39 |
# File 'lib/cosmos/gui/widgets/packet_log_frame.rb', line 37 def time_end @time_end end |
#time_start ⇒ Time
Returns Start time of packets to process.
35 36 37 |
# File 'lib/cosmos/gui/widgets/packet_log_frame.rb', line 35 def time_start @time_start end |
Instance Method Details
#filenames ⇒ Array<String>
Returns The chosen filenames.
181 182 183 184 185 |
# File 'lib/cosmos/gui/widgets/packet_log_frame.rb', line 181 def filenames filename_array = [] @filenames.each {|list_item| filename_array << list_item.text} filename_array end |
#output_filename ⇒ String
Returns The output filename.
188 189 190 |
# File 'lib/cosmos/gui/widgets/packet_log_frame.rb', line 188 def output_filename @output_filename.text end |
#output_filename=(output_filename) ⇒ Object
193 194 195 |
# File 'lib/cosmos/gui/widgets/packet_log_frame.rb', line 193 def output_filename=(output_filename) @output_filename.setText(output_filename.to_s) end |
#select_output_dir ⇒ Object
Change the output selection to select a directory (not a file)
204 205 206 207 |
# File 'lib/cosmos/gui/widgets/packet_log_frame.rb', line 204 def select_output_dir @output_filename_label.text = 'Output Dir:' @output_select = :DIR end |
#select_output_file ⇒ Object
Change the output selection to select a file (not a directory)
198 199 200 201 |
# File 'lib/cosmos/gui/widgets/packet_log_frame.rb', line 198 def select_output_file @output_filename_label.text = 'Output File:' @output_select = :FILE end |
#show_log_fields(show_fields) ⇒ Object
229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 |
# File 'lib/cosmos/gui/widgets/packet_log_frame.rb', line 229 def show_log_fields(show_fields) if show_fields @filenames.show if @filenames @log_files_label.show if @log_files_label @browse_button.show if @browse_button @remove_button.show if @remove_button @packet_log_reader_field.show if @packet_log_reader_field @packet_log_reader_label.show if @packet_log_reader_label @plr_select_button.show if @plr_select_button else @filenames.hide if @filenames @log_files_label.hide if @log_files_label @browse_button.hide if @browse_button @remove_button.hide if @remove_button @packet_log_reader_field.hide if @packet_log_reader_field @packet_log_reader_label.hide if @packet_log_reader_label @plr_select_button.hide if @plr_select_button end end |