summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArno <arno@disconnect.de>2020-07-29 07:41:50 +0200
committerArno <arno@disconnect.de>2020-07-29 07:41:50 +0200
commit9161fa0d0a4a312c2d70550123287bbf821284ba (patch)
tree296df87ebc3dc8f7cc1d4b2e2b7cb8a37075fa44
parent7d9c0622668de64612fadb2dd6d26048935fa608 (diff)
downloadSheMov-9161fa0d0a4a312c2d70550123287bbf821284ba.tar.gz
SheMov-9161fa0d0a4a312c2d70550123287bbf821284ba.tar.bz2
SheMov-9161fa0d0a4a312c2d70550123287bbf821284ba.zip
Add refresh actors in search dialog
Make it possible to call it by context menu and hook it up to deleteSeries.
-rw-r--r--searchdialog.cpp27
-rw-r--r--searchdialog.h1
2 files changed, 27 insertions, 1 deletions
diff --git a/searchdialog.cpp b/searchdialog.cpp
index 6cb5821..b06e487 100644
--- a/searchdialog.cpp
+++ b/searchdialog.cpp
@@ -177,6 +177,10 @@ ActorsAndMore::ActorsAndMore(QWidget *parent, Qt::WindowFlags flags) : QWidget(p
QAction *resultExpandAllA = new QAction(Helper::icon(Qt::transparent, qApp->palette().color(QPalette::Text), QChar(0x2193), true, false), tr("Expand all"), this);
connect(resultExpandAllA, &QAction::triggered, this, &ActorsAndMore::expandAllResult);
mResultView->addAction(resultExpandAllA);
+ QAction *resultRefreshA = new QAction(Helper::icon(Qt::transparent, qApp->palette().color(QPalette::Text), QChar(0x21bb), true, false), tr("Refresh"), this);
+ connect(resultRefreshA, &QAction::triggered, this, &ActorsAndMore::refreshActors);
+ mResultView->addAction(Helper::createSeparator(this));
+ mResultView->addAction(resultRefreshA);
// data view
mDataModel = new QStandardItemModel;
@@ -354,7 +358,28 @@ void ActorsAndMore::deleteSeries(){
deleteQ.prepare("DELETE from seriesparts where iseriesparts_id = :id");
deleteQ.bindValue(":id", seriesPartId);
if(deleteQ.exec()){
- getData(mResultView->currentIndex(), QModelIndex());
+ refreshActors();
+ }
+ }
+}
+
+void ActorsAndMore::refreshActors(){
+ int searchType = mTypeSel->currentData().toInt();
+ if(searchType == Actor){
+ QModelIndexList sel = mResultView->selectionModel()->selectedRows();
+ if(!sel.isEmpty()){
+ QString currentText = sel.at(0).data().toString();
+ doSearch();
+ QList<QStandardItem*> search = mResultModel->findItems(currentText);
+ if(!search.isEmpty()){
+ QModelIndex newSelected = mResultModel->indexFromItem(search.at(0));
+ if(newSelected.isValid()){
+ QSortFilterProxyModel *proxy = static_cast<QSortFilterProxyModel*>(mResultView->model());
+ QModelIndex sourceIdx = proxy->mapFromSource(newSelected);
+ mResultView->selectionModel()->setCurrentIndex(sourceIdx, QItemSelectionModel::ClearAndSelect);
+ mResultView->scrollTo(sourceIdx);
+ }
+ }
}
}
}
diff --git a/searchdialog.h b/searchdialog.h
index c28b5a0..1cd9fdd 100644
--- a/searchdialog.h
+++ b/searchdialog.h
@@ -65,6 +65,7 @@ class ActorsAndMore : public QWidget {
void collapseAllData() { mDataView->collapseAll(); }
void expandAllData() { mDataView->expandAll(); }
void deleteSeries();
+ void refreshActors();
private:
void searchActor(const QString &actor);