1 | // Copyright (C) 2023 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | // |
5 | // W A R N I N G |
6 | // ------------- |
7 | // |
8 | // This file is not part of the QtGraphs API. It exists purely as an |
9 | // implementation detail. This header file may change from version to |
10 | // version without notice, or even be removed. |
11 | // |
12 | // We mean it. |
13 | |
14 | #ifndef ABSTRACTITEMMODELHANDLER_P_H |
15 | #define ABSTRACTITEMMODELHANDLER_P_H |
16 | |
17 | #include "graphsglobal_p.h" |
18 | #include <QtCore/QAbstractItemModel> |
19 | #include <QtCore/QPointer> |
20 | #include <QtCore/QTimer> |
21 | |
22 | QT_BEGIN_NAMESPACE |
23 | |
24 | class AbstractItemModelHandler : public QObject |
25 | { |
26 | Q_OBJECT |
27 | public: |
28 | AbstractItemModelHandler(QObject *parent = 0); |
29 | virtual ~AbstractItemModelHandler(); |
30 | |
31 | virtual void setItemModel(QAbstractItemModel *itemModel); |
32 | virtual QAbstractItemModel *itemModel() const; |
33 | |
34 | public Q_SLOTS: |
35 | virtual void handleColumnsInserted(const QModelIndex &parent, int start, int end); |
36 | virtual void handleColumnsMoved(const QModelIndex &sourceParent, int sourceStart, |
37 | int sourceEnd, const QModelIndex &destinationParent, |
38 | int destinationColumn); |
39 | virtual void handleColumnsRemoved(const QModelIndex &parent, int start, int end); |
40 | virtual void handleDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, |
41 | const QList<int> &roles = QList<int>()); |
42 | virtual void handleLayoutChanged(const QList<QPersistentModelIndex> &parents = QList<QPersistentModelIndex>(), |
43 | QAbstractItemModel::LayoutChangeHint hint = QAbstractItemModel::NoLayoutChangeHint); |
44 | virtual void handleModelReset(); |
45 | virtual void handleRowsInserted(const QModelIndex &parent, int start, int end); |
46 | virtual void handleRowsMoved(const QModelIndex &sourceParent, int sourceStart, int sourceEnd, |
47 | const QModelIndex &destinationParent, int destinationRow); |
48 | virtual void handleRowsRemoved(const QModelIndex &parent, int start, int end); |
49 | |
50 | virtual void handleMappingChanged(); |
51 | virtual void handlePendingResolve(); |
52 | |
53 | Q_SIGNALS: |
54 | void itemModelChanged(const QAbstractItemModel *itemModel); |
55 | |
56 | protected: |
57 | virtual void resolveModel() = 0; |
58 | |
59 | QPointer<QAbstractItemModel> m_itemModel; // Not owned |
60 | bool resolvePending; |
61 | QTimer m_resolveTimer; |
62 | bool m_fullReset; |
63 | |
64 | private: |
65 | Q_DISABLE_COPY(AbstractItemModelHandler) |
66 | }; |
67 | |
68 | QT_END_NAMESPACE |
69 | |
70 | #endif |
71 | |