diff options
author | Gerald Combs <gerald@wireshark.org> | 2016-01-15 16:52:26 -0800 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2016-01-18 16:38:03 +0000 |
commit | 9988542fd5b604354495b25490908436336e315e (patch) | |
tree | 95d9cd059dac32adf4cd4bf1f19b64624f0abeb9 /ui/qt/filter_expressions_preferences_frame.cpp | |
parent | 6d0bc20d4e4853deb7da13312fb3eb3e36b4160f (diff) | |
download | wireshark-9988542fd5b604354495b25490908436336e315e.tar.gz |
Add a copy button to the Filter Expression preferences.
Add a "copy" button to match other parts of the UI.
Change-Id: I4240aaaaf18a6bbf8e6737a12bcfead2248acca7
Reviewed-on: https://code.wireshark.org/review/13322
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'ui/qt/filter_expressions_preferences_frame.cpp')
-rw-r--r-- | ui/qt/filter_expressions_preferences_frame.cpp | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/ui/qt/filter_expressions_preferences_frame.cpp b/ui/qt/filter_expressions_preferences_frame.cpp index 35beeb38fb..4a45caf153 100644 --- a/ui/qt/filter_expressions_preferences_frame.cpp +++ b/ui/qt/filter_expressions_preferences_frame.cpp @@ -36,9 +36,9 @@ #include <QKeyEvent> #include <QTreeWidgetItemIterator> -const int enabled_col_ = 0; -const int label_col_ = 1; -const int expression_col_ = 2; +static const int enabled_col_ = 0; +static const int label_col_ = 1; +static const int expression_col_ = 2; // This shouldn't exist in its current form. Instead it should be the "display filters" // dialog, and the "dfilters" file should support a "show in toolbar" flag. @@ -64,9 +64,14 @@ FilterExpressionsPreferencesFrame::FilterExpressionsPreferencesFrame(QWidget *pa ui->expressionTreeWidget->setDropIndicatorShown(true); ui->expressionTreeWidget->setDragDropMode(QAbstractItemView::InternalMove); - updateWidgets(); + ui->expressionTreeWidget->clear(); - connect(wsApp, SIGNAL(filterExpressionsChanged()), this, SLOT(updateWidgets())); + for (struct filter_expression *fe = *pfilter_expression_head; fe != NULL; fe = fe->next) { + if (fe->deleted) continue; + addExpression(fe->enabled, fe->label, fe->expression); + } + + updateWidgets(); } FilterExpressionsPreferencesFrame::~FilterExpressionsPreferencesFrame() @@ -167,12 +172,10 @@ void FilterExpressionsPreferencesFrame::addExpression(bool enabled, const QStrin void FilterExpressionsPreferencesFrame::updateWidgets() { - ui->expressionTreeWidget->clear(); + int num_selected = ui->expressionTreeWidget->selectedItems().count(); - for (struct filter_expression *fe = *pfilter_expression_head; fe != NULL; fe = fe->next) { - if (fe->deleted) continue; - addExpression(fe->enabled, fe->label, fe->expression); - } + ui->copyToolButton->setEnabled(num_selected == 1); + ui->deleteToolButton->setEnabled(num_selected > 0); } void FilterExpressionsPreferencesFrame::on_expressionTreeWidget_currentItemChanged(QTreeWidgetItem *current, QTreeWidgetItem *previous) @@ -267,6 +270,11 @@ void FilterExpressionsPreferencesFrame::expressionEditingFinished() ui->expressionTreeWidget->removeItemWidget(item, expression_col_); } +void FilterExpressionsPreferencesFrame::on_expressionTreeWidget_itemSelectionChanged() +{ + updateWidgets(); +} + static const QString new_button_label_ = QObject::tr("My Filter"); void FilterExpressionsPreferencesFrame::on_newToolButton_clicked() { @@ -281,6 +289,15 @@ void FilterExpressionsPreferencesFrame::on_deleteToolButton_clicked() } } +void FilterExpressionsPreferencesFrame::on_copyToolButton_clicked() +{ + if (!ui->expressionTreeWidget->currentItem()) return; + QTreeWidgetItem *ti = ui->expressionTreeWidget->currentItem(); + + addExpression(ti->checkState(enabled_col_) == Qt::Checked, + ti->text(label_col_), ti->text(expression_col_)); +} + /* * Editor modelines * |