Dropped ContentManagerModel::fetchMore() and friends

Since `ContentManagerModel::fetchMore()` doesn't perform any actual
incremental loading of the data, it no longer makes any sense.
This commit is contained in:
Veloman Yunkan 2024-02-20 20:04:33 +04:00
parent af67a44147
commit ef1b36fd28
2 changed files with 1 additions and 24 deletions

View File

@ -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)

View File

@ -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<RowNode> rootNode;
int zimCount = 0;
mutable ThumbnailDownloader td;
QMap<QString, size_t> bookIdToRowMap;
QMap<QString, QByteArray> m_iconMap;