mirror of
https://github.com/YACReader/yacreader
synced 2025-07-18 21:14:33 -04:00
Implement support for updating ComicModel without resetting the whole model
TODO: Favorites, Label, ReadingList still fallback to full reload because we need a way of comparing old vs new results. SearchResult does nothing because we don't have access to the search query.
This commit is contained in:
@ -38,6 +38,7 @@ public:
|
||||
PublicationDate = 13,
|
||||
Added = 14,
|
||||
Type = 15,
|
||||
LastTimeOpened = 16,
|
||||
};
|
||||
|
||||
enum Roles {
|
||||
@ -69,12 +70,12 @@ public:
|
||||
Reading,
|
||||
Recent,
|
||||
Label,
|
||||
ReadingList
|
||||
ReadingList,
|
||||
SearchResult
|
||||
};
|
||||
|
||||
public:
|
||||
explicit ComicModel(QObject *parent = nullptr);
|
||||
explicit ComicModel(QSqlQuery &sqlquery, QObject *parent = nullptr);
|
||||
~ComicModel() override;
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
@ -162,8 +163,18 @@ public slots:
|
||||
|
||||
protected:
|
||||
private:
|
||||
void setupModelData(QSqlQuery &sqlquery);
|
||||
void setupModelDataForList(QSqlQuery &sqlquery);
|
||||
QList<ComicItem *> createModelData(QSqlQuery &sqlquery) const;
|
||||
QList<ComicItem *> createModelDataForList(QSqlQuery &sqlquery) const;
|
||||
|
||||
QList<ComicItem *> createFolderModelData(unsigned long long parentLabel, const QString &databasePath) const;
|
||||
QList<ComicItem *> createLabelModelData(unsigned long long parentLabel, const QString &databasePath) const;
|
||||
QList<ComicItem *> createReadingListData(unsigned long long parentReadingList, const QString &databasePath, bool &enableResorting) const;
|
||||
QList<ComicItem *> createFavoritesModelData(const QString &databasePath) const;
|
||||
QList<ComicItem *> createReadingModelData(const QString &databasePath) const;
|
||||
QList<ComicItem *> createRecentModelData(const QString &databasePath) const;
|
||||
|
||||
void takeData(const QList<ComicItem *> &data);
|
||||
void takeUpdatedData(const QList<ComicItem *> &updatedData, std::function<bool(ComicItem *, ComicItem *)> comparator);
|
||||
ComicDB _getComic(const QModelIndex &mi);
|
||||
QList<ComicItem *> _data;
|
||||
|
||||
|
Reference in New Issue
Block a user