Wireshark  4.3.0
The Wireshark network protocol analyzer
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 
15 #ifndef Q_OS_WIN
17 #include "packet_range_group_box.h"
18 #include "ui/help_url.h"
19 #endif // Q_OS_WIN
20 
21 #include <ui/packet_range.h>
22 
24 #include "cfile.h"
25 
26 #include "ui/file_dialog.h"
27 
28 #include <QVBoxLayout>
29 #include <QLabel>
30 #include <QRadioButton>
31 #include <QCheckBox>
32 #include <QDialogButtonBox>
33 #include <QComboBox>
34 
36 {
37  // The GTK+ Open Capture File dialog has the following elements and features:
38  // - The ability to select a capture file from a list of known extensions
39  // - A display filter entry
40  // - Name resolution checkboxes
41  // - Capture file preview information
42  // Ideally we should provide similar functionality here.
43  //
44  // You can subclass QFileDialog (which we've done here) and add widgets as
45  // described at
46  // https://web.archive.org/web/20100528190736/http://developer.qt.nokia.com/faq/answer/how_can_i_add_widgets_to_my_qfiledialog_instance
47  // However, Qt's idea of what a file dialog looks like isn't what Microsoft
48  // and Apple think a file dialog looks like.
49  //
50  // On Windows Vista and later we should probably use IFileOpenDialog. On earlier
51  // versions of Windows (including XP) we should use GetOpenFileName, which is
52  // what we do in ui/win32/file_dlg_win32.c. macOS we should use NSOpenPanel. On
53  // other platforms we should fall back to QFileDialog.
54  //
55  // Yes, that's four implementations of the same window.
56  //
57  // If a plain native open file dialog is good enough we can just the static
58  // version of QFileDialog::getOpenFileName. (Commenting out Q_OBJECT and
59  // "explicit" below has the same effect.)
60 
61  Q_OBJECT
62 public:
63  explicit CaptureFileDialog(QWidget *parent = NULL, capture_file *cf = NULL);
64  static check_savability_t checkSaveAsWithComments(QWidget *
65 #if defined(Q_OS_WIN)
66  parent
67 #endif // Q_OS_WIN
68  , capture_file *cf, int file_type);
69 
70  int mergeType();
71  int selectedFileType();
72  wtap_compression_type compressionType();
73 
74 private:
75  capture_file *cap_file_;
76 
77 #if !defined(Q_OS_WIN)
78  void addMergeControls(QVBoxLayout &v_box);
79  void addFormatTypeSelector(QVBoxLayout &v_box);
80  void addDisplayFilterEdit(QString &display_filter);
81  void addPreview(QVBoxLayout &v_box);
82  QString fileExtensionType(int et, bool extension_globs = true);
83  QString fileType(int ft, QStringList &suffixes);
84  QStringList buildFileOpenTypeList(void);
85 
86  QVBoxLayout left_v_box_;
87  QVBoxLayout right_v_box_;
88 
89  DisplayFilterEdit* display_filter_edit_;
90  int last_row_;
91 
92  QLabel preview_format_;
93  QLabel preview_size_;
94  QLabel preview_first_elapsed_;
95  QList<QLabel *> preview_labels_;
96 
97  QRadioButton merge_prepend_;
98  QRadioButton merge_chrono_;
99  QRadioButton merge_append_;
100 
101  QComboBox format_type_;
102  QHash<QString, int> type_hash_;
103  QHash<QString, QStringList> type_suffixes_;
104 
105  void addGzipControls(QVBoxLayout &v_box);
106  void addRangeControls(QVBoxLayout &v_box, packet_range_t *range, QString selRange = QString());
107  QDialogButtonBox *addHelpButton(topic_action_e help_topic);
108 
109  QStringList buildFileSaveAsTypeList(bool must_support_comments);
110 
111  int default_ft_;
112 
113  QCheckBox compress_;
114 
115  PacketRangeGroupBox packet_range_group_box_;
116  QPushButton *save_bt_;
117  topic_action_e help_topic_;
118 
119 #else // Q_OS_WIN
120  int file_type_;
121  int merge_type_;
122  wtap_compression_type compression_type_;
123 #endif // Q_OS_WIN
124 
125 signals:
126 
127 public slots:
128 
129 #ifndef Q_OS_WIN
130  void accept() Q_DECL_OVERRIDE;
131 #endif
132  int exec() Q_DECL_OVERRIDE;
133  int open(QString &file_name, unsigned int &type, QString &display_filter);
134  check_savability_t saveAs(QString &file_name, bool must_support_comments);
135  check_savability_t exportSelectedPackets(QString &file_name, packet_range_t *range, QString selRange = QString());
136  int merge(QString &file_name, QString &display_filter);
137 
138 private slots:
139 #if !defined(Q_OS_WIN)
140  void fixFilenameExtension();
141  void preview(const QString & path);
142  void on_buttonBox_helpRequested();
143 #endif // Q_OS_WIN
144 };
145 
146 #endif // CAPTURE_FILE_DIALOG_H
Definition: capture_file_dialog.h:36
Definition: display_filter_edit.h:28
Definition: packet_range_group_box.h:31
The WiresharkFileDialog class.
Definition: wireshark_file_dialog.h:30
Definition: cfile.h:67
Definition: packet_range.h:39