filter panel
This commit is contained in:
@@ -35,6 +35,17 @@ void cFilterPanel::initUI()
|
||||
|
||||
void cFilterPanel::createActions()
|
||||
{
|
||||
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);
|
||||
|
||||
connect(ui->m_lpPersonAnd, &QRadioButton::toggled, this, &cFilterPanel::onPersonAnd);
|
||||
connect(ui->m_lpLocationAnd, &QRadioButton::toggled, this, &cFilterPanel::onLocationAnd);
|
||||
connect(ui->m_lpTagsAnd, &QRadioButton::toggled, this, &cFilterPanel::onTagAnd);
|
||||
|
||||
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::clearPersonList()
|
||||
@@ -182,3 +193,120 @@ void cFilterPanel::updateTagList()
|
||||
|
||||
m_bLoading = false;
|
||||
}
|
||||
|
||||
void cFilterPanel::onPersonChanged()
|
||||
{
|
||||
if(m_bLoading)
|
||||
return;
|
||||
|
||||
QList<qint32> idList;
|
||||
|
||||
for(int x = 0;x < m_lpPersonListModel->rowCount();x++)
|
||||
{
|
||||
QStandardItem* lpItem = m_lpPersonListModel->item(x, 0);
|
||||
|
||||
if(lpItem->checkState() == Qt::Checked)
|
||||
{
|
||||
cPerson* lpPerson = lpItem->data(Qt::UserRole+1).value<cPerson*>();
|
||||
if(lpPerson)
|
||||
idList.append(lpPerson->id());
|
||||
}
|
||||
}
|
||||
emit personChanged(idList, ui->m_lpPersonAnd->isChecked());
|
||||
}
|
||||
|
||||
void cFilterPanel::onPersonAnd(bool /*bToggle*/)
|
||||
{
|
||||
onPersonChanged();
|
||||
}
|
||||
|
||||
void cFilterPanel::onPersonFilter(bool bToggle)
|
||||
{
|
||||
if(bToggle)
|
||||
onPersonChanged();
|
||||
else
|
||||
emit(personChanged(QList<qint32>(), false));
|
||||
}
|
||||
|
||||
void cFilterPanel::onPersonChanged(const QModelIndex& /*topLeft*/, const QModelIndex& /*bottomright*/, const QVector<int>& /*roles*/)
|
||||
{
|
||||
onPersonChanged();
|
||||
}
|
||||
|
||||
void cFilterPanel::onLocationChanged()
|
||||
{
|
||||
if(m_bLoading)
|
||||
return;
|
||||
|
||||
QList<qint32> idList;
|
||||
|
||||
for(int x = 0;x < m_lpLocationListModel->rowCount();x++)
|
||||
{
|
||||
QStandardItem* lpItem = m_lpLocationListModel->item(x, 0);
|
||||
|
||||
if(lpItem->checkState() == Qt::Checked)
|
||||
{
|
||||
cLocation* lpLocation = lpItem->data(Qt::UserRole+1).value<cLocation*>();
|
||||
if(lpLocation)
|
||||
idList.append(lpLocation->id());
|
||||
}
|
||||
}
|
||||
emit locationChanged(idList, ui->m_lpLocationAnd->isChecked());
|
||||
}
|
||||
|
||||
void cFilterPanel::onLocationFilter(bool bToggle)
|
||||
{
|
||||
if(bToggle)
|
||||
onLocationChanged();
|
||||
else
|
||||
emit(locationChanged(QList<qint32>(), false));
|
||||
}
|
||||
|
||||
void cFilterPanel::onLocationAnd(bool /*bToggle*/)
|
||||
{
|
||||
onLocationChanged();
|
||||
}
|
||||
|
||||
void cFilterPanel::onLocationChanged(const QModelIndex& /*topLeft*/, const QModelIndex& /*bottomright*/, const QVector<int>& /*roles*/)
|
||||
{
|
||||
onLocationChanged();
|
||||
}
|
||||
|
||||
void cFilterPanel::onTagChanged()
|
||||
{
|
||||
if(m_bLoading)
|
||||
return;
|
||||
|
||||
QList<qint32> idList;
|
||||
|
||||
for(int x = 0;x < m_lpTagListModel->rowCount();x++)
|
||||
{
|
||||
QStandardItem* lpItem = m_lpTagListModel->item(x, 0);
|
||||
|
||||
if(lpItem->checkState() == Qt::Checked)
|
||||
{
|
||||
cTag* lpTag = lpItem->data(Qt::UserRole+1).value<cTag*>();
|
||||
if(lpTag)
|
||||
idList.append(lpTag->id());
|
||||
}
|
||||
}
|
||||
emit tagChanged(idList, ui->m_lpTagsAnd->isChecked());
|
||||
}
|
||||
|
||||
void cFilterPanel::onTagFilter(bool bToggle)
|
||||
{
|
||||
if(bToggle)
|
||||
onTagChanged();
|
||||
else
|
||||
emit(tagChanged(QList<qint32>(), false));
|
||||
}
|
||||
|
||||
void cFilterPanel::onTagAnd(bool /*bToggle*/)
|
||||
{
|
||||
onTagChanged();
|
||||
}
|
||||
|
||||
void cFilterPanel::onTagChanged(const QModelIndex& /*topLeft*/, const QModelIndex& /*bottomright*/, const QVector<int>& /*roles*/)
|
||||
{
|
||||
onTagChanged();
|
||||
}
|
||||
|
||||
+111
@@ -108,6 +108,117 @@ private:
|
||||
\fn createActions
|
||||
*/
|
||||
void createActions();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn onPersonChanged
|
||||
*/
|
||||
void onPersonChanged();
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn onLocationChanged
|
||||
*/
|
||||
void onLocationChanged();
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn onTagChanged
|
||||
*/
|
||||
void onTagChanged();
|
||||
private slots:
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn onPersonFilter
|
||||
\param bToggle
|
||||
*/
|
||||
void onPersonFilter(bool bToggle);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn onPersonAnd
|
||||
\param bToggle
|
||||
*/
|
||||
void onPersonAnd(bool bToggle);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn onPersonChanged
|
||||
\param topLeft
|
||||
\param bottomright
|
||||
\param roles
|
||||
*/
|
||||
void onPersonChanged(const QModelIndex& topLeft, const QModelIndex& bottomright, const QVector<int>& roles);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn onLocationFilter
|
||||
\param bToggle
|
||||
*/
|
||||
void onLocationFilter(bool bToggle);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn onLocationAnd
|
||||
\param bToggle
|
||||
*/
|
||||
void onLocationAnd(bool bToggle);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn onLocationChanged
|
||||
\param topLeft
|
||||
\param bottomright
|
||||
\param roles
|
||||
*/
|
||||
void onLocationChanged(const QModelIndex& topLeft, const QModelIndex& bottomright, const QVector<int>& roles);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn onTagFilter
|
||||
\param bToggle
|
||||
*/
|
||||
void onTagFilter(bool bToggle);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn onTagAnd
|
||||
\param bToggle
|
||||
*/
|
||||
void onTagAnd(bool bToggle);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn onTagChanged
|
||||
\param topLeft
|
||||
\param bottomright
|
||||
\param roles
|
||||
*/
|
||||
void onTagChanged(const QModelIndex& topLeft, const QModelIndex& bottomright, const QVector<int>& roles);
|
||||
signals:
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn personChanged
|
||||
\param idList
|
||||
*/
|
||||
void personChanged(QList<qint32> idList, bool bAnd);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn locationChanged
|
||||
\param idList
|
||||
*/
|
||||
void locationChanged(QList<qint32> idList, bool bAnd);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn tagChanged
|
||||
\param idList
|
||||
*/
|
||||
void tagChanged(QList<qint32> idList, bool bAnd);
|
||||
};
|
||||
|
||||
#endif // CFILTERPANEL_H
|
||||
|
||||
+105
-3
@@ -25,7 +25,7 @@
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<item row="2" column="0">
|
||||
<widget class="QTreeView" name="m_lpPersonList">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
@@ -41,6 +41,40 @@
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="m_lpPersonAnd">
|
||||
<property name="text">
|
||||
<string>and</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="m_lpPersonOr">
|
||||
<property name="text">
|
||||
<string>or</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>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -53,7 +87,7 @@
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="0">
|
||||
<item row="1" column="0">
|
||||
<widget class="QTreeView" name="m_lpLocationList">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
@@ -69,6 +103,40 @@
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="m_lpLocationAnd">
|
||||
<property name="text">
|
||||
<string>and</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="m_lpLocationOr">
|
||||
<property name="text">
|
||||
<string>or</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -81,7 +149,7 @@
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="0">
|
||||
<item row="1" column="0">
|
||||
<widget class="QTreeView" name="m_lpTagList">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
@@ -97,6 +165,40 @@
|
||||
</attribute>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="m_lpTagsAnd">
|
||||
<property name="text">
|
||||
<string>and</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="m_lpTagsOr">
|
||||
<property name="text">
|
||||
<string>or</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -282,3 +282,40 @@ QStringList cLocationList::locationList()
|
||||
szLocationList.sort(Qt::CaseInsensitive);
|
||||
return(szLocationList);
|
||||
}
|
||||
|
||||
bool cLocationList::contains(cLocation* const& lpLocation)
|
||||
{
|
||||
return(QList::contains(lpLocation));
|
||||
}
|
||||
|
||||
bool cLocationList::contains(QList<qint32> idList, bool bAnd)
|
||||
{
|
||||
if(bAnd)
|
||||
{
|
||||
int found = 0;
|
||||
|
||||
for(QList<qint32>::iterator z = idList.begin();z != idList.end();z++)
|
||||
{
|
||||
for(cLocationList::iterator i = begin();i != end();i++)
|
||||
{
|
||||
if((*i)->id() == (*z))
|
||||
{
|
||||
found++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(found == idList.count())
|
||||
return(true);
|
||||
return(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
for(cLocationList::iterator i = begin();i != end();i++)
|
||||
{
|
||||
if(idList.contains((*i)->id()))
|
||||
return(true);
|
||||
}
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
|
||||
+16
@@ -197,6 +197,22 @@ public:
|
||||
\return bool
|
||||
*/
|
||||
bool remove(cLocation* lpLocation);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn contains
|
||||
\param lpLocation
|
||||
\return bool
|
||||
*/
|
||||
bool contains(cLocation* const &lpLocation);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn contains
|
||||
\param idList
|
||||
\return bool
|
||||
*/
|
||||
bool contains(QList<qint32> idList, bool bAnd);
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
@@ -151,6 +151,10 @@ void cMainWindow::createActions()
|
||||
connect(ui->m_lpToolBoxLocation, &cToolBoxLocation::locationRemoved, this, &cMainWindow::onLocationRemoved);
|
||||
connect(ui->m_lpToolBoxLocation, &cToolBoxLocation::locationEdited, this, &cMainWindow::onLocationEdited);
|
||||
connect(ui->m_lpToolBoxLocation, &cToolBoxLocation::locationListChanged, this, &cMainWindow::onLocationListChanged);
|
||||
|
||||
connect(m_lpFilterPanel, &cFilterPanel::personChanged, this, &cMainWindow::onFilterPersonChanged);
|
||||
connect(m_lpFilterPanel, &cFilterPanel::locationChanged, this, &cMainWindow::onFilterLocationChanged);
|
||||
connect(m_lpFilterPanel, &cFilterPanel::tagChanged, this, &cMainWindow::onFilterTagChanged);
|
||||
}
|
||||
|
||||
void cMainWindow::createContextActions()
|
||||
@@ -890,3 +894,27 @@ void cMainWindow::onLocationListChanged()
|
||||
{
|
||||
m_lpFilterPanel->updateLocationList();
|
||||
}
|
||||
|
||||
void cMainWindow::onFilterPersonChanged(QList<qint32> idList, bool bAnd)
|
||||
{
|
||||
if(m_bLoading)
|
||||
return;
|
||||
|
||||
m_lpThumbnailSortFilterProxyModel->setPersonList(idList, bAnd);
|
||||
}
|
||||
|
||||
void cMainWindow::onFilterLocationChanged(QList<qint32> idList, bool bAnd)
|
||||
{
|
||||
if(m_bLoading)
|
||||
return;
|
||||
|
||||
m_lpThumbnailSortFilterProxyModel->setLocationList(idList, bAnd);
|
||||
}
|
||||
|
||||
void cMainWindow::onFilterTagChanged(QList<qint32> idList, bool bAnd)
|
||||
{
|
||||
if(m_bLoading)
|
||||
return;
|
||||
|
||||
m_lpThumbnailSortFilterProxyModel->setTagList(idList, bAnd);
|
||||
}
|
||||
|
||||
@@ -351,6 +351,28 @@ private slots:
|
||||
\fn onLocationListChanged
|
||||
*/
|
||||
void onLocationListChanged();
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn onFilterPersonChanged
|
||||
\param idList
|
||||
*/
|
||||
void onFilterPersonChanged(QList<qint32> idList, bool bAnd);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn onFilterLocationChanged
|
||||
\param idList
|
||||
*/
|
||||
void onFilterLocationChanged(QList<qint32> idList, bool bAnd);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn onFilterTagChanged
|
||||
\param idList
|
||||
*/
|
||||
void onFilterTagChanged(QList<qint32> idList, bool bAnd);
|
||||
};
|
||||
|
||||
#endif // CMAINWINDOW_H
|
||||
|
||||
+37
@@ -289,3 +289,40 @@ QStringList cPersonList::personList()
|
||||
szPersonList.sort(Qt::CaseInsensitive);
|
||||
return(szPersonList);
|
||||
}
|
||||
|
||||
bool cPersonList::contains(cPerson* const& lpPerson)
|
||||
{
|
||||
return(QList::contains(lpPerson));
|
||||
}
|
||||
|
||||
bool cPersonList::contains(QList<qint32> idList, bool bAnd)
|
||||
{
|
||||
if(bAnd)
|
||||
{
|
||||
int found = 0;
|
||||
|
||||
for(QList<qint32>::iterator z = idList.begin();z != idList.end();z++)
|
||||
{
|
||||
for(cPersonList::iterator i = begin();i != end();i++)
|
||||
{
|
||||
if((*i)->id() == (*z))
|
||||
{
|
||||
found++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(found == idList.count())
|
||||
return(true);
|
||||
return(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
for(cPersonList::iterator i = begin();i != end();i++)
|
||||
{
|
||||
if(idList.contains((*i)->id()))
|
||||
return(true);
|
||||
}
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,6 +197,22 @@ public:
|
||||
\return bool
|
||||
*/
|
||||
bool remove(cPerson* lpPerson);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn contains
|
||||
\param lpPerson
|
||||
\return bool
|
||||
*/
|
||||
bool contains(cPerson * const &lpPerson);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn contains
|
||||
\param idList
|
||||
\return bool
|
||||
*/
|
||||
bool contains(QList<qint32> idList, bool bAnd);
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
@@ -282,3 +282,40 @@ QStringList cTagList::tagList()
|
||||
szTagList.sort(Qt::CaseInsensitive);
|
||||
return(szTagList);
|
||||
}
|
||||
|
||||
bool cTagList::contains(cTag* const& lpTag)
|
||||
{
|
||||
return(QList::contains(lpTag));
|
||||
}
|
||||
|
||||
bool cTagList::contains(QList<qint32> idList, bool bAnd)
|
||||
{
|
||||
if(bAnd)
|
||||
{
|
||||
int found = 0;
|
||||
|
||||
for(QList<qint32>::iterator z = idList.begin();z != idList.end();z++)
|
||||
{
|
||||
for(cTagList::iterator i = begin();i != end();i++)
|
||||
{
|
||||
if((*i)->id() == (*z))
|
||||
{
|
||||
found++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(found == idList.count())
|
||||
return(true);
|
||||
return(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
for(cTagList::iterator i = begin();i != end();i++)
|
||||
{
|
||||
if(idList.contains((*i)->id()))
|
||||
return(true);
|
||||
}
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,7 +188,7 @@ public:
|
||||
\param szName
|
||||
\return cTag
|
||||
*/
|
||||
cTag* find(const QString& szName);
|
||||
cTag* find(const QString& szName);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
@@ -197,6 +197,22 @@ public:
|
||||
\return bool
|
||||
*/
|
||||
bool remove(cTag* lpTag);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn contains
|
||||
\param lpTag
|
||||
\return bool
|
||||
*/
|
||||
bool contains(cTag* const &lpTag);
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn contains
|
||||
\param idList
|
||||
\return bool
|
||||
*/
|
||||
bool contains(QList<qint32> idList, bool bAnd);
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
@@ -25,10 +25,48 @@ QString cThumbnailSortFilterProxyModel::filterPath()
|
||||
return(m_szPath);
|
||||
}
|
||||
|
||||
QList<qint32> cThumbnailSortFilterProxyModel::personList()
|
||||
{
|
||||
return(m_personList);
|
||||
}
|
||||
|
||||
void cThumbnailSortFilterProxyModel::setPersonList(const QList<qint32>& personList, bool bAnd)
|
||||
{
|
||||
m_personList = personList;
|
||||
m_bPersonAnd = bAnd;
|
||||
|
||||
invalidateFilter();
|
||||
}
|
||||
|
||||
QList<qint32> cThumbnailSortFilterProxyModel::locationList()
|
||||
{
|
||||
return(m_locationList);
|
||||
}
|
||||
|
||||
void cThumbnailSortFilterProxyModel::setLocationList(const QList<qint32>& locationList, bool bAnd)
|
||||
{
|
||||
m_locationList = locationList;
|
||||
m_bLocationAnd = bAnd;
|
||||
|
||||
invalidateFilter();
|
||||
}
|
||||
|
||||
QList<qint32> cThumbnailSortFilterProxyModel::tagList()
|
||||
{
|
||||
return(m_tagList);
|
||||
}
|
||||
|
||||
void cThumbnailSortFilterProxyModel::setTagList(const QList<qint32>& tagList, bool bAnd)
|
||||
{
|
||||
m_tagList = tagList;
|
||||
m_bTagAnd = bAnd;
|
||||
|
||||
invalidateFilter();
|
||||
}
|
||||
|
||||
bool cThumbnailSortFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
|
||||
{
|
||||
if(m_szPath.isEmpty())
|
||||
return(true);
|
||||
bool bValid = false;
|
||||
|
||||
QModelIndex index0 = sourceModel()->index(sourceRow, 0, sourceParent);
|
||||
cPicture* lpPicture = sourceModel()->data(index0, Qt::UserRole+1).value<cPicture*>();
|
||||
@@ -36,16 +74,42 @@ bool cThumbnailSortFilterProxyModel::filterAcceptsRow(int sourceRow, const QMode
|
||||
if(!lpPicture)
|
||||
return(false);
|
||||
|
||||
QString szPath = lpPicture->filePath();
|
||||
if(m_szPath.isEmpty())
|
||||
bValid = true;
|
||||
else
|
||||
{
|
||||
QString szPath = lpPicture->filePath();
|
||||
|
||||
if(!szPath.startsWith(m_szPath))
|
||||
if(!szPath.startsWith(m_szPath))
|
||||
return(false);
|
||||
|
||||
if(szPath.length() == m_szPath.length())
|
||||
bValid = true;
|
||||
|
||||
if(szPath.mid(m_szPath.length(), 1) == "/")
|
||||
bValid = true;
|
||||
}
|
||||
|
||||
if(!bValid)
|
||||
return(false);
|
||||
|
||||
if(szPath.length() == m_szPath.length())
|
||||
return(true);
|
||||
if(!m_personList.isEmpty())
|
||||
{
|
||||
if(!lpPicture->personList().contains(m_personList, m_bPersonAnd))
|
||||
return(false);
|
||||
}
|
||||
|
||||
if(szPath.mid(m_szPath.length(), 1) == "/")
|
||||
return(true);
|
||||
if(!m_locationList.isEmpty())
|
||||
{
|
||||
if(!lpPicture->locationList().contains(m_locationList, m_bLocationAnd))
|
||||
return(false);
|
||||
}
|
||||
|
||||
return(false);
|
||||
if(!m_tagList.isEmpty())
|
||||
{
|
||||
if(!lpPicture->tagList().contains(m_tagList, m_bTagAnd))
|
||||
return(false);
|
||||
}
|
||||
|
||||
return(true);
|
||||
}
|
||||
|
||||
@@ -36,6 +36,48 @@ public:
|
||||
*/
|
||||
void setFilterPath(const QString& szPath);
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn personList
|
||||
*/
|
||||
QList<qint32> personList();
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn setPersonList
|
||||
\param personList
|
||||
*/
|
||||
void setPersonList(const QList<qint32>& personList, bool bAnd);
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn locationList
|
||||
*/
|
||||
QList<qint32> locationList();
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn setLocationList
|
||||
\param locationList
|
||||
*/
|
||||
void setLocationList(const QList<qint32>& locationList, bool bAnd);
|
||||
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn tagList
|
||||
*/
|
||||
QList<qint32> tagList();
|
||||
/*!
|
||||
\brief
|
||||
|
||||
\fn setTagList
|
||||
\param tagList
|
||||
*/
|
||||
void setTagList(const QList<qint32>& tagList, bool bAnd);
|
||||
|
||||
protected:
|
||||
/*!
|
||||
\brief
|
||||
@@ -49,6 +91,12 @@ protected:
|
||||
|
||||
private:
|
||||
QString m_szPath; /*!< TODO: describe */
|
||||
QList<qint32> m_personList; /*!< TODO: describe */
|
||||
QList<qint32> m_locationList; /*!< TODO: describe */
|
||||
QList<qint32> m_tagList; /*!< TODO: describe */
|
||||
bool m_bPersonAnd; /*!< TODO: describe */
|
||||
bool m_bLocationAnd; /*!< TODO: describe */
|
||||
bool m_bTagAnd; /*!< TODO: describe */
|
||||
};
|
||||
|
||||
#endif // CTHUMBNAILFILTERPROXYMODEL_H
|
||||
|
||||
Reference in New Issue
Block a user