| 1 | #ifndef VIEWCONTROLLER_H |
| 2 | #define VIEWCONTROLLER_H |
| 3 | |
| 4 | #include <QByteArray> |
| 5 | #include <QObject> |
| 6 | #include <QUrl> |
| 7 | |
| 8 | class MainWidget; |
| 9 | class QDomDocument; |
| 10 | |
| 11 | /*! |
| 12 | * \class ViewController |
| 13 | * |
| 14 | * \inmodule ThreadWeaver |
| 15 | */ |
| 16 | class ViewController : public QObject |
| 17 | { |
| 18 | Q_OBJECT |
| 19 | public: |
| 20 | /*! |
| 21 | */ |
| 22 | explicit ViewController(MainWidget *mainwidget); |
| 23 | ~ViewController() override; |
| 24 | |
| 25 | Q_SIGNALS: |
| 26 | /*! |
| 27 | */ |
| 28 | void setImage(QImage image); |
| 29 | /*! |
| 30 | */ |
| 31 | void setCaption(QString text); |
| 32 | /*! |
| 33 | */ |
| 34 | void setStatus(QString text); |
| 35 | |
| 36 | private: |
| 37 | /*! |
| 38 | */ |
| 39 | void loadPlaceholderFromResource(); |
| 40 | /*! |
| 41 | */ |
| 42 | void loadPostFromTumblr(); |
| 43 | /*! |
| 44 | */ |
| 45 | void loadImageFromTumblr(); |
| 46 | |
| 47 | /*! |
| 48 | */ |
| 49 | QByteArray download(const QUrl &url); |
| 50 | /*! |
| 51 | */ |
| 52 | void error(const QString &message); |
| 53 | /*! |
| 54 | */ |
| 55 | void showResourceImage(const char *file); |
| 56 | /*! |
| 57 | */ |
| 58 | QString attributeTextFor(const QDomDocument &doc, const char *tag, const char *attribute); |
| 59 | |
| 60 | QUrl m_imageUrl; |
| 61 | const QString m_apiPostUrl; |
| 62 | QString m_fullPostUrl; |
| 63 | }; |
| 64 | |
| 65 | #endif // VIEWCONTROLLER_H |
| 66 | |