Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
capture_file_dialog.h
Go to the documentation of this file.
1
10#ifndef CAPTURE_FILE_DIALOG_H
11#define CAPTURE_FILE_DIALOG_H
12
14
18#include "ui/help_url.h"
19
20#include <ui/packet_range.h>
21
23#include <epan/cfile.h>
24
25#include "ui/file_dialog.h"
26
27#include <QVBoxLayout>
28#include <QLabel>
29#include <QRadioButton>
30#include <QCheckBox>
31#include <QDialogButtonBox>
32#include <QComboBox>
33
38{
39 // The GTK+ Open Capture File dialog has the following elements and features:
40 // - The ability to select a capture file from a list of known extensions
41 // - A display filter entry
42 // - Name resolution checkboxes
43 // - Capture file preview information
44 // Ideally we should provide similar functionality here.
45 //
46 // You can subclass QFileDialog (which we've done here) and add widgets as
47 // described at
48 //
49 // https://web.archive.org/web/20100528190736/http://developer.qt.nokia.com/faq/answer/how_can_i_add_widgets_to_my_qfiledialog_instance
50 //
51 // However, Qt's idea of what a file dialog looks like isn't what Microsoft
52 // and Apple think a file dialog looks like.
53 //
54 // On Windows, we should probably use the Common Item Dialog:
55 //
56 // https://learn.microsoft.com/en-us/windows/win32/shell/common-file-dialog
57 //
58 // We currently use GetOpenFileNam in ui/win32/file_dlg_win32.c.
59 //
60 // On macOS we should use NSOpenPanel and NSSavePanel:
61 //
62 // https://developer.apple.com/documentation/appkit/nsopenpanel?language=objc
63 // https://developer.apple.com/documentation/appkit/nssavepanel?language=objc
64 //
65 // On other platforms we should fall back to QFileDialog (or maybe
66 // KDE's or GTK+/GNOME's file dialog, as appropriate for the desktop
67 // environment being used, if QFileDialog doesn't do so with various
68 // platform plugins).
69 //
70 // Yes, that's four implementations of the same window.
71 //
72 // If a plain native open file dialog is good enough we can just the static
73 // version of QFileDialog::getOpenFileName. (Commenting out Q_OBJECT and
74 // "explicit" below has the same effect.)
75
76 Q_OBJECT
77public:
83 explicit CaptureFileDialog(QWidget *parent = NULL, capture_file *cf = NULL);
84
92 static check_savability_t checkSaveAsWithComments(QWidget *parent, capture_file *cf, int file_type);
93
98 int mergeType();
99
104 int selectedFileType();
105
110 ws_compression_type compressionType();
111
112private:
114 capture_file *cap_file_;
115
120 void addMergeControls(QVBoxLayout &v_box);
121
126 void addFormatTypeSelector(QVBoxLayout &v_box);
127
132 void addDisplayFilterEdit(QString &display_filter);
133
138 void addPreview(QVBoxLayout &v_box);
139
146 QString fileExtensionType(int et, bool extension_globs = true);
147
154 QString fileType(int ft, QStringList &suffixes);
155
160 QStringList buildFileOpenTypeList(void);
161
163 QVBoxLayout left_v_box_;
164
166 QVBoxLayout right_v_box_;
167
169 DisplayFilterEdit* display_filter_edit_;
170
172 int last_row_;
173
175 QLabel preview_format_;
176
178 QLabel preview_size_;
179
181 QLabel preview_first_elapsed_;
182
184 QList<QLabel *> preview_labels_;
185
187 QRadioButton merge_prepend_;
188
190 QRadioButton merge_chrono_;
191
193 QRadioButton merge_append_;
194
196 QComboBox format_type_;
197
199 QHash<QString, int> type_hash_;
200
202 QHash<QString, QStringList> type_suffixes_;
203
208 void addGzipControls(QVBoxLayout &v_box);
209
216 void addRangeControls(QVBoxLayout &v_box, packet_range_t *range, QString selRange = QString());
217
223 QDialogButtonBox *addHelpButton(topic_action_e help_topic);
224
230 QStringList buildFileSaveAsTypeList(bool must_support_comments);
231
233 int default_ft_;
234
236 CompressionGroupBox compress_group_box_;
237
239 PacketRangeGroupBox packet_range_group_box_;
240
242 QPushButton *save_bt_;
243
245 topic_action_e help_topic_;
246
247signals:
248
249public slots:
253 void accept() Q_DECL_OVERRIDE;
254
259 int exec() Q_DECL_OVERRIDE;
260
268 int open(QString &file_name, unsigned int &type, QString &display_filter);
269
276 check_savability_t saveAs(QString &file_name, bool must_support_comments);
277
285 check_savability_t exportSelectedPackets(QString &file_name, packet_range_t *range, QString selRange = QString());
286
293 int merge(QString &file_name, QString &display_filter);
294
295private slots:
299 void fixFilenameExtension();
300
305 void preview(const QString & path);
306
310 void on_buttonBox_helpRequested();
311};
312
313#endif // CAPTURE_FILE_DIALOG_H
A file dialog for opening, saving, and merging capture files with additional options.
Definition capture_file_dialog.h:38
int mergeType()
Retrieves the selected merge type.
Definition capture_file_dialog.cpp:769
ws_compression_type compressionType()
Retrieves the selected compression type.
Definition capture_file_dialog.cpp:505
int selectedFileType()
Retrieves the selected file type.
Definition capture_file_dialog.cpp:501
void accept() Q_DECL_OVERRIDE
Accepts the dialog and finalizes the operation.
Definition capture_file_dialog.cpp:201
int merge(QString &file_name, QString &display_filter)
Opens a file dialog to merge capture files.
Definition capture_file_dialog.cpp:693
int open(QString &file_name, unsigned int &type, QString &display_filter)
Opens a file dialog to open a capture file.
Definition capture_file_dialog.cpp:570
int exec() Q_DECL_OVERRIDE
Executes the dialog in a modal state.
Definition capture_file_dialog.cpp:225
check_savability_t saveAs(QString &file_name, bool must_support_comments)
Opens a file dialog to save the capture file.
Definition capture_file_dialog.cpp:602
check_savability_t exportSelectedPackets(QString &file_name, packet_range_t *range, QString selRange=QString())
Opens a file dialog to export specific packets.
Definition capture_file_dialog.cpp:643
static check_savability_t checkSaveAsWithComments(QWidget *parent, capture_file *cf, int file_type)
Checks whether the capture file can be saved with comments in the specified format.
Definition capture_file_dialog.cpp:76
UI element for selecting compression type from among those supported.
Definition compression_group_box.h:25
A line edit widget specialized for entering, validating, and managing display filters.
Definition display_filter_edit.h:36
UI element for controlling a range selection. The range provided in "initRange" is not owned by this ...
Definition packet_range_group_box.h:29
The WiresharkFileDialog class.
Definition wireshark_file_dialog.h:35
check_savability_t
Outcome of a "check if savable" prompt when closing or overwriting a capture file.
Definition file_dialog.h:22
topic_action_e
Identifies a help topic or navigable destination reachable from the UI help system.
Definition help_url.h:28
Represents a capture file and its associated metadata.
Definition cfile.h:84
Fully describes a packet range selection, including UI settings, derived counts, and dependency sets ...
Definition packet_range.h:46