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;
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++)
{
QStandardItem* lpItem = m_lpPersonListModel->item(x, 0);
@@ -78,6 +88,9 @@ void cFilterPanel::initUI()
{
ui->setupUi(this);
m_lpTitleListModel = new QStandardItemModel;
ui->m_lpTitleList->setModel(m_lpTitleListModel);
m_lpPersonListModel = new QStandardItemModel;
ui->m_lpPersonList->setModel(m_lpPersonListModel);
@@ -89,6 +102,8 @@ void cFilterPanel::initUI()
QSettings settings;
ui->m_lpTitleFilter->setChecked(settings.value("filter/titleActive", true).toBool());
ui->m_lpPersonFilter->setChecked(settings.value("filter/personActive", true).toBool());
ui->m_lpPersonAnd->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()
{
connect(ui->m_lpTitleFilter, &QGroupBox::toggled, this, &cFilterPanel::onTitleFilter);
connect(ui->m_lpPersonFilter, &QGroupBox::toggled, this, &cFilterPanel::onPersonFilter);
connect(ui->m_lpLocationFilter, &QGroupBox::toggled, this, &cFilterPanel::onLocationFilter);
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_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_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>)));
}
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()
{
m_lpPersonListModel->clear();
@@ -339,6 +417,37 @@ QList<qint32> cFilterPanel::selectedTag()
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()
{
if(m_bLoading)
+78 -19
View File
@@ -30,6 +30,34 @@ public:
*/
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
@@ -111,10 +139,37 @@ public:
*/
QList<qint32> selectedTag();
/*!
\brief
\fn onTitleChanged
*/
void onTitleChanged();
/*!
\brief
\fn onPersonChanged
*/
void onPersonChanged();
/*!
\brief
\fn onLocationChanged
*/
void onLocationChanged();
/*!
\brief
\fn onTagChanged
*/
void onTagChanged();
private:
Ui::cFilterPanel* ui;
bool m_bLoading; /*!< TODO: describe */
QStandardItemModel* m_lpTitleListModel; /*!< TODO: describe */
QStandardItemModel* m_lpPersonListModel; /*!< TODO: describe */
cPersonList* m_lpPersonList; /*!< TODO: describe */
@@ -136,26 +191,23 @@ private:
\fn createActions
*/
void createActions();
/*!
\brief
\fn onPersonChanged
*/
void onPersonChanged();
/*!
\brief
\fn onLocationChanged
*/
void onLocationChanged();
/*!
\brief
\fn onTagChanged
*/
void onTagChanged();
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
@@ -226,6 +278,13 @@ private slots:
*/
void onTagChanged(const QModelIndex& topLeft, const QModelIndex& bottomright, const QVector<int>& roles);
signals:
/*!
\brief
\fn titleChanged
\param titleList
*/
void titleChanged(QStringList titleList);
/*!
\brief
+61 -9
View File
@@ -6,27 +6,33 @@
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>189</height>
<width>570</width>
<height>152</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<item row="0" column="1">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QGroupBox" name="m_lpPersonFilter">
<widget class="QGroupBox" name="m_lpTitleFilter">
<property name="title">
<string>Person</string>
<string>Title</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="2" column="0">
<widget class="QTreeView" name="m_lpPersonList">
<layout class="QGridLayout" name="gridLayout_5">
<item row="1" column="0">
<widget class="QTreeView" name="m_lpTitleList">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>100</height>
</size>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
@@ -41,7 +47,19 @@
</attribute>
</widget>
</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">
<item>
<widget class="QRadioButton" name="m_lpPersonAnd">
@@ -75,6 +93,28 @@
</item>
</layout>
</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>
</widget>
</item>
@@ -89,6 +129,12 @@
<layout class="QGridLayout" name="gridLayout_3">
<item row="1" column="0">
<widget class="QTreeView" name="m_lpLocationList">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>100</height>
</size>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
@@ -151,6 +197,12 @@
<layout class="QGridLayout" name="gridLayout_4">
<item row="1" column="0">
<widget class="QTreeView" name="m_lpTagList">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>100</height>
</size>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</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::locationListChanged, this, &cMainWindow::onLocationListChanged);
connect(m_lpFilterPanel, &cFilterPanel::titleChanged, this, &cMainWindow::onFilterTitleChanged);
connect(m_lpFilterPanel, &cFilterPanel::personChanged, this, &cMainWindow::onFilterPersonChanged);
connect(m_lpFilterPanel, &cFilterPanel::locationChanged, this, &cMainWindow::onFilterLocationChanged);
connect(m_lpFilterPanel, &cFilterPanel::tagChanged, this, &cMainWindow::onFilterTagChanged);
@@ -281,6 +282,7 @@ void cMainWindow::displayData()
ui->m_lpToolBoxLocation->setLocationList(&m_locationList);
ui->m_lpToolBoxTags->setTagList(&m_tagList);
m_lpFilterPanel->setTitleList(m_pictureList.titleList());
m_lpFilterPanel->setPersonList(&m_personList);
m_lpFilterPanel->setLocationList(&m_locationList);
m_lpFilterPanel->setTagList(&m_tagList);
@@ -329,8 +331,15 @@ void cMainWindow::displayData()
m_lpFolderSortFilterProxyModel->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);
m_lpThumbnailSortFilterProxyModel->invalidate();
showCount();
}
@@ -925,6 +934,14 @@ void cMainWindow::onLocationListChanged()
m_lpFilterPanel->updateLocationList();
}
void cMainWindow::onFilterTitleChanged(QStringList titleList)
{
if(m_bLoading)
return;
m_lpThumbnailSortFilterProxyModel->setTitleList(titleList);
}
void cMainWindow::onFilterPersonChanged(QList<qint32> idList, bool bAnd)
{
if(m_bLoading)
+7
View File
@@ -365,6 +365,13 @@ private slots:
*/
void onLocationListChanged();
/*!
\brief
\fn onFilterTitleChanged
\param titleList
*/
void onFilterTitleChanged(QStringList titleList);
/*!
\brief
+4 -1
View File
@@ -1128,7 +1128,10 @@ QStringList cPictureList::titleList()
QStringList szTitleList;
for(cPictureList::iterator i = begin(); i != end();i++)
szTitleList.append((*i)->title());
{
if(!(*i)->title().isEmpty())
szTitleList.append((*i)->title());
}
szTitleList.removeDuplicates();
szTitleList.sort(Qt::CaseInsensitive);
+13
View File
@@ -25,6 +25,16 @@ QString cThumbnailSortFilterProxyModel::filterPath()
return(m_szPath);
}
QStringList cThumbnailSortFilterProxyModel::titleList()
{
return(m_titleList);
}
void cThumbnailSortFilterProxyModel::setTitleList(const QStringList& titleList)
{
m_titleList = titleList;
}
QList<qint32> cThumbnailSortFilterProxyModel::personList()
{
return(m_personList);
@@ -93,6 +103,9 @@ bool cThumbnailSortFilterProxyModel::filterAcceptsRow(int sourceRow, const QMode
if(!bValid)
return(false);
if(!m_titleList.contains(lpPicture->title()))
return(false);
if(!m_personList.isEmpty())
{
if(!lpPicture->personList().contains(m_personList, m_bPersonAnd))
+15
View File
@@ -36,6 +36,20 @@ public:
*/
void setFilterPath(const QString& szPath);
/*!
\brief
\fn titleList
*/
QStringList titleList();
/*!
\brief
\fn setTitleList
\param titleList
*/
void setTitleList(const QStringList& titleList);
/*!
\brief
@@ -91,6 +105,7 @@ protected:
private:
QString m_szPath; /*!< TODO: describe */
QStringList m_titleList; /*!< TODO: describe */
QList<qint32> m_personList; /*!< TODO: describe */
QList<qint32> m_locationList; /*!< TODO: describe */
QList<qint32> m_tagList; /*!< TODO: describe */