Akonadi

entityorderproxymodel.h
1/*
2 SPDX-FileCopyrightText: 2010 Klarälvdalens Datakonsult AB,
3 a KDAB Group company, info@kdab.net
4 SPDX-FileContributor: Stephen Kelly <stephen@kdab.com>
5
6 SPDX-License-Identifier: LGPL-2.0-or-later
7*/
8
9#pragma once
10
11#include "akonadicore_export.h"
12#include "collection.h"
13
14#include <QSortFilterProxyModel>
15
16#include <memory>
17
18class KConfigGroup;
19
20namespace Akonadi
21{
22class EntityOrderProxyModelPrivate;
23
24/**
25 * @short A model that keeps the order of entities persistent.
26 *
27 * This proxy maintains the order of entities in a tree. The user can re-order
28 * items and the new order will be persisted restored on reset or restart.
29 *
30 * @author Stephen Kelly <stephen@kdab.com>
31 * @since 4.6
32 */
33class AKONADICORE_EXPORT EntityOrderProxyModel : public QSortFilterProxyModel
34{
35 Q_OBJECT
36
37public:
38 /**
39 * Creates a new entity order proxy model.
40 *
41 * @param parent The parent object.
42 */
43 explicit EntityOrderProxyModel(QObject *parent = nullptr);
44
45 /**
46 * Destroys the entity order proxy model.
47 */
49
50 /**
51 * Sets the config @p group that will be used for storing the order.
52 */
53 void setOrderConfig(const KConfigGroup &group);
54
55 /**
56 * Saves the order.
57 */
58 void saveOrder();
59
60 void clearOrder(const QModelIndex &index);
61 void clearTreeOrder();
62
63 /**
64 * @reimp
65 */
66 [[nodiscard]] bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
67
68 /**
69 * @reimp
70 */
71 [[nodiscard]] bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
72
73 /**
74 * @reimp
75 */
76 [[nodiscard]] QModelIndexList match(const QModelIndex &start,
77 int role,
78 const QVariant &value,
79 int hits = 1,
81
82protected:
83 std::unique_ptr<EntityOrderProxyModelPrivate> const d_ptr;
84
85 virtual QString parentConfigString(const QModelIndex &index) const;
86 virtual QString configString(const QModelIndex &index) const;
87 virtual Akonadi::Collection parentCollection(const QModelIndex &index) const;
88
89private:
90 QStringList configStringsForDroppedUrls(const QList<QUrl> &urls, const Akonadi::Collection &parentCol, bool *containsMove) const;
91
92 /// @cond PRIVATE
93 Q_DECLARE_PRIVATE(EntityOrderProxyModel)
94 /// @endcond
95};
96
97}
Represents a collection of PIM items.
Definition collection.h:62
A model that keeps the order of entities persistent.
~EntityOrderProxyModel() override
Destroys the entity order proxy model.
Q_SCRIPTABLE Q_NOREPLY void start()
Helper integration between Akonadi and Qt.
DropAction
typedef MatchFlags
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:01:42 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.