summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArno <arno@disconnect.de>2020-07-25 09:35:13 +0200
committerArno <arno@disconnect.de>2020-07-25 09:35:13 +0200
commit5db8e0636c5fe4b4f51cf5654b93c67ae8d4c923 (patch)
tree40d9dcd2c9ba80bf09f2dd33621b3c05395e526e
parentd0f81a70688241adab6327cc55049bc0b1bbf848 (diff)
downloadSheMov-5db8e0636c5fe4b4f51cf5654b93c67ae8d4c923.tar.gz
SheMov-5db8e0636c5fe4b4f51cf5654b93c67ae8d4c923.tar.bz2
SheMov-5db8e0636c5fe4b4f51cf5654b93c67ae8d4c923.zip
Implement search for subtitles
-rw-r--r--searchdialog.cpp54
-rw-r--r--searchdialog.h2
2 files changed, 54 insertions, 2 deletions
diff --git a/searchdialog.cpp b/searchdialog.cpp
index 52bdc1b..3746bcb 100644
--- a/searchdialog.cpp
+++ b/searchdialog.cpp
@@ -134,7 +134,7 @@ ActorsAndMore::ActorsAndMore(QWidget *parent, Qt::WindowFlags flags) : QWidget(p
QLabel *typeL = new QLabel(tr("Search by:"));
mTypeSel = new QComboBox;
mTypeSel->addItem(tr("Actor"), Actor);
- mTypeSel->addItem(tr("Title"), Title);
+ mTypeSel->addItem(tr("Subtitle"), Title);
mSearch = new QLineEdit;
connect(mSearch, &QLineEdit::returnPressed, this, &ActorsAndMore::doSearch);
QToolBar *searchTB = new QToolBar;
@@ -183,6 +183,8 @@ void ActorsAndMore::doSearch(){
int searchType = mTypeSel->currentData().toInt();
if(searchType == Actor){
searchActor(input);
+ }else if(searchType == Title){
+ searchSubtitle(input);
}
}
@@ -210,6 +212,29 @@ void ActorsAndMore::searchActor(const QString &actor){
mResultView->sortByColumn(0, Qt::AscendingOrder);
}
+void ActorsAndMore::searchSubtitle(const QString &subtitle){
+ mResultView->setSortingEnabled(false);
+ mResultModel->clear();
+ mResultModel->setColumnCount(1);
+ mResultModel->setHeaderData(0, Qt::Horizontal, tr("Title"));
+ QIcon icon = SmGlobals::instance()->iconFor("series");
+ QStandardItem *root = mResultModel->invisibleRootItem();
+ QSqlDatabase db = QSqlDatabase::database("treedb");
+ QSqlQuery titleQ(db);
+ titleQ.prepare("SELECT DISTINCT(series.iseries_id), tseries_name FROM series, seriesparts WHERE seriesparts.tsubtitle ~ :title AND seriesparts.iseries_id = series.iseries_id ORDER BY tseries_name");
+ titleQ.bindValue(":title", subtitle);
+ titleQ.exec();
+ while(titleQ.next()){
+ QStandardItem *cur = new QStandardItem(titleQ.value(1).toString());
+ cur->setIcon(icon);
+ cur->setData(titleQ.value(0), IdRole);
+ cur->setEditable(false);
+ root->appendRow(cur);
+ }
+ mResultView->setSortingEnabled(true);
+ mResultView->sortByColumn(0, Qt::AscendingOrder);
+}
+
void ActorsAndMore::getGenresForActor(QStandardItem *actorItem){
QStringList res;
QIcon icon = SmGlobals::instance()->iconFor("genre");
@@ -237,6 +262,8 @@ void ActorsAndMore::doData(const QModelIndex &cur, const QModelIndex &prev){
int searchType = mTypeSel->currentData().toInt();
if(searchType == Actor){
getDataForActor(cur);
+ }else if(searchType == Title){
+ getDataForTitle(cur);
}
}
@@ -246,7 +273,7 @@ void ActorsAndMore::dataDoubleClicked(const QModelIndex &index){
cur = cur.parent();
}
int searchType = mTypeSel->currentData().toInt();
- if(searchType == Actor){
+ if(searchType == Actor || searchType == Title){
MoviePropertiesDialog propDlg(this);
propDlg.init(cur.data(IdRole).toInt());
propDlg.exec();
@@ -307,6 +334,29 @@ void ActorsAndMore::getDataForActor(QModelIndex cur){
}
}
+void ActorsAndMore::getDataForTitle(QModelIndex cur){
+ mDataModel->clear();
+ mDataModel->setColumnCount(1);
+ mDataModel->setHeaderData(0, Qt::Horizontal, tr("Subtitle"));
+ QIcon icon = SmGlobals::instance()->iconFor("series");
+ QStandardItem *root = mDataModel->invisibleRootItem();
+ QSqlDatabase db = QSqlDatabase::database("treedb");
+ QSqlQuery titleDataQ(db);
+ titleDataQ.prepare("SELECT tsubtitle, iseriesparts_id FROM seriesparts WHERE iseries_id = :id AND tsubtitle ~ :title ORDER BY tsubtitle");
+ titleDataQ.bindValue(":id", cur.data(IdRole));
+ titleDataQ.bindValue(":title", mSearch->text());
+ titleDataQ.exec();
+ while(titleDataQ.next()){
+ QStandardItem *curTitle = new QStandardItem(titleDataQ.value(0).toString());
+ curTitle->setIcon(icon);
+ curTitle->setData(titleDataQ.value(1), IdRole);
+ curTitle->setEditable(false);
+ root->appendRow(curTitle);
+ }
+ mDataView->setSortingEnabled(true);
+ mDataView->sortByColumn(0, Qt::AscendingOrder);
+}
+
SearchDialog::SearchDialog(QWidget *parent, Qt::WindowFlags flags) : QDialog(parent, flags) {
QHBoxLayout *gbLayout = new QHBoxLayout;
QGroupBox *metaFnGb = new QGroupBox(tr("Metadata and Filenames"));
diff --git a/searchdialog.h b/searchdialog.h
index ca16b79..3e90122 100644
--- a/searchdialog.h
+++ b/searchdialog.h
@@ -56,8 +56,10 @@ class ActorsAndMore : public QWidget {
private:
void searchActor(const QString &actor);
+ void searchSubtitle(const QString &subtitle);
void getGenresForActor(QStandardItem *actorItem);
void getDataForActor(QModelIndex cur);
+ void getDataForTitle(QModelIndex cur);
QComboBox *mTypeSel;
QLineEdit *mSearch;
QStandardItemModel *mResultModel;