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.
This commit is contained in:
Igor Kushnir 2021-02-13 15:05:14 +02:00
parent 93596a4972
commit 0f372a001e

View File

@ -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;
}
}