summaryrefslogtreecommitdiffstats
path: root/desktop-widgets
diff options
context:
space:
mode:
Diffstat (limited to 'desktop-widgets')
-rw-r--r--desktop-widgets/CMakeLists.txt3
-rw-r--r--desktop-widgets/command_divelist.cpp26
-rw-r--r--desktop-widgets/divelistview.cpp12
-rw-r--r--desktop-widgets/divelogimportdialog.cpp1
-rw-r--r--desktop-widgets/downloadfromdivecomputer.cpp24
-rw-r--r--desktop-widgets/filterwidget.ui140
-rw-r--r--desktop-widgets/filterwidget2.cpp105
-rw-r--r--desktop-widgets/filterwidget2.h35
-rw-r--r--desktop-widgets/filterwidget2.ui260
-rw-r--r--desktop-widgets/listfilter.ui4
-rw-r--r--desktop-widgets/locationinformation.cpp2
-rw-r--r--desktop-widgets/mainwindow.cpp24
-rw-r--r--desktop-widgets/mainwindow.h2
-rw-r--r--desktop-widgets/mainwindow.ui60
-rw-r--r--desktop-widgets/modeldelegates.cpp5
-rw-r--r--desktop-widgets/printdialog.cpp1
-rw-r--r--desktop-widgets/simplewidgets.cpp113
-rw-r--r--desktop-widgets/simplewidgets.h54
-rw-r--r--desktop-widgets/subsurfacewebservices.cpp4
-rw-r--r--desktop-widgets/tab-widgets/TabDiveStatistics.cpp14
-rw-r--r--desktop-widgets/tab-widgets/TabDiveStatistics.ui2
-rw-r--r--desktop-widgets/tab-widgets/maintab.cpp2
22 files changed, 488 insertions, 405 deletions
diff --git a/desktop-widgets/CMakeLists.txt b/desktop-widgets/CMakeLists.txt
index 519061ac0..629c0507e 100644
--- a/desktop-widgets/CMakeLists.txt
+++ b/desktop-widgets/CMakeLists.txt
@@ -33,7 +33,7 @@ set (SUBSURFACE_UI
diveplanner.ui
diveshareexportdialog.ui
downloadfromdivecomputer.ui
- filterwidget.ui
+ filterwidget2.ui
findmovedimagesdialog.ui
listfilter.ui
locationInformation.ui
@@ -90,6 +90,7 @@ set(SUBSURFACE_INTERFACE
command_divelist.cpp
locationinformation.cpp
qtwaitingspinner.cpp
+ filterwidget2.cpp
tab-widgets/TabDiveStatistics.cpp
tab-widgets/TabDiveInformation.cpp
tab-widgets/TabDivePhotos.cpp
diff --git a/desktop-widgets/command_divelist.cpp b/desktop-widgets/command_divelist.cpp
index 2c474cf94..b85b9a65f 100644
--- a/desktop-widgets/command_divelist.cpp
+++ b/desktop-widgets/command_divelist.cpp
@@ -92,6 +92,7 @@ dive *DiveListBase::addDive(DiveToAdd &d)
res->hidden_by_filter = !show;
add_single_dive(d.idx, res); // Return ownership to backend
+ invalidate_dive_cache(res); // Ensure that dive is written in git_save()
// If the dive to be removed is selected, we will inform the frontend
// later via a signal that the dive changed.
@@ -109,11 +110,6 @@ std::vector<DiveToAdd> DiveListBase::removeDives(std::vector<dive *> &divesToDel
std::vector<DiveToAdd> res;
res.reserve(divesToDelete.size());
- // First, tell the filters that dives are removed. This could
- // be done later using the emitted signals, but we do this here
- // for symmetry with addDives()
- MultiFilterSortModel::instance()->divesDeleted(QVector<dive *>::fromStdVector(divesToDelete));
-
for (dive *d: divesToDelete)
res.push_back(removeDive(d));
divesToDelete.clear();
@@ -153,7 +149,6 @@ std::vector<dive *> DiveListBase::addDives(std::vector<DiveToAdd> &divesToAdd)
QVector<dive *> divesForFilter;
for (const DiveToAdd &entry: divesToAdd)
divesForFilter.push_back(entry.dive.get());
- MultiFilterSortModel::instance()->divesAdded(divesForFilter);
// At the end of the function, to send the proper dives-added signals,
// we the the list of added trips. Create this list now.
@@ -191,7 +186,7 @@ std::vector<dive *> DiveListBase::addDives(std::vector<DiveToAdd> &divesToAdd)
// This helper function renumbers dives according to an array of id/number pairs.
// The old numbers are stored in the array, thus calling this function twice has no effect.
-// TODO: switch from uniq-id to indexes once all divelist-actions are controlled by undo-able commands
+// TODO: switch from uniq-id to indices once all divelist-actions are controlled by undo-able commands
static void renumberDives(QVector<QPair<dive *, int>> &divesToRenumber)
{
for (auto &pair: divesToRenumber) {
@@ -199,6 +194,7 @@ static void renumberDives(QVector<QPair<dive *, int>> &divesToRenumber)
if (!d)
continue;
std::swap(d->number, pair.second);
+ invalidate_dive_cache(d);
}
// Emit changed signals per trip.
@@ -239,6 +235,7 @@ static OwningTripPtr moveDiveToTrip(DiveToTrip &diveToTrip)
// Store old trip and get new trip we should associate this dive with
std::swap(trip, diveToTrip.trip);
add_dive_to_trip(diveToTrip.dive, trip);
+ invalidate_dive_cache(diveToTrip.dive); // Ensure that dive is written in git_save()
return res;
}
@@ -302,9 +299,12 @@ static void moveDivesBetweenTrips(DivesToTrip &dives)
for (size_t k = i; k < j; ++k)
divesInTrip[k - i] = divesMoved[k].d;
- // Check if the from-trip was deleted: If yes, it was recorded in the tripsToAdd structure
+ // Check if the from-trip was deleted: If yes, it was recorded in the tripsToAdd structure.
+ // Only set the flag if this is that last time this trip is featured.
bool deleteFrom = from &&
- std::find_if(dives.tripsToAdd.begin(), dives.tripsToAdd.end(),
+ std::find_if(divesMoved.begin() + j, divesMoved.end(), // Is this the last occurence of "from"?
+ [from](const DiveMoved &entry) { return entry.from == from; }) == divesMoved.end() &&
+ std::find_if(dives.tripsToAdd.begin(), dives.tripsToAdd.end(), // Is "from" in tripsToAdd?
[from](const OwningTripPtr &trip) { return trip.get() == from; }) != dives.tripsToAdd.end();
// Check if the to-trip has to be created. For this purpose, we saved an array of trips to be created.
bool createTo = false;
@@ -600,7 +600,7 @@ ShiftTime::ShiftTime(const QVector<dive *> &changedDives, int amount)
void ShiftTime::redoit()
{
for (dive *d: diveList)
- d->when -= timeChanged;
+ d->when += timeChanged;
// Changing times may have unsorted the dive table
sort_table(&dive_table);
@@ -737,7 +737,7 @@ MergeTrips::MergeTrips(dive_trip *trip1, dive_trip *trip2)
{
if (trip1 == trip2)
return;
- dive_trip *newTrip = combine_trips_create(trip1, trip2);
+ dive_trip *newTrip = combine_trips(trip1, trip2);
divesToMove.tripsToAdd.emplace_back(newTrip);
for (int i = 0; i < trip1->dives.nr; ++i)
divesToMove.divesToMove.push_back( { trip1->dives.dives[i], newTrip } );
@@ -752,8 +752,8 @@ SplitDives::SplitDives(dive *d, duration_t time)
// Split the dive
dive *new1, *new2;
int idx = time.seconds < 0 ?
- split_dive_dont_insert(d, &new1, &new2) :
- split_dive_at_time_dont_insert(d, time, &new1, &new2);
+ split_dive(d, &new1, &new2) :
+ split_dive_at_time(d, time, &new1, &new2);
// If this didn't work, simply return. Empty arrays indicate that nothing is to be done.
if (idx < 0)
diff --git a/desktop-widgets/divelistview.cpp b/desktop-widgets/divelistview.cpp
index 9167bea5e..c340b556b 100644
--- a/desktop-widgets/divelistview.cpp
+++ b/desktop-widgets/divelistview.cpp
@@ -25,6 +25,7 @@
#include "qt-models/divepicturemodel.h"
#include "core/metrics.h"
#include "core/subsurface-qt/DiveListNotifier.h"
+#include "desktop-widgets/simplewidgets.h"
DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelection(false),
currentLayout(DiveTripModel::TREE), dontEmitDiveChangedSignal(false), selectionSaved(false),
@@ -969,15 +970,8 @@ void DiveListView::matchImagesToDives(QStringList fileNames)
return;
updateLastImageTimeOffset(shiftDialog.amount());
- Q_FOREACH (const QString &fileName, fileNames) {
- int j = 0;
- struct dive *dive;
- for_each_dive (j, dive) {
- if (!dive->selected)
- continue;
- dive_create_picture(dive, copy_qstring(fileName), shiftDialog.amount(), shiftDialog.matchAll());
- }
- }
+ for (const QString &fileName: fileNames)
+ create_picture(qPrintable(fileName), shiftDialog.amount(), shiftDialog.matchAll());
mark_divelist_changed(true);
copy_dive(current_dive, &displayed_dive);
diff --git a/desktop-widgets/divelogimportdialog.cpp b/desktop-widgets/divelogimportdialog.cpp
index 668b230a8..f4f9311ff 100644
--- a/desktop-widgets/divelogimportdialog.cpp
+++ b/desktop-widgets/divelogimportdialog.cpp
@@ -9,6 +9,7 @@
#include <QMimeData>
#include <QRegExp>
#include <QUndoStack>
+#include <QPainter>
#include "core/qthelper.h"
#include "core/import-csv.h"
diff --git a/desktop-widgets/downloadfromdivecomputer.cpp b/desktop-widgets/downloadfromdivecomputer.cpp
index 3c70d8686..f92fdbb70 100644
--- a/desktop-widgets/downloadfromdivecomputer.cpp
+++ b/desktop-widgets/downloadfromdivecomputer.cpp
@@ -29,14 +29,12 @@ DownloadFromDCWidget::DownloadFromDCWidget(QWidget *parent, Qt::WindowFlags f) :
currentState(INITIAL)
{
diveImportedModel = new DiveImportedModel(this);
- diveImportedModel->setDiveTable(&downloadTable);
vendorModel.setStringList(vendorList);
QShortcut *close = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), this);
QShortcut *quit = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), this);
int startingWidth = defaultModelFont().pointSize();
- clear_table(&downloadTable);
ui.setupUi(this);
ui.progressBar->hide();
ui.progressBar->setMinimum(0);
@@ -254,7 +252,7 @@ void DownloadFromDCWidget::updateState(states state)
markChildrenAsEnabled();
progress_bar_text = "";
} else {
- if (downloadTable.nr != 0)
+ if (thread.table()->nr != 0)
progress_bar_text = "";
ui.progressBar->setValue(100);
markChildrenAsEnabled();
@@ -349,7 +347,7 @@ void DownloadFromDCWidget::on_downloadCancelRetryButton_clicked()
// this means we are retrying - so we better clean out the partial
// list of downloaded dives from the last attempt
diveImportedModel->clearTable();
- clear_table(&downloadTable);
+ clear_table(thread.table());
}
updateState(DOWNLOADING);
@@ -492,10 +490,7 @@ void DownloadFromDCWidget::onDownloadThreadFinished()
}
ui.downloadCancelRetryButton->setText(tr("Retry download"));
ui.downloadCancelRetryButton->setEnabled(true);
- // regardless, if we got dives, we should show them to the user
- if (downloadTable.nr) {
- diveImportedModel->setImportedDivesIndexes(0, downloadTable.nr - 1);
- }
+ diveImportedModel->repopulate(thread.table());
}
void DownloadFromDCWidget::on_cancel_clicked()
@@ -504,7 +499,7 @@ void DownloadFromDCWidget::on_cancel_clicked()
return;
// now discard all the dives
- clear_table(&downloadTable);
+ clear_table(thread.table());
done(-1);
}
@@ -512,23 +507,24 @@ void DownloadFromDCWidget::on_ok_clicked()
{
if (currentState != DONE && currentState != ERROR)
return;
+ struct dive_table *table = thread.table();
// delete non-selected dives
- int total = downloadTable.nr;
+ int total = table->nr;
int j = 0;
for (int i = 0; i < total; i++) {
if (diveImportedModel->data(diveImportedModel->index(i, 0), Qt::CheckStateRole) == Qt::Checked)
j++;
else
- delete_dive_from_table(&downloadTable, j);
+ delete_dive_from_table(thread.table(), j);
}
- if (downloadTable.nr > 0) {
+ if (table->nr > 0) {
MainWindow::instance()->diveList->unselectDives();
// remember the last downloaded dive (on most dive computers this will be the chronologically
// first new dive) and select it again after processing all the dives
- int uniqId = downloadTable.dives[downloadTable.nr - 1]->id;
- process_imported_dives(&downloadTable, preferDownloaded(), true);
+ int uniqId = table->dives[table->nr - 1]->id;
+ process_imported_dives(table, preferDownloaded(), true);
autogroup_dives();
Command::clear();
// after process_imported_dives does any merging or resorting needed, we need
diff --git a/desktop-widgets/filterwidget.ui b/desktop-widgets/filterwidget.ui
deleted file mode 100644
index 7f548a931..000000000
--- a/desktop-widgets/filterwidget.ui
+++ /dev/null
@@ -1,140 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<ui version="4.0">
- <class>FilterWidget2</class>
- <widget class="QWidget" name="FilterWidget2">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>594</width>
- <height>362</height>
- </rect>
- </property>
- <property name="windowTitle">
- <string></string>
- </property>
- <layout class="QVBoxLayout" name="verticalLayout">
- <property name="spacing">
- <number>0</number>
- </property>
- <property name="leftMargin">
- <number>0</number>
- </property>
- <property name="topMargin">
- <number>0</number>
- </property>
- <property name="rightMargin">
- <number>0</number>
- </property>
- <property name="bottomMargin">
- <number>0</number>
- </property>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <property name="spacing">
- <number>0</number>
- </property>
- <item>
- <spacer name="horizontalSpacer_2">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QLabel" name="filterText">
- <property name="text">
- <string/>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QToolButton" name="clear">
- <property name="toolTip">
- <string>Reset filters</string>
- </property>
- <property name="icon">
- <iconset resource="../subsurface.qrc">
- <normaloff>:edit-clear-icon</normaloff>:edit-clear-icon</iconset>
- </property>
- <property name="autoRaise">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QToolButton" name="maximize">
- <property name="toolTip">
- <string>Show/hide filters</string>
- </property>
- <property name="icon">
- <iconset resource="../subsurface.qrc">
- <normaloff>:hide-icon</normaloff>:hide-icon</iconset>
- </property>
- <property name="autoRaise">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QToolButton" name="close">
- <property name="toolTip">
- <string>Close and reset filters</string>
- </property>
- <property name="icon">
- <iconset resource="../subsurface.qrc">
- <normaloff>:filter-close</normaloff>:filter-close</iconset>
- </property>
- <property name="autoRaise">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- </layout>
- </item>
- <item>
- <widget class="QScrollArea" name="scrollArea">
- <property name="frameShape">
- <enum>QFrame::NoFrame</enum>
- </property>
- <property name="widgetResizable">
- <bool>true</bool>
- </property>
- <widget class="QWidget" name="scrollAreaWidgetContents">
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>594</width>
- <height>337</height>
- </rect>
- </property>
- </widget>
- </widget>
- </item>
- </layout>
- </widget>
- <resources>
- <include location="../subsurface.qrc"/>
- </resources>
- <connections/>
-</ui>
diff --git a/desktop-widgets/filterwidget2.cpp b/desktop-widgets/filterwidget2.cpp
new file mode 100644
index 000000000..d120ffe4d
--- /dev/null
+++ b/desktop-widgets/filterwidget2.cpp
@@ -0,0 +1,105 @@
+#include "desktop-widgets/filterwidget2.h"
+#include "desktop-widgets/simplewidgets.h"
+
+#include <QDoubleSpinBox>
+
+FilterWidget2::FilterWidget2(QWidget* parent)
+: QWidget(parent)
+, ui(new Ui::FilterWidget2())
+{
+ ui->setupUi(this);
+
+ FilterData data;
+ ui->minRating->setCurrentStars(data.minRating);
+ ui->maxRating->setCurrentStars(data.maxRating);
+ ui->minVisibility->setCurrentStars(data.minVisibility);
+ ui->maxVisibility->setCurrentStars(data.maxVisibility);
+ ui->minAirTemp->setValue(data.minAirTemp);
+ ui->maxAirTemp->setValue(data.maxAirTemp);
+ ui->minWaterTemp->setValue(data.minWaterTemp);
+ ui->maxWaterTemp->setValue(data.maxWaterTemp);
+
+ // TODO: unhide this when we discover how to search for equipment.
+ ui->equipment->hide();
+ ui->labelEquipment->hide();
+ ui->invertFilter->hide();
+
+ ui->to->setDate(data.to.date());
+
+ connect(ui->maxRating, &StarWidget::valueChanged,
+ this, &FilterWidget2::updateFilter);
+
+ connect(ui->minRating, &StarWidget::valueChanged,
+ this, &FilterWidget2::updateFilter);
+
+ connect(ui->maxVisibility, &StarWidget::valueChanged,
+ this, &FilterWidget2::updateFilter);
+
+ connect(ui->minVisibility, &StarWidget::valueChanged,
+ this, &FilterWidget2::updateFilter);
+
+ connect(ui->maxAirTemp, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
+ this, &FilterWidget2::updateFilter);
+
+ connect(ui->minAirTemp, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
+ this, &FilterWidget2::updateFilter);
+
+ connect(ui->maxWaterTemp, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
+ this, &FilterWidget2::updateFilter);
+
+ connect(ui->minWaterTemp, static_cast<void (QDoubleSpinBox::*)(double)>(&QDoubleSpinBox::valueChanged),
+ this, &FilterWidget2::updateFilter);
+
+ connect(ui->from, &QDateTimeEdit::dateTimeChanged,
+ this, &FilterWidget2::updateFilter);
+
+ connect(ui->to, &QDateTimeEdit::dateTimeChanged,
+ this, &FilterWidget2::updateFilter);
+
+ connect(ui->tags, &QLineEdit::textChanged,
+ this, &FilterWidget2::updateFilter);
+
+ connect(ui->people, &QLineEdit::textChanged,
+ this, &FilterWidget2::updateFilter);
+
+ connect(ui->location, &QLineEdit::textChanged,
+ this, &FilterWidget2::updateFilter);
+}
+
+void FilterWidget2::updateFilter()
+{
+ FilterData data;
+
+ data.validFilter = true;
+ data.minVisibility = ui->minVisibility->currentStars();
+ data.maxVisibility = ui->maxVisibility->currentStars();
+ data.minRating = ui->minRating->currentStars();
+ data.maxRating = ui->maxRating->currentStars();
+ data.minWaterTemp = ui->minWaterTemp->value();
+ data.maxWaterTemp = ui->maxWaterTemp->value();
+ data.minAirTemp = ui->minAirTemp->value();
+ data.maxWaterTemp = ui->maxWaterTemp->value();
+ data.from = ui->from->dateTime();
+ data.to = ui->to->dateTime();
+ data.tags = ui->tags->text().split(",", QString::SkipEmptyParts);
+ data.people = ui->people->text().split(",", QString::SkipEmptyParts);
+ data.location = ui->location->text().split(",", QString::SkipEmptyParts);
+ data.equipment = ui->equipment->text().split(",", QString::SkipEmptyParts);
+ data.invertFilter = ui->invertFilter->isChecked();
+
+ filterData = data;
+ emit filterDataChanged(data);
+}
+
+void FilterWidget2::showEvent(QShowEvent *event)
+{
+ QWidget::showEvent(event);
+ emit filterDataChanged(filterData);
+}
+
+void FilterWidget2::hideEvent(QHideEvent *event)
+{
+ QWidget::hideEvent(event);
+ FilterData data;
+ emit filterDataChanged(data);
+}
diff --git a/desktop-widgets/filterwidget2.h b/desktop-widgets/filterwidget2.h
new file mode 100644
index 000000000..80629f0cc
--- /dev/null
+++ b/desktop-widgets/filterwidget2.h
@@ -0,0 +1,35 @@
+#ifndef FILTERWIDGET_2_H
+#define FILTERWIDGET_2_H
+
+#include <QWidget>
+#include <QHideEvent>
+#include <QShowEvent>
+
+#include <memory>
+
+#include "ui_filterwidget2.h"
+#include "qt-models/filtermodels.h"
+
+namespace Ui {
+ class FilterWidget2;
+}
+
+class FilterWidget2 : public QWidget {
+ Q_OBJECT
+
+public:
+ explicit FilterWidget2(QWidget *parent = 0);
+ void updateFilter();
+protected:
+ void hideEvent(QHideEvent *event) override;
+ void showEvent(QShowEvent *event) override;
+
+signals:
+ void filterDataChanged(const FilterData& data);
+
+private:
+ std::unique_ptr<Ui::FilterWidget2> ui;
+ FilterData filterData;
+};
+
+#endif
diff --git a/desktop-widgets/filterwidget2.ui b/desktop-widgets/filterwidget2.ui
new file mode 100644
index 000000000..978dafc6e
--- /dev/null
+++ b/desktop-widgets/filterwidget2.ui
@@ -0,0 +1,260 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>FilterWidget2</class>
+ <widget class="QWidget" name="FilterWidget2">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>510</width>
+ <height>320</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="3" column="1">
+ <widget class="QLabel" name="label_12">
+ <property name="text">
+ <string>Min</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="4">
+ <widget class="StarWidget" name="maxVisibility" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="focusPolicy">
+ <enum>Qt::TabFocus</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="2">
+ <widget class="QDoubleSpinBox" name="minWaterTemp"/>
+ </item>
+ <item row="2" column="2">
+ <widget class="StarWidget" name="minVisibility" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="focusPolicy">
+ <enum>Qt::TabFocus</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="7" column="0">
+ <widget class="QLabel" name="label_7">
+ <property name="text">
+ <string>Tags</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string> Rating</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2">
+ <widget class="StarWidget" name="minRating" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="focusPolicy">
+ <enum>Qt::TabFocus</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="8" column="0">
+ <widget class="QLabel" name="label_8">
+ <property name="text">
+ <string>People</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="3">
+ <widget class="QLabel" name="label_13">
+ <property name="text">
+ <string>Max</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Min</string>
+ </property>
+ </widget>
+ </item>
+ <item row="7" column="1" colspan="4">
+ <widget class="QLineEdit" name="tags"/>
+ </item>
+ <item row="11" column="1" colspan="4">
+ <widget class="QCheckBox" name="invertFilter">
+ <property name="toolTip">
+ <string>Display dives that will not match the search, only applies to tags, people, location and equipment</string>
+ </property>
+ <property name="text">
+ <string>Invert filter</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="3">
+ <widget class="QLabel" name="label_16">
+ <property name="text">
+ <string>Max</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="1" colspan="4">
+ <widget class="QDateTimeEdit" name="from"/>
+ </item>
+ <item row="8" column="1" colspan="4">
+ <widget class="QLineEdit" name="people"/>
+ </item>
+ <item row="1" column="4">
+ <widget class="StarWidget" name="maxRating" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="focusPolicy">
+ <enum>Qt::TabFocus</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="4">
+ <widget class="QDoubleSpinBox" name="maxWaterTemp"/>
+ </item>
+ <item row="10" column="0">
+ <widget class="QLabel" name="labelEquipment">
+ <property name="text">
+ <string>Equipment</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="3">
+ <widget class="QLabel" name="label_15">
+ <property name="text">
+ <string>Max</string>
+ </property>
+ </widget>
+ </item>
+ <item row="9" column="0">
+ <widget class="QLabel" name="label_9">
+ <property name="text">
+ <string>Location</string>
+ </property>
+ </widget>
+ </item>
+ <item row="9" column="1" colspan="4">
+ <widget class="QLineEdit" name="location"/>
+ </item>
+ <item row="6" column="1" colspan="4">
+ <widget class="QDateTimeEdit" name="to"/>
+ </item>
+ <item row="10" column="1" colspan="4">
+ <widget class="QLineEdit" name="equipment"/>
+ </item>
+ <item row="5" column="0">
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>From</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="0">
+ <widget class="QLabel" name="label_6">
+ <property name="text">
+ <string>To</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_5">
+ <property name="text">
+ <string>Visibility</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="label_11">
+ <property name="text">
+ <string>Water Temp</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QLabel" name="label_14">
+ <property name="text">
+ <string>Min</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Air Temp</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <widget class="QLabel" name="label_17">
+ <property name="text">
+ <string>Min</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="3">
+ <widget class="QLabel" name="label_18">
+ <property name="text">
+ <string>Max</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="2">
+ <widget class="QDoubleSpinBox" name="minAirTemp"/>
+ </item>
+ <item row="4" column="4">
+ <widget class="QDoubleSpinBox" name="maxAirTemp"/>
+ </item>
+ </layout>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>StarWidget</class>
+ <extends>QWidget</extends>
+ <header location="global">desktop-widgets/starwidget.h</header>
+ <container>1</container>
+ </customwidget>
+ </customwidgets>
+ <tabstops>
+ <tabstop>minRating</tabstop>
+ <tabstop>maxRating</tabstop>
+ <tabstop>minVisibility</tabstop>
+ <tabstop>maxVisibility</tabstop>
+ <tabstop>from</tabstop>
+ <tabstop>to</tabstop>
+ <tabstop>tags</tabstop>
+ <tabstop>people</tabstop>
+ <tabstop>location</tabstop>
+ <tabstop>equipment</tabstop>
+ <tabstop>invertFilter</tabstop>
+ </tabstops>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/desktop-widgets/listfilter.ui b/desktop-widgets/listfilter.ui
index 06f1889a8..91d430617 100644
--- a/desktop-widgets/listfilter.ui
+++ b/desktop-widgets/listfilter.ui
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
- <class>FilterWidget</class>
- <widget class="QWidget" name="FilterWidget">
+ <class>ListFilter</class>
+ <widget class="QWidget" name="ListFilter">
<property name="geometry">
<rect>
<x>0</x>
diff --git a/desktop-widgets/locationinformation.cpp b/desktop-widgets/locationinformation.cpp
index 2d0807474..7356f8370 100644
--- a/desktop-widgets/locationinformation.cpp
+++ b/desktop-widgets/locationinformation.cpp
@@ -34,8 +34,6 @@ LocationInformationWidget::LocationInformationWidget(QWidget *parent) : QGroupBo
ui.diveSiteMessage->addAction(rejectAction);
connect(ui.geoCodeButton, SIGNAL(clicked()), this, SLOT(reverseGeocode()));
- connect(this, SIGNAL(nameChanged(const QString &, const QString &)),
- LocationFilterModel::instance(), SLOT(changeName(const QString &, const QString &)));
connect(ui.updateLocationButton, SIGNAL(clicked()), this, SLOT(updateLocationOnMap()));
connect(ui.diveSiteCoordinates, SIGNAL(returnPressed()), this, SLOT(updateLocationOnMap()));
ui.diveSiteCoordinates->installEventFilter(this);
diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp
index 99942ec56..6c0b42c9d 100644
--- a/desktop-widgets/mainwindow.cpp
+++ b/desktop-widgets/mainwindow.cpp
@@ -53,6 +53,8 @@
#include "desktop-widgets/tab-widgets/maintab.h"
#include "desktop-widgets/updatemanager.h"
#include "desktop-widgets/usersurvey.h"
+#include "desktop-widgets/filterwidget2.h"
+#include "desktop-widgets/simplewidgets.h"
#include "profile-widget/profilewidget2.h"
@@ -141,10 +143,10 @@ MainWindow::MainWindow() : QMainWindow(),
diveList = new DiveListView(this);
graphics = new ProfileWidget2(this);
MapWidget *mapWidget = MapWidget::instance();
-
divePlannerSettingsWidget = new PlannerSettingsWidget(this);
divePlannerWidget = new DivePlannerWidget(this);
plannerDetails = new PlannerDetails(this);
+ auto *filterWidget2 = new FilterWidget2();
// what is a sane order for those icons? we should have the ones the user is
// most likely to want towards the top so they are always visible
@@ -193,6 +195,7 @@ MainWindow::MainWindow() : QMainWindow(),
registerApplicationState("PlanDive", divePlannerWidget, profileContainer, divePlannerSettingsWidget, plannerDetails );
registerApplicationState("EditPlannedDive", divePlannerWidget, profileContainer, diveList, mapWidget );
registerApplicationState("EditDiveSite", diveSiteEdit, profileContainer, diveList, mapWidget);
+ registerApplicationState("FilterDive", mainTab, profileContainer, diveList, filterWidget2);
setStateProperties("Default", enabledList, enabledList, enabledList,enabledList);
setStateProperties("AddDive", enabledList, enabledList, enabledList,enabledList);
@@ -200,11 +203,9 @@ MainWindow::MainWindow() : QMainWindow(),
setStateProperties("PlanDive", enabledList, enabledList, enabledList,enabledList);
setStateProperties("EditPlannedDive", enabledList, enabledList, enabledList,enabledList);
setStateProperties("EditDiveSite", enabledList, disabledList, disabledList, enabledList);
-
+ setStateProperties("FilterDive", enabledList, enabledList, enabledList, enabledList);
setApplicationState("Default");
- ui.multiFilter->hide();
-
setWindowIcon(QIcon(":subsurface-icon"));
if (!QIcon::hasThemeIcon("window-close")) {
QIcon::setThemeName("subsurface");
@@ -495,10 +496,6 @@ void MainWindow::refreshDisplay(bool doRecreateDiveList)
void MainWindow::recreateDiveList()
{
diveList->reload();
- TagFilterModel::instance()->repopulate();
- BuddyFilterModel::instance()->repopulate();
- LocationFilterModel::instance()->repopulate();
- SuitsFilterModel::instance()->repopulate();
MultiFilterSortModel::instance()->myInvalidate();
}
@@ -759,9 +756,8 @@ void MainWindow::on_actionClose_triggered()
{
if (okToClose(tr("Please save or cancel the current dive edit before closing the file."))) {
closeCurrentFile();
- // hide any pictures and the filter
DivePictureModel::instance()->updateDivePictures();
- ui.multiFilter->closeFilter();
+ setApplicationState("Default");
recreateDiveList();
}
}
@@ -1874,13 +1870,7 @@ void MainWindow::on_paste_triggered()
void MainWindow::on_actionFilterTags_triggered()
{
- if (ui.multiFilter->isVisible()) {
- ui.multiFilter->closeFilter();
- ui.actionFilterTags->setChecked(false);
- } else {
- ui.multiFilter->setVisible(true);
- ui.actionFilterTags->setChecked(true);
- }
+ setApplicationState(getCurrentAppState() == "FilterDive" ? "Default" : "FilterDive");
}
void MainWindow::setCheckedActionFilterTags(bool checked)
diff --git a/desktop-widgets/mainwindow.h b/desktop-widgets/mainwindow.h
index be35ecf1e..a18738de4 100644
--- a/desktop-widgets/mainwindow.h
+++ b/desktop-widgets/mainwindow.h
@@ -18,6 +18,7 @@
#include "ui_plannerDetails.h"
#include "desktop-widgets/notificationwidget.h"
#include "core/gpslocation.h"
+#include "core/dive.h"
#define NUM_RECENT_FILES 4
@@ -35,6 +36,7 @@ class ProfileWidget2;
class PlannerDetails;
class PlannerSettingsWidget;
class LocationInformationWidget;
+class FilterWidget2;
typedef std::pair<QByteArray, QVariant> WidgetProperty;
typedef QVector<WidgetProperty> PropertyList;
diff --git a/desktop-widgets/mainwindow.ui b/desktop-widgets/mainwindow.ui
index 1263b4093..2dcd3e8a6 100644
--- a/desktop-widgets/mainwindow.ui
+++ b/desktop-widgets/mainwindow.ui
@@ -15,12 +15,18 @@
<property name="spacing">
<number>0</number>
</property>
- <property name="margin">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
<number>0</number>
</property>
- <item>
- <widget class="MultiFilter" name="multiFilter" native="true"/>
- </item>
<item>
<widget class="QSplitter" name="mainSplitter">
<property name="orientation">
@@ -53,7 +59,7 @@
<x>0</x>
<y>0</y>
<width>861</width>
- <height>23</height>
+ <height>29</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
@@ -133,7 +139,7 @@
</widget>
<widget class="QMenu" name="menuShare_on">
<property name="title">
- <string>Share on</string>
+ <string>Share o&amp;n</string>
</property>
<addaction name="separator"/>
</widget>
@@ -438,7 +444,7 @@
<bool>true</bool>
</property>
<property name="icon">
- <iconset resource="../subsurface.qrc">
+ <iconset>
<normaloff>:pp-o2-icon</normaloff>:pp-o2-icon</iconset>
</property>
<property name="text">
@@ -450,7 +456,7 @@
<bool>true</bool>
</property>
<property name="icon">
- <iconset resource="../subsurface.qrc">
+ <iconset>
<normaloff>:pp-n2-icon</normaloff>:pp-n2-icon</iconset>
</property>
<property name="text">
@@ -462,7 +468,7 @@
<bool>true</bool>
</property>
<property name="icon">
- <iconset resource="../subsurface.qrc">
+ <iconset>
<normaloff>:pp-he-icon</normaloff>:pp-he-icon</iconset>
</property>
<property name="text">
@@ -474,7 +480,7 @@
<bool>true</bool>
</property>
<property name="icon">
- <iconset resource="../subsurface.qrc">
+ <iconset>
<normaloff>:ceiling-dc-icon</normaloff>:ceiling-dc-icon</iconset>
</property>
<property name="text">
@@ -486,7 +492,7 @@
<bool>true</bool>
</property>
<property name="icon">
- <iconset resource="../subsurface.qrc">
+ <iconset>
<normaloff>:ceiling-calculated-icon</normaloff>:ceiling-calculated-icon</iconset>
</property>
<property name="text">
@@ -498,7 +504,7 @@
<bool>true</bool>
</property>
<property name="icon">
- <iconset resource="../subsurface.qrc">
+ <iconset>
<normaloff>:ceiling-tissues-icon</normaloff>:ceiling-tissues-icon</iconset>
</property>
<property name="text">
@@ -510,7 +516,7 @@
<bool>true</bool>
</property>
<property name="icon">
- <iconset resource="../subsurface.qrc">
+ <iconset>
<normaloff>:ceiling-increments-icon</normaloff>:ceiling-increments-icon</iconset>
</property>
<property name="text">
@@ -522,7 +528,7 @@
<bool>true</bool>
</property>
<property name="icon">
- <iconset resource="../subsurface.qrc">
+ <iconset>
<normaloff>:rate-heart-icon</normaloff>:rate-heart-icon</iconset>
</property>
<property name="text">
@@ -534,7 +540,7 @@
<bool>true</bool>
</property>
<property name="icon">
- <iconset resource="../subsurface.qrc">
+ <iconset>
<normaloff>:depth-mod-icon</normaloff>:depth-mod-icon</iconset>
</property>
<property name="text">
@@ -546,7 +552,7 @@
<bool>true</bool>
</property>
<property name="icon">
- <iconset resource="../subsurface.qrc">
+ <iconset>
<normaloff>:depth-ead-icon</normaloff>:depth-ead-icon</iconset>
</property>
<property name="text">
@@ -558,7 +564,7 @@
<bool>true</bool>
</property>
<property name="icon">
- <iconset resource="../subsurface.qrc">
+ <iconset>
<normaloff>:depth-ndl-icon</normaloff>:depth-ndl-icon</iconset>
</property>
<property name="text">
@@ -570,7 +576,7 @@
<bool>true</bool>
</property>
<property name="icon">
- <iconset resource="../subsurface.qrc">
+ <iconset>
<normaloff>:rate-sac-icon</normaloff>:rate-sac-icon</iconset>
</property>
<property name="text">
@@ -582,7 +588,7 @@
<bool>true</bool>
</property>
<property name="icon">
- <iconset resource="../subsurface.qrc">
+ <iconset>
<normaloff>:ruler-icon</normaloff>:ruler-icon</iconset>
</property>
<property name="text">
@@ -594,7 +600,7 @@
<bool>true</bool>
</property>
<property name="icon">
- <iconset resource="../subsurface.qrc">
+ <iconset>
<normaloff>:scale-graph-icon</normaloff>:scale-graph-icon</iconset>
</property>
<property name="text">
@@ -606,7 +612,7 @@
<bool>true</bool>
</property>
<property name="icon">
- <iconset resource="../subsurface.qrc">
+ <iconset>
<normaloff>:photo-icon</normaloff>:photo-icon</iconset>
</property>
<property name="text">
@@ -618,7 +624,7 @@
<bool>true</bool>
</property>
<property name="icon">
- <iconset resource="../subsurface.qrc">
+ <iconset>
<normaloff>:gaschange-icon</normaloff>:gaschange-icon</iconset>
</property>
<property name="text">
@@ -641,7 +647,7 @@
<bool>true</bool>
</property>
<property name="icon">
- <iconset resource="../subsurface.qrc">
+ <iconset>
<normaloff>:heatmap-icon</normaloff>:heatmap-icon</iconset>
</property>
<property name="text">
@@ -704,7 +710,7 @@
<bool>true</bool>
</property>
<property name="text">
- <string>Cloud storage online</string>
+ <string>Cloud stora&amp;ge online</string>
</property>
</action>
</widget>
@@ -715,12 +721,6 @@
<header>desktop-widgets/notificationwidget.h</header>
<container>1</container>
</customwidget>
- <customwidget>
- <class>MultiFilter</class>
- <extends>QWidget</extends>
- <header>desktop-widgets/simplewidgets.h</header>
- <container>1</container>
- </customwidget>
</customwidgets>
<resources>
<include location="../subsurface.qrc"/>
diff --git a/desktop-widgets/modeldelegates.cpp b/desktop-widgets/modeldelegates.cpp
index f008f4bc2..41fe1c083 100644
--- a/desktop-widgets/modeldelegates.cpp
+++ b/desktop-widgets/modeldelegates.cpp
@@ -1,4 +1,5 @@
// SPDX-License-Identifier: GPL-2.0
+
#include "desktop-widgets/modeldelegates.h"
#include "core/subsurface-string.h"
#include "core/gettextfromc.h"
@@ -13,6 +14,7 @@
#include "qt-models/divetripmodel.h"
#include "qt-models/divelocationmodel.h"
#include "core/qthelper.h"
+#include "desktop-widgets/simplewidgets.h"
#include <QCompleter>
#include <QKeyEvent>
@@ -22,6 +24,9 @@
#include <QBrush>
#include <QColor>
#include <QAbstractProxyModel>
+#include <QLineEdit>
+#include <QAbstractItemView>
+#include <QSpinBox>
QSize DiveListDelegate::sizeHint(const QStyleOptionViewItem&, const QModelIndex&) const
{
diff --git a/desktop-widgets/printdialog.cpp b/desktop-widgets/printdialog.cpp
index bbbade2e4..4c863fbea 100644
--- a/desktop-widgets/printdialog.cpp
+++ b/desktop-widgets/printdialog.cpp
@@ -10,6 +10,7 @@
#include <QShortcut>
#include <QSettings>
#include <QMessageBox>
+#include <QDialogButtonBox>
#define SETTINGS_GROUP "PrintDialog"
diff --git a/desktop-widgets/simplewidgets.cpp b/desktop-widgets/simplewidgets.cpp
index 42747cd3e..42569a270 100644
--- a/desktop-widgets/simplewidgets.cpp
+++ b/desktop-widgets/simplewidgets.cpp
@@ -200,7 +200,7 @@ void SetpointDialog::setpointData(struct divecomputer *divecomputer, int second)
void SetpointDialog::buttonClicked(QAbstractButton *button)
{
if (ui.buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole && dc) {
- add_event(dc, time, SAMPLE_EVENT_PO2, 0, (int)(1000.0 * ui.spinbox->value()),
+ add_event(dc, time, SAMPLE_EVENT_PO2, 0, (int)(1000.0 * ui.spinbox->value()),
QT_TRANSLATE_NOOP("gettextFromC", "SP change"));
invalidate_dive_cache(current_dive);
}
@@ -493,117 +493,6 @@ void DiveComponentSelection::buttonClicked(QAbstractButton *button)
}
}
-void FilterBase::addContextMenuEntry(const QString &s, void (FilterModelBase::*fn)())
-{
- QAction *act = new QAction(s, this);
- connect(act, &QAction::triggered, model, fn);
- ui.filterList->addAction(act);
-}
-
-FilterBase::FilterBase(FilterModelBase *model_, QWidget *parent) : QWidget(parent),
- model(model_)
-{
- ui.setupUi(this);
-#if QT_VERSION >= 0x050200
- ui.filterInternalList->setClearButtonEnabled(true);
-#endif
- QSortFilterProxyModel *filter = new QSortFilterProxyModel();
- filter->setSourceModel(model);
- filter->setFilterCaseSensitivity(Qt::CaseInsensitive);
- connect(ui.filterInternalList, SIGNAL(textChanged(QString)), filter, SLOT(setFilterFixedString(QString)));
- connect(ui.notButton, &QToolButton::toggled, model, &FilterModelBase::setNegate);
- ui.filterList->setModel(filter);
-
- addContextMenuEntry(tr("Select All"), &FilterModelBase::selectAll);
- addContextMenuEntry(tr("Unselect All"), &FilterModelBase::clearFilter);
- addContextMenuEntry(tr("Invert Selection"), &FilterModelBase::invertSelection);
- ui.filterList->setContextMenuPolicy(Qt::ActionsContextMenu);
-}
-
-void FilterBase::showEvent(QShowEvent *event)
-{
- MultiFilterSortModel::instance()->addFilterModel(model);
- QWidget::showEvent(event);
-}
-
-void FilterBase::hideEvent(QHideEvent *event)
-{
- MultiFilterSortModel::instance()->removeFilterModel(model);
- QWidget::hideEvent(event);
-}
-
-TagFilter::TagFilter(QWidget *parent) : FilterBase(TagFilterModel::instance(), parent)
-{
- ui.label->setText(tr("Tags") + QStringLiteral(": "));
-}
-
-BuddyFilter::BuddyFilter(QWidget *parent) : FilterBase(BuddyFilterModel::instance(), parent)
-{
- ui.label->setText(tr("Person") + QStringLiteral(": "));
- ui.label->setToolTip(tr("Searches for buddies and divemasters"));
-}
-
-LocationFilter::LocationFilter(QWidget *parent) : FilterBase(LocationFilterModel::instance(), parent)
-{
- ui.label->setText(tr("Location") + QStringLiteral(": "));
-}
-
-SuitFilter::SuitFilter(QWidget *parent) : FilterBase(SuitsFilterModel::instance(), parent)
-{
- ui.label->setText(tr("Suits") + QStringLiteral(": "));
-}
-
-MultiFilter::MultiFilter(QWidget *parent) : QWidget(parent)
-{
- ui.setupUi(this);
-
- QWidget *expandedWidget = new QWidget();
- QHBoxLayout *l = new QHBoxLayout();
-
- TagFilter *tagFilter = new TagFilter(this);
- int minimumHeight = tagFilter->ui.filterInternalList->height() +
- tagFilter->ui.verticalLayout->spacing() * tagFilter->ui.verticalLayout->count();
-
- QListView *dummyList = new QListView();
- QStringListModel *dummy = new QStringListModel(QStringList() << "Dummy Text");
- dummyList->setModel(dummy);
-
- connect(ui.close, SIGNAL(clicked(bool)), this, SLOT(closeFilter()));
- connect(ui.clear, SIGNAL(clicked(bool)), MultiFilterSortModel::instance(), SLOT(clearFilter()));
- connect(ui.maximize, SIGNAL(clicked(bool)), this, SLOT(adjustHeight()));
-
- l->addWidget(tagFilter);
- l->addWidget(new BuddyFilter());
- l->addWidget(new LocationFilter());
- l->addWidget(new SuitFilter());
- l->setContentsMargins(0, 0, 0, 0);
- l->setSpacing(0);
- expandedWidget->setLayout(l);
-
- ui.scrollArea->setWidget(expandedWidget);
- expandedWidget->resize(expandedWidget->width(), minimumHeight + dummyList->sizeHintForRow(0) * 5);
- ui.scrollArea->setMinimumHeight(expandedWidget->height() + 5);
-
- connect(MultiFilterSortModel::instance(), SIGNAL(filterFinished()), this, SLOT(filterFinished()));
-}
-
-void MultiFilter::filterFinished()
-{
- ui.filterText->setText(tr("Filter shows %1 (of %2) dives").arg(MultiFilterSortModel::instance()->divesDisplayed).arg(dive_table.nr));
-}
-
-void MultiFilter::adjustHeight()
-{
- ui.scrollArea->setVisible(!ui.scrollArea->isVisible());
-}
-
-void MultiFilter::closeFilter()
-{
- MultiFilterSortModel::instance()->clearFilter();
- hide();
- MainWindow::instance()->setCheckedActionFilterTags(false);
-}
-
TextHyperlinkEventFilter::TextHyperlinkEventFilter(QTextEdit *txtEdit) : QObject(txtEdit),
textEdit(txtEdit),
scrollView(textEdit->viewport())
diff --git a/desktop-widgets/simplewidgets.h b/desktop-widgets/simplewidgets.h
index 48e5e7e3d..a814519c4 100644
--- a/desktop-widgets/simplewidgets.h
+++ b/desktop-widgets/simplewidgets.h
@@ -20,7 +20,6 @@ class FilterModelBase;
#include "ui_urldialog.h"
#include "ui_divecomponentselection.h"
#include "ui_listfilter.h"
-#include "ui_filterwidget.h"
#include "core/exif.h"
#include "core/dive.h"
@@ -150,59 +149,6 @@ private:
struct dive_components *what;
};
-namespace Ui{
- class FilterWidget2;
-};
-
-class MultiFilter : public QWidget {
- Q_OBJECT
-public
-slots:
- void closeFilter();
- void adjustHeight();
- void filterFinished();
-
-public:
- MultiFilter(QWidget *parent);
- Ui::FilterWidget2 ui;
-};
-
-class FilterBase : public QWidget {
- Q_OBJECT
- void addContextMenuEntry(const QString &s, void (FilterModelBase::*)());
-protected:
- FilterBase(FilterModelBase *model, QWidget *parent = 0);
- FilterModelBase *model;
- Ui::FilterWidget ui;
- void showEvent(QShowEvent *) override;
- void hideEvent(QHideEvent *) override;
- friend class MultiFilter;
-};
-
-class TagFilter : public FilterBase {
- Q_OBJECT
-public:
- TagFilter(QWidget *parent = 0);
-};
-
-class BuddyFilter : public FilterBase {
- Q_OBJECT
-public:
- BuddyFilter(QWidget *parent = 0);
-};
-
-class SuitFilter : public FilterBase {
- Q_OBJECT
-public:
- SuitFilter(QWidget *parent = 0);
-};
-
-class LocationFilter : public FilterBase {
- Q_OBJECT
-public:
- LocationFilter(QWidget *parent = 0);
-};
-
class TextHyperlinkEventFilter : public QObject {
Q_OBJECT
public:
diff --git a/desktop-widgets/subsurfacewebservices.cpp b/desktop-widgets/subsurfacewebservices.cpp
index 2acc7451e..d62cd8552 100644
--- a/desktop-widgets/subsurfacewebservices.cpp
+++ b/desktop-widgets/subsurfacewebservices.cpp
@@ -484,6 +484,10 @@ void DivelogsDeWebServices::prepareDivesForUpload(bool selected)
{
/* generate a random filename and create/open that file with zip_open */
QString filename = QDir::tempPath() + "/import-" + QString::number(qrand() % 99999999) + ".dld";
+ if (!amount_selected) {
+ report_error(tr("no dives were selected").toUtf8());
+ return;
+ }
if (prepare_dives_for_divelogs(filename, selected)) {
QFile f(filename);
if (f.open(QIODevice::ReadOnly)) {
diff --git a/desktop-widgets/tab-widgets/TabDiveStatistics.cpp b/desktop-widgets/tab-widgets/TabDiveStatistics.cpp
index 67e80ed24..1b3fe9522 100644
--- a/desktop-widgets/tab-widgets/TabDiveStatistics.cpp
+++ b/desktop-widgets/tab-widgets/TabDiveStatistics.cpp
@@ -48,17 +48,13 @@ void TabDiveStatistics::updateData()
calculate_stats_selected(&stats_selection);
clear();
ui->depthLimits->setMaximum(get_depth_string(stats_selection.max_depth, true));
- if (amount_selected > 1)
+ if (amount_selected > 1) {
ui->depthLimits->setMinimum(get_depth_string(stats_selection.min_depth, true));
- else
+ ui->depthLimits->setAverage(get_depth_string(stats_selection.combined_max_depth.mm / stats_selection.selection_size, true));
+ } else {
ui->depthLimits->setMinimum("");
- // the overall average depth is really confusing when listed between the
- // deepest and shallowest dive - let's just not set it
- // ui->depthLimits->setAverage(get_depth_string(stats_selection.avg_depth, true));
-
- // Also hide the avgIco, so its clear that its not there.
- ui->depthLimits->overrideAvgToolTipText("");
- ui->depthLimits->setAvgVisibility(false);
+ ui->depthLimits->setAverage("");
+ }
if (stats_selection.max_sac.mliter && (stats_selection.max_sac.mliter != stats_selection.avg_sac.mliter))
ui->sacLimits->setMaximum(get_volume_string(stats_selection.max_sac, true).append(tr("/min")));
diff --git a/desktop-widgets/tab-widgets/TabDiveStatistics.ui b/desktop-widgets/tab-widgets/TabDiveStatistics.ui
index d954dca3b..1be4bbcfc 100644
--- a/desktop-widgets/tab-widgets/TabDiveStatistics.ui
+++ b/desktop-widgets/tab-widgets/TabDiveStatistics.ui
@@ -70,7 +70,7 @@
<item row="1" column="0">
<widget class="QGroupBox" name="groupBoxb">
<property name="title">
- <string>Depth</string>
+ <string>Max. depth</string>
</property>
<layout class="QHBoxLayout" name="statsDepthLayout">
<item>
diff --git a/desktop-widgets/tab-widgets/maintab.cpp b/desktop-widgets/tab-widgets/maintab.cpp
index 567e1737f..f22b7cf1e 100644
--- a/desktop-widgets/tab-widgets/maintab.cpp
+++ b/desktop-widgets/tab-widgets/maintab.cpp
@@ -27,6 +27,7 @@
#include "core/gettextfromc.h"
#include "desktop-widgets/locationinformation.h"
#include "desktop-widgets/command.h"
+#include "desktop-widgets/simplewidgets.h"
#include "TabDiveExtraInfo.h"
#include "TabDiveInformation.h"
@@ -688,7 +689,6 @@ struct dive_site *MainTab::updateDiveSite(struct dive_site *pickedDs, dive *d)
QString name = ui.location->text().isEmpty() ? tr("New dive site") : ui.location->text();
pickedDs = create_dive_site(qPrintable(name), displayed_dive.when);
createdNewDive = true;
- LocationFilterModel::instance()->addName(name);
}
if (origDs) {