File indexing completed on 2024-05-05 17:33:57

0001 /*
0002  *   SPDX-FileCopyrightText: 2012 Matthias Fuchs <mat69@gmx.net>
0003  *
0004  *   SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #ifndef COMIC_DATA_H
0008 #define COMIC_DATA_H
0009 
0010 #include "comicinfo.h"
0011 #include "engine/types.h"
0012 
0013 // Qt
0014 #include <KConfigGroup>
0015 #include <QImage>
0016 #include <QString>
0017 #include <QUrl>
0018 
0019 class ComicData
0020 {
0021 public:
0022     ComicData();
0023 
0024     void init(const QString &id, const KConfigGroup &config);
0025 
0026     void setData(const ComicMetaData &data);
0027 
0028     IdentifierType type() const
0029     {
0030         return mType;
0031     }
0032 
0033     /**
0034      * The identifier of the comic, e.g. "garfield"
0035      */
0036     QString id() const
0037     {
0038         return mId;
0039     }
0040 
0041     /**
0042      * The stored comic e.g. "2007-12-21" for a comic of the Date type
0043      */
0044     QString stored() const
0045     {
0046         return mStored;
0047     }
0048 
0049     void storePosition(bool store);
0050 
0051     /**
0052      * The previous comic e.g. "2007-12-21" for a comic of the Date type
0053      */
0054     QString prev() const
0055     {
0056         return mPrev;
0057     }
0058 
0059     /**
0060      * The current comic e.g. "2007-12-21" for a comic of the Date type
0061      */
0062     QString current() const
0063     {
0064         return mCurrent;
0065     }
0066 
0067     /**
0068      * The next comic e.g. "2007-12-21" for a comic of the Date type
0069      */
0070     QString next() const
0071     {
0072         return mNext;
0073     }
0074 
0075     QString currentReadable() const
0076     {
0077         return mCurrentReadable;
0078     }
0079 
0080     /**
0081      * The first comic e.g. "2007-12-21" for a comic of the Date type
0082      */
0083     QString first() const
0084     {
0085         return mFirst;
0086     }
0087 
0088     bool hasNext() const
0089     {
0090         return !mNext.isEmpty();
0091     }
0092 
0093     bool hasPrev() const
0094     {
0095         return !mPrev.isEmpty();
0096     }
0097 
0098     bool hasFirst() const
0099     {
0100         return !mFirst.isEmpty();
0101     }
0102 
0103     bool hasStored() const
0104     {
0105         return !mStored.isEmpty();
0106     }
0107 
0108     bool hasImage() const
0109     {
0110         return !mImage.isNull();
0111     }
0112 
0113     QString additionalText() const
0114     {
0115         return mAdditionalText;
0116     }
0117 
0118     QString title() const
0119     {
0120         return mTitle;
0121     }
0122     void setTitle(const QString &title)
0123     {
0124         mTitle = title;
0125     }
0126 
0127     QString stripTitle() const
0128     {
0129         return mStripTitle;
0130     }
0131 
0132     QUrl websiteUrl() const
0133     {
0134         return mWebsiteUrl;
0135     }
0136 
0137     QUrl imageUrl() const
0138     {
0139         return mImageUrl;
0140     }
0141 
0142     QUrl shopUrl() const
0143     {
0144         return mShopUrl;
0145     }
0146 
0147     QString author() const
0148     {
0149         return mAuthor;
0150     }
0151 
0152     QImage image() const
0153     {
0154         return mImage;
0155     }
0156 
0157     bool scaleComic() const
0158     {
0159         return mScaleComic;
0160     }
0161 
0162     bool isLeftToRight() const
0163     {
0164         return mIsLeftToRight;
0165     }
0166 
0167     bool isTopToBottom() const
0168     {
0169         return mIsTopToBottom;
0170     }
0171 
0172     bool storePosition() const
0173     {
0174         return !mStored.isEmpty();
0175     }
0176 
0177     void setScaleComic(bool scale);
0178 
0179     QString errorStrip() const
0180     {
0181         return mErrorStrip;
0182     }
0183 
0184     int firstStripNum() const
0185     {
0186         return mFirstStripNum;
0187     }
0188 
0189     int maxStripNum() const
0190     {
0191         return mMaxStripNum;
0192     }
0193 
0194     bool ready() const
0195     {
0196         return mReady;
0197     }
0198 
0199     void save();
0200 
0201 private:
0202     void load();
0203 
0204 private:
0205     IdentifierType mType;
0206     QString mId;
0207     QString mFirst;
0208     QString mLast;
0209     QString mCurrent;
0210     QString mNext;
0211     QString mPrev;
0212     QString mStored;
0213     QString mCurrentReadable;
0214 
0215     QString mErrorStrip;
0216 
0217     QString mAuthor;
0218     QString mTitle;
0219     QString mStripTitle;
0220     QString mAdditionalText;
0221     QUrl mWebsiteUrl;
0222     QUrl mImageUrl;
0223     QUrl mShopUrl;
0224 
0225     QImage mImage;
0226 
0227     // only applicable if the comic is of type Number
0228     int mFirstStripNum = 0;
0229     int mMaxStripNum = 0;
0230 
0231     bool mScaleComic = false;
0232     bool mIsLeftToRight = false;
0233     bool mIsTopToBottom = false;
0234     bool mReady = false;
0235 
0236     KConfigGroup mCfg;
0237 };
0238 
0239 #endif