QGIS API Documentation 3.41.0-Master (57ec4277f5e)
Loading...
Searching...
No Matches
qgshistoryentrymodel.h
Go to the documentation of this file.
1/***************************************************************************
2 qgshistoryentrymodel.h
3 --------------------------
4 begin : April 2023
5 copyright : (C) 2023 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8/***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16#ifndef QGSHISTORYENTRYMODEL_H
17#define QGSHISTORYENTRYMODEL_H
18
19#include "qgis_gui.h"
20#include "qgis_sip.h"
21#include "qgis.h"
23#include <QAbstractItemModel>
24
25class QWidget;
26class QAction;
27
30class QgsHistoryEntry;
32class QgsHistoryEntryRootNode;
33
34class QgsHistoryEntryDateGroupNode;
35
42class GUI_EXPORT QgsHistoryEntryModel : public QAbstractItemModel
43{
44 Q_OBJECT
45
46 public:
57 QgsHistoryEntryModel( const QString &providerId = QString(), Qgis::HistoryProviderBackends backends = Qgis::HistoryProviderBackend::LocalProfile, QgsHistoryProviderRegistry *registry = nullptr, const QgsHistoryWidgetContext &context = QgsHistoryWidgetContext(), QObject *parent SIP_TRANSFERTHIS = nullptr );
58
59 ~QgsHistoryEntryModel() override;
60 // Implementation of virtual functions from QAbstractItemModel
61
62 int rowCount( const QModelIndex &parent = QModelIndex() ) const final;
63 int columnCount( const QModelIndex &parent = QModelIndex() ) const final;
64 QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const final;
65 QModelIndex parent( const QModelIndex &child ) const final;
66 QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override;
67 Qt::ItemFlags flags( const QModelIndex &index ) const override;
68
72 QgsHistoryEntryNode *index2node( const QModelIndex &index ) const;
73
74 private slots:
75
76 void entryAdded( long long id, const QgsHistoryEntry &entry, Qgis::HistoryProviderBackend backend );
77 void entryUpdated( long long id, const QVariantMap &entry, Qgis::HistoryProviderBackend backend );
78 void historyCleared( Qgis::HistoryProviderBackend backend, const QString &providerId );
79
80 private:
82 QModelIndex node2index( QgsHistoryEntryNode *node ) const;
83 QModelIndex indexOfParentNode( QgsHistoryEntryNode *parentNode ) const;
84
86
87 std::unique_ptr<QgsHistoryEntryRootNode> mRootNode;
88 QgsHistoryProviderRegistry *mRegistry = nullptr;
89 QString mProviderId;
91 QHash<long long, QgsHistoryEntryNode *> mIdToNodeHash;
92
93 friend class QgsHistoryEntryRootNode;
94};
95
96#endif // QGSHISTORYENTRYMODEL_H
HistoryProviderBackend
History provider backends.
Definition qgis.h:3317
@ LocalProfile
Local profile.
QFlags< HistoryProviderBackend > HistoryProviderBackends
Definition qgis.h:3322
Base class for history entry "group" nodes, which contain children of their own.
An item model representing history entries in a hierarchical tree structure.
Base class for nodes representing a QgsHistoryEntry.
Encapsulates a history entry.
The QgsHistoryProviderRegistry is a registry for objects which track user history (i....
Contains settings which reflect the context in which a history widget is shown, e....
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53