From ef1b36fd28f742a22e8c656dd1be5569dc420b2f Mon Sep 17 00:00:00 2001 From: Veloman Yunkan Date: Tue, 20 Feb 2024 20:04:33 +0400 Subject: [PATCH] Dropped ContentManagerModel::fetchMore() and friends Since `ContentManagerModel::fetchMore()` doesn't perform any actual incremental loading of the data, it no longer makes any sense. --- src/contentmanagermodel.cpp | 20 +------------------- src/contentmanagermodel.h | 5 ----- 2 files changed, 1 insertion(+), 24 deletions(-) diff --git a/src/contentmanagermodel.cpp b/src/contentmanagermodel.cpp index 84c9cf7..bb8169a 100644 --- a/src/contentmanagermodel.cpp +++ b/src/contentmanagermodel.cpp @@ -94,7 +94,7 @@ QModelIndex ContentManagerModel::parent(const QModelIndex &index) const int ContentManagerModel::rowCount(const QModelIndex &parent) const { Q_UNUSED(parent); - return zimCount; + return m_data.size(); } QVariant ContentManagerModel::headerData(int section, Qt::Orientation orientation, int role) const @@ -178,24 +178,6 @@ bool ContentManagerModel::hasChildren(const QModelIndex &parent) const return true; } -bool ContentManagerModel::canFetchMore(const QModelIndex &parent) const -{ - if (parent.isValid()) - return false; - return (zimCount < m_data.size()); -} - -void ContentManagerModel::fetchMore(const QModelIndex &parent) -{ - if (parent.isValid()) - return; - int remainder = m_data.size() - zimCount; - int zimsToFetch = qMin(5, remainder); - beginInsertRows(QModelIndex(), zimCount, zimCount + zimsToFetch - 1); - zimCount += zimsToFetch; - endInsertRows(); -} - void ContentManagerModel::sort(int column, Qt::SortOrder order) { if (column == 0 || column == 4 || column == 5) diff --git a/src/contentmanagermodel.h b/src/contentmanagermodel.h index 7f0d178..b6f0e5b 100644 --- a/src/contentmanagermodel.h +++ b/src/contentmanagermodel.h @@ -51,10 +51,6 @@ public slots: void removeDownload(QString bookId); void updateDownload(QString bookId); -protected: // functions - bool canFetchMore(const QModelIndex &parent) const override; - void fetchMore(const QModelIndex &parent) override; - private: // functions // Returns either data of the thumbnail (as a QByteArray) or a URL (as a // QString) from where the actual data can be obtained. @@ -64,7 +60,6 @@ private: // functions private: // data BookInfoList m_data; std::shared_ptr rootNode; - int zimCount = 0; mutable ThumbnailDownloader td; QMap bookIdToRowMap; QMap m_iconMap;