diff --git a/cfilterpanel.cpp b/cfilterpanel.cpp index 693c5be..adfd0a3 100644 --- a/cfilterpanel.cpp +++ b/cfilterpanel.cpp @@ -1,14 +1,104 @@ #include "cfilterpanel.h" #include "ui_cfilterpanel.h" + cFilterPanel::cFilterPanel(QWidget *parent) : QWidget(parent), - ui(new Ui::cFilterPanel) + ui(new Ui::cFilterPanel), + m_bLoading(false), + m_lpPersonList(nullptr), + m_lpLocationList(nullptr), + m_lpTagList(nullptr) { - ui->setupUi(this); + initUI(); + createActions(); } cFilterPanel::~cFilterPanel() { delete ui; } + +void cFilterPanel::initUI() +{ + ui->setupUi(this); + + m_lpPersonListModel = new QStandardItemModel; + ui->m_lpPersonList->setModel(m_lpPersonListModel); + + m_lpLocationListModel = new QStandardItemModel; + ui->m_lpLocationList->setModel(m_lpLocationListModel); + + m_lpTagListModel = new QStandardItemModel; + ui->m_lpTagList->setModel(m_lpTagListModel); +} + +void cFilterPanel::createActions() +{ +} + +void cFilterPanel::clearPersonList() +{ + m_lpPersonListModel->clear(); +} + +void cFilterPanel::setPersonList(cPersonList* lpPersonList) +{ + m_bLoading = true; + + m_lpPersonList = lpPersonList; + + for(cPersonList::iterator i = lpPersonList->begin();i != lpPersonList->end();i++) + { + QStandardItem* lpItem = new QStandardItem((*i)->name()); + lpItem->setData(QVariant::fromValue(*i), Qt::UserRole+1); + lpItem->setCheckable(true); + m_lpPersonListModel->appendRow(lpItem); + } + + m_bLoading = false; +} + +void cFilterPanel::clearLocationList() +{ + m_lpLocationListModel->clear(); +} + +void cFilterPanel::setLocationList(cLocationList* lpLocationList) +{ + m_bLoading = true; + + m_lpLocationList = lpLocationList; + + for(cLocationList::iterator i = lpLocationList->begin();i != lpLocationList->end();i++) + { + QStandardItem* lpItem = new QStandardItem((*i)->name()); + lpItem->setData(QVariant::fromValue(*i), Qt::UserRole+1); + lpItem->setCheckable(true); + m_lpLocationListModel->appendRow(lpItem); + } + + m_bLoading = false; +} + +void cFilterPanel::clearTagList() +{ + m_lpTagListModel->clear(); +} + +void cFilterPanel::setTagList(cTagList* lpTagList) +{ + m_bLoading = true; + + m_lpTagList = lpTagList; + + for(cTagList::iterator i = lpTagList->begin();i != lpTagList->end();i++) + { + QStandardItem* lpItem = new QStandardItem((*i)->name()); + lpItem->setData(QVariant::fromValue(*i), Qt::UserRole+1); + lpItem->setCheckable(true); + m_lpTagListModel->appendRow(lpItem); + } + + m_bLoading = false; +} diff --git a/cfilterpanel.h b/cfilterpanel.h index 7db6533..96d387b 100644 --- a/cfilterpanel.h +++ b/cfilterpanel.h @@ -1,7 +1,15 @@ #ifndef CFILTERPANEL_H #define CFILTERPANEL_H + +#include "ctag.h" +#include "cperson.h" +#include "clocation.h" + #include +#include +#include + namespace Ui { class cFilterPanel; @@ -15,8 +23,73 @@ public: explicit cFilterPanel(QWidget *parent = nullptr); ~cFilterPanel(); + /*! + \brief + + \fn clearPersonList + */ + void clearPersonList(); + /*! + \brief + + \param lpPersonList + \fn setPersonList + */ + void setPersonList(cPersonList* lpPersonList); + + /*! + \brief + + \fn clearLocationList + */ + void clearLocationList(); + /*! + \brief + + \param lpLocationList + \fn setLocationList + */ + void setLocationList(cLocationList* lpLocationList); + + /*! + \brief + + \fn clearTagList + */ + void clearTagList(); + /*! + \brief + + \param lpTagList + \fn setTagList + */ + void setTagList(cTagList* lpTagList); + private: - Ui::cFilterPanel *ui; + Ui::cFilterPanel* ui; + bool m_bLoading; /*!< TODO: describe */ + + QStandardItemModel* m_lpPersonListModel; /*!< TODO: describe */ + cPersonList* m_lpPersonList; /*!< TODO: describe */ + + QStandardItemModel* m_lpLocationListModel; /*!< TODO: describe */ + cLocationList* m_lpLocationList; /*!< TODO: describe */ + + QStandardItemModel* m_lpTagListModel; /*!< TODO: describe */ + cTagList* m_lpTagList; /*!< TODO: describe */ + + /*! + \brief + + \fn initUI + */ + void initUI(); + /*! + \brief + + \fn createActions + */ + void createActions(); }; #endif // CFILTERPANEL_H diff --git a/cfilterpanel.ui b/cfilterpanel.ui index 41aaf31..de367a8 100644 --- a/cfilterpanel.ui +++ b/cfilterpanel.ui @@ -26,7 +26,20 @@ - + + + QAbstractItemView::NoEditTriggers + + + true + + + false + + + false + + @@ -41,7 +54,20 @@ - + + + QAbstractItemView::NoEditTriggers + + + true + + + false + + + false + + @@ -56,7 +82,20 @@ - + + + QAbstractItemView::NoEditTriggers + + + true + + + false + + + false + + diff --git a/cmainwindow.cpp b/cmainwindow.cpp index b3c77e3..a2e8552 100644 --- a/cmainwindow.cpp +++ b/cmainwindow.cpp @@ -79,9 +79,9 @@ void cMainWindow::initUI() QIcon::setThemeName("TangoMFK"); - ui->m_lpSpoiler->setTitle(tr("Filter")); + ui->m_lpFilter->setTitle(tr("Filter")); m_lpFilterPanel = new cFilterPanel(this); - ui->m_lpSpoiler->setContentWidget(m_lpFilterPanel); + ui->m_lpFilter->setContentWidget(m_lpFilterPanel); m_lpFolderViewModel = new QStandardItemModel; m_lpFolderSortFilterProxyModel = new cFolderSortFilterProxyModel(this); @@ -136,6 +136,21 @@ void cMainWindow::createActions() connect(ui->m_lpThumbnailView, &QListView::customContextMenuRequested, this, &cMainWindow::onThumbnailViewContextMenu); connect(ui->m_lpThumbnailView, &QListView::doubleClicked, this, &cMainWindow::onThumbnailDoubleClicked); + + connect(ui->m_lpToolBoxTags, &cToolBoxTag::tagAdded, this, &cMainWindow::onTagAdded); + connect(ui->m_lpToolBoxTags, &cToolBoxTag::tagRemoved, this, &cMainWindow::onTagRemoved); + connect(ui->m_lpToolBoxTags, &cToolBoxTag::tagEdited, this, &cMainWindow::onTagEdited); + connect(ui->m_lpToolBoxTags, &cToolBoxTag::tagListChanged, this, &cMainWindow::onTagListChanged); + + connect(ui->m_lpToolBoxPerson, &cToolBoxPerson::personAdded, this, &cMainWindow::onPersonAdded); + connect(ui->m_lpToolBoxPerson, &cToolBoxPerson::personRemoved, this, &cMainWindow::onPersonRemoved); + connect(ui->m_lpToolBoxPerson, &cToolBoxPerson::personEdited, this, &cMainWindow::onPersonEdited); + connect(ui->m_lpToolBoxPerson, &cToolBoxPerson::personListChanged, this, &cMainWindow::onPersonListChanged); + + connect(ui->m_lpToolBoxLocation, &cToolBoxLocation::locationAdded, this, &cMainWindow::onLocationAdded); + 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); } void cMainWindow::createContextActions() @@ -256,6 +271,10 @@ void cMainWindow::displayData() ui->m_lpToolBoxLocation->setLocationList(&m_locationList); ui->m_lpToolBoxTags->setTagList(&m_tagList); + m_lpFilterPanel->setPersonList(&m_personList); + m_lpFilterPanel->setLocationList(&m_locationList); + m_lpFilterPanel->setTagList(&m_tagList); + m_lpRootItem = new QStandardItem("library"); m_lpFolderViewModel->appendRow(m_lpRootItem); @@ -820,3 +839,57 @@ void cMainWindow::onUnsetHDR() m_lpFolderSortFilterProxyModel->sort(0); m_lpThumbnailSortFilterProxyModel->invalidate(); } + +void cMainWindow::onTagAdded(cTag* /*lpTag*/) +{ +} + +void cMainWindow::onTagRemoved(cTag* /*lpTag*/) +{ +} + +void cMainWindow::onTagEdited(cTag* /*lpTag*/) +{ +} + +void cMainWindow::onTagListChanged() +{ + m_lpFilterPanel->clearTagList(); + m_lpFilterPanel->setTagList(&m_tagList); +} + +void cMainWindow::onPersonAdded(cPerson* /*lpPerson*/) +{ +} + +void cMainWindow::onPersonRemoved(cPerson* /*lpPerson*/) +{ +} + +void cMainWindow::onPersonEdited(cPerson* /*lpPerson*/) +{ +} + +void cMainWindow::onPersonListChanged() +{ + m_lpFilterPanel->clearPersonList(); + m_lpFilterPanel->setPersonList(&m_personList); +} + +void cMainWindow::onLocationAdded(cLocation* /*lpLocation*/) +{ +} + +void cMainWindow::onLocationRemoved(cLocation* /*lpLocation*/) +{ +} + +void cMainWindow::onLocationEdited(cLocation* /*lpLocation*/) +{ +} + +void cMainWindow::onLocationListChanged() +{ + m_lpFilterPanel->clearLocationList(); + m_lpFilterPanel->setLocationList(&m_locationList); +} diff --git a/cmainwindow.h b/cmainwindow.h index 0f4b0b1..e19c675 100644 --- a/cmainwindow.h +++ b/cmainwindow.h @@ -270,6 +270,87 @@ private slots: \fn onUnsetHDR */ void onUnsetHDR(); + /*! + \brief + + \fn onTagAdded + \param lpTag + */ + void onTagAdded(cTag* lpTag); + /*! + \brief + + \fn onTagRemoved + \param lpTag + */ + void onTagRemoved(cTag* lpTag); + /*! + \brief + + \fn onTagEdited + \param lpTag + */ + void onTagEdited(cTag* lpTag); + /*! + \brief + + \fn onTagListChanged + */ + void onTagListChanged(); + /*! + \brief + + \fn onPersonAdded + \param lpPerson + */ + void onPersonAdded(cPerson* lpPerson); + /*! + \brief + + \fn onPersonRemoved + \param lpPerson + */ + void onPersonRemoved(cPerson* lpPerson); + /*! + \brief + + \fn onPersonEdited + \param lpPerson + */ + void onPersonEdited(cPerson* lpPerson); + /*! + \brief + + \fn onPersonListChanged + */ + void onPersonListChanged(); + /*! + \brief + + \fn onLocationAdded + \param lpLocation + */ + void onLocationAdded(cLocation* lpLocation); + /*! + \brief + + \fn onLocationRemoved + \param lpLocation + */ + void onLocationRemoved(cLocation* lpLocation); + /*! + \brief + + \fn onLocationEdited + \param lpLocation + */ + void onLocationEdited(cLocation* lpLocation); + /*! + \brief + + \fn onLocationListChanged + */ + void onLocationListChanged(); }; #endif // CMAINWINDOW_H diff --git a/cmainwindow.ui b/cmainwindow.ui index 312f526..7de304a 100644 --- a/cmainwindow.ui +++ b/cmainwindow.ui @@ -173,7 +173,7 @@ - + diff --git a/ctoolboxlocation.cpp b/ctoolboxlocation.cpp index f92c359..c47cb0d 100644 --- a/ctoolboxlocation.cpp +++ b/ctoolboxlocation.cpp @@ -208,6 +208,9 @@ void cToolBoxLocation::onLocationAdd() m_lpLocationListModel->appendRow(lpItem); m_lpLocationListModel->sort(0); + emit locationAdded(lpLocation); + emit locationListChanged(); + m_bLoading = false; } @@ -237,6 +240,9 @@ void cToolBoxLocation::onLocationEdit() return; lpItem->setText(input.textValue()); + + emit locationEdited(lpLocation); + emit locationListChanged(); } void cToolBoxLocation::onLocationDelete() @@ -255,12 +261,15 @@ void cToolBoxLocation::onLocationDelete() if(!m_lpLocationList->remove(lpLocation)) QMessageBox::critical(this, tr("Delete Location"), QString(tr("%1 is in use and can't be deleted!")).arg(lpLocation->name())); else + { m_lpLocationListModel->removeRow(index.row()); + emit locationRemoved(lpLocation); + } } } } } - + emit locationListChanged(); } void cToolBoxLocation::onLocationViewContextMenu(const QPoint& pos) diff --git a/ctoolboxlocation.h b/ctoolboxlocation.h index 6223310..94f4813 100644 --- a/ctoolboxlocation.h +++ b/ctoolboxlocation.h @@ -143,6 +143,35 @@ private slots: \param lpItem */ void onLocationChanged(QStandardItem* lpItem); + +signals: + /*! + \brief + + \fn locationAdded + \param lpTag + */ + void locationAdded(cLocation* lpLocation); + /*! + \brief + + \fn locationRemoved + \param lpTag + */ + void locationRemoved(cLocation* lpLocation); + /*! + \brief + + \fn locationEdited + \param lpTag + */ + void locationEdited(cLocation* lpLocation); + /*! + \brief + + \fn locationListChanged + */ + void locationListChanged(); }; #endif // CTOOLBOXLOCATION_H diff --git a/ctoolboxlocation.ui b/ctoolboxlocation.ui index 3ad1167..2d4274e 100644 --- a/ctoolboxlocation.ui +++ b/ctoolboxlocation.ui @@ -22,7 +22,7 @@ Qt::CustomContextMenu - QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed + QAbstractItemView::NoEditTriggers true diff --git a/ctoolboxperson.cpp b/ctoolboxperson.cpp index 0cb6ecf..95108f8 100644 --- a/ctoolboxperson.cpp +++ b/ctoolboxperson.cpp @@ -213,6 +213,9 @@ void cToolBoxPerson::onPersonAdd() m_lpPersonListModel->appendRow(lpItem); m_lpPersonListModel->sort(0); + emit personAdded(lpPerson); + emit personListChanged(); + m_bLoading = false; } @@ -242,6 +245,9 @@ void cToolBoxPerson::onPersonEdit() return; lpItem->setText(input.textValue()); + + emit personEdited(lpPerson); + emit personListChanged(); } void cToolBoxPerson::onPersonDelete() @@ -260,12 +266,15 @@ void cToolBoxPerson::onPersonDelete() if(!m_lpPersonList->remove(lpPerson)) QMessageBox::critical(this, tr("Delete Person"), QString(tr("%1 is in use and can't be deleted!")).arg(lpPerson->name())); else + { m_lpPersonListModel->removeRow(index.row()); + emit personRemoved(lpPerson); + } } } } } - + emit personListChanged(); } void cToolBoxPerson::onPersonViewContextMenu(const QPoint& pos) diff --git a/ctoolboxperson.h b/ctoolboxperson.h index eb5a08b..22fd85b 100644 --- a/ctoolboxperson.h +++ b/ctoolboxperson.h @@ -142,6 +142,35 @@ private slots: \param lpItem */ void onPersonChanged(QStandardItem* lpItem); + +signals: + /*! + \brief + + \fn personAdded + \param lpPerson + */ + void personAdded(cPerson* lpPerson); + /*! + \brief + + \fn personRemoved + \param lpPerson + */ + void personRemoved(cPerson* lpPerson); + /*! + \brief + + \fn personEdited + \param lpPerson + */ + void personEdited(cPerson* lpPerson); + /*! + \brief + + \fn personListChanged + */ + void personListChanged(); }; #endif // CTOOLBOXPERSON_H diff --git a/ctoolboxperson.ui b/ctoolboxperson.ui index cdef3cb..cb67f1f 100644 --- a/ctoolboxperson.ui +++ b/ctoolboxperson.ui @@ -22,7 +22,7 @@ Qt::CustomContextMenu - QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed + QAbstractItemView::NoEditTriggers true diff --git a/ctoolboxtag.cpp b/ctoolboxtag.cpp index 453ba91..5b0a6f9 100644 --- a/ctoolboxtag.cpp +++ b/ctoolboxtag.cpp @@ -213,6 +213,9 @@ void cToolBoxTag::onTagAdd() m_lpTagListModel->appendRow(lpItem); m_lpTagListModel->sort(0); + emit tagAdded(lpTag); + emit tagListChanged(); + m_bLoading = false; } @@ -242,6 +245,9 @@ void cToolBoxTag::onTagEdit() return; lpItem->setText(input.textValue()); + + emit tagEdited(lpTag); + emit tagListChanged(); } void cToolBoxTag::onTagDelete() @@ -260,12 +266,15 @@ void cToolBoxTag::onTagDelete() if(!m_lpTagList->remove(lpTag)) QMessageBox::critical(this, tr("Delete Tag"), QString(tr("%1 is in use and can't be deleted!")).arg(lpTag->name())); else + { m_lpTagListModel->removeRow(index.row()); + emit tagRemoved(lpTag); + } } } } } - + emit tagListChanged(); } void cToolBoxTag::onTagViewContextMenu(const QPoint& pos) diff --git a/ctoolboxtag.h b/ctoolboxtag.h index 06485ba..5e1c00f 100644 --- a/ctoolboxtag.h +++ b/ctoolboxtag.h @@ -143,6 +143,35 @@ private slots: \param lpItem */ void onTagChanged(QStandardItem* lpItem); + +signals: + /*! + \brief + + \fn tagAdded + \param lpTag + */ + void tagAdded(cTag* lpTag); + /*! + \brief + + \fn tagRemoved + \param lpTag + */ + void tagRemoved(cTag* lpTag); + /*! + \brief + + \fn tagEdited + \param lpTag + */ + void tagEdited(cTag* lpTag); + /*! + \brief + + \fn tagListChanged + */ + void tagListChanged(); }; #endif // CTOOLBOXTAG_H diff --git a/ctoolboxtag.ui b/ctoolboxtag.ui index 8243ad4..a44d215 100644 --- a/ctoolboxtag.ui +++ b/ctoolboxtag.ui @@ -22,7 +22,7 @@ Qt::CustomContextMenu - QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed + QAbstractItemView::NoEditTriggers true