summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/filterwidget2.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'desktop-widgets/filterwidget2.cpp')
-rw-r--r--desktop-widgets/filterwidget2.cpp29
1 files changed, 25 insertions, 4 deletions
diff --git a/desktop-widgets/filterwidget2.cpp b/desktop-widgets/filterwidget2.cpp
index f1cd3263d..490892cc1 100644
--- a/desktop-widgets/filterwidget2.cpp
+++ b/desktop-widgets/filterwidget2.cpp
@@ -2,9 +2,11 @@
#include "desktop-widgets/filterconstraintwidget.h"
#include "desktop-widgets/simplewidgets.h"
#include "desktop-widgets/mainwindow.h"
+#include "commands/command.h"
#include "core/qthelper.h"
#include "core/divelist.h"
#include "core/settings/qPrefUnit.h"
+#include "core/filterpreset.h"
#include <QDoubleSpinBox>
@@ -100,19 +102,38 @@ void FilterWidget2::closeFilter()
MainWindow::instance()->setApplicationState(ApplicationState::Default);
}
-void FilterWidget2::updateFilter()
+FilterData FilterWidget2::createFilterData() const
{
- if (ignoreSignal)
- return;
-
FilterData filterData;
filterData.fulltextStringMode = (StringFilterMode)ui.fulltextStringMode->currentIndex();
filterData.fullText = ui.fullText->text();
filterData.constraints = constraintModel.getConstraints();
+ return filterData;
+}
+
+void FilterWidget2::updateFilter()
+{
+ if (ignoreSignal)
+ return;
+
+ FilterData filterData = createFilterData();
validFilter = filterData.validFilter();
DiveFilter::instance()->setFilter(filterData);
}
+void FilterWidget2::on_addSetButton_clicked()
+{
+ AddFilterPresetDialog dialog(this);
+ QString name = dialog.doit();
+ if (name.isEmpty())
+ return;
+ int idx = filter_preset_id(name);
+ if (idx >= 0)
+ Command::editFilterPreset(idx, createFilterData());
+ else
+ Command::createFilterPreset(name, createFilterData());
+}
+
void FilterWidget2::showEvent(QShowEvent *event)
{
QWidget::showEvent(event);