summaryrefslogtreecommitdiff
path: root/ui/qt/main_window_slots.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ui/qt/main_window_slots.cpp')
-rw-r--r--ui/qt/main_window_slots.cpp44
1 files changed, 31 insertions, 13 deletions
diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp
index 51851e6caa..8f675926d9 100644
--- a/ui/qt/main_window_slots.cpp
+++ b/ui/qt/main_window_slots.cpp
@@ -894,9 +894,36 @@ void MainWindow::captureFileSaveStarted(const QString &file_path)
main_ui_->statusBar->pushFileStatus(tr("Saving %1" UTF8_HORIZONTAL_ELLIPSIS).arg(file_info.baseName()));
}
+struct filter_expression_data
+{
+ MainWindow* window;
+ bool actions_added;
+};
+
+gboolean MainWindow::filter_expression_add_action(const void *key _U_, void *value, void *user_data)
+{
+ filter_expression_t* fe = (filter_expression_t*)value;
+ struct filter_expression_data* data = (filter_expression_data*)user_data;
+
+ if (!fe->enabled)
+ return FALSE;
+
+ QAction *dfb_action = new QAction(fe->label, data->window->filter_expression_toolbar_);
+ dfb_action->setToolTip(fe->expression);
+ dfb_action->setData(fe->expression);
+ dfb_action->setProperty(dfe_property_, true);
+ data->window->filter_expression_toolbar_->addAction(dfb_action);
+ connect(dfb_action, SIGNAL(data->window->triggered()), data->window, SLOT(data->window->displayFilterButtonClicked()));
+ data->actions_added = true;
+ return FALSE;
+}
+
void MainWindow::filterExpressionsChanged()
{
- bool actions_added = false;
+ struct filter_expression_data data;
+
+ data.window = this;
+ data.actions_added = false;
// Recreate filter buttons
foreach (QAction *act, filter_expression_toolbar_->actions()) {
@@ -908,18 +935,9 @@ void MainWindow::filterExpressionsChanged()
}
// XXX Add a context menu for removing and changing buttons.
- for (struct filter_expression *fe = *pfilter_expression_head; fe != NULL; fe = fe->next) {
- if (!fe->enabled) continue;
- QAction *dfb_action = new QAction(fe->label, filter_expression_toolbar_);
- dfb_action->setToolTip(fe->expression);
- dfb_action->setData(fe->expression);
- dfb_action->setProperty(dfe_property_, true);
- filter_expression_toolbar_->addAction(dfb_action);
- connect(dfb_action, SIGNAL(triggered()), this, SLOT(displayFilterButtonClicked()));
- actions_added = true;
- }
-
- if (actions_added) {
+ filter_expression_iterate_expressions(filter_expression_add_action, &data);
+
+ if (data.actions_added) {
main_ui_->displayFilterToolBar->adjustSize();
}
}