-
Notifications
You must be signed in to change notification settings - Fork 1
/
qalarmsnoozevaluebutton.cpp
69 lines (51 loc) · 1.6 KB
/
qalarmsnoozevaluebutton.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
#include <QListView>
#include <osso-intl.h>
#include "qalarmsnoozevaluebutton.h"
#define MAX_SNOOZE_ITEMS 4
QWidget *QAlarmSnoozeListPickSelector::widget(QWidget *parent)
{
QWidget *widget;
QListView *_view = new QListView();
_view->setModel(model());
if (_view->sizeHintForRow(0) > 0)
_view->setMinimumHeight(_view->sizeHintForRow(0) *
(MAX_SNOOZE_ITEMS < 5 ? MAX_SNOOZE_ITEMS : 5));
setView(_view);
widget = QMaemo5ListPickSelector::widget(parent);
return widget;
}
QAlarmSnoozeValueButton::QAlarmSnoozeValueButton(QWidget *parent) :
QAlarmValueButton(parent),
selector(new QAlarmSnoozeListPickSelector(this))
{
setText(_("dati_fi_snooze_time"));
for (int i = 1; i <= MAX_SNOOZE_ITEMS; i ++)
{
QStandardItem *item;
QString rowText =_("cloc_va_diff_hours_mins");
rowText.replace("%s %d", QString::number(i * 5));
item = new QStandardItem(rowText);
item->setTextAlignment(Qt::AlignCenter);
item->setEditable(false);
model.appendRow(item);
}
selector->setModel(&model);
setPickSelector(selector);
connect(selector, SIGNAL(selected(QString)),
this, SLOT(snoozeSelected(QString)));
}
void QAlarmSnoozeValueButton::setSnooze(int minutes)
{
int i = (minutes / 5) - 1;
if (i >= MAX_SNOOZE_ITEMS)
i = MAX_SNOOZE_ITEMS - 1;
selector->setCurrentIndex(i);
}
int QAlarmSnoozeValueButton::getSnooze()
{
return (selector->currentIndex() + 1) * 5;
}
void QAlarmSnoozeValueButton::snoozeSelected(QString)
{
emit selected(getSnooze());
}