Astyle kdelibs
[kdepim.git] / kaddressbook / mainwidget.h
blobae7ffdbbab4f1a4340d4541b7c90642f06dca942
1 /*
2 This file is part of KAddressBook.
4 Copyright (c) 2007 Tobias Koenig <tokoe@kde.org>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License along
17 with this program; if not, write to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #ifndef MAINWIDGET_H
22 #define MAINWIDGET_H
24 #include "kaddressbook_export.h"
25 #include <AkonadiCore/Item>
26 #include <QWidget>
28 namespace GrantleeTheme
30 class GrantleeThemeManager;
32 class QAction;
33 namespace Akonadi
35 class Collection;
36 class ContactGroupViewer;
37 class ContactViewer;
38 class ContactsFilterProxyModel;
39 class EntityMimeTypeFilterModel;
40 class EntityTreeView;
41 class Item;
42 class StandardContactActionManager;
43 class EntityTreeModel;
46 namespace KAddressBookGrantlee
48 class GrantleeContactFormatter;
49 class GrantleeContactGroupFormatter;
52 class ContactSwitcher;
53 class KActionCollection;
54 class KXMLGUIClient;
55 class ModelColumnManager;
56 class QAbstractItemModel;
57 class QItemSelectionModel;
58 class QModelIndex;
59 class QSplitter;
60 class QStackedWidget;
61 class QuickSearchWidget;
62 class XXPortManager;
63 class QActionGroup;
64 class CategorySelectWidget;
65 class CategoryFilterProxyModel;
67 class KADDRESSBOOK_EXPORT MainWidget : public QWidget
69 Q_OBJECT
71 public:
72 explicit MainWidget(KXMLGUIClient *guiClient, QWidget *parent = Q_NULLPTR);
73 ~MainWidget();
75 XXPortManager *importManager() const;
76 void updateQuickSearchText();
78 public Q_SLOTS:
79 void newContact();
80 void newGroup();
81 void print();
82 void printPreview();
83 void configure();
84 void mergeContacts();
85 void slotSearchDuplicateContacts();
87 void handleCommandLine(const QStringList &arguments);
89 private Q_SLOTS:
90 void delayedInit();
92 void itemSelected(const Akonadi::Item &item);
93 void itemSelectionChanged(const QModelIndex &, const QModelIndex &);
94 void selectFirstItem();
96 void setViewMode(QAction *action);
97 void setQRCodeShow(bool on);
99 void restoreState();
100 void saveState();
102 void slotGrantleeThemeSelected();
103 void slotGrantleeThemesUpdated();
104 void slotCheckNewCalendar(const QModelIndex &parent, int begin, int end);
106 void slotSendMail();
107 void slotSendMailsError(const QString &error);
109 void slotSendMails(const QStringList &emails);
111 void slotDebugBaloo();
112 void slotSendVcards();
113 void slotSendVcardsError(const QString &error);
114 void slotServerSideSubscription();
115 void slotCurrentCollectionChanged(const Akonadi::Collection &col);
116 void slotCheckGravatar();
117 private:
118 const Akonadi::Item::List collectSelectedAllContactsItem(QItemSelectionModel *model);
119 void initGrantleeThemeName();
120 void setupGui();
121 void setupActions(KActionCollection *);
122 bool showQRCodes();
123 void setViewMode(int mode);
124 void saveSplitterStates() const;
125 void restoreSplitterStates();
127 QAbstractItemModel *allContactsModel();
130 * Returns the address book collection that is currently
131 * selected by the user or an invalid collection if no
132 * address book is selected.
134 Akonadi::Collection currentAddressBook() const;
136 Akonadi::EntityMimeTypeFilterModel *mCollectionTree;
137 Akonadi::EntityMimeTypeFilterModel *mItemTree;
138 Akonadi::EntityMimeTypeFilterModel *mAllContactsModel;
139 Akonadi::ContactsFilterProxyModel *mContactsFilterModel;
140 CategoryFilterProxyModel *mCategoryFilterModel;
142 QuickSearchWidget *mQuickSearchWidget;
143 Akonadi::EntityTreeView *mCollectionView;
144 Akonadi::EntityTreeView *mItemView;
145 CategorySelectWidget *mCategorySelectWidget;
147 QWidget *mDetailsPane;
148 QStackedWidget *mDetailsViewStack;
149 ContactSwitcher *mContactSwitcher;
151 QSplitter *mMainWidgetSplitter1;
152 QSplitter *mMainWidgetSplitter2;
153 Akonadi::ContactViewer *mContactDetails;
154 Akonadi::ContactGroupViewer *mContactGroupDetails;
155 QWidget *mEmptyDetails;
156 Akonadi::StandardContactActionManager *mActionManager;
157 QItemSelectionModel *mCollectionSelectionModel;
159 QActionGroup *mViewModeGroup;
161 XXPortManager *mXXPortManager;
162 ModelColumnManager *mModelColumnManager;
163 KXMLGUIClient *mXmlGuiClient;
164 KAddressBookGrantlee::GrantleeContactFormatter *mFormatter;
165 KAddressBookGrantlee::GrantleeContactGroupFormatter *mGroupFormatter;
166 GrantleeTheme::GrantleeThemeManager *mGrantleeThemeManager;
167 Akonadi::EntityTreeModel *entityTreeModel() const;
168 QAction *mQuickSearchAction;
169 QAction *mServerSideSubscription;
172 #endif