-
Notifications
You must be signed in to change notification settings - Fork 1
/
MainWindow.h
109 lines (82 loc) · 2.71 KB
/
MainWindow.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
105
106
107
108
109
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <glib.h>
#include <gio/gio.h>
#include <QMainWindow>
#include <QMenu>
#include <QDate>
#include <CMulticalendar.h>
#include <CCalendar.h>
#include "MonthPlug.h"
#include "WeekPlug.h"
#include "AgendaPlug.h"
#include "TodosPlug.h"
#include "JournalsPlug.h"
class MainWindow : public QMainWindow
{
Q_OBJECT
#define DBUS_SERVICE "com.nokia.calendar"
#define DBUS_PATH "/com/nokia/calendar"
#define DBUS_INTERFACE "com.nokia.calendar"
Q_CLASSINFO("D-Bus Interface", "com.nokia.calendar")
public:
MainWindow(bool runInBackground);
void setPlug(Plug *plug);
public slots:
Q_SCRIPTABLE void top_application();
Q_SCRIPTABLE void launch_view(uint type, int stamp, QString componentId, int calendarId = 0);
Q_SCRIPTABLE void open_bday_event(uint, QString contactId);
Q_SCRIPTABLE void mime_open(QString uri);
Q_SCRIPTABLE void deferred_close();
private:
QMenu *windowMenu;
MonthPlug *monthPlug;
WeekPlug *weekPlug;
AgendaPlug *agendaPlug;
TodosPlug *todosPlug;
JournalsPlug *journalsPlug;
Plug *currentPlug;
QAction *monthAction;
QAction *weekAction;
QAction *agendaAction;
QAction *todosAction;
QAction *journalsAction;
QAction *settingsAction;
QActionGroup *plugGroup;
QLayout *mainLayout;
bool runInBackground;
void closeEvent(QCloseEvent *e);
void changeEvent(QEvent *e);
void deleteOldComponents();
QMainWindow *topWindow();
void showComponent(CEvent *event, QMainWindow *parent);
void showComponent(CTodo *todo, QMainWindow *parent);
// Display component C obtained using function Getter
template<class C, C* (CCalendar::*Getter)(string, int&)>
void showComponent(int calendarId, QString componentId)
{
// Check if there is a window which could be used as a parent
if (QMainWindow *topWindow = this->topWindow()) {
int error;
// Get the calendar
if (CCalendar *calendar = CMulticalendar::MCInstance()->getCalendarById(calendarId, error)) {
// Get the component
if (C *component = (calendar->*Getter)(componentId.toLatin1().data(), error)) {
// Fix up and display the component
component->setCalendarId(calendarId);
showComponent(component, topWindow);
delete component;
}
delete calendar;
}
}
}
private slots:
void showMonth(QDate date = QDate());
void showWeek(QDate date = QDate());
void showAgenda(QDate date = QDate());
void showTodos();
void showJournals();
void openSettings();
};
#endif // MAINWINDOW_H