-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrundowncreator.h
81 lines (63 loc) · 2.49 KB
/
rundowncreator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/**************************************************************************
RCExportCG
Copyright (C) 2017 Peter Simonsson <[email protected]>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
**************************************************************************/
#ifndef RUNDOWNCREATORFETCHER_H
#define RUNDOWNCREATORFETCHER_H
#include <QObject>
#include <QUrl>
#include <QList>
#include <QJsonDocument>
class QNetworkAccessManager;
class QNetworkReply;
class Rundown;
class RundownRowModel;
class Folder;
class RundownCreator : public QObject
{
Q_OBJECT
public:
explicit RundownCreator(QObject *parent = nullptr);
~RundownCreator();
void setApiUrl(const QUrl &url) { m_apiUrl = url; }
QUrl apiUrl() const { return m_apiUrl; }
void setApiKey(const QString &key) { m_apiKey = key; }
void setApiToken(const QString &token) { m_apiToken = token; }
RundownRowModel *rundownRowModel() const { return m_rundownRowModel; }
QHash<quint32, Folder*> folderHash() const { return m_folderHash; }
public slots:
void getFoldersAndRundows();
void fetchRows(quint32 rundownId);
private slots:
void handleFinished(QNetworkReply *reply);
void handleRundowns(const QByteArray &data);
void handleRows(const QByteArray &data);
void handleFolders(const QByteArray &data);
private:
typedef QPair<QString, QString> QueryItem;
QUrlQuery createRequestQuery(const QString &action, const QList<QueryItem> &extraItems = QList<QueryItem>()) const;
void getRundowns();
QUrl m_apiUrl;
QString m_apiKey;
QString m_apiToken;
QNetworkAccessManager *m_netManager;
QHash<quint32, Folder*> m_folderHash;
RundownRowModel *m_rundownRowModel;
signals:
void rundownsReceived();
void rundownRowsReceived();
void error(const QString &errorString);
void status(const QString &statusString);
void debug(const QString &message);
};
#endif // RUNDOWNCREATORFETCHER_H