Akonadi Contacts

contactstreemodel.h
1 /*
2  This file is part of Akonadi Contact.
3 
4  SPDX-FileCopyrightText: 2009 Stephen Kelly <[email protected]>
5  SPDX-FileCopyrightText: 2009 Tobias Koenig <[email protected]>
6 
7  SPDX-License-Identifier: LGPL-2.0-or-later
8 */
9 
10 #pragma once
11 
12 #include "akonadi-contact_export.h"
13 
14 #include <entitytreemodel.h>
15 
16 namespace Akonadi
17 {
18 /**
19  * @short A model for contacts and contact groups as available in Akonadi.
20  *
21  * This class provides a model for displaying the contacts and
22  * contact groups which are available from Akonadi.
23  *
24  * Example:
25  *
26  * @code
27  *
28  * // use a separated session for this model
29  * Akonadi::Session *session = new Akonadi::Session( "MySession" );
30  *
31  * Akonadi::ItemFetchScope scope;
32  * // fetch all content of the contacts, including images
33  * scope.fetchFullPayload( true );
34  * // fetch the EntityDisplayAttribute, which contains custom names and icons
35  * scope.fetchAttribute<Akonadi::EntityDisplayAttribute>();
36  *
37  * Akonadi::Monitor *monitor = new Akonadi::Monitor;
38  * monitor->setSession( session );
39  * // include fetching the collection tree
40  * monitor->fetchCollection( true );
41  * // set the fetch scope that shall be used
42  * monitor->setItemFetchScope( scope );
43  * // monitor all collections below the root collection for changes
44  * monitor->setCollectionMonitored( Akonadi::Collection::root() );
45  * // list only contacts and contact groups
46  * monitor->setMimeTypeMonitored( KContacts::Addressee::mimeType(), true );
47  * monitor->setMimeTypeMonitored( KContacts::ContactGroup::mimeType(), true );
48  *
49  * Akonadi::ContactsTreeModel *model = new Akonadi::ContactsTreeModel( monitor );
50  *
51  * Akonadi::ContactsTreeModel::Columns columns;
52  * columns << Akonadi::ContactsTreeModel::FullName;
53  * columns << Akonadi::ContactsTreeModel::AllEmails;
54  * model->setColumns( columns );
55  *
56  * Akonadi::EntityTreeView *view = new Akonadi::EntityTreeView;
57  * view->setModel( model );
58  *
59  * @endcode
60  *
61  * @author Tobias Koenig <[email protected]>
62  * @since 4.5
63  */
64 class AKONADI_CONTACT_EXPORT ContactsTreeModel : public EntityTreeModel
65 {
66  Q_OBJECT
67 
68 public:
69  /**
70  * Describes the columns that can be shown by the model.
71  */
72  enum Column {
73  /**
74  * Shows the formatted name or, if empty, the assembled name.
75  */
77 
78  /**
79  * Shows the family name.
80  */
82 
83  /**
84  * Shows the given name.
85  */
87 
88  /**
89  * Shows the birthday.
90  */
92 
93  /**
94  * Shows the formatted home address.
95  */
97 
98  /**
99  * Shows the formatted business address.
100  */
102 
103  /**
104  * Shows the phone numbers.
105  */
107 
108  /**
109  * Shows the preferred email address.
110  */
112 
113  /**
114  * Shows all email address.
115  */
117 
118  /**
119  * Shows organization name.
120  */
122 
123  /**
124  * Shows the role of a contact.
125  */
127 
128  /**
129  * Shows homepage url.
130  */
132 
133  /**
134  * Shows the note.
135  */
136  Note
137  };
138 
139  /**
140  * Describes a list of columns of the contacts tree model.
141  */
143 
144  /**
145  * Describes the role for contacts and contact groups.
146  */
147  enum Roles {
148  DateRole = EntityTreeModel::UserRole + 1, ///< The QDate object for the current index.
149  UserRole = DateRole + 42
150  };
151 
152  /**
153  * Creates a new contacts tree model.
154  *
155  * @param monitor The Monitor whose entities should be represented in the model.
156  * @param parent The parent object.
157  */
158  explicit ContactsTreeModel(Monitor *monitor, QObject *parent = nullptr);
159 
160  /**
161  * Destroys the contacts tree model.
162  */
163  ~ContactsTreeModel() override;
164 
165  /**
166  * Sets the @p columns that the model should show.
167  */
168  void setColumns(const Columns &columns);
169 
170  /**
171  * Returns the columns that the model currently shows.
172  */
173  Q_REQUIRED_RESULT Columns columns() const;
174 
175  //@cond PRIVATE
176  Q_REQUIRED_RESULT QVariant entityData(const Item &item, int column, int role = Qt::DisplayRole) const override;
177  Q_REQUIRED_RESULT QVariant entityData(const Collection &collection, int column, int role = Qt::DisplayRole) const override;
178  Q_REQUIRED_RESULT QVariant entityHeaderData(int section, Qt::Orientation orientation, int role, HeaderGroup headerGroup) const override;
179  Q_REQUIRED_RESULT int entityColumnCount(HeaderGroup headerGroup) const override;
180  //@endcond
181 
182 private:
183  //@cond PRIVATE
184  class Private;
185  Private *const d;
186  //@endcond
187 };
188 }
189 
Column
Describes the columns that can be shown by the model.
Shows the formatted home address.
Shows the preferred email address.
DisplayRole
Shows the formatted name or, if empty, the assembled name.
A model for contacts and contact groups as available in Akonadi.
Shows the role of a contact.
Orientation
Shows the formatted business address.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Thu Jun 17 2021 23:09:02 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.