diff options
author | Tomaz Canabrava <tomaz.canabrava@intel.com> | 2014-11-16 14:04:06 -0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-11-16 18:34:47 +0000 |
commit | 7c5c38b154baeeb05d2c70a3c248cda41349133a (patch) | |
tree | 4084a8661d50e536f96eb9e98e327ee25a1bcc27 /qt-ui | |
parent | 7967d2bec1f90f230800ada64c7fe69b3f2009cd (diff) | |
download | subsurface-7c5c38b154baeeb05d2c70a3c248cda41349133a.tar.gz |
Addded a min / max layout for the filter, and a filter count
But the filter count seems to be broken for some reason and
I really don't know why. It seems to work for tags, but
not for everything else.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r-- | qt-ui/filtermodels.cpp | 15 | ||||
-rw-r--r-- | qt-ui/filtermodels.h | 5 | ||||
-rw-r--r-- | qt-ui/filterwidget.ui | 127 | ||||
-rw-r--r-- | qt-ui/simplewidgets.cpp | 54 | ||||
-rw-r--r-- | qt-ui/simplewidgets.h | 12 |
5 files changed, 179 insertions, 34 deletions
diff --git a/qt-ui/filtermodels.cpp b/qt-ui/filtermodels.cpp index 5b2553d96..6751a8cfe 100644 --- a/qt-ui/filtermodels.cpp +++ b/qt-ui/filtermodels.cpp @@ -379,7 +379,7 @@ bool MultiFilterSortModel::filterAcceptsRow(int source_row, const QModelIndex &s if (!model->doFilter(d, index0, sourceModel())) shouldShow = false; } - // if it's a dive, mark it accordingly + filter_dive(d, shouldShow); return shouldShow; } @@ -390,7 +390,11 @@ void MultiFilterSortModel::myInvalidate() struct dive *d; DiveListView *dlv = MainWindow::instance()->dive_list(); + divesDisplayed = 0; + divesFilteredOut = 0; + invalidate(); + // first make sure the trips are no longer shown as selected // (but without updating the selection state of the dives... this just cleans // up an oddity in the filter handling) @@ -412,6 +416,15 @@ void MultiFilterSortModel::myInvalidate() } dlv->selectDives(curSelectedDives); } + + for_each_dive (i,d) { + if (d->hidden_by_filter) + divesFilteredOut++; + else + divesDisplayed++; + } + + emit filterFinished(); } void MultiFilterSortModel::addFilterModel(MultiFilterInterface *model) diff --git a/qt-ui/filtermodels.h b/qt-ui/filtermodels.h index b8439bb81..c70264b3d 100644 --- a/qt-ui/filtermodels.h +++ b/qt-ui/filtermodels.h @@ -93,11 +93,14 @@ public: virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const; void addFilterModel(MultiFilterInterface *model); void removeFilterModel(MultiFilterInterface *model); + int divesFilteredOut; + int divesDisplayed; public slots: void myInvalidate(); void clearFilter(); - +signals: + void filterFinished(); private: MultiFilterSortModel(QObject *parent = 0); QList<MultiFilterInterface *> models; diff --git a/qt-ui/filterwidget.ui b/qt-ui/filterwidget.ui new file mode 100644 index 000000000..4b5f9d9d4 --- /dev/null +++ b/qt-ui/filterwidget.ui @@ -0,0 +1,127 @@ +<?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>Form</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> + <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="text"> + <string>...</string> + </property> + <property name="icon"> + <iconset resource="../subsurface.qrc"> + <normaloff>:/plus</normaloff>:/plus</iconset> + </property> + <property name="autoRaise"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="maximize"> + <property name="text"> + <string>...</string> + </property> + <property name="icon"> + <iconset resource="../subsurface.qrc"> + <normaloff>:/average</normaloff>:/average</iconset> + </property> + <property name="autoRaise"> + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="QToolButton" name="close"> + <property name="text"> + <string>...</string> + </property> + <property name="icon"> + <iconset resource="../subsurface.qrc"> + <normaloff>:/flag</normaloff>:/flag</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>332</height> + </rect> + </property> + </widget> + </widget> + </item> + </layout> + </widget> + <resources> + <include location="../subsurface.qrc"/> + </resources> + <connections/> +</ui> diff --git a/qt-ui/simplewidgets.cpp b/qt-ui/simplewidgets.cpp index 192682774..1020e0ec3 100644 --- a/qt-ui/simplewidgets.cpp +++ b/qt-ui/simplewidgets.cpp @@ -17,6 +17,7 @@ #include "display.h" #include "mainwindow.h" #include "helpers.h" +#include "ui_filterwidget.h" class MinMaxAvgWidgetPrivate { public: @@ -560,55 +561,50 @@ void SuitFilter::hideEvent(QHideEvent *event) QWidget::hideEvent(event); } -MultiFilter::MultiFilter(QWidget *parent) : QScrollArea(parent) +MultiFilter::MultiFilter(QWidget *parent) : QWidget(parent) { + ui = new Ui::FilterWidget2(); + ui->setupUi(this); + QWidget *expandedWidget = new QWidget(); QHBoxLayout *l = new QHBoxLayout(); - TagFilter *tagFilter = new TagFilter(); int minimumHeight = tagFilter->ui.filterInternalList->height() + - tagFilter->ui.verticalLayout->spacing() * tagFilter->ui.verticalLayout->count(); + tagFilter->ui.verticalLayout->spacing() * tagFilter->ui.verticalLayout->count(); QListView *dummyList = new QListView(); QStringListModel *dummy = new QStringListModel(QStringList() << "Dummy Text"); dummyList->setModel(dummy); - // Buttons to Clear/Minimize/Close - QToolBar *tb = new QToolBar(); - QToolButton *clearBtn = new QToolButton(); - clearBtn->setToolTip(tr("Reset the filters")); - clearBtn->setIcon(QIcon(":/trash")); - clearBtn->setAutoRaise(true); - QToolButton *closeBtn = new QToolButton(); - closeBtn->setToolTip(tr("Close this window and reset the filters")); - closeBtn->setIcon(QIcon(":/close")); - closeBtn->setAutoRaise(true); - QToolButton *minimize = new QToolButton(); - minimize->setToolTip(tr("Minimize this window")); - minimize->setIcon(QIcon(":/arrow_up")); - minimize->setAutoRaise(true); - - tb->setOrientation(Qt::Vertical); - tb->addWidget(clearBtn); - tb->addWidget(minimize); - tb->addWidget(closeBtn); - - connect(closeBtn, SIGNAL(clicked(bool)), this, SLOT(closeFilter())); - connect(clearBtn, SIGNAL(clicked(bool)), MultiFilterSortModel::instance(), SLOT(clearFilter())); - l->addWidget(tb); + 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); - setWidget(expandedWidget); + + ui->scrollArea->setWidget(expandedWidget); expandedWidget->resize(expandedWidget->width(), minimumHeight + dummyList->sizeHintForRow(0) * 5 ); + ui->scrollArea->setMinimumHeight(expandedWidget->height() + 5); - setMinimumHeight(expandedWidget->height() + 5); + connect(MultiFilterSortModel::instance(), SIGNAL(filterFinished()), this, SLOT(filterFinished())); +} + +void MultiFilter::filterFinished() +{ + ui->filterText->setText(tr("Dives filtered out: ") + QString::number(MultiFilterSortModel::instance()->divesFilteredOut) + + tr("Dives being shown: ") + QString::number(MultiFilterSortModel::instance()->divesDisplayed)); +} + +void MultiFilter::adjustHeight() +{ + ui->scrollArea->setVisible(!ui->scrollArea->isVisible()); } void MultiFilter::closeFilter() diff --git a/qt-ui/simplewidgets.h b/qt-ui/simplewidgets.h index 68735451e..00992d6ec 100644 --- a/qt-ui/simplewidgets.h +++ b/qt-ui/simplewidgets.h @@ -130,15 +130,21 @@ private: struct dive_components *what; }; -class MultiFilter : public QScrollArea { +namespace Ui{ + class FilterWidget2; +}; + +class MultiFilter : public QWidget { Q_OBJECT public slots: void closeFilter(); + void adjustHeight(); + void filterFinished(); + public: MultiFilter(QWidget *parent); - QWidget *expandedWidget; - QWidget *minimizedWidget; + Ui::FilterWidget2 *ui; }; class TagFilter : public QWidget { |