-
Notifications
You must be signed in to change notification settings - Fork 1
/
qalarmdaysvaluebutton.h
104 lines (83 loc) · 2.05 KB
/
qalarmdaysvaluebutton.h
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
95
96
97
98
99
100
101
102
103
104
#ifndef QALARMDAYSVALUEBUTTON_H
#define QALARMDAYSVALUEBUTTON_H
#include <qalarmvaluebutton.h>
#include <QDialog>
#include <QTreeView>
#include <QStandardItemModel>
#include <QMaemo5AbstractPickSelector>
#include <QDialogButtonBox>
#include <libalarm.h>
#include "utils.h"
class QMaemo5DaysPickSelector : public QMaemo5AbstractPickSelector
{
Q_OBJECT
public:
explicit QMaemo5DaysPickSelector(QObject *parent = 0);
~QMaemo5DaysPickSelector();
QWidget *widget(QWidget *parent);
QString currentValueText() const
{
return daysFromWday(days()).join(",");
}
void setDays(uint32_t days)
{
/* Sun, Mon, ... */
days &= ALARM_RECUR_WDAY_ALL;
d = (days >> 1) | ((days & 1) << 6);
updateSelection();
}
uint32_t days() const
{
return ((d << 1) | (d >> 6)) & ALARM_RECUR_WDAY_ALL;
}
private Q_SLOTS:
void viewClicked(const QModelIndex &index);
private:
uint32_t d;
QTreeView *view;
QStandardItemModel *model;
void appendDay(const QString &name);
void checkRow(int row, bool check);
void updateSelection();
friend class DaysPickerDialog;
};
class QAlarmDaysValueButton : public QAlarmValueButton
{
Q_OBJECT
public:
explicit QAlarmDaysValueButton(QWidget *parent = 0);
void setDays(uint32_t days)
{
selector->setDays(days);
}
uint32_t days() const
{
return selector->days();
}
Q_SIGNALS:
void selected(uint32_t) const;
private Q_SLOTS:
void daysSelected(const QString &) const
{
emit selected(selector->days());
}
protected:
QMaemo5DaysPickSelector *selector;
virtual QString valueText() const;
};
class DaysPickerDialog : public QDialog
{
Q_OBJECT
public:
DaysPickerDialog(QMaemo5DaysPickSelector *picker, QWidget *parent);
~DaysPickerDialog();
protected:
void paintEvent(QPaintEvent *e);
private Q_SLOTS:
void accepted();
void orientationChanged();
private:
QMaemo5DaysPickSelector *p;
QDialogButtonBox *box;
};
#endif // QALARMDAYSVALUEBUTTON_H