filter panel added

This commit is contained in:
2019-03-18 17:08:38 +01:00
parent d72f7da1ef
commit 95179c2db1
9 changed files with 439 additions and 154 deletions
+14
View File
@@ -0,0 +1,14 @@
#include "cfilterpanel.h"
#include "ui_cfilterpanel.h"
cFilterPanel::cFilterPanel(QWidget *parent) :
QWidget(parent),
ui(new Ui::cFilterPanel)
{
ui->setupUi(this);
}
cFilterPanel::~cFilterPanel()
{
delete ui;
}
+22
View File
@@ -0,0 +1,22 @@
#ifndef CFILTERPANEL_H
#define CFILTERPANEL_H
#include <QWidget>
namespace Ui {
class cFilterPanel;
}
class cFilterPanel : public QWidget
{
Q_OBJECT
public:
explicit cFilterPanel(QWidget *parent = nullptr);
~cFilterPanel();
private:
Ui::cFilterPanel *ui;
};
#endif // CFILTERPANEL_H
+70
View File
@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>cFilterPanel</class>
<widget class="QWidget" name="cFilterPanel">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QGroupBox" name="m_lpPersonFilter">
<property name="title">
<string>Person</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QTreeView" name="m_lpPersonList"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="m_lpLocationFilter">
<property name="title">
<string>Location</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QTreeView" name="m_lpLocationList"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="m_lpTagFilter">
<property name="title">
<string>Tags</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QTreeView" name="m_lpTagsList"/>
</item>
</layout>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
+9 -1
View File
@@ -13,7 +13,6 @@
#include "ccombopicker.h"
#include "cimage.h"
#include "cimageviewer.h"
#include "ui_cmainwindow.h"
@@ -31,11 +30,13 @@
#include <QPixmap>
#include <QInputDialog>
#include <QFileDialog>
#include <QPushButton>
cMainWindow::cMainWindow(cSplashScreen* lpSplashScreen, QWidget *parent) :
QMainWindow(parent),
ui(new Ui::cMainWindow),
m_lpFilterPanel(nullptr),
m_lpProgressBar(nullptr),
m_lpFolderViewModel(nullptr),
m_lpFolderSortFilterProxyModel(nullptr),
@@ -61,6 +62,9 @@ cMainWindow::cMainWindow(cSplashScreen* lpSplashScreen, QWidget *parent) :
cMainWindow::~cMainWindow()
{
if(m_lpFilterPanel)
delete m_lpFilterPanel;
delete m_lpThumbnailViewModel;
delete m_lpFolderViewModel;
delete m_lpThumbnailSortFilterProxyModel;
@@ -75,6 +79,10 @@ void cMainWindow::initUI()
QIcon::setThemeName("TangoMFK");
ui->m_lpSpoiler->setTitle(tr("Filter"));
m_lpFilterPanel = new cFilterPanel(this);
ui->m_lpSpoiler->setContentWidget(m_lpFilterPanel);
m_lpFolderViewModel = new QStandardItemModel;
m_lpFolderSortFilterProxyModel = new cFolderSortFilterProxyModel(this);
ui->m_lpFolderView->setModel(m_lpFolderSortFilterProxyModel);
+3
View File
@@ -19,6 +19,8 @@
#include "ctoolboxinfo.h"
#include "cfilterpanel.h"
#include <QMainWindow>
#include <QCloseEvent>
@@ -64,6 +66,7 @@ public:
private:
Ui::cMainWindow* ui; /*!< TODO: describe */
cFilterPanel* m_lpFilterPanel; /*!< TODO: describe */
QProgressBar* m_lpProgressBar; /*!< TODO: describe */
QStandardItemModel* m_lpFolderViewModel; /*!< TODO: describe */
cFolderSortFilterProxyModel* m_lpFolderSortFilterProxyModel; /*!< TODO: describe */
+163 -150
View File
@@ -15,158 +15,165 @@
</property>
<widget class="QWidget" name="centralWidget">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QSplitter" name="m_lpSplitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QTreeView" name="m_lpFolderView">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>10</width>
<height>0</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="headerHidden">
<bool>true</bool>
</property>
</widget>
<widget class="QListView" name="m_lpThumbnailView">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<property name="iconSize">
<size>
<width>160</width>
<height>120</height>
</size>
</property>
<property name="resizeMode">
<enum>QListView::Adjust</enum>
</property>
<property name="gridSize">
<size>
<width>180</width>
<height>180</height>
</size>
</property>
<property name="viewMode">
<enum>QListView::IconMode</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
<widget class="QScrollArea" name="m_lpInfoScrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>87</width>
<height>609</height>
</rect>
<item row="1" column="0">
<layout class="QVBoxLayout" name="verticalLayout" stretch="1">
<item>
<widget class="QSplitter" name="m_lpSplitter">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QToolBox" name="m_lpToolBox">
<property name="currentIndex">
<number>3</number>
</property>
<widget class="cToolBoxInfo" name="m_lpToolBoxInfo">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>69</width>
<height>483</height>
</rect>
</property>
<attribute name="label">
<string>Information</string>
</attribute>
</widget>
<widget class="cToolBoxPerson" name="m_lpToolBoxPerson">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>69</width>
<height>483</height>
</rect>
</property>
<attribute name="label">
<string>Person</string>
</attribute>
</widget>
<widget class="cToolBoxLocation" name="m_lpToolBoxLocation">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>69</width>
<height>483</height>
</rect>
</property>
<attribute name="label">
<string>Location</string>
</attribute>
</widget>
<widget class="cToolBoxTag" name="m_lpToolBoxTags">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>69</width>
<height>483</height>
</rect>
</property>
<attribute name="label">
<string>Tags</string>
</attribute>
</widget>
</widget>
</item>
</layout>
<widget class="QTreeView" name="m_lpFolderView">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>10</width>
<height>0</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="headerHidden">
<bool>true</bool>
</property>
</widget>
<widget class="QListView" name="m_lpThumbnailView">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="contextMenuPolicy">
<enum>Qt::CustomContextMenu</enum>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<property name="iconSize">
<size>
<width>160</width>
<height>120</height>
</size>
</property>
<property name="resizeMode">
<enum>QListView::Adjust</enum>
</property>
<property name="gridSize">
<size>
<width>180</width>
<height>180</height>
</size>
</property>
<property name="viewMode">
<enum>QListView::IconMode</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
<widget class="QScrollArea" name="m_lpInfoScrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>87</width>
<height>591</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QToolBox" name="m_lpToolBox">
<property name="currentIndex">
<number>3</number>
</property>
<widget class="cToolBoxInfo" name="m_lpToolBoxInfo">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>69</width>
<height>465</height>
</rect>
</property>
<attribute name="label">
<string>Information</string>
</attribute>
</widget>
<widget class="cToolBoxPerson" name="m_lpToolBoxPerson">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>69</width>
<height>465</height>
</rect>
</property>
<attribute name="label">
<string>Person</string>
</attribute>
</widget>
<widget class="cToolBoxLocation" name="m_lpToolBoxLocation">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>69</width>
<height>465</height>
</rect>
</property>
<attribute name="label">
<string>Location</string>
</attribute>
</widget>
<widget class="cToolBoxTag" name="m_lpToolBoxTags">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>69</width>
<height>465</height>
</rect>
</property>
<attribute name="label">
<string>Tags</string>
</attribute>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
</widget>
</widget>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="cSpoiler" name="m_lpSpoiler" native="true"/>
</item>
</layout>
</widget>
@@ -221,6 +228,12 @@
<header>ctoolboxtag.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>cSpoiler</class>
<extends>QWidget</extends>
<header>cspoiler.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
+80
View File
@@ -0,0 +1,80 @@
/*!
\file cspoiler.cpp
*/
#include "cspoiler.h"
#include <QPropertyAnimation>
cSpoiler::cSpoiler(QWidget *parent) :
QWidget(parent),
m_animationDuration(300)
{
m_toggleButton.setStyleSheet("QToolButton { border: none; }");
m_toggleButton.setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
m_toggleButton.setArrowType(Qt::ArrowType::RightArrow);
m_toggleButton.setText("");
m_toggleButton.setCheckable(true);
m_toggleButton.setChecked(false);
m_headerLine.setFrameShape(QFrame::HLine);
m_headerLine.setFrameShadow(QFrame::Sunken);
m_headerLine.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
m_contentArea.setStyleSheet("QScrollArea { border: none; }");
m_contentArea.setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
// start out collapsed
m_contentArea.setMaximumHeight(0);
m_contentArea.setMinimumHeight(0);
// let the entire widget grow and shrink with its content
m_toggleAnimation.addAnimation(new QPropertyAnimation(this, "minimumHeight"));
m_toggleAnimation.addAnimation(new QPropertyAnimation(this, "maximumHeight"));
m_toggleAnimation.addAnimation(new QPropertyAnimation(&m_contentArea, "maximumHeight"));
// don't waste space
m_mainLayout.setVerticalSpacing(0);
m_mainLayout.setContentsMargins(0, 0, 0, 0);
int row = 0;
m_mainLayout.addWidget(&m_toggleButton, row, 0, 1, 1, Qt::AlignLeft);
m_mainLayout.addWidget(&m_headerLine, row++, 2, 1, 1);
m_mainLayout.addWidget(&m_contentArea, row, 0, 1, 3);
setLayout(&m_mainLayout);
QObject::connect(&m_toggleButton, &QToolButton::clicked, [this](const bool checked)
{
m_toggleButton.setArrowType(checked ? Qt::ArrowType::DownArrow : Qt::ArrowType::RightArrow);
m_toggleAnimation.setDirection(checked ? QAbstractAnimation::Forward : QAbstractAnimation::Backward);
m_toggleAnimation.start();
});
}
void cSpoiler::setTitle(const QString& title)
{
m_toggleButton.setText(title);
}
void cSpoiler::setContentLayout(QLayout& contentLayout)
{
delete m_contentArea.layout();
m_contentArea.setLayout(&contentLayout);
const auto collapsedHeight = sizeHint().height() - m_contentArea.maximumHeight();
auto contentHeight = contentLayout.sizeHint().height();
for (int i = 0; i < m_toggleAnimation.animationCount() - 1; ++i)
{
QPropertyAnimation * spoilerAnimation = static_cast<QPropertyAnimation *>(m_toggleAnimation.animationAt(i));
spoilerAnimation->setDuration(m_animationDuration);
spoilerAnimation->setStartValue(collapsedHeight);
spoilerAnimation->setEndValue(collapsedHeight + contentHeight);
}
QPropertyAnimation * contentAnimation = static_cast<QPropertyAnimation *>(m_toggleAnimation.animationAt(m_toggleAnimation.animationCount() - 1));
contentAnimation->setDuration(m_animationDuration);
contentAnimation->setStartValue(0);
contentAnimation->setEndValue(contentHeight);
}
void cSpoiler::setContentWidget(QWidget* contentWidget)
{
auto* lpLayout = new QVBoxLayout();
lpLayout->addWidget(contentWidget);
setContentLayout(*lpLayout);
}
+70
View File
@@ -0,0 +1,70 @@
/*!
\file cspoiler.h
*/
#ifndef CSPOILER_H
#define CSPOILER_H
#include <QFrame>
#include <QGridLayout>
#include <QParallelAnimationGroup>
#include <QScrollArea>
#include <QToolButton>
#include <QWidget>
/*!
\brief
\class cSpoiler cspoiler.h "cspoiler.h"
*/
class cSpoiler : public QWidget
{
Q_OBJECT
public:
/*!
\brief
\fn cSpoiler
\param parent
*/
explicit cSpoiler(QWidget *parent = nullptr);
/*!
\brief
\fn setTitle
\param title
*/
void setTitle(const QString& title);
/*!
\brief
\fn setContentLayout
\param contentLayout
*/
void setContentLayout(QLayout& contentLayout);
/*!
\brief
\fn setContentWidget
\param contentWidget
*/
void setContentWidget(QWidget* contentWidget);
signals:
public slots:
private:
QGridLayout m_mainLayout; /*!< TODO: describe */
QToolButton m_toggleButton; /*!< TODO: describe */
QFrame m_headerLine; /*!< TODO: describe */
QParallelAnimationGroup m_toggleAnimation; /*!< TODO: describe */
QScrollArea m_contentArea; /*!< TODO: describe */
int m_animationDuration{300}; /*!< TODO: describe */
};
#endif // CSPOILER_H
+8 -3
View File
@@ -76,7 +76,9 @@ SOURCES += \
ctag.cpp \
clocation.cpp \
ctoolboxlocation.cpp \
ctoolboxtag.cpp
ctoolboxtag.cpp \
cspoiler.cpp \
cfilterpanel.cpp
HEADERS += \
cmainwindow.h \
@@ -101,7 +103,9 @@ HEADERS += \
ctag.h \
clocation.h \
ctoolboxlocation.h \
ctoolboxtag.h
ctoolboxtag.h \
cspoiler.h \
cfilterpanel.h
FORMS += \
cmainwindow.ui \
@@ -113,7 +117,8 @@ FORMS += \
ctoolboxperson.ui \
cimageviewer.ui \
ctoolboxlocation.ui \
ctoolboxtag.ui
ctoolboxtag.ui \
cfilterpanel.ui
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin