-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathtelegramapp.cpp
75 lines (61 loc) · 1.17 KB
/
telegramapp.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
#include "telegramapp.h"
class TelegramAppPrivate
{
public:
qint32 appId;
QString appHash;
bool valid;
};
TelegramApp::TelegramApp(QObject *parent) :
QObject(parent)
{
p = new TelegramAppPrivate;
p->valid = false;
p->appId = 0;
}
void TelegramApp::setAppId(const qint32 &appId)
{
if(p->appId == appId)
return;
p->appId = appId;
Q_EMIT appIdChanged();
refreshValid();
}
qint32 TelegramApp::appId() const
{
return p->appId;
}
void TelegramApp::setAppHash(const QString &appHash)
{
if(p->appHash == appHash)
return;
p->appHash = appHash;
Q_EMIT appHashChanged();
refreshValid();
}
QString TelegramApp::appHash() const
{
return p->appHash;
}
bool TelegramApp::isValid() const
{
return p->appId && !p->appHash.isEmpty();
}
QStringList TelegramApp::requiredProperties()
{
return QStringList() << FUNCTION_NAME(appHash) << FUNCTION_NAME(appId);
}
void TelegramApp::refreshValid()
{
const bool valid = isValid();
if(valid == p->valid)
return;
p->valid = valid;
Q_EMIT isValidChanged();
}
TelegramApp::~TelegramApp()
{
p->appHash.clear();
refreshValid();
delete p;
}