Akonadi Calendar

incidencetreemodel.h
1 /*
2  SPDX-FileCopyrightText: 2012 Sérgio Martins <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later WITH Qt-Commercial-exception-1.0
5 */
6 
7 #pragma once
8 
9 #include "akonadi-calendar_export.h"
10 #include <Akonadi/Item>
11 
12 #include <QAbstractProxyModel>
13 
14 #include <memory>
15 
16 namespace Akonadi
17 {
18 
19 class IncidenceTreeModelPrivate;
20 
21 /** Hierarchical incidence model.
22  * Useful as a source for TodoModel for example.
23  */
24 class AKONADI_CALENDAR_EXPORT IncidenceTreeModel : public QAbstractProxyModel
25 {
26  Q_OBJECT
27 public:
28  /**
29  * Constructs a new IncidenceTreeModel.
30  */
31  explicit IncidenceTreeModel(QObject *parent = nullptr);
32 
33  /**
34  * Constructs a new IncidenceTreeModel which will only show incidences of
35  * type @p mimeTypes. Common use case is a to-do tree.
36  *
37  * This constructor is offered for performance reasons. The filtering has
38  * zero overhead, and we avoid stacking mime type filter proxy models.
39  *
40  * If you're more concerned about clean design than performance, use the default
41  * constructor and stack a Akonadi::EntityMimeTypeFilterModel on top of this one.
42  */
43  explicit IncidenceTreeModel(const QStringList &mimeTypes, QObject *parent = nullptr);
44 
45  ~IncidenceTreeModel() override;
46 
47  Q_REQUIRED_RESULT int rowCount(const QModelIndex &parent = QModelIndex()) const override;
48  Q_REQUIRED_RESULT int columnCount(const QModelIndex &parent = QModelIndex()) const override;
49 
50  Q_REQUIRED_RESULT QVariant data(const QModelIndex &index, int role) const override;
51 
52  Q_REQUIRED_RESULT QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
53 
54  Q_REQUIRED_RESULT QModelIndex mapFromSource(const QModelIndex &sourceIndex) const override;
55  Q_REQUIRED_RESULT QModelIndex mapToSource(const QModelIndex &proxyIndex) const override;
56 
57  Q_REQUIRED_RESULT QModelIndex parent(const QModelIndex &child) const override;
58 
59  void setSourceModel(QAbstractItemModel *sourceModel) override;
60  Q_REQUIRED_RESULT bool hasChildren(const QModelIndex &parent = QModelIndex()) const override;
61 
62  /**
63  * Returns the akonadi item containing the incidence with @p incidenceUid.
64  */
65  Q_REQUIRED_RESULT Akonadi::Item item(const QString &incidenceUid) const;
66 
67 Q_SIGNALS:
68  /**
69  * This signal is emitted whenever an index changes parent.
70  * The view can then expand the parent if desired.
71  * This is better than the view waiting for "rows moved" signals because those
72  * signals are also sent when the model is initially populated.
73  */
74  void indexChangedParent(const QModelIndex &index);
75 
76  /**
77  * Signals that we finished doing a batch of insertions.
78  *
79  * One rowsInserted() signal from the ETM, will make IncidenceTreeModel generate
80  * several rowsInserted(), layoutChanged() or rowsMoved() signals.
81  *
82  * A tree view can use this signal to know when to call KConfigViewStateSaver::restore()
83  * to restore expansion states. Listening to rowsInserted() signals would be a
84  * performance problem.
85  */
86  void batchInsertionFinished();
87 
88 private:
89  friend class IncidenceTreeModelPrivate;
90  std::unique_ptr<IncidenceTreeModelPrivate> const d;
91 };
92 
93 }
Hierarchical incidence model.
FreeBusyManager::Singleton.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sun Sep 25 2022 03:57:22 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.