filter panel

This commit is contained in:
2019-03-20 13:52:36 +01:00
parent ead5308a97
commit 354c6154e7
9 changed files with 156 additions and 7 deletions
+80
View File
@@ -56,6 +56,34 @@ void cFilterPanel::setPersonList(cPersonList* lpPersonList)
m_lpPersonListModel->appendRow(lpItem);
}
m_lpPersonListModel->sort(0);
m_bLoading = false;
}
void cFilterPanel::updatePersonList()
{
m_bLoading = true;
for(cPersonList::iterator i = m_lpPersonList->begin();i != m_lpPersonList->end();i++)
{
if(m_lpPersonListModel->findItems((*i)->name()).isEmpty())
{
QStandardItem* lpItem = new QStandardItem((*i)->name());
lpItem->setData(QVariant::fromValue(*i), Qt::UserRole+1);
lpItem->setCheckable(true);
m_lpPersonListModel->appendRow(lpItem);
}
}
for(int x = m_lpPersonListModel->rowCount()-1;x >= 0;x--)
{
if(!m_lpPersonList->find(m_lpPersonListModel->item(x, 0)->text()))
m_lpPersonListModel->removeRow(x);
}
m_lpPersonListModel->sort(0);
m_bLoading = false;
}
@@ -81,6 +109,32 @@ void cFilterPanel::setLocationList(cLocationList* lpLocationList)
m_bLoading = false;
}
void cFilterPanel::updateLocationList()
{
m_bLoading = true;
for(cLocationList::iterator i = m_lpLocationList->begin();i != m_lpLocationList->end();i++)
{
if(m_lpLocationListModel->findItems((*i)->name()).isEmpty())
{
QStandardItem* lpItem = new QStandardItem((*i)->name());
lpItem->setData(QVariant::fromValue(*i), Qt::UserRole+1);
lpItem->setCheckable(true);
m_lpLocationListModel->appendRow(lpItem);
}
}
for(int x = m_lpLocationListModel->rowCount()-1;x >= 0;x--)
{
if(!m_lpLocationList->find(m_lpLocationListModel->item(x, 0)->text()))
m_lpLocationListModel->removeRow(x);
}
m_lpLocationListModel->sort(0);
m_bLoading = false;
}
void cFilterPanel::clearTagList()
{
m_lpTagListModel->clear();
@@ -102,3 +156,29 @@ void cFilterPanel::setTagList(cTagList* lpTagList)
m_bLoading = false;
}
void cFilterPanel::updateTagList()
{
m_bLoading = true;
for(cTagList::iterator i = m_lpTagList->begin();i != m_lpTagList->end();i++)
{
if(m_lpTagListModel->findItems((*i)->name()).isEmpty())
{
QStandardItem* lpItem = new QStandardItem((*i)->name());
lpItem->setData(QVariant::fromValue(*i), Qt::UserRole+1);
lpItem->setCheckable(true);
m_lpTagListModel->appendRow(lpItem);
}
}
for(int x = m_lpTagListModel->rowCount()-1;x >= 0;x--)
{
if(!m_lpTagList->find(m_lpTagListModel->item(x, 0)->text()))
m_lpTagListModel->removeRow(x);
}
m_lpTagListModel->sort(0);
m_bLoading = false;
}
+18
View File
@@ -36,6 +36,12 @@ public:
\fn setPersonList
*/
void setPersonList(cPersonList* lpPersonList);
/*!
\brief
\fn updatePersonList
*/
void updatePersonList();
/*!
\brief
@@ -50,6 +56,12 @@ public:
\fn setLocationList
*/
void setLocationList(cLocationList* lpLocationList);
/*!
\brief
\fn updateLocationList
*/
void updateLocationList();
/*!
\brief
@@ -64,6 +76,12 @@ public:
\fn setTagList
*/
void setTagList(cTagList* lpTagList);
/*!
\brief
\fn updateTagList
*/
void updateTagList();
private:
Ui::cFilterPanel* ui;
+10
View File
@@ -230,6 +230,16 @@ cLocation* cLocationList::find(cLocation* lpLocation)
return(nullptr);
}
cLocation* cLocationList::find(const QString& szName)
{
for(cLocationList::iterator i = begin(); i != end(); i++)
{
if(szName == (*i)->name())
return(*i);
}
return(nullptr);
}
bool cLocationList::remove(cLocation* lpLocation)
{
if(!find(lpLocation))
+8
View File
@@ -184,6 +184,14 @@ public:
/*!
\brief
\fn find
\param szName
\return cLocation
*/
cLocation* find(const QString& szLocation);
/*!
\brief
\fn remove
\param lpLocation
\return bool
+3 -6
View File
@@ -854,8 +854,7 @@ void cMainWindow::onTagEdited(cTag* /*lpTag*/)
void cMainWindow::onTagListChanged()
{
m_lpFilterPanel->clearTagList();
m_lpFilterPanel->setTagList(&m_tagList);
m_lpFilterPanel->updateTagList();
}
void cMainWindow::onPersonAdded(cPerson* /*lpPerson*/)
@@ -872,8 +871,7 @@ void cMainWindow::onPersonEdited(cPerson* /*lpPerson*/)
void cMainWindow::onPersonListChanged()
{
m_lpFilterPanel->clearPersonList();
m_lpFilterPanel->setPersonList(&m_personList);
m_lpFilterPanel->updatePersonList();
}
void cMainWindow::onLocationAdded(cLocation* /*lpLocation*/)
@@ -890,6 +888,5 @@ void cMainWindow::onLocationEdited(cLocation* /*lpLocation*/)
void cMainWindow::onLocationListChanged()
{
m_lpFilterPanel->clearLocationList();
m_lpFilterPanel->setLocationList(&m_locationList);
m_lpFilterPanel->updateLocationList();
}
+10
View File
@@ -237,6 +237,16 @@ cPerson* cPersonList::find(cPerson* lpPerson)
return(nullptr);
}
cPerson* cPersonList::find(const QString& szName)
{
for(cPersonList::iterator i = begin(); i != end(); i++)
{
if(szName == (*i)->name())
return(*i);
}
return(nullptr);
}
bool cPersonList::remove(cPerson* lpPerson)
{
if(!find(lpPerson))
+9 -1
View File
@@ -177,13 +177,21 @@ public:
\brief
\fn find
\param iID
\param lpPerson
\return cPerson
*/
cPerson* find(cPerson* lpPerson);
/*!
\brief
\fn find
\param szName
\return cPerson
*/
cPerson* find(const QString& szName);
/*!
\brief
\fn remove
\param lpPerson
\return bool
+10
View File
@@ -230,6 +230,16 @@ cTag* cTagList::find(cTag* lpTag)
return(nullptr);
}
cTag* cTagList::find(const QString& szName)
{
for(cTagList::iterator i = begin(); i != end(); i++)
{
if(szName == (*i)->name())
return(*i);
}
return(nullptr);
}
bool cTagList::remove(cTag* lpTag)
{
if(!find(lpTag))
+8
View File
@@ -184,6 +184,14 @@ public:
/*!
\brief
\fn find
\param szName
\return cTag
*/
cTag* find(const QString& szName);
/*!
\brief
\fn remove
\param lpTag
\return bool