Build with clang.
[kdepim.git] / kalarm / resourceselector.h
blobd46df73f13ac6eb89abea9517ff8465e04429599
1 /*
2 * resourceselector.h - alarm calendar resource selection widget
3 * Program: kalarm
4 * Copyright © 2006-2011 by David Jarvie <djarvie@kde.org>
5 * Based on KOrganizer's ResourceView class and KAddressBook's ResourceSelection class,
6 * Copyright (C) 2003,2004 Cornelius Schumacher <schumacher@kde.org>
7 * Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
8 * Copyright (c) 2004 Tobias Koenig <tokoe@kde.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with this program; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 #ifndef RESOURCESELECTOR_H
26 #define RESOURCESELECTOR_H
28 #ifdef USE_AKONADI
29 #include "akonadimodel.h"
30 #include "collectionmodel.h"
32 #include <akonadi/agentinstance.h>
33 #else
34 #include "alarmresource.h"
35 #include "alarmresources.h"
36 #endif
38 #include <QModelIndex>
39 #include <QFrame>
40 #include <QSize>
41 #ifdef USE_AKONADI
42 #include <QList>
43 #endif
45 class QPushButton;
46 class QResizeEvent;
47 class KAction;
48 class KActionCollection;
49 class KToggleAction;
50 class KComboBox;
51 class KMenu;
52 class ResourceView;
53 #ifdef USE_AKONADI
54 class AkonadiModel;
55 class AkonadiResourceCreator;
56 class CollectionFilterCheckListModel;
57 namespace Akonadi {
58 class Collection;
60 #else
61 using KCal::ResourceCalendar;
62 #endif
65 /**
66 This class provides a view of alarm calendar resources.
68 class ResourceSelector : public QFrame
70 Q_OBJECT
71 public:
72 #ifdef USE_AKONADI
73 explicit ResourceSelector(QWidget* parent = 0);
74 #else
75 explicit ResourceSelector(AlarmResources*, QWidget* parent = 0);
76 AlarmResources* calendar() const { return mCalendar; }
77 #endif
78 void initActions(KActionCollection*);
79 void setContextMenu(KMenu*);
81 signals:
82 void resized(const QSize& oldSize, const QSize& newSize);
84 protected:
85 virtual void resizeEvent(QResizeEvent*);
87 private slots:
88 void alarmTypeSelected();
89 void addResource();
90 void editResource();
91 #ifdef USE_AKONADI
92 void updateResource();
93 #endif
94 void removeResource();
95 void selectionChanged();
96 void contextMenuRequested(const QPoint&);
97 void reloadResource();
98 void saveResource();
99 void setStandard();
100 void setColour();
101 void clearColour();
102 void importCalendar();
103 void exportCalendar();
104 void showInfo();
105 void archiveDaysChanged(int days);
106 #ifdef USE_AKONADI
107 void resourceAdded(AkonadiResourceCreator*, bool success);
108 void slotCollectionAdded(const Akonadi::Collection&);
109 #else
110 void slotStatusChanged(AlarmResource*, AlarmResources::Change);
111 #endif
112 void reinstateAlarmTypeScrollBars();
114 private:
115 KAlarm::CalEvent::Type currentResourceType() const;
116 #ifdef USE_AKONADI
117 Akonadi::Collection currentResource() const;
119 CollectionView* mListView;
120 QList<Akonadi::AgentInstance> mAddAgents; // agent added by addResource()
121 #else
122 AlarmResource* currentResource() const;
124 AlarmResources* mCalendar;
125 ResourceView* mListView;
126 #endif
127 KComboBox* mAlarmType;
128 QPushButton* mAddButton;
129 QPushButton* mDeleteButton;
130 QPushButton* mEditButton;
131 KAlarm::CalEvent::Type mCurrentAlarmType;
132 KMenu* mContextMenu;
133 KAction* mActionReload;
134 KAction* mActionSave;
135 KAction* mActionShowDetails;
136 KAction* mActionSetColour;
137 KAction* mActionClearColour;
138 KAction* mActionEdit;
139 #ifdef USE_AKONADI
140 KAction* mActionUpdate;
141 #endif
142 KAction* mActionRemove;
143 KAction* mActionImport;
144 KAction* mActionExport;
145 KToggleAction* mActionSetDefault;
148 #endif
150 // vim: et sw=4: