Skip to content

Commit

Permalink
Don't reselect current source needlessly
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
vedgy committed Feb 27, 2021
1 parent a1d88b0 commit 8b00ee8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 16 deletions.
6 changes: 3 additions & 3 deletions YACReaderLibrary/library_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()));
Expand Down Expand Up @@ -1800,7 +1800,7 @@ void LibraryWindow::checkEmptyFolder()
toggleFullScreenAction->setEnabled(true);
#endif
if (comicsModel->rowCount() == 0)
navigationController->reselectCurrentFolder();
reloadComicsView();
}
}

Expand Down
11 changes: 1 addition & 10 deletions YACReaderLibrary/yacreader_navigation_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 0 additions & 3 deletions YACReaderLibrary/yacreader_navigation_controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8b00ee8

Please sign in to comment.