diff --git a/AUTHORS.src b/AUTHORS.src index 6e8bd4f44f..b2cb14330e 100644 --- a/AUTHORS.src +++ b/AUTHORS.src @@ -3990,3 +3990,5 @@ Martin Pool . Emanuel Eichhammer granted permission to use QCustomPlot. + +Some icons made by Freepik, http://www.freepik.com from https://www.flaticon.com diff --git a/image/README.image b/image/README.image index a64db97c86..07ce6a1790 100644 --- a/image/README.image +++ b/image/README.image @@ -61,3 +61,5 @@ plus-8.png macOS style add / remove icons. Created by Peter Hosey. minus-8.png Released under CC-PD. copy-8.png macOS style copy icon. + +delete_list.png by Freepik, http://www.freepik.com from https://www.flaticon.com \ No newline at end of file diff --git a/image/delete_list.png b/image/delete_list.png new file mode 100644 index 0000000000..8668b43250 Binary files /dev/null and b/image/delete_list.png differ diff --git a/image/toolbar.qrc b/image/toolbar.qrc index 6974d641bc..f60a0df480 100644 --- a/image/toolbar.qrc +++ b/image/toolbar.qrc @@ -7,6 +7,7 @@ minus-8.png plus-8.png copy-8.png + delete_list.png toolbar/14x14/x-capture-comment-update.png 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 ¤t, 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 ¤t, 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 @@ -77,6 +77,21 @@ + + + + Clear all entries. + + + + + + + :/stock/delete_list.png:/stock/delete_list.png + + + + 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 ¤t, 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 ¤t, 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 @@ -95,6 +95,21 @@ + + + + Clear all entries. + + + + + + + :/stock/delete_list.png:/stock/delete_list.png + + + +