mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
filter: create a primitive "create filter preset" dialog
The dialog asks the user for a name and warns if the name already exists, i.e. an old filter preset will be overwritten. Possibly, this should contain an auto-completion facility in the case that the user wants to overwrite old presets. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
2f5223035a
commit
581eb1f563
7 changed files with 194 additions and 24 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
FilterData FilterWidget2::createFilterData() const
|
||||
{
|
||||
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;
|
||||
filterData.fulltextStringMode = (StringFilterMode)ui.fulltextStringMode->currentIndex();
|
||||
filterData.fullText = ui.fullText->text();
|
||||
filterData.constraints = constraintModel.getConstraints();
|
||||
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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue