-
Notifications
You must be signed in to change notification settings - Fork 1
/
CalendarPickSelector.cpp
59 lines (42 loc) · 1.39 KB
/
CalendarPickSelector.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
#include "CalendarPickSelector.h"
#include <QMaemo5ValueButton>
#include <CMulticalendar.h>
#include "CalendarPickDialog.h"
#include "CWrapper.h"
CalendarPickSelector::CalendarPickSelector(QObject *parent) : QMaemo5AbstractPickSelector(parent)
{
// This is the ID of the default calendar, so it should always be valid
setCalendar(1);
}
void CalendarPickSelector::setCalendar(int calendarId)
{
int error = 0;
CCalendar *calendar = CMulticalendar::MCInstance()->getCalendarById(calendarId, error);
if (calendar) {
currentCalendarId = calendarId;
currentCalendarName = CWrapper::calendarName(calendar->getCalendarName());
QMaemo5ValueButton *button = qobject_cast<QMaemo5ValueButton*>(this->parent());
if (button)
button->setIcon(QIcon::fromTheme(CWrapper::colorIcon(calendar->getCalendarColor())));
delete calendar;
emit selected(currentCalendarName);
}
}
QString CalendarPickSelector::currentValueText() const
{
return currentCalendarName;
}
int CalendarPickSelector::currentId() const
{
return currentCalendarId;
}
QWidget* CalendarPickSelector::widget(QWidget *parent)
{
CalendarPickDialog *dialog = new CalendarPickDialog(parent, currentId());
connect(dialog, SIGNAL(selected(int)), this, SLOT(onSelected(int)));
return dialog;
}
void CalendarPickSelector::onSelected(int id)
{
setCalendar(id);
}