diff options
author | Arno <arno@disconnect.de> | 2020-07-25 06:01:19 +0200 |
---|---|---|
committer | Arno <arno@disconnect.de> | 2020-07-25 06:01:19 +0200 |
commit | 4b083defccae30fe7dc7f9eaaad96c051b8e4b59 (patch) | |
tree | ac482af67bfbfb405379ddab8db15b2b3755dcf9 /searchdialog.cpp | |
parent | 3ecc076df43e9f8a597b4c4d7aa203eb048a781a (diff) | |
download | SheMov-4b083defccae30fe7dc7f9eaaad96c051b8e4b59.tar.gz SheMov-4b083defccae30fe7dc7f9eaaad96c051b8e4b59.tar.bz2 SheMov-4b083defccae30fe7dc7f9eaaad96c051b8e4b59.zip |
Layout for enhanced search dialog
Add Actor and Title search. This commit only makes visual changes and
moves some code around. The search itself is not implemented yet.
Diffstat (limited to 'searchdialog.cpp')
-rw-r--r-- | searchdialog.cpp | 119 |
1 files changed, 90 insertions, 29 deletions
diff --git a/searchdialog.cpp b/searchdialog.cpp index 642f02f..65ade63 100644 --- a/searchdialog.cpp +++ b/searchdialog.cpp @@ -19,6 +19,10 @@ #include <QApplication> #include <QHeaderView> #include <QSettings> +#include <QGroupBox> +#include <QComboBox> +#include <QStandardItemModel> +#include <QSplitter> #include "smtreeview.h" #include "smtreeitem.h" @@ -26,15 +30,15 @@ #include "searchdialog.h" #include "helper.h" -SearchDialog::SearchDialog(QWidget *parent, Qt::WindowFlags flags) : QDialog(parent, flags){ +FilenamesAndMetadata::FilenamesAndMetadata(QWidget *parent, Qt::WindowFlags flags) : QWidget(parent, flags){ // Define GUI items setWindowTitle(tr("Search...")); QLabel *l1 = new QLabel(tr("Search")); mSearch = new QLineEdit; - connect(mSearch, &QLineEdit::returnPressed, this, &SearchDialog::search); + connect(mSearch, &QLineEdit::returnPressed, this, &FilenamesAndMetadata::search); QToolBar *searchTB = new QToolBar; QAction *doSearchA = new QAction(Helper::icon(Qt::transparent, qApp->palette().color(QPalette::Text), QChar(0x2245), true, false), tr("Search"), this); - connect(doSearchA, &QAction::triggered, this, &SearchDialog::search); + connect(doSearchA, &QAction::triggered, this, &FilenamesAndMetadata::search); searchTB->addAction(doSearchA); QAction *clearSearchA= new QAction(Helper::icon(Qt::transparent, qApp->palette().color(QPalette::Text), QChar(0x2694), true, false), tr("Clear"), this); connect(clearSearchA, &QAction::triggered, [=] { mSearch->clear(); }); @@ -62,18 +66,9 @@ SearchDialog::SearchDialog(QWidget *parent, Qt::WindowFlags flags) : QDialog(par mainLayout->addLayout(topLayout); mainLayout->addLayout(bottomLayout); setLayout(mainLayout); - setMinimumSize(QSize(1024, 600)); - connect(this, &SearchDialog::rejected, this, &SearchDialog::writeSettings); - readSettings(); -} - -void SearchDialog::show(){ - mSearch->setFocus(); - mSearch->selectAll(); - QDialog::show(); } -void SearchDialog::search(){ +void FilenamesAndMetadata::search(){ if(mSearch->text().isEmpty()){ return; } @@ -115,21 +110,7 @@ void SearchDialog::search(){ mResult->expandAll(); } -void SearchDialog::writeSettings(){ - QHeaderView *h = mResult->header(); - QSettings s; - s.setValue("searchdlgheaders", h->saveState()); - s.setValue("searchdlgpos", pos()); -} - -void SearchDialog::readSettings(){ - QSettings s; - QByteArray headerState = s.value("searchdlgheaders").toByteArray(); - mResult->header()->restoreState(headerState); - move(s.value("searchdlgpos").toPoint()); -} - -void SearchDialog::appendChild(QVariant id, QVariant subject, QVariant name, QVariant sub, SmTreeItem *parent){ +void FilenamesAndMetadata::appendChild(QVariant id, QVariant subject, QVariant name, QVariant sub, SmTreeItem *parent){ QString match; if(!sub.toString().isEmpty()){ match = QString("%1 - %2").arg(name.toString()).arg(sub.toString()); @@ -141,7 +122,87 @@ void SearchDialog::appendChild(QVariant id, QVariant subject, QVariant name, QVa parent->appendChild(retval); } -void SearchDialog::appendEmpty(SmTreeItem *parent){ +void FilenamesAndMetadata::appendEmpty(SmTreeItem *parent){ SmTreeItem *emptyItem = new SmTreeItem(QVariantList() << tr("no match!") << QVariant() << QVariant(), parent); parent->appendChild(emptyItem); } + +ActorsAndMore::ActorsAndMore(QWidget *parent, Qt::WindowFlags flags) : QWidget(parent, flags) { + //search bar + QLabel *typeL = new QLabel(tr("Search by:")); + mTypeSel = new QComboBox; + mTypeSel->addItem(tr("Actor"), Actor); + mTypeSel->addItem(tr("Title"), Title); + mSearch = new QLineEdit; + connect(mSearch, &QLineEdit::returnPressed, this, &ActorsAndMore::doSearch); + QToolBar *searchTB = new QToolBar; + QAction *doSearchA = new QAction(Helper::icon(Qt::transparent, qApp->palette().color(QPalette::Text), QChar(0x2245), true, false), tr("Search"), this); + connect(doSearchA, &QAction::triggered, this, &ActorsAndMore::doSearch); + searchTB->addAction(doSearchA); + QAction *clearSearchA= new QAction(Helper::icon(Qt::transparent, qApp->palette().color(QPalette::Text), QChar(0x2694), true, false), tr("Clear"), this); + connect(clearSearchA, &QAction::triggered, [=] { mSearch->clear(); }); + searchTB->addAction(clearSearchA); + QHBoxLayout *topHBL = new QHBoxLayout; + topHBL->addWidget(typeL); + topHBL->addWidget(mSearch); + topHBL->addWidget(mTypeSel); + topHBL->addWidget(searchTB); + + // result view + mResultModel = new QStandardItemModel; + QSortFilterProxyModel *resultProxy = new QSortFilterProxyModel; + resultProxy->setSourceModel(mResultModel); + mResultView = new QTreeView; + mResultView->setModel(resultProxy); + mDataModel = new QStandardItemModel; + QSortFilterProxyModel *dataProxy = new QSortFilterProxyModel; + dataProxy->setSourceModel(mDataModel); + mDataView = new QTreeView; + mDataView->setModel(dataProxy); + QHBoxLayout *resultHBL = new QHBoxLayout; + resultHBL->addWidget(mResultView); + resultHBL->addWidget(mDataView); + + //main Layout + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addLayout(topHBL); + mainLayout->addLayout(resultHBL); + setLayout(mainLayout); +} + +void ActorsAndMore::doSearch(){ + +} + +SearchDialog::SearchDialog(QWidget *parent, Qt::WindowFlags flags) : QDialog(parent, flags) { + QHBoxLayout *gbLayout = new QHBoxLayout; + QGroupBox *metaFnGb = new QGroupBox(tr("Metadata and Filenames")); + FilenamesAndMetadata *metaFnW = new FilenamesAndMetadata; + gbLayout->addWidget(metaFnW); + metaFnGb->setLayout(gbLayout); + QHBoxLayout *gbLayout2 = new QHBoxLayout; + QGroupBox *actorsAndMoreGb = new QGroupBox(tr("Actors and more...")); + ActorsAndMore *actorsAndMoreW = new ActorsAndMore; + gbLayout2->addWidget(actorsAndMoreW); + actorsAndMoreGb->setLayout(gbLayout2); + QSplitter *splitter = new QSplitter(Qt::Vertical); + splitter->addWidget(metaFnGb); + splitter->addWidget(actorsAndMoreGb); + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addWidget(splitter); + setLayout(mainLayout); + setWindowTitle(tr("Search Dialog")); + readSettings(); +} + +void SearchDialog::writeSettings(){ + QSettings s; + s.setValue("searchdlgpos", pos()); + s.setValue("searchdlgsize", size()); +} + +void SearchDialog::readSettings(){ + QSettings s; + move(s.value("searchdlgpos").toPoint()); + resize(s.value("searchdlgsize").toSize()); +} |