ContentManager::updateModel()

`ContentManager::getBooksList()` was replaced by
`ContentManager::updateModel()` (which combines the now removed
`ContentManager::getBooksList()` and `ContentManagerModel::setBooksData()`
into a single operation).

Notes:

- The call to `ContentManagerModel::refreshIcons()` could not be
  included in `ContentManager::updateModel()`. A few attempts to do
  so failed for various reasons, but the outcome of those efforts is
  that a better design for thumbnail loading was identified which
  enables dropping the `ContentManagerModel::refreshIcons()` operation.
  That redesign is pursued in the next few commits.
This commit is contained in:
Veloman Yunkan 2024-02-18 17:25:58 +04:00
parent 6c095adf8a
commit 14d3c8ff04
2 changed files with 5 additions and 7 deletions

View File

@ -91,8 +91,7 @@ ContentManager::ContentManager(Library* library, kiwix::Downloader* downloader,
// so, we don't need to delete it.
mp_view = new ContentManagerView();
managerModel = new ContentManagerModel(&m_downloads, this);
const auto booksList = getBooksList();
managerModel->setBooksData(booksList);
updateModel();
auto treeView = mp_view->getView();
treeView->setModel(managerModel);
treeView->show();
@ -120,8 +119,7 @@ ContentManager::ContentManager(Library* library, kiwix::Downloader* downloader,
connect(mp_library, &Library::booksChanged, this, [=]() {emit(this->booksChanged());});
connect(this, &ContentManager::filterParamsChanged, this, &ContentManager::updateLibrary);
connect(this, &ContentManager::booksChanged, this, [=]() {
const auto nBookList = getBooksList();
managerModel->setBooksData(nBookList);
updateModel();
managerModel->refreshIcons();
});
connect(&m_remoteLibraryManager, &OpdsRequestManager::requestReceived, this, &ContentManager::updateRemoteLibrary);
@ -138,7 +136,7 @@ ContentManager::ContentManager(Library* library, kiwix::Downloader* downloader,
this, &ContentManager::updateDownloads);
}
ContentManager::BookInfoList ContentManager::getBooksList()
void ContentManager::updateModel()
{
const auto bookIds = getBookIds();
BookInfoList bookList;
@ -148,7 +146,7 @@ ContentManager::BookInfoList ContentManager::getBooksList()
auto mp = getBookInfos(bookId, keys);
bookList.append(mp);
}
return bookList;
managerModel->setBooksData(bookList);
}
void ContentManager::onCustomContextMenu(const QPoint &point)

View File

@ -74,7 +74,7 @@ private: // functions
// reallyEraseBook() doesn't ask for confirmation (unlike eraseBook())
void reallyEraseBook(const QString& id, bool moveToTrash);
void eraseBookFilesFromComputer(const QString dirPath, const QString filename, const bool moveToTrash);
BookInfoList getBooksList();
void updateModel();
void setCategories();
void setLanguages();