-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtraktrequest.cpp
94 lines (76 loc) · 1.68 KB
/
traktrequest.cpp
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
82
83
84
85
86
87
88
89
90
91
92
93
94
#include "traktrequest.h"
#include "traktconnection.h"
#include "traktreply.h"
TraktRequest::TraktRequest(QObject *parent) :
QObject(parent),
m_connection(TraktConnection::instance()),
m_operation(OperationGet)
{
}
TraktRequest::TraktRequest(TraktConnection *connection, QObject *parent) :
QObject(parent),
m_connection(connection)
{
}
QVariantMap TraktRequest::data() const
{
return m_data;
}
void TraktRequest::setData(const QVariantMap &data)
{
m_data = data;
}
TraktRequest::Operation TraktRequest::operation() const
{
return m_operation;
}
void TraktRequest::setOperation(Operation operation)
{
m_operation = operation;
}
QString TraktRequest::path() const
{
return m_path;
}
void TraktRequest::setPath(const QString &path)
{
m_path = path;
}
void TraktRequest::setPage(int page)
{
replaceQueryItem("page", QString::number(page));
}
void TraktRequest::setLimit(int limit)
{
replaceQueryItem("limit", QString::number(limit));
}
void TraktRequest::addQueryItem(const QString &key, const QString &value)
{
m_query.addQueryItem(key, value);
}
void TraktRequest::replaceQueryItem(const QString &key, const QString &value)
{
m_query.removeQueryItem(key);
m_query.addQueryItem(key, value);
}
void TraktRequest::removeQueryItem(const QString &key)
{
m_query.removeQueryItem(key);
}
QUrlQuery TraktRequest::query() const
{
return m_query;
}
void TraktRequest::fire()
{
connect(this, &TraktRequest::replyReceived, this, &TraktRequest::cleanup);
m_connection->sendRequest(this);
}
void TraktRequest::send()
{
m_connection->sendRequest(this);
}
void TraktRequest::cleanup(TraktReply *reply)
{
reply->deleteLater();
}