Skip to content

Latest commit

 

History

History
124 lines (104 loc) · 2.98 KB

calendarnotebookquery.cpp

File metadata and controls

124 lines (104 loc) · 2.98 KB
 
1
2
3
#include "calendarnotebookquery.h"
#include "calendarmanager.h"
May 24, 2019
May 24, 2019
4
CalendarNotebookQuery::CalendarNotebookQuery(QObject *parent) :
5
6
7
QObject(parent),
m_isValid(false)
{
May 24, 2019
May 24, 2019
8
connect(CalendarManager::instance(), SIGNAL(notebooksChanged(QList<CalendarData::Notebook>)),
9
10
11
this, SLOT(updateData()));
}
May 24, 2019
May 24, 2019
12
CalendarNotebookQuery::~CalendarNotebookQuery()
May 24, 2019
May 24, 2019
16
QString CalendarNotebookQuery::targetUid() const
17
18
19
20
{
return m_targetUid;
}
May 24, 2019
May 24, 2019
21
void CalendarNotebookQuery::setTargetUid(const QString &target)
22
23
24
25
26
27
28
29
{
if (target != m_targetUid) {
m_targetUid = target;
updateData();
emit targetUidChanged();
}
}
May 24, 2019
May 24, 2019
30
bool CalendarNotebookQuery::isValid() const
31
32
33
34
{
return m_isValid;
}
May 24, 2019
May 24, 2019
35
QString CalendarNotebookQuery::name() const
36
37
38
39
{
return m_notebook.name;
}
May 24, 2019
May 24, 2019
40
QString CalendarNotebookQuery::description() const
41
42
43
44
{
return m_notebook.description;
}
May 24, 2019
May 24, 2019
45
QString CalendarNotebookQuery::color() const
46
47
48
49
{
return m_notebook.color;
}
May 24, 2019
May 24, 2019
50
int CalendarNotebookQuery::accountId() const
Apr 13, 2015
Apr 13, 2015
51
52
53
54
{
return m_notebook.accountId;
}
May 24, 2019
May 24, 2019
55
QUrl CalendarNotebookQuery::accountIcon() const
Apr 13, 2015
Apr 13, 2015
56
57
58
59
{
return m_notebook.accountIcon;
}
May 24, 2019
May 24, 2019
60
bool CalendarNotebookQuery::isDefault() const
61
62
63
64
{
return m_notebook.isDefault;
}
May 24, 2019
May 24, 2019
65
bool CalendarNotebookQuery::localCalendar() const
66
67
68
69
{
return m_notebook.localCalendar;
}
May 24, 2019
May 24, 2019
70
bool CalendarNotebookQuery::isReadOnly() const
71
72
73
74
{
return m_notebook.readOnly;
}
May 24, 2019
May 24, 2019
75
void CalendarNotebookQuery::updateData()
76
77
{
// fetch new info and signal changes
May 24, 2019
May 24, 2019
78
QList<CalendarData::Notebook> notebooks = CalendarManager::instance()->notebooks();
May 24, 2019
May 24, 2019
80
CalendarData::Notebook notebook;
81
82
83
bool found = false;
for (int i = 0; i < notebooks.length(); ++i) {
May 24, 2019
May 24, 2019
84
CalendarData::Notebook current = notebooks.at(i);
85
86
87
88
89
90
91
92
93
94
if (current.uid == m_targetUid) {
notebook = current;
found = true;
break;
}
}
bool nameUpdated = (notebook.name != m_notebook.name);
bool descriptionUpdated = (notebook.description != m_notebook.description);
bool colorUpdated = (notebook.color != m_notebook.color);
Apr 13, 2015
Apr 13, 2015
95
96
bool accountIdUpdated = (notebook.accountId != m_notebook.accountId);
bool accountIconUpdated = (notebook.accountIcon != m_notebook.accountIcon);
97
98
99
100
101
102
103
104
105
106
107
108
bool isDefaultUpdated = (notebook.isDefault != m_notebook.isDefault);
bool localCalendarUpdated = (notebook.localCalendar != m_notebook.localCalendar);
bool isReadOnlyUpdated = (notebook.readOnly != m_notebook.readOnly);
m_notebook = notebook;
if (nameUpdated)
emit nameChanged();
if (descriptionUpdated)
emit descriptionChanged();
if (colorUpdated)
emit colorChanged();
Apr 13, 2015
Apr 13, 2015
109
110
111
112
if (accountIdUpdated)
emit accountIdChanged();
if (accountIconUpdated)
emit accountIconChanged();
113
114
115
116
117
118
119
120
121
122
123
124
if (isDefaultUpdated)
emit isDefaultChanged();
if (localCalendarUpdated)
emit localCalendarChanged();
if (isReadOnlyUpdated)
emit isReadOnlyChanged();
if (m_isValid != found) {
m_isValid = found;
emit isValidChanged();
}
}