mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
updated tablemodel for future usages with QML
This commit is contained in:
parent
7c496c7e1f
commit
e20ede86f8
@ -81,6 +81,9 @@ QVariant TableModel::data(const QModelIndex &index, int role) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//TODO check here if any view is asking for TableModel::Roles
|
||||||
|
//these roles will be used from QML/GridView
|
||||||
|
|
||||||
if (role != Qt::DisplayRole)
|
if (role != Qt::DisplayRole)
|
||||||
return QVariant();
|
return QVariant();
|
||||||
|
|
||||||
@ -597,6 +600,28 @@ void TableModel::resetComicRating(const QModelIndex &mi)
|
|||||||
QSqlDatabase::removeDatabase(_databasePath);
|
QSqlDatabase::removeDatabase(_databasePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QHash<int, QByteArray> TableModel::roleNames()
|
||||||
|
{
|
||||||
|
QHash<int, QByteArray> roles;
|
||||||
|
|
||||||
|
roles[NumberRole] = "number";
|
||||||
|
roles[TitleRole] = "title";
|
||||||
|
roles[FileNameRole] = "file_name";
|
||||||
|
roles[NumPagesRole] = "num_pages";
|
||||||
|
roles[IdRole] = "id";
|
||||||
|
roles[Parent_IdRole] = "parent_id";
|
||||||
|
roles[PathRole] = "path";
|
||||||
|
roles[HashRole] = "hash";
|
||||||
|
roles[ReadColumnRole] = "read";
|
||||||
|
roles[IsBisRole] = "is_bis";
|
||||||
|
roles[CurrentPageRole] = "current_page";
|
||||||
|
roles[RatingRole] = "rating";
|
||||||
|
roles[HasBeenOpenedRole] = "has_been_opened";
|
||||||
|
roles[CoverPathRole] = "cover_path";
|
||||||
|
|
||||||
|
return roles;
|
||||||
|
}
|
||||||
|
|
||||||
void TableModel::updateRating(int rating, QModelIndex mi)
|
void TableModel::updateRating(int rating, QModelIndex mi)
|
||||||
{
|
{
|
||||||
ComicDB comic = getComic(mi);
|
ComicDB comic = getComic(mi);
|
||||||
|
@ -56,6 +56,8 @@ public:
|
|||||||
void reload(const ComicDB & comic);
|
void reload(const ComicDB & comic);
|
||||||
void resetComicRating(const QModelIndex & mi);
|
void resetComicRating(const QModelIndex & mi);
|
||||||
|
|
||||||
|
QHash<int, QByteArray> roleNames();
|
||||||
|
|
||||||
enum Columns {
|
enum Columns {
|
||||||
Number = 0,
|
Number = 0,
|
||||||
Title = 1,
|
Title = 1,
|
||||||
@ -71,6 +73,25 @@ public:
|
|||||||
Rating = 11,
|
Rating = 11,
|
||||||
HasBeenOpened = 12
|
HasBeenOpened = 12
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum Roles {
|
||||||
|
NumberRole = Qt::UserRole + 1,
|
||||||
|
TitleRole,
|
||||||
|
FileNameRole,
|
||||||
|
NumPagesRole,
|
||||||
|
IdRole,
|
||||||
|
Parent_IdRole,
|
||||||
|
PathRole,
|
||||||
|
HashRole,
|
||||||
|
ReadColumnRole,
|
||||||
|
IsBisRole,
|
||||||
|
CurrentPageRole,
|
||||||
|
RatingRole,
|
||||||
|
HasBeenOpenedRole,
|
||||||
|
CoverPathRole
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void remove(int row);
|
void remove(int row);
|
||||||
void startTransaction();
|
void startTransaction();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user