Akonadi Calendar

incidencetreemodel.h
1/*
2 SPDX-FileCopyrightText: 2012 Sérgio Martins <iamsergio@gmail.com>
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
16namespace Akonadi
17{
18
19class IncidenceTreeModelPrivate;
20
21/** Hierarchical incidence model.
22 * Useful as a source for TodoModel for example.
23 */
24class AKONADI_CALENDAR_EXPORT IncidenceTreeModel : public QAbstractProxyModel
25{
26 Q_OBJECT
27public:
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 [[nodiscard]] int rowCount(const QModelIndex &parent = QModelIndex()) const override;
48 [[nodiscard]] int columnCount(const QModelIndex &parent = QModelIndex()) const override;
49
50 [[nodiscard]] QVariant data(const QModelIndex &index, int role) const override;
51
52 [[nodiscard]] QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
53
54 [[nodiscard]] QModelIndex mapFromSource(const QModelIndex &sourceIndex) const override;
55 [[nodiscard]] QModelIndex mapToSource(const QModelIndex &proxyIndex) const override;
56
57 [[nodiscard]] QModelIndex parent(const QModelIndex &child) const override;
58
59 void setSourceModel(QAbstractItemModel *sourceModel) override;
60 [[nodiscard]] bool hasChildren(const QModelIndex &parent = QModelIndex()) const override;
61
62 /**
63 * Returns the akonadi item containing the incidence with @p incidenceUid.
64 */
65 [[nodiscard]] Akonadi::Item item(const QString &incidenceUid) const;
66
67Q_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 */
87
88private:
89 friend class IncidenceTreeModelPrivate;
90 std::unique_ptr<IncidenceTreeModelPrivate> const d;
91};
92
93}
Hierarchical incidence model.
void indexChangedParent(const QModelIndex &index)
This signal is emitted whenever an index changes parent.
void batchInsertionFinished()
Signals that we finished doing a batch of insertions.
FreeBusyManager::Singleton.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:17:16 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.