From 8b00ee8bd9dc41c1a9fa5335a26a0ff28794028b Mon Sep 17 00:00:00 2001 From: Igor Kushnir Date: Thu, 18 Feb 2021 16:07:22 +0200 Subject: [PATCH] Don't reselect current source needlessly Wherever YACReaderNavigationController::reselectCurrentSource() was called, simply reloading the comics view is sufficient: when a dialog is accepted or when the last comic is deleted from the current reading list. Similarly there is no need to reselect the current folder when the last comic is deleted from the current folder. Simply reloading the comics view saves some work. In addition, in all changed places forward navigation history entries were cut off and lost because of the call to YACReaderHistoryController::updateHistory() in selectedFolder() or selectedList(). Now that reselectCurrentSource() is not used anymore, it can be safely removed rather than fixed. Its implementation suffered from two bugs: 1. Checking whether a reading list is selected is not reliable, because a reading list can be deselected but not unloaded by clicking outside of all rows in YACReaderReadingListsView. 2. It didn't account for the possibility of active search mode. --- YACReaderLibrary/library_window.cpp | 6 +++--- YACReaderLibrary/yacreader_navigation_controller.cpp | 11 +---------- YACReaderLibrary/yacreader_navigation_controller.h | 3 --- 3 files changed, 4 insertions(+), 16 deletions(-) diff --git a/YACReaderLibrary/library_window.cpp b/YACReaderLibrary/library_window.cpp index 67cfe6dbc..22930d4ac 100644 --- a/YACReaderLibrary/library_window.cpp +++ b/YACReaderLibrary/library_window.cpp @@ -1086,10 +1086,10 @@ void LibraryWindow::createConnections() connect(importComicsInfoAction, SIGNAL(triggered()), this, SLOT(showImportComicsInfo())); //properties & config - connect(propertiesDialog, SIGNAL(accepted()), navigationController, SLOT(reselectCurrentSource())); + connect(propertiesDialog, &QDialog::accepted, this, &LibraryWindow::reloadComicsView); //comic vine - connect(comicVineDialog, SIGNAL(accepted()), navigationController, SLOT(reselectCurrentSource()), Qt::QueuedConnection); + connect(comicVineDialog, &QDialog::accepted, this, &LibraryWindow::reloadComicsView, Qt::QueuedConnection); connect(updateLibraryAction, SIGNAL(triggered()), this, SLOT(updateLibrary())); connect(renameLibraryAction, SIGNAL(triggered()), this, SLOT(renameLibrary())); @@ -1800,7 +1800,7 @@ void LibraryWindow::checkEmptyFolder() toggleFullScreenAction->setEnabled(true); #endif if (comicsModel->rowCount() == 0) - navigationController->reselectCurrentFolder(); + reloadComicsView(); } } diff --git a/YACReaderLibrary/yacreader_navigation_controller.cpp b/YACReaderLibrary/yacreader_navigation_controller.cpp index 4a2fb76c7..56fd4291f 100644 --- a/YACReaderLibrary/yacreader_navigation_controller.cpp +++ b/YACReaderLibrary/yacreader_navigation_controller.cpp @@ -200,15 +200,6 @@ void YACReaderNavigationController::reselectCurrentList() selectedList(libraryWindow->listsView->currentIndex()); } -void YACReaderNavigationController::reselectCurrentSource() -{ - if (!libraryWindow->listsView->selectionModel()->selectedRows().isEmpty()) { - reselectCurrentList(); - } else { - reselectCurrentFolder(); - } -} - void YACReaderNavigationController::selectedIndexFromHistory(const YACReaderLibrarySourceContainer &sourceContainer) { //TODO NO searching allowed, just disable backward/forward actions in searching mode @@ -274,7 +265,7 @@ void YACReaderNavigationController::setupConnections() connect(libraryWindow->listsView, SIGNAL(clicked(QModelIndex)), this, SLOT(selectedList(QModelIndex))); connect(libraryWindow->historyController, SIGNAL(modelIndexSelected(YACReaderLibrarySourceContainer)), this, SLOT(selectedIndexFromHistory(YACReaderLibrarySourceContainer))); connect(comicsViewsManager->emptyFolderWidget, SIGNAL(subfolderSelected(QModelIndex, int)), this, SLOT(selectSubfolder(QModelIndex, int))); - connect(libraryWindow->comicsModel, SIGNAL(isEmpty()), this, SLOT(reselectCurrentSource())); + connect(libraryWindow->comicsModel, &ComicModel::isEmpty, libraryWindow, &LibraryWindow::reloadComicsView); } qulonglong YACReaderNavigationController::folderModelIndexToID(const QModelIndex &mi) diff --git a/YACReaderLibrary/yacreader_navigation_controller.h b/YACReaderLibrary/yacreader_navigation_controller.h index d1d53c101..914305eed 100644 --- a/YACReaderLibrary/yacreader_navigation_controller.h +++ b/YACReaderLibrary/yacreader_navigation_controller.h @@ -27,9 +27,6 @@ public slots: //reading lists void selectedList(const QModelIndex &mi); void reselectCurrentList(); - - void reselectCurrentSource(); - //history navigation void selectedIndexFromHistory(const YACReaderLibrarySourceContainer &sourceContainer); //empty subfolder