ExportDissectionDialog::ExportDissectionDialog(QWidget *parent, capture_file *cap_file, export_type_e export_type): QFileDialog(parent), export_type_(export_type), cap_file_(cap_file) #if !defined(Q_OS_WIN) , save_bt_(NULL) #endif /* Q_OS_WIN */ { #if !defined(Q_OS_WIN) QDialogButtonBox *button_box = findChild<QDialogButtonBox *>(); QGridLayout *fd_grid = qobject_cast<QGridLayout*>(layout()); QHBoxLayout *h_box = new QHBoxLayout(); QStringList name_filters; int last_row; setWindowTitle(tr("Wireshark: Export Packet Dissections")); setAcceptMode(QFileDialog::AcceptSave); setLabelText(FileType, tr("Export as:")); // export_type_map_keys() sorts alphabetically. We don't want that. name_filters << tr("Plain text (*.txt)") << tr("Comma Separated Values - summary (*.csv)") << tr("PSML - summary (*.psml, *.xml)") << tr("PDML - details (*.pdml, *.xml)") << tr("C Arrays - bytes (*.c, *.h)"); export_type_map_[name_filters[0]] = export_type_text; export_type_map_[name_filters[1]] = export_type_csv; export_type_map_[name_filters[2]] = export_type_psml; export_type_map_[name_filters[3]] = export_type_pdml; export_type_map_[name_filters[4]] = export_type_carrays; setNameFilters(name_filters); selectNameFilter(export_type_map_.key(export_type)); exportTypeChanged(export_type_map_.key(export_type)); last_row = fd_grid->rowCount(); fd_grid->addItem(new QSpacerItem(1, 1), last_row, 0); fd_grid->addLayout(h_box, last_row, 1); /* Init the export range */ packet_range_init(&print_args_.range, cap_file_); /* Default to displayed packets */ print_args_.range.process_filtered = TRUE; packet_range_group_box_.initRange(&print_args_.range); h_box->addWidget(&packet_range_group_box_); h_box->addWidget(&packet_format_group_box_, 0, Qt::AlignTop); if (button_box) { button_box->addButton(QDialogButtonBox::Help); connect(button_box, SIGNAL(helpRequested()), this, SLOT(on_buttonBox_helpRequested())); save_bt_ = button_box->button(QDialogButtonBox::Save); } if (save_bt_) { connect(&packet_range_group_box_, SIGNAL(validityChanged(bool)), this, SLOT(checkValidity())); connect(&packet_format_group_box_, SIGNAL(formatChanged()), this, SLOT(checkValidity())); } connect(this, SIGNAL(filterSelected(QString)), this, SLOT(exportTypeChanged(QString))); // Grow the dialog to account for the extra widgets. resize(width(), height() + (packet_range_group_box_.height() * 2 / 3)); #else // Q_OS_WIN #endif // Q_OS_WIN }
ExportDissectionDialog::ExportDissectionDialog(QWidget *parent, capture_file *cap_file, export_type_e export_type): QFileDialog(parent), export_type_(export_type), cap_file_(cap_file) #if !defined(Q_OS_WIN) , save_bt_(NULL) #endif /* Q_OS_WIN */ { switch (prefs.gui_fileopen_style) { case FO_STYLE_LAST_OPENED: /* The user has specified that we should start out in the last directory * we looked in. If we've already opened a file, use its containing * directory, if we could determine it, as the directory, otherwise * use the "last opened" directory saved in the preferences file if * there was one. */ setDirectory(wsApp->lastOpenDir()); break; case FO_STYLE_SPECIFIED: /* The user has specified that we should always start out in a * specified directory; if they've specified that directory, * start out by showing the files in that dir. */ if (prefs.gui_fileopen_dir[0] != '\0') setDirectory(prefs.gui_fileopen_dir); break; } #if !defined(Q_OS_WIN) QDialogButtonBox *button_box = findChild<QDialogButtonBox *>(); // Add extra widgets // https://wiki.qt.io/Qt_project_org_faq#How_can_I_add_widgets_to_my_QFileDialog_instance.3F setOption(QFileDialog::DontUseNativeDialog, true); QGridLayout *fd_grid = qobject_cast<QGridLayout*>(layout()); QHBoxLayout *h_box = new QHBoxLayout(); QStringList name_filters; int last_row; setWindowTitle(wsApp->windowTitleString(tr("Export Packet Dissections"))); setAcceptMode(QFileDialog::AcceptSave); setLabelText(FileType, tr("Export As:")); // export_type_map_keys() sorts alphabetically. We don't want that. name_filters << tr("Plain text (*.txt)") << tr("Comma Separated Values - summary (*.csv)") << tr("PSML - summary (*.psml, *.xml)") << tr("PDML - details (*.pdml, *.xml)") << tr("JSON (*.json)") << tr("C Arrays - bytes (*.c, *.h)"); export_type_map_[name_filters[0]] = export_type_text; export_type_map_[name_filters[1]] = export_type_csv; export_type_map_[name_filters[2]] = export_type_psml; export_type_map_[name_filters[3]] = export_type_pdml; export_type_map_[name_filters[4]] = export_type_json; export_type_map_[name_filters[5]] = export_type_carrays; setNameFilters(name_filters); selectNameFilter(export_type_map_.key(export_type)); exportTypeChanged(export_type_map_.key(export_type)); last_row = fd_grid->rowCount(); fd_grid->addItem(new QSpacerItem(1, 1), last_row, 0); fd_grid->addLayout(h_box, last_row, 1); print_args_.file = NULL; /* Init the export range */ packet_range_init(&print_args_.range, cap_file_); /* Default to displayed packets */ print_args_.range.process_filtered = TRUE; packet_range_group_box_.initRange(&print_args_.range); h_box->addWidget(&packet_range_group_box_); h_box->addWidget(&packet_format_group_box_, 0, Qt::AlignTop); if (button_box) { button_box->addButton(QDialogButtonBox::Help); connect(button_box, SIGNAL(helpRequested()), this, SLOT(on_buttonBox_helpRequested())); save_bt_ = button_box->button(QDialogButtonBox::Save); } if (save_bt_) { connect(&packet_range_group_box_, SIGNAL(validityChanged(bool)), this, SLOT(checkValidity())); connect(&packet_format_group_box_, SIGNAL(formatChanged()), this, SLOT(checkValidity())); } connect(this, SIGNAL(filterSelected(QString)), this, SLOT(exportTypeChanged(QString))); // Grow the dialog to account for the extra widgets. resize(width(), height() + (packet_range_group_box_.height() * 2 / 3)); #else // Q_OS_WIN #endif // Q_OS_WIN }