summaryrefslogtreecommitdiffstats
path: root/searchdialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'searchdialog.cpp')
-rw-r--r--searchdialog.cpp43
1 files changed, 41 insertions, 2 deletions
diff --git a/searchdialog.cpp b/searchdialog.cpp
index 6d81b58..6cb5821 100644
--- a/searchdialog.cpp
+++ b/searchdialog.cpp
@@ -23,6 +23,7 @@
#include <QComboBox>
#include <QStandardItemModel>
#include <QSplitter>
+#include <QMessageBox>
#include "moviepropertiesdialog.h"
#include "smtreeview.h"
@@ -169,7 +170,7 @@ ActorsAndMore::ActorsAndMore(QWidget *parent, Qt::WindowFlags flags) : QWidget(p
resultProxy->setSourceModel(mResultModel);
mResultView = new SmView;
mResultView->setModel(resultProxy);
- connect(mResultView->selectionModel(), &QItemSelectionModel::currentChanged, this, &ActorsAndMore::doData);
+ connect(mResultView->selectionModel(), &QItemSelectionModel::currentChanged, this, &ActorsAndMore::getData);
QAction *resultCollapseAllA = new QAction(Helper::icon(Qt::transparent, qApp->palette().color(QPalette::Text), QChar(0x2191), true, false), tr("Collapse all"), this);
connect(resultCollapseAllA, &QAction::triggered, this, &ActorsAndMore::collapseAllResult);
mResultView->addAction(resultCollapseAllA);
@@ -192,6 +193,12 @@ ActorsAndMore::ActorsAndMore(QWidget *parent, Qt::WindowFlags flags) : QWidget(p
connect(dataExpandAllA, &QAction::triggered, this, &ActorsAndMore::expandAllData);
mDataView->addAction(dataExpandAllA);
QHBoxLayout *resultHBL = new QHBoxLayout;
+ mDeleteSeriesA = new QAction(Helper::icon(Qt::transparent, qApp->palette().color(QPalette::Text), QChar(0x2718), true, false), tr("Delete Series..."), this);
+ mDeleteSeriesA->setEnabled(false);
+ connect(mDeleteSeriesA, &QAction::triggered, this, &ActorsAndMore::deleteSeries);
+ connect(mDataView->selectionModel(), &QItemSelectionModel::currentChanged, this, &ActorsAndMore::doData);
+ mDataView->addAction(Helper::createSeparator(this));
+ mDataView->addAction(mDeleteSeriesA);
resultHBL->addWidget(mResultView);
resultHBL->addWidget(mDataView);
@@ -297,7 +304,7 @@ void ActorsAndMore::getGenresForActor(QStandardItem *actorItem){
}
}
-void ActorsAndMore::doData(const QModelIndex &cur, const QModelIndex &prev){
+void ActorsAndMore::getData(const QModelIndex &cur, const QModelIndex &prev){
Q_UNUSED(prev)
int searchType = mTypeSel->currentData().toInt();
if(searchType == Actor){
@@ -307,6 +314,22 @@ void ActorsAndMore::doData(const QModelIndex &cur, const QModelIndex &prev){
}
}
+void ActorsAndMore::doData(const QModelIndex &cur, const QModelIndex &prev){
+ Q_UNUSED(prev)
+ int searchType = mTypeSel->currentData().toInt();
+ if(searchType == Actor){
+ // check if parent is invisible root item
+ if(cur.parent() == QModelIndex()){
+ // check if we don't have a child
+ if(!mDataView->model()->hasChildren(cur)){
+ mDeleteSeriesA->setEnabled(true);
+ return;
+ }
+ }
+ }
+ mDeleteSeriesA->setEnabled(false);
+}
+
void ActorsAndMore::dataDoubleClicked(const QModelIndex &index){
QModelIndex cur = index;
while(cur.parent().isValid()){
@@ -320,6 +343,22 @@ void ActorsAndMore::dataDoubleClicked(const QModelIndex &index){
}
}
+void ActorsAndMore::deleteSeries(){
+ QModelIndex cur = mDataView->selectionModel()->currentIndex();
+ int seriesPartId = cur.data(IdRole).toInt();
+ QString question = QString("Delete Series %1 (ID: %2)?").arg(cur.data().toString()).arg(seriesPartId);
+ int res = QMessageBox::question(this, "Delete", question);
+ if(res == QMessageBox::Yes){
+ QSqlDatabase db = QSqlDatabase::database("treedb");
+ QSqlQuery deleteQ(db);
+ deleteQ.prepare("DELETE from seriesparts where iseriesparts_id = :id");
+ deleteQ.bindValue(":id", seriesPartId);
+ if(deleteQ.exec()){
+ getData(mResultView->currentIndex(), QModelIndex());
+ }
+ }
+}
+
void ActorsAndMore::getDataForActor(QModelIndex cur){
mDataModel->clear();
mDataModel->setColumnCount(1);