diff --git a/ui/qt/decode_as_dialog.cpp b/ui/qt/decode_as_dialog.cpp
index bb972c2e4b..0c78e389bd 100644
--- a/ui/qt/decode_as_dialog.cpp
+++ b/ui/qt/decode_as_dialog.cpp
@@ -50,6 +50,9 @@ DecodeAsDialog::DecodeAsDialog(QWidget *parent, capture_file *cf, bool create_ne
fillTable();
+ connect(model_, SIGNAL(modelReset()), this, SLOT(modelRowsReset()));
+ ui->clearToolButton->setEnabled(model_->rowCount() > 0);
+
if (create_new)
on_newToolButton_clicked();
}
@@ -83,14 +86,23 @@ void DecodeAsDialog::resizeColumns()
}
}
+void DecodeAsDialog::modelRowsReset()
+{
+ ui->deleteToolButton->setEnabled(false);
+ ui->copyToolButton->setEnabled(false);
+ ui->clearToolButton->setEnabled(false);
+}
+
void DecodeAsDialog::on_decodeAsTreeView_currentItemChanged(const QModelIndex ¤t, const QModelIndex&)
{
if (current.isValid()) {
ui->deleteToolButton->setEnabled(true);
ui->copyToolButton->setEnabled(true);
+ ui->clearToolButton->setEnabled(true);
} else {
ui->deleteToolButton->setEnabled(false);
ui->copyToolButton->setEnabled(false);
+ ui->clearToolButton->setEnabled(false);
}
}
@@ -138,6 +150,11 @@ void DecodeAsDialog::on_copyToolButton_clicked()
addRecord(true);
}
+void DecodeAsDialog::on_clearToolButton_clicked()
+{
+ model_->clearAll();
+}
+
void DecodeAsDialog::applyChanges()
{
model_->applyChanges();
diff --git a/ui/qt/decode_as_dialog.h b/ui/qt/decode_as_dialog.h
index 08629b86f5..222b956a00 100644
--- a/ui/qt/decode_as_dialog.h
+++ b/ui/qt/decode_as_dialog.h
@@ -47,12 +47,16 @@ private:
void fillTable();
void resizeColumns();
+public slots:
+ void modelRowsReset();
+
private slots:
void on_decodeAsTreeView_currentItemChanged(const QModelIndex ¤t, const QModelIndex &previous);
void on_newToolButton_clicked();
void on_deleteToolButton_clicked();
void on_copyToolButton_clicked();
+ void on_clearToolButton_clicked();
void on_buttonBox_clicked(QAbstractButton *button);
};
diff --git a/ui/qt/decode_as_dialog.ui b/ui/qt/decode_as_dialog.ui
index 607014a243..6dde51957a 100644
--- a/ui/qt/decode_as_dialog.ui
+++ b/ui/qt/decode_as_dialog.ui
@@ -62,6 +62,20 @@
+ -
+
+
+ Clear all coloring rules.
+
+
+
+ :/stock/delete_list.png:/stock/delete_list.png
+
+
+ false
+
+
+
-
diff --git a/ui/qt/models/decode_as_model.cpp b/ui/qt/models/decode_as_model.cpp
index 303ba565ff..18b9c8834a 100644
--- a/ui/qt/models/decode_as_model.cpp
+++ b/ui/qt/models/decode_as_model.cpp
@@ -391,6 +391,16 @@ bool DecodeAsModel::removeRows(int row, int count, const QModelIndex &/*parent*/
return true;
}
+void DecodeAsModel::clearAll()
+{
+ if (rowCount() < 1)
+ return;
+
+ beginResetModel();
+ decode_as_items_.clear();
+ endResetModel();
+}
+
bool DecodeAsModel::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/decode_as_model.h b/ui/qt/models/decode_as_model.h
index f1cf825808..003d005dde 100644
--- a/ui/qt/models/decode_as_model.h
+++ b/ui/qt/models/decode_as_model.h
@@ -72,6 +72,7 @@ public:
bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex());
bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
+ void clearAll();
bool copyRow(int dst_row, int src_row);
static QString entryString(const gchar *table_name, gpointer value);