From 19f6e8810cdaedcbecd87aa762c75e59bebe26c9 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Sat, 13 Oct 2018 11:52:08 +0200 Subject: Start to implement a simplified version of the filter widget The idea of this new widget is to be able to filter more types of data, while keeping it simple and extending the feature set to something that was impossible with the old implementation. While the old implementation had 4 panels that you could use to filter specific tags / people / types of dives the new one will let you filter by visibility, temperature people, name, equipment, etc, in a more natural way than the old one. Signed-off-by: Tomaz Canabrava --- desktop-widgets/CMakeLists.txt | 2 + desktop-widgets/filterwidget.ui | 18 +-- desktop-widgets/filterwidget2.cpp | 59 +++++++++ desktop-widgets/filterwidget2.h | 27 ++++ desktop-widgets/filterwidget2.ui | 260 ++++++++++++++++++++++++++++++++++++++ desktop-widgets/listfilter.ui | 4 +- desktop-widgets/simplewidgets.cpp | 2 +- desktop-widgets/simplewidgets.h | 6 +- 8 files changed, 363 insertions(+), 15 deletions(-) create mode 100644 desktop-widgets/filterwidget2.cpp create mode 100644 desktop-widgets/filterwidget2.h create mode 100644 desktop-widgets/filterwidget2.ui diff --git a/desktop-widgets/CMakeLists.txt b/desktop-widgets/CMakeLists.txt index 519061ac0..149ba32c0 100644 --- a/desktop-widgets/CMakeLists.txt +++ b/desktop-widgets/CMakeLists.txt @@ -34,6 +34,7 @@ set (SUBSURFACE_UI diveshareexportdialog.ui downloadfromdivecomputer.ui filterwidget.ui + filterwidget2.ui findmovedimagesdialog.ui listfilter.ui locationInformation.ui @@ -90,6 +91,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/filterwidget.ui b/desktop-widgets/filterwidget.ui index 7f548a931..6a8b8e863 100644 --- a/desktop-widgets/filterwidget.ui +++ b/desktop-widgets/filterwidget.ui @@ -1,7 +1,7 @@ - FilterWidget2 - + FilterWidget + 0 @@ -11,7 +11,7 @@ - + @@ -70,10 +70,10 @@ - Reset filters + Reset filters - + :edit-clear-icon:edit-clear-icon @@ -84,10 +84,10 @@ - Show/hide filters + Show/hide filters - + :hide-icon:hide-icon @@ -101,7 +101,7 @@ Close and reset filters - + :filter-close:filter-close @@ -125,7 +125,7 @@ 0 0 594 - 337 + 332 diff --git a/desktop-widgets/filterwidget2.cpp b/desktop-widgets/filterwidget2.cpp new file mode 100644 index 000000000..9bf526a88 --- /dev/null +++ b/desktop-widgets/filterwidget2.cpp @@ -0,0 +1,59 @@ +#include "desktop-widgets/filterwidget2.h" +#include "desktop-widgets/simplewidgets.h" + +#include + +FilterWidget2::FilterWidget2(QWidget* parent) +: QWidget(parent) +, ui(new Ui::FilterWidget2()) +{ + ui->setupUi(this); + ui->minRating->setCurrentStars(0); + ui->maxRating->setCurrentStars(5); + ui->minVisibility->setCurrentStars(0); + ui->maxVisibility->setCurrentStars(5); + + 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(&QDoubleSpinBox::valueChanged), + this, &FilterWidget2::updateFilter); + + connect(ui->minAirTemp, static_cast(&QDoubleSpinBox::valueChanged), + this, &FilterWidget2::updateFilter); + + connect(ui->maxWaterTemp, static_cast(&QDoubleSpinBox::valueChanged), + this, &FilterWidget2::updateFilter); + + connect(ui->minWaterTemp, static_cast(&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() +{ + +} diff --git a/desktop-widgets/filterwidget2.h b/desktop-widgets/filterwidget2.h new file mode 100644 index 000000000..70313c5d2 --- /dev/null +++ b/desktop-widgets/filterwidget2.h @@ -0,0 +1,27 @@ +#ifndef FILTERWIDGET_2_H +#define FILTERWIDGET_2_H + +#include + +#include + +#include "ui_filterwidget2.h" + +namespace Ui { + class FilterWidget2; +} + +class FilterWidget2 : public QWidget { + Q_OBJECT +public: + explicit FilterWidget2(QWidget *parent = 0); + void updateFilter(); + +signals: + void filterUpdated(); + +private: + std::unique_ptr ui; +}; + +#endif diff --git a/desktop-widgets/filterwidget2.ui b/desktop-widgets/filterwidget2.ui new file mode 100644 index 000000000..bf6d6a8ed --- /dev/null +++ b/desktop-widgets/filterwidget2.ui @@ -0,0 +1,260 @@ + + + FilterWidget2 + + + + 0 + 0 + 510 + 320 + + + + Form + + + + + + Min + + + + + + + + 0 + 0 + + + + Qt::TabFocus + + + + + + + + + + + 0 + 0 + + + + Qt::TabFocus + + + + + + + Tags + + + + + + + Rating + + + + + + + + 0 + 0 + + + + Qt::TabFocus + + + + + + + People + + + + + + + Max + + + + + + + Min + + + + + + + + + + Display dives that will not match the search, only applies to tags, people, location and equipment + + + Invert filter + + + + + + + Max + + + + + + + + + + + + + + 0 + 0 + + + + Qt::TabFocus + + + + + + + + + + Equipment + + + + + + + Max + + + + + + + Location + + + + + + + + + + + + + + + + From + + + + + + + To + + + + + + + Visibility + + + + + + + Water Temp + + + + + + + Min + + + + + + + Air Temp + + + + + + + Min + + + + + + + Max + + + + + + + + + + + + + + StarWidget + QWidget +
desktop-widgets/starwidget.h
+ 1 +
+
+ + minRating + maxRating + minVisibility + maxVisibility + from + to + tags + people + location + equipment + invertFilter + + + +
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 @@ - FilterWidget - + ListFilter + 0 diff --git a/desktop-widgets/simplewidgets.cpp b/desktop-widgets/simplewidgets.cpp index 42747cd3e..8cfb63100 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); } diff --git a/desktop-widgets/simplewidgets.h b/desktop-widgets/simplewidgets.h index 48e5e7e3d..040754a98 100644 --- a/desktop-widgets/simplewidgets.h +++ b/desktop-widgets/simplewidgets.h @@ -151,7 +151,7 @@ private: }; namespace Ui{ - class FilterWidget2; + class FilterWidget; }; class MultiFilter : public QWidget { @@ -164,7 +164,7 @@ slots: public: MultiFilter(QWidget *parent); - Ui::FilterWidget2 ui; + Ui::FilterWidget ui; }; class FilterBase : public QWidget { @@ -173,7 +173,7 @@ class FilterBase : public QWidget { protected: FilterBase(FilterModelBase *model, QWidget *parent = 0); FilterModelBase *model; - Ui::FilterWidget ui; + Ui::ListFilter ui; void showEvent(QShowEvent *) override; void hideEvent(QHideEvent *) override; friend class MultiFilter; -- cgit v1.2.3-70-g09d2