mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
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>
This commit is contained in:
parent
7967d2bec1
commit
7c5c38b154
6 changed files with 181 additions and 35 deletions
|
@ -379,7 +379,7 @@ bool MultiFilterSortModel::filterAcceptsRow(int source_row, const QModelIndex &s
|
||||||
if (!model->doFilter(d, index0, sourceModel()))
|
if (!model->doFilter(d, index0, sourceModel()))
|
||||||
shouldShow = false;
|
shouldShow = false;
|
||||||
}
|
}
|
||||||
// if it's a dive, mark it accordingly
|
|
||||||
filter_dive(d, shouldShow);
|
filter_dive(d, shouldShow);
|
||||||
return shouldShow;
|
return shouldShow;
|
||||||
}
|
}
|
||||||
|
@ -390,7 +390,11 @@ void MultiFilterSortModel::myInvalidate()
|
||||||
struct dive *d;
|
struct dive *d;
|
||||||
DiveListView *dlv = MainWindow::instance()->dive_list();
|
DiveListView *dlv = MainWindow::instance()->dive_list();
|
||||||
|
|
||||||
|
divesDisplayed = 0;
|
||||||
|
divesFilteredOut = 0;
|
||||||
|
|
||||||
invalidate();
|
invalidate();
|
||||||
|
|
||||||
// first make sure the trips are no longer shown as selected
|
// first make sure the trips are no longer shown as selected
|
||||||
// (but without updating the selection state of the dives... this just cleans
|
// (but without updating the selection state of the dives... this just cleans
|
||||||
// up an oddity in the filter handling)
|
// up an oddity in the filter handling)
|
||||||
|
@ -412,6 +416,15 @@ void MultiFilterSortModel::myInvalidate()
|
||||||
}
|
}
|
||||||
dlv->selectDives(curSelectedDives);
|
dlv->selectDives(curSelectedDives);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for_each_dive (i,d) {
|
||||||
|
if (d->hidden_by_filter)
|
||||||
|
divesFilteredOut++;
|
||||||
|
else
|
||||||
|
divesDisplayed++;
|
||||||
|
}
|
||||||
|
|
||||||
|
emit filterFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiFilterSortModel::addFilterModel(MultiFilterInterface *model)
|
void MultiFilterSortModel::addFilterModel(MultiFilterInterface *model)
|
||||||
|
|
|
@ -93,11 +93,14 @@ public:
|
||||||
virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
|
virtual bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
|
||||||
void addFilterModel(MultiFilterInterface *model);
|
void addFilterModel(MultiFilterInterface *model);
|
||||||
void removeFilterModel(MultiFilterInterface *model);
|
void removeFilterModel(MultiFilterInterface *model);
|
||||||
|
int divesFilteredOut;
|
||||||
|
int divesDisplayed;
|
||||||
public
|
public
|
||||||
slots:
|
slots:
|
||||||
void myInvalidate();
|
void myInvalidate();
|
||||||
void clearFilter();
|
void clearFilter();
|
||||||
|
signals:
|
||||||
|
void filterFinished();
|
||||||
private:
|
private:
|
||||||
MultiFilterSortModel(QObject *parent = 0);
|
MultiFilterSortModel(QObject *parent = 0);
|
||||||
QList<MultiFilterInterface *> models;
|
QList<MultiFilterInterface *> models;
|
||||||
|
|
127
qt-ui/filterwidget.ui
Normal file
127
qt-ui/filterwidget.ui
Normal file
|
@ -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>
|
|
@ -17,6 +17,7 @@
|
||||||
#include "display.h"
|
#include "display.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
|
#include "ui_filterwidget.h"
|
||||||
|
|
||||||
class MinMaxAvgWidgetPrivate {
|
class MinMaxAvgWidgetPrivate {
|
||||||
public:
|
public:
|
||||||
|
@ -560,55 +561,50 @@ void SuitFilter::hideEvent(QHideEvent *event)
|
||||||
QWidget::hideEvent(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();
|
QWidget *expandedWidget = new QWidget();
|
||||||
QHBoxLayout *l = new QHBoxLayout();
|
QHBoxLayout *l = new QHBoxLayout();
|
||||||
|
|
||||||
|
|
||||||
TagFilter *tagFilter = new TagFilter();
|
TagFilter *tagFilter = new TagFilter();
|
||||||
int minimumHeight = tagFilter->ui.filterInternalList->height() +
|
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();
|
QListView *dummyList = new QListView();
|
||||||
QStringListModel *dummy = new QStringListModel(QStringList() << "Dummy Text");
|
QStringListModel *dummy = new QStringListModel(QStringList() << "Dummy Text");
|
||||||
dummyList->setModel(dummy);
|
dummyList->setModel(dummy);
|
||||||
|
|
||||||
// Buttons to Clear/Minimize/Close
|
connect(ui->close, SIGNAL(clicked(bool)), this, SLOT(closeFilter()));
|
||||||
QToolBar *tb = new QToolBar();
|
connect(ui->clear, SIGNAL(clicked(bool)), MultiFilterSortModel::instance(), SLOT(clearFilter()));
|
||||||
QToolButton *clearBtn = new QToolButton();
|
connect(ui->maximize, SIGNAL(clicked(bool)), this, SLOT(adjustHeight()));
|
||||||
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);
|
|
||||||
l->addWidget(tagFilter);
|
l->addWidget(tagFilter);
|
||||||
l->addWidget(new BuddyFilter());
|
l->addWidget(new BuddyFilter());
|
||||||
l->addWidget(new LocationFilter());
|
l->addWidget(new LocationFilter());
|
||||||
l->addWidget(new SuitFilter());
|
l->addWidget(new SuitFilter());
|
||||||
l->setContentsMargins(0, 0, 0, 0);
|
l->setContentsMargins(0, 0, 0, 0);
|
||||||
l->setSpacing(0);
|
l->setSpacing(0);
|
||||||
|
|
||||||
expandedWidget->setLayout(l);
|
expandedWidget->setLayout(l);
|
||||||
setWidget(expandedWidget);
|
|
||||||
expandedWidget->resize(expandedWidget->width(), minimumHeight + dummyList->sizeHintForRow(0) * 5 );
|
|
||||||
|
|
||||||
setMinimumHeight(expandedWidget->height() + 5);
|
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("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()
|
void MultiFilter::closeFilter()
|
||||||
|
|
|
@ -130,15 +130,21 @@ private:
|
||||||
struct dive_components *what;
|
struct dive_components *what;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MultiFilter : public QScrollArea {
|
namespace Ui{
|
||||||
|
class FilterWidget2;
|
||||||
|
};
|
||||||
|
|
||||||
|
class MultiFilter : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public
|
public
|
||||||
slots:
|
slots:
|
||||||
void closeFilter();
|
void closeFilter();
|
||||||
|
void adjustHeight();
|
||||||
|
void filterFinished();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MultiFilter(QWidget *parent);
|
MultiFilter(QWidget *parent);
|
||||||
QWidget *expandedWidget;
|
Ui::FilterWidget2 *ui;
|
||||||
QWidget *minimizedWidget;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class TagFilter : public QWidget {
|
class TagFilter : public QWidget {
|
||||||
|
|
|
@ -232,7 +232,8 @@ FORMS = \
|
||||||
qt-ui/divecomponentselection.ui \
|
qt-ui/divecomponentselection.ui \
|
||||||
qt-ui/configuredivecomputerdialog.ui \
|
qt-ui/configuredivecomputerdialog.ui \
|
||||||
qt-ui/listfilter.ui \
|
qt-ui/listfilter.ui \
|
||||||
qt-ui/diveshareexportdialog.ui
|
qt-ui/diveshareexportdialog.ui \
|
||||||
|
qt-ui/filterwidget.ui
|
||||||
|
|
||||||
# Nether usermanual or printing is supported on android right now
|
# Nether usermanual or printing is supported on android right now
|
||||||
android: FORMS -= qt-ui/printoptions.ui
|
android: FORMS -= qt-ui/printoptions.ui
|
||||||
|
|
Loading…
Reference in a new issue