summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--desktop-widgets/filterwidget2.cpp20
-rw-r--r--desktop-widgets/filterwidget2.ui62
-rw-r--r--qt-models/filtermodels.cpp29
-rw-r--r--qt-models/filtermodels.h4
4 files changed, 113 insertions, 2 deletions
diff --git a/desktop-widgets/filterwidget2.cpp b/desktop-widgets/filterwidget2.cpp
index 5f78d6396..17e43f941 100644
--- a/desktop-widgets/filterwidget2.cpp
+++ b/desktop-widgets/filterwidget2.cpp
@@ -99,6 +99,18 @@ FilterWidget2::FilterWidget2(QWidget* parent) :
connect(ui.locationMode, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &FilterWidget2::updateFilter);
+ connect(ui.suit, &QLineEdit::textChanged,
+ this, &FilterWidget2::updateFilter);
+
+ connect(ui.suitMode, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
+ this, &FilterWidget2::updateFilter);
+
+ connect(ui.dnotes, &QLineEdit::textChanged,
+ this, &FilterWidget2::updateFilter);
+
+ connect(ui.dnotesMode, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
+ this, &FilterWidget2::updateFilter);
+
connect(ui.logged, &QCheckBox::stateChanged,
this, &FilterWidget2::updateLogged);
@@ -136,6 +148,8 @@ void FilterWidget2::clearFilter()
ui.planned->setChecked(filterData.planned);
ui.people->clear();
ui.location->clear();
+ ui.suit->clear();
+ ui.dnotes->clear();
ui.equipment->clear();
ui.tags->clear();
ui.fromDate->setDate(filterData.fromDate.date());
@@ -145,6 +159,8 @@ void FilterWidget2::clearFilter()
ui.tagsMode->setCurrentIndex((int)filterData.tagsMode);
ui.peopleMode->setCurrentIndex((int)filterData.peopleMode);
ui.locationMode->setCurrentIndex((int)filterData.locationMode);
+ ui.suitMode->setCurrentIndex((int)filterData.suitMode);
+ ui.dnotesMode->setCurrentIndex((int)filterData.dnotesMode);
ui.equipmentMode->setCurrentIndex((int)filterData.equipmentMode);
ignoreSignal = false;
@@ -187,10 +203,14 @@ void FilterWidget2::updateFilter()
filterData.tags = ui.tags->text().split(",", QString::SkipEmptyParts);
filterData.people = ui.people->text().split(",", QString::SkipEmptyParts);
filterData.location = ui.location->text().split(",", QString::SkipEmptyParts);
+ filterData.suit = ui.suit->text().split(",", QString::SkipEmptyParts);
+ filterData.dnotes = ui.dnotes->text().split(",", QString::SkipEmptyParts);
filterData.equipment = ui.equipment->text().split(",", QString::SkipEmptyParts);
filterData.tagsMode = (FilterData::Mode)ui.tagsMode->currentIndex();
filterData.peopleMode = (FilterData::Mode)ui.peopleMode->currentIndex();
filterData.locationMode = (FilterData::Mode)ui.locationMode->currentIndex();
+ filterData.suitMode = (FilterData::Mode)ui.suitMode->currentIndex();
+ filterData.dnotesMode = (FilterData::Mode)ui.dnotesMode->currentIndex();
filterData.equipmentMode = (FilterData::Mode)ui.equipmentMode->currentIndex();
filterData.logged = ui.logged->isChecked();
filterData.planned = ui.planned->isChecked();
diff --git a/desktop-widgets/filterwidget2.ui b/desktop-widgets/filterwidget2.ui
index eba4840e2..6b1318fc6 100644
--- a/desktop-widgets/filterwidget2.ui
+++ b/desktop-widgets/filterwidget2.ui
@@ -124,7 +124,13 @@
<item row="10" column="4" colspan="2">
<widget class="QLineEdit" name="location"/>
</item>
- <item row="11" column="0">
+ <item row="11" column="4" colspan="2">
+ <widget class="QLineEdit" name="suit"/>
+ </item>
+ <item row="12" column="4" colspan="2">
+ <widget class="QLineEdit" name="dnotes"/>
+ </item>
+ <item row="13" column="0">
<widget class="QLabel" name="labelEquipment">
<property name="text">
<string>Equipment</string>
@@ -164,6 +170,20 @@
</property>
</widget>
</item>
+ <item row="11" column="0">
+ <widget class="QLabel" name="label_10">
+ <property name="text">
+ <string>Suit</string>
+ </property>
+ </widget>
+ </item>
+ <item row="12" column="0">
+ <widget class="QLabel" name="label_19">
+ <property name="text">
+ <string>Notes</string>
+ </property>
+ </widget>
+ </item>
<item row="4" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
@@ -349,6 +369,44 @@
</widget>
</item>
<item row="11" column="1" colspan="2">
+ <widget class="QComboBox" name="suitMode">
+ <item>
+ <property name="text">
+ <string>All of</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Any of</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>None of</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="12" column="1" colspan="2">
+ <widget class="QComboBox" name="dnotesMode">
+ <item>
+ <property name="text">
+ <string>All of</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Any of</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>None of</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="13" column="1" colspan="2">
<widget class="QComboBox" name="equipmentMode">
<item>
<property name="text">
@@ -367,7 +425,7 @@
</item>
</widget>
</item>
- <item row="12" column="0">
+ <item row="13" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
diff --git a/qt-models/filtermodels.cpp b/qt-models/filtermodels.cpp
index 359b9a7f6..a5ba07204 100644
--- a/qt-models/filtermodels.cpp
+++ b/qt-models/filtermodels.cpp
@@ -74,6 +74,27 @@ namespace {
{
return true;
}
+
+ bool hasSuits(const QStringList &suits, const struct dive *d, FilterData::Mode mode)
+ {
+ if (suits.isEmpty())
+ return true;
+ QStringList diveSuits;
+ if (d->suit)
+ diveSuits.push_back(QString(d->suit));
+ return check(suits, diveSuits, mode);
+ }
+
+ bool hasNotes(const QStringList &dnotes, const struct dive *d, FilterData::Mode mode)
+ {
+ if (dnotes.isEmpty())
+ return true;
+ QStringList diveNotes;
+ if (d->notes)
+ diveNotes.push_back(QString(d->notes));
+ return check(dnotes, diveNotes, mode);
+ }
+
}
MultiFilterSortModel *MultiFilterSortModel::instance()
@@ -149,6 +170,14 @@ bool MultiFilterSortModel::showDive(const struct dive *d) const
if (!hasLocations(filterData.location, d, filterData.locationMode))
return false;
+ // Suit
+ if (!hasSuits(filterData.suit, d, filterData.suitMode))
+ return false;
+
+ // Notes
+ if (!hasNotes(filterData.dnotes, d, filterData.dnotesMode))
+ return false;
+
if (!hasEquipment(filterData.equipment, d, filterData.equipmentMode))
return false;
diff --git a/qt-models/filtermodels.h b/qt-models/filtermodels.h
index 996c2efaa..3b3e14abc 100644
--- a/qt-models/filtermodels.h
+++ b/qt-models/filtermodels.h
@@ -41,10 +41,14 @@ struct FilterData {
QStringList tags;
QStringList people;
QStringList location;
+ QStringList suit;
+ QStringList dnotes;
QStringList equipment;
Mode tagsMode = Mode::ALL_OF;
Mode peopleMode = Mode::ALL_OF;
Mode locationMode = Mode::ANY_OF;
+ Mode dnotesMode = Mode::ALL_OF;
+ Mode suitMode = Mode::ANY_OF;
Mode equipmentMode = Mode::ALL_OF;
bool logged = true;
bool planned = true;