summaryrefslogtreecommitdiff
path: root/ui/qt/capture_file_properties_dialog.cpp
diff options
context:
space:
mode:
authorGerald Combs <gerald@zing.org>2014-12-22 15:51:36 -0800
committerGerald Combs <gerald@wireshark.org>2014-12-29 01:42:13 +0000
commite8ec11fb7e67f83a7296f1e87451f3d7ddd5d85d (patch)
treeebac5b8251ca402bbb09dce014bdd883fd192f3b /ui/qt/capture_file_properties_dialog.cpp
parentc1d9d93efb3581f11ea8115e5b1d6a4c7105a1d2 (diff)
downloadwireshark-e8ec11fb7e67f83a7296f1e87451f3d7ddd5d85d.tar.gz
Qt: Add a WiresharkDialog convenience class.
Add WiresharkDialog, a common base class for dialogs centered around capture files. Make it a parent of Capture File Properties, Traffic Table, Conversations, and Endpoints. Rename CaptureFile::read_only_ to file_closed_. Add methods to WiresharkApplication for generating consistent window titles. Change-Id: Idc771556d8192e60f85dddc08fc4757698dee257 Reviewed-on: https://code.wireshark.org/review/6097 Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'ui/qt/capture_file_properties_dialog.cpp')
-rw-r--r--ui/qt/capture_file_properties_dialog.cpp41
1 files changed, 16 insertions, 25 deletions
diff --git a/ui/qt/capture_file_properties_dialog.cpp b/ui/qt/capture_file_properties_dialog.cpp
index c397a0009d..1950b3bfb6 100644
--- a/ui/qt/capture_file_properties_dialog.cpp
+++ b/ui/qt/capture_file_properties_dialog.cpp
@@ -29,6 +29,7 @@
#include "wsutil/str_util.h"
#include "wsutil/ws_version_info.h"
+#include "qt_ui_utils.h"
#include "wireshark_application.h"
#include <QDateTime>
@@ -39,17 +40,14 @@
// - Add file hashes
// - Add formats (HTML, plain text, YAML)?
-CaptureFilePropertiesDialog::CaptureFilePropertiesDialog(QWidget *parent, capture_file *cf) :
- QDialog(parent),
- ui(new Ui::CaptureFilePropertiesDialog),
- cap_file_(cf)
+CaptureFilePropertiesDialog::CaptureFilePropertiesDialog(QWidget &parent, CaptureFile &capture_file) :
+ WiresharkDialog(parent, capture_file),
+ ui(new Ui::CaptureFilePropertiesDialog)
{
ui->setupUi(this);
// XXX Use recent settings instead
- if (parent) {
- resize(parent->width() * 2 / 3, parent->height());
- }
+ resize(parent.width() * 2 / 3, parent.height());
QPushButton *button = ui->buttonBox->button(QDialogButtonBox::Reset);
if (button) {
@@ -66,11 +64,12 @@ CaptureFilePropertiesDialog::CaptureFilePropertiesDialog(QWidget *parent, captur
button->setText(tr("Save Comments"));
}
+ setWindowSubtitle(tr("Capture File Properties"));
updateWidgets();
}
/*
- * Slots
+ * Slots
*/
CaptureFilePropertiesDialog::~CaptureFilePropertiesDialog()
@@ -80,20 +79,12 @@ CaptureFilePropertiesDialog::~CaptureFilePropertiesDialog()
/**/
-void CaptureFilePropertiesDialog::setCaptureFile(capture_file *cf)
-{
- if (!cf) { // We only want to know when the file closes.
- cap_file_ = NULL;
- }
- updateWidgets();
-}
-
void CaptureFilePropertiesDialog::updateWidgets()
{
QPushButton *refresh_bt = ui->buttonBox->button(QDialogButtonBox::Reset);
QPushButton *save_bt = ui->buttonBox->button(QDialogButtonBox::Save);
- if (!cap_file_) {
+ if (file_closed_) {
if (refresh_bt) {
refresh_bt->setEnabled(false);
}
@@ -104,12 +95,12 @@ void CaptureFilePropertiesDialog::updateWidgets()
return;
}
- bool enable = wtap_dump_can_write(cap_file_->linktypes, WTAP_COMMENT_PER_SECTION);
+ bool enable = wtap_dump_can_write(cap_file_.capFile()->linktypes, WTAP_COMMENT_PER_SECTION);
save_bt->setEnabled(enable);
ui->commentsTextEdit->setEnabled(enable);
ui->detailsTextEdit->setHtml(summaryToHtml());
- ui->commentsTextEdit->setText(cf_read_shb_comment(cap_file_));
+ ui->commentsTextEdit->setText(cf_read_shb_comment(cap_file_.capFile()));
}
QString CaptureFilePropertiesDialog::timeToString(time_t ti_time)
@@ -145,11 +136,11 @@ QString CaptureFilePropertiesDialog::summaryToHtml()
table_hheader25_tmpl = "<td width=\"25%\"><u>%1</u></td>";
table_data_tmpl = "<td>%1</td>";
- if (cap_file_) {
+ if (!file_closed_) {
/* initial computations */
- summary_fill_in(cap_file_, &summary);
+ summary_fill_in(cap_file_.capFile(), &summary);
#ifdef HAVE_LIBPCAP
- summary_fill_in_capture(cap_file_, &global_capture_opts, &summary);
+ summary_fill_in_capture(cap_file_.capFile(), &global_capture_opts, &summary);
#endif
}
@@ -514,14 +505,14 @@ void CaptureFilePropertiesDialog::on_buttonBox_helpRequested()
void CaptureFilePropertiesDialog::on_buttonBox_accepted()
{
- if (!cap_file_ || !cap_file_->filename) {
+ if (file_closed_ || !cap_file_.capFile()->filename) {
return;
}
- if (wtap_dump_can_write(cap_file_->linktypes, WTAP_COMMENT_PER_SECTION))
+ if (wtap_dump_can_write(cap_file_.capFile()->linktypes, WTAP_COMMENT_PER_SECTION))
{
gchar *str = qstring_strdup(ui->commentsTextEdit->toPlainText());
- cf_update_capture_comment(cap_file_, str);
+ cf_update_capture_comment(cap_file_.capFile(), str);
emit captureCommentChanged();
}
}