aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2017-10-17 13:57:04 -0400
committerMichael Mann <mmann78@netscape.net>2017-10-21 16:33:03 +0000
commit61380f950428dc7166647e6b5973415b691e1b70 (patch)
tree35d60f2e5c2afe9cfbe2b60299485eb5c74323e5 /ui
parent4e3114d01dd2ddbf4044bcd5c91812d3bd3f7fbd (diff)
Add button in Qt UAT dialog/frame to remove all UAT entries at once.
Change-Id: If5a172cd69beeb0b9a22eb7f6b9e7cb25f350b49 Reviewed-on: https://code.wireshark.org/review/23968 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'ui')
-rw-r--r--ui/qt/models/uat_model.cpp14
-rw-r--r--ui/qt/models/uat_model.h1
-rw-r--r--ui/qt/uat_dialog.cpp21
-rw-r--r--ui/qt/uat_dialog.h2
-rw-r--r--ui/qt/uat_dialog.ui15
-rw-r--r--ui/qt/uat_frame.cpp17
-rw-r--r--ui/qt/uat_frame.h2
-rw-r--r--ui/qt/uat_frame.ui15
8 files changed, 87 insertions, 0 deletions
diff --git a/ui/qt/models/uat_model.cpp b/ui/qt/models/uat_model.cpp
index b782247b13..37879ccdbb 100644
--- a/ui/qt/models/uat_model.cpp
+++ b/ui/qt/models/uat_model.cpp
@@ -333,6 +333,20 @@ bool UatModel::removeRows(int row, int count, const QModelIndex &/*parent*/)
return true;
}
+void UatModel::clearAll()
+{
+ if (rowCount() < 1)
+ return;
+
+ beginResetModel();
+ uat_clear(uat_);
+ record_errors.clear();
+ dirty_records.clear();
+ uat_->changed = TRUE;
+ endResetModel();
+}
+
+
bool UatModel::copyRow(int dst_row, int src_row)
{
if (src_row < 0 || src_row >= rowCount() || dst_row < 0 || dst_row >= rowCount()) {
diff --git a/ui/qt/models/uat_model.h b/ui/qt/models/uat_model.h
index c52646d7c3..d68684e41c 100644
--- a/ui/qt/models/uat_model.h
+++ b/ui/qt/models/uat_model.h
@@ -55,6 +55,7 @@ public:
bool copyRow(int dst_row, int src_row);
bool hasErrors() const;
+ void clearAll();
QModelIndex findRowForColumnContent(QVariant columnContent, int columnToCheckAgainst, int role = Qt::DisplayRole);
diff --git a/ui/qt/uat_dialog.cpp b/ui/qt/uat_dialog.cpp
index eeaf7ed3f6..52a7891c9c 100644
--- a/ui/qt/uat_dialog.cpp
+++ b/ui/qt/uat_dialog.cpp
@@ -50,6 +50,7 @@ UatDialog::UatDialog(QWidget *parent, epan_uat *uat) :
ui->deleteToolButton->setEnabled(false);
ui->copyToolButton->setEnabled(false);
+ ui->clearToolButton->setEnabled(false);
ok_button_ = ui->buttonBox->button(QDialogButtonBox::Ok);
help_button_ = ui->buttonBox->button(QDialogButtonBox::Help);
@@ -57,6 +58,7 @@ UatDialog::UatDialog(QWidget *parent, epan_uat *uat) :
ui->newToolButton->setAttribute(Qt::WA_MacSmallSize, true);
ui->deleteToolButton->setAttribute(Qt::WA_MacSmallSize, true);
ui->copyToolButton->setAttribute(Qt::WA_MacSmallSize, true);
+ ui->clearToolButton->setAttribute(Qt::WA_MacSmallSize, true);
ui->pathLabel->setAttribute(Qt::WA_MacSmallSize, true);
#endif
@@ -119,6 +121,8 @@ void UatDialog::setUat(epan_uat *uat)
this, SLOT(modelDataChanged(QModelIndex)));
connect(uat_model_, SIGNAL(rowsRemoved(QModelIndex, int, int)),
this, SLOT(modelRowsRemoved()));
+ connect(uat_model_, SIGNAL(modelReset()), this, SLOT(modelRowsReset()));
+
ok_button_->setEnabled(!uat_model_->hasErrors());
if (uat_->help && strlen(uat_->help) > 0) {
@@ -147,15 +151,25 @@ void UatDialog::modelRowsRemoved()
ok_button_->setEnabled(!uat_model_->hasErrors());
}
+void UatDialog::modelRowsReset()
+{
+ ui->deleteToolButton->setEnabled(false);
+ ui->clearToolButton->setEnabled(false);
+ ui->copyToolButton->setEnabled(false);
+}
+
+
// Invoked when a different field is selected. Note: when selecting a different
// field after editing, this event is triggered after modelDataChanged.
void UatDialog::on_uatTreeView_currentItemChanged(const QModelIndex &current, const QModelIndex &previous)
{
if (current.isValid()) {
ui->deleteToolButton->setEnabled(true);
+ ui->clearToolButton->setEnabled(true);
ui->copyToolButton->setEnabled(true);
} else {
ui->deleteToolButton->setEnabled(false);
+ ui->clearToolButton->setEnabled(false);
ui->copyToolButton->setEnabled(false);
}
@@ -248,6 +262,13 @@ void UatDialog::on_copyToolButton_clicked()
addRecord(true);
}
+void UatDialog::on_clearToolButton_clicked()
+{
+ if (uat_model_) {
+ uat_model_->clearAll();
+ }
+}
+
void UatDialog::applyChanges()
{
if (!uat_) return;
diff --git a/ui/qt/uat_dialog.h b/ui/qt/uat_dialog.h
index b90c758066..6eba0cd144 100644
--- a/ui/qt/uat_dialog.h
+++ b/ui/qt/uat_dialog.h
@@ -52,12 +52,14 @@ public:
private slots:
void modelDataChanged(const QModelIndex &topLeft);
void modelRowsRemoved();
+ void modelRowsReset();
void on_uatTreeView_currentItemChanged(const QModelIndex &current, const QModelIndex &previous);
void acceptChanges();
void rejectChanges();
void on_newToolButton_clicked();
void on_deleteToolButton_clicked();
void on_copyToolButton_clicked();
+ void on_clearToolButton_clicked();
void on_buttonBox_helpRequested();
private:
diff --git a/ui/qt/uat_dialog.ui b/ui/qt/uat_dialog.ui
index 01a5712073..2e708aaad7 100644
--- a/ui/qt/uat_dialog.ui
+++ b/ui/qt/uat_dialog.ui
@@ -78,6 +78,21 @@
</widget>
</item>
<item>
+ <widget class="QToolButton" name="clearToolButton">
+ <property name="toolTip">
+ <string>Clear all entries.</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="icon">
+ <iconset resource="../../image/toolbar.qrc">
+ <normaloff>:/stock/delete_list.png</normaloff>:/stock/delete_list.png
+ </iconset>
+ </property>
+ </widget>
+ </item>
+ <item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
diff --git a/ui/qt/uat_frame.cpp b/ui/qt/uat_frame.cpp
index 95aab9530f..e922ddd1db 100644
--- a/ui/qt/uat_frame.cpp
+++ b/ui/qt/uat_frame.cpp
@@ -53,6 +53,7 @@ UatFrame::UatFrame(QWidget *parent) :
ui->newToolButton->setAttribute(Qt::WA_MacSmallSize, true);
ui->deleteToolButton->setAttribute(Qt::WA_MacSmallSize, true);
ui->copyToolButton->setAttribute(Qt::WA_MacSmallSize, true);
+ ui->clearToolButton->setAttribute(Qt::WA_MacSmallSize, true);
ui->pathLabel->setAttribute(Qt::WA_MacSmallSize, true);
#endif
@@ -110,6 +111,7 @@ void UatFrame::setUat(epan_uat *uat)
this, SLOT(modelDataChanged(QModelIndex)));
connect(uat_model_, SIGNAL(rowsRemoved(QModelIndex, int, int)),
this, SLOT(modelRowsRemoved()));
+ connect(uat_model_, SIGNAL(modelReset()), this, SLOT(modelRowsReset()));
}
setWindowTitle(title);
@@ -193,9 +195,11 @@ void UatFrame::on_uatTreeView_currentItemChanged(const QModelIndex &current, con
{
if (current.isValid()) {
ui->deleteToolButton->setEnabled(true);
+ ui->clearToolButton->setEnabled(true);
ui->copyToolButton->setEnabled(true);
} else {
ui->deleteToolButton->setEnabled(false);
+ ui->clearToolButton->setEnabled(false);
ui->copyToolButton->setEnabled(false);
}
@@ -215,6 +219,13 @@ void UatFrame::modelRowsRemoved()
checkForErrorHint(current, QModelIndex());
}
+void UatFrame::modelRowsReset()
+{
+ ui->deleteToolButton->setEnabled(false);
+ ui->clearToolButton->setEnabled(false);
+ ui->copyToolButton->setEnabled(false);
+}
+
// If the current field has errors, show them.
// Otherwise if the row has not changed, but the previous field has errors, show them.
// Otherwise pick the first error in the current row.
@@ -279,6 +290,12 @@ void UatFrame::on_copyToolButton_clicked()
addRecord(true);
}
+void UatFrame::on_clearToolButton_clicked()
+{
+ if (uat_model_) {
+ uat_model_->clearAll();
+ }
+}
/*
* Editor modelines
*
diff --git a/ui/qt/uat_frame.h b/ui/qt/uat_frame.h
index 31499245ba..c86d0ab2f4 100644
--- a/ui/qt/uat_frame.h
+++ b/ui/qt/uat_frame.h
@@ -60,10 +60,12 @@ private:
private slots:
void modelDataChanged(const QModelIndex &topLeft);
void modelRowsRemoved();
+ void modelRowsReset();
void on_uatTreeView_currentItemChanged(const QModelIndex &current, const QModelIndex &previous);
void on_newToolButton_clicked();
void on_deleteToolButton_clicked();
void on_copyToolButton_clicked();
+ void on_clearToolButton_clicked();
};
#endif // UAT_FRAME_H
diff --git a/ui/qt/uat_frame.ui b/ui/qt/uat_frame.ui
index a9128e1a83..ccb9958982 100644
--- a/ui/qt/uat_frame.ui
+++ b/ui/qt/uat_frame.ui
@@ -96,6 +96,21 @@
</widget>
</item>
<item>
+ <widget class="QToolButton" name="clearToolButton">
+ <property name="toolTip">
+ <string>Clear all entries.</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="icon">
+ <iconset resource="../../image/toolbar.qrc">
+ <normaloff>:/stock/delete_list.png</normaloff>:/stock/delete_list.png
+ </iconset>
+ </property>
+ </widget>
+ </item>
+ <item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>