title filter

This commit is contained in:
2019-04-01 14:43:01 +02:00
parent a95957e2fc
commit 7bccf8fb19
8 changed files with 304 additions and 29 deletions
+109
View File
@@ -26,6 +26,16 @@ void cFilterPanel::saveSettings()
QSettings settings; QSettings settings;
QStringList szIDs; QStringList szIDs;
for(int x = 0;x < m_lpTitleListModel->rowCount();x++)
{
QStandardItem* lpItem = m_lpTitleListModel->item(x, 0);
if(lpItem->checkState() == Qt::Checked)
szIDs.append(lpItem->text());
}
settings.setValue("filter/title", QVariant::fromValue(szIDs));
settings.setValue("filter/titleActive", QVariant::fromValue(ui->m_lpTitleFilter->isChecked()));
for(int x = 0;x < m_lpPersonListModel->rowCount();x++) for(int x = 0;x < m_lpPersonListModel->rowCount();x++)
{ {
QStandardItem* lpItem = m_lpPersonListModel->item(x, 0); QStandardItem* lpItem = m_lpPersonListModel->item(x, 0);
@@ -78,6 +88,9 @@ void cFilterPanel::initUI()
{ {
ui->setupUi(this); ui->setupUi(this);
m_lpTitleListModel = new QStandardItemModel;
ui->m_lpTitleList->setModel(m_lpTitleListModel);
m_lpPersonListModel = new QStandardItemModel; m_lpPersonListModel = new QStandardItemModel;
ui->m_lpPersonList->setModel(m_lpPersonListModel); ui->m_lpPersonList->setModel(m_lpPersonListModel);
@@ -89,6 +102,8 @@ void cFilterPanel::initUI()
QSettings settings; QSettings settings;
ui->m_lpTitleFilter->setChecked(settings.value("filter/titleActive", true).toBool());
ui->m_lpPersonFilter->setChecked(settings.value("filter/personActive", true).toBool()); ui->m_lpPersonFilter->setChecked(settings.value("filter/personActive", true).toBool());
ui->m_lpPersonAnd->setChecked(settings.value("filter/personAnd", true).toBool()); ui->m_lpPersonAnd->setChecked(settings.value("filter/personAnd", true).toBool());
ui->m_lpPersonOr->setChecked(!settings.value("filter/personAnd", true).toBool()); ui->m_lpPersonOr->setChecked(!settings.value("filter/personAnd", true).toBool());
@@ -104,6 +119,7 @@ void cFilterPanel::initUI()
void cFilterPanel::createActions() void cFilterPanel::createActions()
{ {
connect(ui->m_lpTitleFilter, &QGroupBox::toggled, this, &cFilterPanel::onTitleFilter);
connect(ui->m_lpPersonFilter, &QGroupBox::toggled, this, &cFilterPanel::onPersonFilter); connect(ui->m_lpPersonFilter, &QGroupBox::toggled, this, &cFilterPanel::onPersonFilter);
connect(ui->m_lpLocationFilter, &QGroupBox::toggled, this, &cFilterPanel::onLocationFilter); connect(ui->m_lpLocationFilter, &QGroupBox::toggled, this, &cFilterPanel::onLocationFilter);
connect(ui->m_lpTagFilter, &QGroupBox::toggled, this, &cFilterPanel::onTagFilter); connect(ui->m_lpTagFilter, &QGroupBox::toggled, this, &cFilterPanel::onTagFilter);
@@ -112,11 +128,73 @@ void cFilterPanel::createActions()
connect(ui->m_lpLocationAnd, &QRadioButton::toggled, this, &cFilterPanel::onLocationAnd); connect(ui->m_lpLocationAnd, &QRadioButton::toggled, this, &cFilterPanel::onLocationAnd);
connect(ui->m_lpTagsAnd, &QRadioButton::toggled, this, &cFilterPanel::onTagAnd); connect(ui->m_lpTagsAnd, &QRadioButton::toggled, this, &cFilterPanel::onTagAnd);
connect(m_lpTitleListModel, SIGNAL(dataChanged(QModelIndex, QModelIndex, QVector<int>)), SLOT(onTitleChanged(QModelIndex, QModelIndex, QVector<int>)));
connect(m_lpPersonListModel, SIGNAL(dataChanged(QModelIndex, QModelIndex, QVector<int>)), SLOT(onPersonChanged(QModelIndex, QModelIndex, QVector<int>))); connect(m_lpPersonListModel, SIGNAL(dataChanged(QModelIndex, QModelIndex, QVector<int>)), SLOT(onPersonChanged(QModelIndex, QModelIndex, QVector<int>)));
connect(m_lpLocationListModel, SIGNAL(dataChanged(QModelIndex, QModelIndex, QVector<int>)), SLOT(onLocationChanged(QModelIndex, QModelIndex, QVector<int>))); connect(m_lpLocationListModel, SIGNAL(dataChanged(QModelIndex, QModelIndex, QVector<int>)), SLOT(onLocationChanged(QModelIndex, QModelIndex, QVector<int>)));
connect(m_lpTagListModel, SIGNAL(dataChanged(QModelIndex, QModelIndex, QVector<int>)), SLOT(onTagChanged(QModelIndex, QModelIndex, QVector<int>))); connect(m_lpTagListModel, SIGNAL(dataChanged(QModelIndex, QModelIndex, QVector<int>)), SLOT(onTagChanged(QModelIndex, QModelIndex, QVector<int>)));
} }
void cFilterPanel::clearTitleList()
{
m_lpTitleListModel->clear();
}
void cFilterPanel::setTitleList(QStringList titleList)
{
m_bLoading = true;
QSettings settings;
QStringList szIDs;
szIDs = settings.value("filter/title").toStringList();
for(QStringList::iterator i = titleList.begin();i != titleList.end();i++)
{
QStandardItem* lpItem = new QStandardItem(*i);
lpItem->setCheckable(true);
m_lpTitleListModel->appendRow(lpItem);
if(szIDs.contains(*i))
lpItem->setCheckState(Qt::Checked);
}
m_lpPersonListModel->sort(0);
m_bLoading = false;
}
void cFilterPanel::updateTitleList(QStringList& titleList)
{
m_bLoading = true;
for(QStringList::iterator i = titleList.begin();i != titleList.end();i++)
{
if(m_lpTitleListModel->findItems(*i).isEmpty())
{
QStandardItem* lpItem = new QStandardItem(*i);
lpItem->setCheckable(true);
m_lpTitleListModel->appendRow(lpItem);
}
}
m_lpPersonListModel->sort(0);
m_bLoading = false;
}
QStringList cFilterPanel::selectedTitle()
{
QStringList titleList;
for(int x = 0;x < m_lpTitleListModel->rowCount();x++)
{
QStandardItem* lpItem = m_lpTitleListModel->item(x, 0);
if(lpItem->checkState() == Qt::Checked)
titleList.append(lpItem->text());
}
return(titleList);
}
void cFilterPanel::clearPersonList() void cFilterPanel::clearPersonList()
{ {
m_lpPersonListModel->clear(); m_lpPersonListModel->clear();
@@ -339,6 +417,37 @@ QList<qint32> cFilterPanel::selectedTag()
return(idList); return(idList);
} }
void cFilterPanel::onTitleFilter(bool bToggle)
{
if(bToggle)
onTitleChanged();
else {
emit(titleChanged(QStringList()));
}
}
void cFilterPanel::onTitleChanged(const QModelIndex& /*topLeft*/, const QModelIndex& /*bottomright*/, const QVector<int>& /*roles*/)
{
onTitleChanged();
}
void cFilterPanel::onTitleChanged()
{
if(m_bLoading)
return;
QStringList titleList;
for(int x = 0;x < m_lpTitleListModel->rowCount();x++)
{
QStandardItem* lpItem = m_lpTitleListModel->item(x, 0);
if(lpItem->checkState() == Qt::Checked)
titleList.append(lpItem->text());
}
emit titleChanged(titleList);
}
void cFilterPanel::onPersonChanged() void cFilterPanel::onPersonChanged()
{ {
if(m_bLoading) if(m_bLoading)
+78 -19
View File
@@ -30,6 +30,34 @@ public:
*/ */
void saveSettings(); void saveSettings();
/*!
\brief
\fn clearTitleList
*/
void clearTitleList();
/*!
\brief
\param titleList
\fn setTitleList
*/
void setTitleList(QStringList titleList);
/*!
\brief
\param titleList
\fn updateTitleList
*/
void updateTitleList(QStringList& titleList);
/*!
\brief
\fn selectedTitle
\return QStringList
*/
QStringList selectedTitle();
/*! /*!
\brief \brief
@@ -111,10 +139,37 @@ public:
*/ */
QList<qint32> selectedTag(); QList<qint32> selectedTag();
/*!
\brief
\fn onTitleChanged
*/
void onTitleChanged();
/*!
\brief
\fn onPersonChanged
*/
void onPersonChanged();
/*!
\brief
\fn onLocationChanged
*/
void onLocationChanged();
/*!
\brief
\fn onTagChanged
*/
void onTagChanged();
private: private:
Ui::cFilterPanel* ui; Ui::cFilterPanel* ui;
bool m_bLoading; /*!< TODO: describe */ bool m_bLoading; /*!< TODO: describe */
QStandardItemModel* m_lpTitleListModel; /*!< TODO: describe */
QStandardItemModel* m_lpPersonListModel; /*!< TODO: describe */ QStandardItemModel* m_lpPersonListModel; /*!< TODO: describe */
cPersonList* m_lpPersonList; /*!< TODO: describe */ cPersonList* m_lpPersonList; /*!< TODO: describe */
@@ -136,26 +191,23 @@ private:
\fn createActions \fn createActions
*/ */
void createActions(); void createActions();
/*!
\brief
\fn onPersonChanged
*/
void onPersonChanged();
/*!
\brief
\fn onLocationChanged
*/
void onLocationChanged();
/*!
\brief
\fn onTagChanged
*/
void onTagChanged();
private slots: private slots:
/*!
\brief
\fn onTitleFilter
\param bToggle
*/
void onTitleFilter(bool bToggle);
/*!
\brief
\fn onTitleChanged
\param topLeft
\param bottomright
\param roles
*/
void onTitleChanged(const QModelIndex& topLeft, const QModelIndex& bottomright, const QVector<int>& roles);
/*! /*!
\brief \brief
@@ -226,6 +278,13 @@ private slots:
*/ */
void onTagChanged(const QModelIndex& topLeft, const QModelIndex& bottomright, const QVector<int>& roles); void onTagChanged(const QModelIndex& topLeft, const QModelIndex& bottomright, const QVector<int>& roles);
signals: signals:
/*!
\brief
\fn titleChanged
\param titleList
*/
void titleChanged(QStringList titleList);
/*! /*!
\brief \brief
+61 -9
View File
@@ -6,27 +6,33 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>400</width> <width>570</width>
<height>189</height> <height>152</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="0" column="0"> <item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<widget class="QGroupBox" name="m_lpPersonFilter"> <widget class="QGroupBox" name="m_lpTitleFilter">
<property name="title"> <property name="title">
<string>Person</string> <string>Title</string>
</property> </property>
<property name="checkable"> <property name="checkable">
<bool>true</bool> <bool>true</bool>
</property> </property>
<layout class="QGridLayout" name="gridLayout_2"> <layout class="QGridLayout" name="gridLayout_5">
<item row="2" column="0"> <item row="1" column="0">
<widget class="QTreeView" name="m_lpPersonList"> <widget class="QTreeView" name="m_lpTitleList">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>100</height>
</size>
</property>
<property name="editTriggers"> <property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set> <set>QAbstractItemView::NoEditTriggers</set>
</property> </property>
@@ -41,7 +47,19 @@
</attribute> </attribute>
</widget> </widget>
</item> </item>
<item row="0" column="0"> </layout>
</widget>
</item>
<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="1">
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_2">
<item> <item>
<widget class="QRadioButton" name="m_lpPersonAnd"> <widget class="QRadioButton" name="m_lpPersonAnd">
@@ -75,6 +93,28 @@
</item> </item>
</layout> </layout>
</item> </item>
<item row="2" column="1">
<widget class="QTreeView" name="m_lpPersonList">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>100</height>
</size>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="rootIsDecorated">
<bool>false</bool>
</property>
<attribute name="headerVisible">
<bool>false</bool>
</attribute>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
@@ -89,6 +129,12 @@
<layout class="QGridLayout" name="gridLayout_3"> <layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="0"> <item row="1" column="0">
<widget class="QTreeView" name="m_lpLocationList"> <widget class="QTreeView" name="m_lpLocationList">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>100</height>
</size>
</property>
<property name="editTriggers"> <property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set> <set>QAbstractItemView::NoEditTriggers</set>
</property> </property>
@@ -151,6 +197,12 @@
<layout class="QGridLayout" name="gridLayout_4"> <layout class="QGridLayout" name="gridLayout_4">
<item row="1" column="0"> <item row="1" column="0">
<widget class="QTreeView" name="m_lpTagList"> <widget class="QTreeView" name="m_lpTagList">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>100</height>
</size>
</property>
<property name="editTriggers"> <property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set> <set>QAbstractItemView::NoEditTriggers</set>
</property> </property>
+17
View File
@@ -175,6 +175,7 @@ void cMainWindow::createActions()
connect(ui->m_lpToolBoxLocation, &cToolBoxLocation::locationEdited, this, &cMainWindow::onLocationEdited); connect(ui->m_lpToolBoxLocation, &cToolBoxLocation::locationEdited, this, &cMainWindow::onLocationEdited);
connect(ui->m_lpToolBoxLocation, &cToolBoxLocation::locationListChanged, this, &cMainWindow::onLocationListChanged); connect(ui->m_lpToolBoxLocation, &cToolBoxLocation::locationListChanged, this, &cMainWindow::onLocationListChanged);
connect(m_lpFilterPanel, &cFilterPanel::titleChanged, this, &cMainWindow::onFilterTitleChanged);
connect(m_lpFilterPanel, &cFilterPanel::personChanged, this, &cMainWindow::onFilterPersonChanged); connect(m_lpFilterPanel, &cFilterPanel::personChanged, this, &cMainWindow::onFilterPersonChanged);
connect(m_lpFilterPanel, &cFilterPanel::locationChanged, this, &cMainWindow::onFilterLocationChanged); connect(m_lpFilterPanel, &cFilterPanel::locationChanged, this, &cMainWindow::onFilterLocationChanged);
connect(m_lpFilterPanel, &cFilterPanel::tagChanged, this, &cMainWindow::onFilterTagChanged); connect(m_lpFilterPanel, &cFilterPanel::tagChanged, this, &cMainWindow::onFilterTagChanged);
@@ -281,6 +282,7 @@ void cMainWindow::displayData()
ui->m_lpToolBoxLocation->setLocationList(&m_locationList); ui->m_lpToolBoxLocation->setLocationList(&m_locationList);
ui->m_lpToolBoxTags->setTagList(&m_tagList); ui->m_lpToolBoxTags->setTagList(&m_tagList);
m_lpFilterPanel->setTitleList(m_pictureList.titleList());
m_lpFilterPanel->setPersonList(&m_personList); m_lpFilterPanel->setPersonList(&m_personList);
m_lpFilterPanel->setLocationList(&m_locationList); m_lpFilterPanel->setLocationList(&m_locationList);
m_lpFilterPanel->setTagList(&m_tagList); m_lpFilterPanel->setTagList(&m_tagList);
@@ -329,8 +331,15 @@ void cMainWindow::displayData()
m_lpFolderSortFilterProxyModel->sort(0); m_lpFolderSortFilterProxyModel->sort(0);
m_lpThumbnailSortFilterProxyModel->sort(0); m_lpThumbnailSortFilterProxyModel->sort(0);
m_lpFilterPanel->onTitleChanged();
m_lpFilterPanel->onPersonChanged();
m_lpFilterPanel->onLocationChanged();
m_lpFilterPanel->onTagChanged();
ui->m_lpStatusBar->showMessage(tr("done."), 3); ui->m_lpStatusBar->showMessage(tr("done."), 3);
m_lpThumbnailSortFilterProxyModel->invalidate();
showCount(); showCount();
} }
@@ -925,6 +934,14 @@ void cMainWindow::onLocationListChanged()
m_lpFilterPanel->updateLocationList(); m_lpFilterPanel->updateLocationList();
} }
void cMainWindow::onFilterTitleChanged(QStringList titleList)
{
if(m_bLoading)
return;
m_lpThumbnailSortFilterProxyModel->setTitleList(titleList);
}
void cMainWindow::onFilterPersonChanged(QList<qint32> idList, bool bAnd) void cMainWindow::onFilterPersonChanged(QList<qint32> idList, bool bAnd)
{ {
if(m_bLoading) if(m_bLoading)
+7
View File
@@ -365,6 +365,13 @@ private slots:
*/ */
void onLocationListChanged(); void onLocationListChanged();
/*!
\brief
\fn onFilterTitleChanged
\param titleList
*/
void onFilterTitleChanged(QStringList titleList);
/*! /*!
\brief \brief
+4 -1
View File
@@ -1128,7 +1128,10 @@ QStringList cPictureList::titleList()
QStringList szTitleList; QStringList szTitleList;
for(cPictureList::iterator i = begin(); i != end();i++) for(cPictureList::iterator i = begin(); i != end();i++)
szTitleList.append((*i)->title()); {
if(!(*i)->title().isEmpty())
szTitleList.append((*i)->title());
}
szTitleList.removeDuplicates(); szTitleList.removeDuplicates();
szTitleList.sort(Qt::CaseInsensitive); szTitleList.sort(Qt::CaseInsensitive);
+13
View File
@@ -25,6 +25,16 @@ QString cThumbnailSortFilterProxyModel::filterPath()
return(m_szPath); return(m_szPath);
} }
QStringList cThumbnailSortFilterProxyModel::titleList()
{
return(m_titleList);
}
void cThumbnailSortFilterProxyModel::setTitleList(const QStringList& titleList)
{
m_titleList = titleList;
}
QList<qint32> cThumbnailSortFilterProxyModel::personList() QList<qint32> cThumbnailSortFilterProxyModel::personList()
{ {
return(m_personList); return(m_personList);
@@ -93,6 +103,9 @@ bool cThumbnailSortFilterProxyModel::filterAcceptsRow(int sourceRow, const QMode
if(!bValid) if(!bValid)
return(false); return(false);
if(!m_titleList.contains(lpPicture->title()))
return(false);
if(!m_personList.isEmpty()) if(!m_personList.isEmpty())
{ {
if(!lpPicture->personList().contains(m_personList, m_bPersonAnd)) if(!lpPicture->personList().contains(m_personList, m_bPersonAnd))
+15
View File
@@ -36,6 +36,20 @@ public:
*/ */
void setFilterPath(const QString& szPath); void setFilterPath(const QString& szPath);
/*!
\brief
\fn titleList
*/
QStringList titleList();
/*!
\brief
\fn setTitleList
\param titleList
*/
void setTitleList(const QStringList& titleList);
/*! /*!
\brief \brief
@@ -91,6 +105,7 @@ protected:
private: private:
QString m_szPath; /*!< TODO: describe */ QString m_szPath; /*!< TODO: describe */
QStringList m_titleList; /*!< TODO: describe */
QList<qint32> m_personList; /*!< TODO: describe */ QList<qint32> m_personList; /*!< TODO: describe */
QList<qint32> m_locationList; /*!< TODO: describe */ QList<qint32> m_locationList; /*!< TODO: describe */
QList<qint32> m_tagList; /*!< TODO: describe */ QList<qint32> m_tagList; /*!< TODO: describe */