Fix Bug 361605 - kmail crash on double click email
[kdepim.git] / korganizer / akonadicollectionview.h
blob5828e9f321d2091de27db28892505be5b46df128
1 /*
2 This file is part of KOrganizer.
4 Copyright (c) 2003,2004 Cornelius Schumacher <schumacher@kde.org>
5 Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
6 Copyright (C) 2009 Sebastian Sauer <sebsauer@kdab.net>
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License along
19 with this program; if not, write to the Free Software Foundation, Inc.,
20 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 As a special exception, permission is given to link this program
23 with any edition of Qt, and distribute the resulting executable,
24 without including the source code for Qt in the source distribution.
27 #ifndef KORG_AKONADICOLLECTIONVIEW_H
28 #define KORG_AKONADICOLLECTIONVIEW_H
30 #include "calendarview.h"
31 #include <AkonadiCore/Collection>
32 #include "views/collectionview/reparentingmodel.h"
33 #include "views/collectionview/controller.h"
35 class AkonadiCollectionView;
37 namespace Akonadi
39 class EntityTreeView;
40 class EntityTreeModel;
41 class StandardCalendarActionManager;
44 class QAction;
45 class KJob;
46 class QAbstractProxyModel;
47 class QModelIndex;
49 /**
50 * The factory for AkonadiCollectionView instances.
52 class AkonadiCollectionViewFactory : public CalendarViewExtension::Factory
54 public:
55 explicit AkonadiCollectionViewFactory(CalendarView *view);
57 CalendarView *view() const;
58 AkonadiCollectionView *collectionView() const;
60 CalendarViewExtension *create(QWidget *) Q_DECL_OVERRIDE;
62 private:
63 CalendarView *mView;
64 AkonadiCollectionView *mAkonadiCollectionView;
67 class NewNodeExpander;
69 /**
70 * This class provides a view of calendar resources.
72 class AkonadiCollectionView : public CalendarViewExtension
74 Q_OBJECT
75 public:
76 explicit AkonadiCollectionView(CalendarView *view, bool hasContextMenu = true,
77 QWidget *parent = Q_NULLPTR);
78 ~AkonadiCollectionView();
80 Akonadi::EntityTreeView *view() const;
82 KCheckableProxyModel *collectionSelectionProxyModel() const;
83 void setCollectionSelectionProxyModel(KCheckableProxyModel *);
85 Akonadi::Collection selectedCollection() const;
86 Akonadi::Collection::List checkedCollections() const;
87 bool isChecked(const Akonadi::Collection &) const;
88 public Q_SLOTS:
89 void edit_disable();
90 void edit_enable();
92 Q_SIGNALS:
93 void resourcesChanged(bool enabled);
94 void resourcesAddedRemoved();
95 void defaultResourceChanged(const Akonadi::Collection &);
96 void colorsChanged();
98 private Q_SLOTS:
99 void updateView();
100 void updateMenu();
102 void newCalendar();
103 void newCalendarDone(KJob *);
105 void deleteCalendar();
106 void deleteCalendarDone(KJob *);
107 void rowsInserted(const QModelIndex &, int, int);
108 void assignColor();
109 void disableColor();
110 void setDefaultCalendar();
111 void onSearchIsActive(bool);
112 void onAction(const QModelIndex &index, int action);
113 void slotServerSideSubscription();
114 private:
115 Akonadi::EntityTreeModel *entityTreeModel() const;
117 Akonadi::StandardCalendarActionManager *mActionManager;
118 Akonadi::EntityTreeView *mCollectionView;
119 QStackedWidget *mStackedWidget;
120 QAbstractProxyModel *mBaseModel;
121 KCheckableProxyModel *mSelectionProxyModel;
122 QAction *mAssignColor;
123 QAction *mDisableColor;
124 QAction *mDefaultCalendar;
125 QAction *mEnableAction;
126 QAction *mServerSideSubscription;
127 bool mNotSendAddRemoveSignal;
128 bool mWasDefaultCalendar;
129 bool mHasContextMenu;
130 Controller *mController;
131 NewNodeExpander *mNewNodeExpander;
134 #endif