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 | class ViewController : public QObject |
12 | { |
13 | Q_OBJECT |
14 | public: |
15 | explicit ViewController(MainWidget *mainwidget); |
16 | ~ViewController() override; |
17 | |
18 | Q_SIGNALS: |
19 | void setImage(QImage image); |
20 | void setCaption(QString text); |
21 | void setStatus(QString text); |
22 | |
23 | private: |
24 | void loadPlaceholderFromResource(); |
25 | void loadPostFromTumblr(); |
26 | void loadImageFromTumblr(); |
27 | |
28 | QByteArray download(const QUrl &url); |
29 | void error(const QString &message); |
30 | void showResourceImage(const char *file); |
31 | QString attributeTextFor(const QDomDocument &doc, const char *tag, const char *attribute); |
32 | |
33 | QUrl m_imageUrl; |
34 | const QString m_apiPostUrl; |
35 | QString m_fullPostUrl; |
36 | }; |
37 | |
38 | #endif // VIEWCONTROLLER_H |
39 | |