From 0f372a001e940b77b391c5a559dc3cecaf8711a1 Mon Sep 17 00:00:00 2001 From: Igor Kushnir Date: Sat, 13 Feb 2021 15:05:14 +0200 Subject: [PATCH] Library: update toolbar title on history navigation When Back or Forward action was triggered, the toolbar title was not updated to match the reselected entry. I am calling LibraryWindow::setToolbarTitle() from selectedIndexFromHistory() rather than loadIndexFromHistory(), because the latter is also called from YACReaderNavigationController::loadPreviousStatus(), which in turn is called only from LibraryWindow::setSearchFilter() when the search line text becomes empty. The toolbar title is already correct and does not have to be updated in this case. My code analysis and experiments have revealed that YACReader code never creates YACReaderLibrarySourceContainer objects of type None. This type could be removed altogether along with YACReaderLibrarySourceContainer's default constructor, but for Q_DECLARE_METATYPE macro's requirement. So YACReaderNavigationController::loadIndexFromHistory() now simply prints an error message instead of introducing a failure condition by returning false when the type is None. --- YACReaderLibrary/yacreader_navigation_controller.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/YACReaderLibrary/yacreader_navigation_controller.cpp b/YACReaderLibrary/yacreader_navigation_controller.cpp index c258d951..6cc4aa05 100644 --- a/YACReaderLibrary/yacreader_navigation_controller.cpp +++ b/YACReaderLibrary/yacreader_navigation_controller.cpp @@ -219,6 +219,7 @@ void YACReaderNavigationController::selectedIndexFromHistory(const YACReaderLibr } loadIndexFromHistory(sourceContainer); + libraryWindow->setToolbarTitle(sourceContainer.getSourceModelIndex()); } void YACReaderNavigationController::loadIndexFromHistory(const YACReaderLibrarySourceContainer &sourceContainer) @@ -240,6 +241,7 @@ void YACReaderNavigationController::loadIndexFromHistory(const YACReaderLibraryS break; } case YACReaderLibrarySourceContainer::None: + QLOG_ERROR() << "Cannot load a source container of type None"; break; } }