Akonadi

entityorderproxymodel.h
1 /*
2  SPDX-FileCopyrightText: 2010 Klarälvdalens Datakonsult AB,
3  a KDAB Group company, [email protected]
4  SPDX-FileContributor: Stephen Kelly <[email protected]>
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 
18 class KConfigGroup;
19 
20 namespace Akonadi
21 {
22 class 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 <[email protected]>
31  * @since 4.6
32  */
33 class AKONADICORE_EXPORT EntityOrderProxyModel : public QSortFilterProxyModel
34 {
35  Q_OBJECT
36 
37 public:
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  */
48  ~EntityOrderProxyModel() override;
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  Q_REQUIRED_RESULT bool lessThan(const QModelIndex &left, const QModelIndex &right) const override;
67 
68  /**
69  * @reimp
70  */
71  Q_REQUIRED_RESULT bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override;
72 
73  /**
74  * @reimp
75  */
76  Q_REQUIRED_RESULT QModelIndexList match(const QModelIndex &start,
77  int role,
78  const QVariant &value,
79  int hits = 1,
81 
82 protected:
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 
89 private:
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 }
98 
Q_SCRIPTABLE Q_NOREPLY void start()
Represents a collection of PIM items.
Definition: collection.h:61
A model that keeps the order of entities persistent.
DropAction
typedef MatchFlags
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Jun 25 2022 06:00:32 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.