Made DownloadManager::Downloads private

This commit is contained in:
Veloman Yunkan 2024-05-30 11:18:48 +04:00 committed by Kelson
parent e6c2effa0f
commit efddb36fef
4 changed files with 7 additions and 6 deletions

View File

@ -187,7 +187,9 @@ void ContentManager::updateModel()
auto mp = getBookInfos(bookId, keys); auto mp = getBookInfos(bookId, keys);
bookList.append(mp); bookList.append(mp);
} }
managerModel->setBooksData(bookList, m_downloads);
const DownloadManager& downloadMgr = *this;
managerModel->setBooksData(bookList, downloadMgr);
} }
void ContentManager::onCustomContextMenu(const QPoint &point) void ContentManager::onCustomContextMenu(const QPoint &point)

View File

@ -153,7 +153,7 @@ QVariant ContentManagerModel::headerData(int section, Qt::Orientation orientatio
} }
} }
void ContentManagerModel::setBooksData(const BookInfoList& data, const Downloads& downloads) void ContentManagerModel::setBooksData(const BookInfoList& data, const DownloadManager& downloadMgr)
{ {
rootNode = std::shared_ptr<RowNode>(new RowNode({tr("Icon"), tr("Name"), tr("Date"), tr("Size"), tr("Content Type"), tr("Download")}, "", std::weak_ptr<RowNode>())); rootNode = std::shared_ptr<RowNode>(new RowNode({tr("Icon"), tr("Name"), tr("Date"), tr("Size"), tr("Content Type"), tr("Download")}, "", std::weak_ptr<RowNode>()));
beginResetModel(); beginResetModel();
@ -162,7 +162,7 @@ void ContentManagerModel::setBooksData(const BookInfoList& data, const Downloads
const auto rowNode = createNode(bookItem); const auto rowNode = createNode(bookItem);
// Restore download state during model updates (filtering, etc) // Restore download state during model updates (filtering, etc)
rowNode->setDownloadState(downloads.value(rowNode->getBookId())); rowNode->setDownloadState(downloadMgr.getDownloadState(rowNode->getBookId()));
bookIdToRowMap[bookItem["id"].toString()] = rootNode->childCount(); bookIdToRowMap[bookItem["id"].toString()] = rootNode->childCount();
rootNode->appendChild(rowNode); rootNode->appendChild(rowNode);

View File

@ -23,8 +23,6 @@ public: // types
typedef QMap<QString, QVariant> BookInfo; typedef QMap<QString, QVariant> BookInfo;
typedef QList<BookInfo> BookInfoList; typedef QList<BookInfo> BookInfoList;
typedef DownloadManager::Downloads Downloads;
public: // functions public: // functions
explicit ContentManagerModel(ContentManager* contentMgr); explicit ContentManagerModel(ContentManager* contentMgr);
~ContentManagerModel(); ~ContentManagerModel();
@ -38,7 +36,7 @@ public: // functions
QModelIndex parent(const QModelIndex &index) const override; QModelIndex parent(const QModelIndex &index) const override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override; int rowCount(const QModelIndex &parent = QModelIndex()) const override;
int columnCount(const QModelIndex &parent = QModelIndex()) const override; int columnCount(const QModelIndex &parent = QModelIndex()) const override;
void setBooksData(const BookInfoList& data, const Downloads& downloads); void setBooksData(const BookInfoList& data, const DownloadManager& downloadMgr);
bool hasChildren(const QModelIndex &parent) const override; bool hasChildren(const QModelIndex &parent) const override;
void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override; void sort(int column, Qt::SortOrder order = Qt::AscendingOrder) override;

View File

@ -35,6 +35,7 @@ class DownloadManager : public QObject
public: // types public: // types
typedef std::shared_ptr<DownloadState> DownloadStatePtr; typedef std::shared_ptr<DownloadState> DownloadStatePtr;
private:
// BookId -> DownloadState map // BookId -> DownloadState map
class Downloads class Downloads
{ {