From cd07135af250732a811a92741796937e3691a7c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Wed, 13 Apr 2016 18:12:33 +0200 Subject: [PATCH] Updated comic info for writing read and rating properties in QML. --- common/comic_db.cpp | 18 ++++++++++++++++++ common/comic_db.h | 11 +++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/common/comic_db.cpp b/common/comic_db.cpp index c1b8f14c..f06bd30b 100644 --- a/common/comic_db.cpp +++ b/common/comic_db.cpp @@ -445,6 +445,24 @@ QStringList ComicInfo::getCharacters() return QStringList(); } +void ComicInfo::setRead(bool r) +{ + if(r != read) + { + read = r; + emit readChanged(); + } +} + +void ComicInfo::setRating(int r) +{ + if(r != rating) + { + rating = r; + emit ratingChanged(); + } +} + QDataStream &operator<<(QDataStream & stream, const ComicDB & comic) { stream << comic.id; diff --git a/common/comic_db.h b/common/comic_db.h index 113c79aa..2303f30d 100644 --- a/common/comic_db.h +++ b/common/comic_db.h @@ -132,12 +132,12 @@ public: friend QDataStream &operator>>(QDataStream & stream, ComicInfo & comicInfo); Q_PROPERTY(qulonglong id MEMBER id CONSTANT) - Q_PROPERTY(bool read MEMBER read CONSTANT) + Q_PROPERTY(bool read MEMBER read WRITE setRead NOTIFY readChanged) Q_PROPERTY(bool edited MEMBER edited CONSTANT) Q_PROPERTY(QString hash MEMBER hash CONSTANT) Q_PROPERTY(bool existOnDb MEMBER existOnDb CONSTANT) - Q_PROPERTY(int rating MEMBER rating CONSTANT) + Q_PROPERTY(int rating MEMBER rating WRITE setRating NOTIFY ratingChanged) Q_PROPERTY(bool hasBeenOpened MEMBER hasBeenOpened CONSTANT) @@ -186,8 +186,15 @@ public: Q_PROPERTY(QImage cover MEMBER cover CONSTANT) + //setters, used in QML only by now + void setRead(bool r); + void setRating(int r); private: +signals: + void readChanged(); + void ratingChanged(); + }; class ComicDB : public LibraryItem