Skip to content

Commit 8b00ee8

Browse files
committed
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.
1 parent a1d88b0 commit 8b00ee8

3 files changed

Lines changed: 4 additions & 16 deletions

File tree

YACReaderLibrary/library_window.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,10 +1086,10 @@ void LibraryWindow::createConnections()
10861086
connect(importComicsInfoAction, SIGNAL(triggered()), this, SLOT(showImportComicsInfo()));
10871087

10881088
//properties & config
1089-
connect(propertiesDialog, SIGNAL(accepted()), navigationController, SLOT(reselectCurrentSource()));
1089+
connect(propertiesDialog, &QDialog::accepted, this, &LibraryWindow::reloadComicsView);
10901090

10911091
//comic vine
1092-
connect(comicVineDialog, SIGNAL(accepted()), navigationController, SLOT(reselectCurrentSource()), Qt::QueuedConnection);
1092+
connect(comicVineDialog, &QDialog::accepted, this, &LibraryWindow::reloadComicsView, Qt::QueuedConnection);
10931093

10941094
connect(updateLibraryAction, SIGNAL(triggered()), this, SLOT(updateLibrary()));
10951095
connect(renameLibraryAction, SIGNAL(triggered()), this, SLOT(renameLibrary()));
@@ -1800,7 +1800,7 @@ void LibraryWindow::checkEmptyFolder()
18001800
toggleFullScreenAction->setEnabled(true);
18011801
#endif
18021802
if (comicsModel->rowCount() == 0)
1803-
navigationController->reselectCurrentFolder();
1803+
reloadComicsView();
18041804
}
18051805
}
18061806

YACReaderLibrary/yacreader_navigation_controller.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -200,15 +200,6 @@ void YACReaderNavigationController::reselectCurrentList()
200200
selectedList(libraryWindow->listsView->currentIndex());
201201
}
202202

203-
void YACReaderNavigationController::reselectCurrentSource()
204-
{
205-
if (!libraryWindow->listsView->selectionModel()->selectedRows().isEmpty()) {
206-
reselectCurrentList();
207-
} else {
208-
reselectCurrentFolder();
209-
}
210-
}
211-
212203
void YACReaderNavigationController::selectedIndexFromHistory(const YACReaderLibrarySourceContainer &sourceContainer)
213204
{
214205
//TODO NO searching allowed, just disable backward/forward actions in searching mode
@@ -274,7 +265,7 @@ void YACReaderNavigationController::setupConnections()
274265
connect(libraryWindow->listsView, SIGNAL(clicked(QModelIndex)), this, SLOT(selectedList(QModelIndex)));
275266
connect(libraryWindow->historyController, SIGNAL(modelIndexSelected(YACReaderLibrarySourceContainer)), this, SLOT(selectedIndexFromHistory(YACReaderLibrarySourceContainer)));
276267
connect(comicsViewsManager->emptyFolderWidget, SIGNAL(subfolderSelected(QModelIndex, int)), this, SLOT(selectSubfolder(QModelIndex, int)));
277-
connect(libraryWindow->comicsModel, SIGNAL(isEmpty()), this, SLOT(reselectCurrentSource()));
268+
connect(libraryWindow->comicsModel, &ComicModel::isEmpty, libraryWindow, &LibraryWindow::reloadComicsView);
278269
}
279270

280271
qulonglong YACReaderNavigationController::folderModelIndexToID(const QModelIndex &mi)

YACReaderLibrary/yacreader_navigation_controller.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ public slots:
2727
//reading lists
2828
void selectedList(const QModelIndex &mi);
2929
void reselectCurrentList();
30-
31-
void reselectCurrentSource();
32-
3330
//history navigation
3431
void selectedIndexFromHistory(const YACReaderLibrarySourceContainer &sourceContainer);
3532
//empty subfolder

0 commit comments

Comments
 (0)