mirror of
https://github.com/YACReader/yacreader
synced 2025-07-14 11:04:25 -04:00
Add the possibility to show a recently added/updated indicator
This commit is contained in:
@ -17,12 +17,13 @@
|
||||
#include "QsLog.h"
|
||||
|
||||
ComicModel::ComicModel(QObject *parent)
|
||||
: QAbstractItemModel(parent)
|
||||
: QAbstractItemModel(parent), showRecent(false)
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
ComicModel::ComicModel(QSqlQuery &sqlquery, QObject *parent)
|
||||
: QAbstractItemModel(parent)
|
||||
: QAbstractItemModel(parent), showRecent(false)
|
||||
{
|
||||
setupModelData(sqlquery);
|
||||
}
|
||||
@ -239,7 +240,9 @@ QHash<int, QByteArray> ComicModel::roleNames() const
|
||||
roles[CoverPathRole] = "cover_path";
|
||||
roles[PublicationDate] = "date";
|
||||
roles[ReadableTitle] = "readable_title";
|
||||
roles[Added] = "added_date";
|
||||
roles[AddedRole] = "added_date";
|
||||
roles[TypeRole] = "type";
|
||||
roles[ShowRecentRole] = "show_recent";
|
||||
|
||||
return roles;
|
||||
}
|
||||
@ -306,6 +309,8 @@ QVariant ComicModel::data(const QModelIndex &index, int role) const
|
||||
return item->data(Added);
|
||||
else if (role == TypeRole)
|
||||
return item->data(Type);
|
||||
else if (role == ShowRecentRole)
|
||||
return showRecent;
|
||||
|
||||
if (role != Qt::DisplayRole)
|
||||
return QVariant();
|
||||
@ -1129,6 +1134,16 @@ bool ComicModel::isFavorite(const QModelIndex &index)
|
||||
return isFavorite;
|
||||
}
|
||||
|
||||
void ComicModel::setShowRecent(bool showRecent)
|
||||
{
|
||||
if (this->showRecent == showRecent)
|
||||
return;
|
||||
|
||||
this->showRecent = showRecent;
|
||||
|
||||
emit dataChanged(index(0, 0), index(rowCount() - 1, 0), { ComicModel::ShowRecentRole });
|
||||
}
|
||||
|
||||
void ComicModel::updateRating(int rating, QModelIndex mi)
|
||||
{
|
||||
ComicDB comic = getComic(mi);
|
||||
|
Reference in New Issue
Block a user