summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArno <arno@disconnect.de>2020-07-29 06:27:33 +0200
committerArno <arno@disconnect.de>2020-07-29 06:27:33 +0200
commit7d9c0622668de64612fadb2dd6d26048935fa608 (patch)
tree9a781815bf5c391b3e7dc9c5bf4f9aaebfc0c77d
parentb384639799a68ca7d7c07eee518d3ef4b34812d0 (diff)
downloadSheMov-7d9c0622668de64612fadb2dd6d26048935fa608.tar.gz
SheMov-7d9c0622668de64612fadb2dd6d26048935fa608.tar.bz2
SheMov-7d9c0622668de64612fadb2dd6d26048935fa608.zip
Delete seriesparts from search dialog
Allow to delete seriesparts without files to be deleted from the search dialog.
-rw-r--r--searchdialog.cpp43
-rw-r--r--searchdialog.h3
2 files changed, 44 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);
diff --git a/searchdialog.h b/searchdialog.h
index 09ed259..c28b5a0 100644
--- a/searchdialog.h
+++ b/searchdialog.h
@@ -57,12 +57,14 @@ class ActorsAndMore : public QWidget {
public slots:
void doSearch();
+ void getData(const QModelIndex &cur, const QModelIndex &prev);
void doData(const QModelIndex &cur, const QModelIndex &prev);
void dataDoubleClicked(const QModelIndex &index);
void collapseAllResult() { mResultView->collapseAll(); }
void expandAllResult() { mResultView->expandAll(); }
void collapseAllData() { mDataView->collapseAll(); }
void expandAllData() { mDataView->expandAll(); }
+ void deleteSeries();
private:
void searchActor(const QString &actor);
@@ -76,6 +78,7 @@ class ActorsAndMore : public QWidget {
QStandardItemModel *mDataModel;
SmView *mResultView;
SmView *mDataView;
+ QAction *mDeleteSeriesA;
};
class SearchDialog : public QDialog {