aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/divefilter.cpp4
-rw-r--r--core/divefilter.h1
-rw-r--r--desktop-widgets/filterwidget2.cpp12
-rw-r--r--desktop-widgets/filterwidget2.ui22
4 files changed, 34 insertions, 5 deletions
diff --git a/core/divefilter.cpp b/core/divefilter.cpp
index ed8e30f5f..89fbd731d 100644
--- a/core/divefilter.cpp
+++ b/core/divefilter.cpp
@@ -349,6 +349,10 @@ bool DiveFilter::showDive(const struct dive *d) const
if (!filterData.planned && !has_planned(d, false))
return false;
+ // Dive mode
+ if (filterData.diveMode >= 0 && d->dc.divemode != (divemode_t)filterData.diveMode)
+ return false;
+
return true;
}
diff --git a/core/divefilter.h b/core/divefilter.h
index ae5ba9869..37024be47 100644
--- a/core/divefilter.h
+++ b/core/divefilter.h
@@ -101,6 +101,7 @@ struct FilterData {
StringFilterMode equipmentStringMode = StringFilterMode::SUBSTRING;
bool logged = true;
bool planned = true;
+ int diveMode = -1; // -1: don't filter, >= 0: corresponds to divemode_t
};
class DiveFilter {
diff --git a/desktop-widgets/filterwidget2.cpp b/desktop-widgets/filterwidget2.cpp
index 2dee9979b..6d90ae0b3 100644
--- a/desktop-widgets/filterwidget2.cpp
+++ b/desktop-widgets/filterwidget2.cpp
@@ -21,6 +21,13 @@ FilterWidget2::FilterWidget2(QWidget* parent) :
ui.minWaterTemp->setRange(data.minWaterTemp, data.maxWaterTemp);
ui.maxWaterTemp->setRange(data.minWaterTemp, data.maxWaterTemp);
+ // This needs to be the same order as enum dive_comp_type in dive.h!
+ QStringList types;
+ types.append(""); // Empty means don't filter on dive mode
+ for (int i = 0; i < NUM_DIVEMODE; i++)
+ types.append(gettextFromC::tr(divemode_text_ui[i]));
+ ui.diveMode->insertItems(0, types);
+
// TODO: unhide this when we discover how to search for equipment.
ui.equipment->hide();
ui.equipmentMode->hide();
@@ -135,6 +142,9 @@ FilterWidget2::FilterWidget2(QWidget* parent) :
connect(ui.planned, &QCheckBox::stateChanged,
this, &FilterWidget2::updatePlanned);
+ connect(ui.diveMode, QOverload<int>::of(&QComboBox::currentIndexChanged),
+ this, &FilterWidget2::updateFilter);
+
// Update temperature fields if user changes temperature-units in preferences.
connect(qPrefUnits::instance(), &qPrefUnits::temperatureChanged,
this, &FilterWidget2::temperatureChanged);
@@ -183,6 +193,7 @@ void FilterWidget2::clearFilter()
ui.suitStringMode->setCurrentIndex((int)filterData.suitStringMode);
ui.dnotesStringMode->setCurrentIndex((int)filterData.dnotesStringMode);
ui.equipmentStringMode->setCurrentIndex((int)filterData.equipmentStringMode);
+ ui.diveMode->setCurrentIndex(filterData.diveMode + 1); // -1 means don't filter, transform that into index 0
ignoreSignal = false;
@@ -243,6 +254,7 @@ void FilterWidget2::updateFilter()
filterData.equipmentStringMode = (StringFilterMode)ui.equipmentStringMode->currentIndex();
filterData.logged = ui.logged->isChecked();
filterData.planned = ui.planned->isChecked();
+ filterData.diveMode = ui.diveMode->currentIndex() - 1; // The first entry means don't filter, transform that to -1.
filterDataChanged(filterData);
}
diff --git a/desktop-widgets/filterwidget2.ui b/desktop-widgets/filterwidget2.ui
index 74f1e5da7..395083204 100644
--- a/desktop-widgets/filterwidget2.ui
+++ b/desktop-widgets/filterwidget2.ui
@@ -115,7 +115,7 @@
</property>
</widget>
</item>
- <item row="15" column="0">
+ <item row="16" column="0">
<widget class="QLabel" name="labelEquipment">
<property name="text">
<string>Equipment</string>
@@ -188,7 +188,7 @@
</property>
</widget>
</item>
- <item row="15" column="1">
+ <item row="16" column="1">
<widget class="QComboBox" name="equipmentMode">
<item>
<property name="text">
@@ -234,7 +234,7 @@
</property>
</widget>
</item>
- <item row="15" column="0">
+ <item row="16" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@@ -247,7 +247,7 @@
</property>
</spacer>
</item>
- <item row="13" column="4" colspan="2">
+ <item row="16" column="4" colspan="2">
<widget class="QLineEdit" name="equipment"/>
</item>
<item row="8" column="4">
@@ -452,7 +452,7 @@
</property>
</widget>
</item>
- <item row="15" column="2">
+ <item row="16" column="2">
<widget class="QComboBox" name="equipmentStringMode">
<item>
<property name="text">
@@ -602,6 +602,17 @@
<item row="1" column="2" colspan="4">
<widget class="QLineEdit" name="fullText"/>
</item>
+ <item row="15" column="0">
+ <widget class="QLabel" name="label_21">
+ <property name="text">
+ <string>Dive mode</string>
+ </property>
+ </widget>
+ </item>
+ <item row="15" column="1">
+ <widget class="QComboBox" name="diveMode">
+ </widget>
+ </item>
</layout>
</widget>
</widget>
@@ -648,6 +659,7 @@
<tabstop>dnotesMode</tabstop>
<tabstop>dnotesStringMode</tabstop>
<tabstop>dnotes</tabstop>
+ <tabstop>diveMode</tabstop>
<tabstop>equipmentMode</tabstop>
<tabstop>equipmentStringMode</tabstop>
<tabstop>equipment</tabstop>