QGIS API Documentation 3.99.0-Master (26c88405ac0)
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.h"
20#include "qgis_gui.h"
21#include "qgis_sip.h"
23
24#include <QAbstractItemModel>
25
26class QWidget;
27class QAction;
28
31class QgsHistoryEntry;
33class QgsHistoryEntryRootNode;
34
35class QgsHistoryEntryDateGroupNode;
36
43class GUI_EXPORT QgsHistoryEntryModel : public QAbstractItemModel
44{
45 Q_OBJECT
46
47 public:
48
59 QgsHistoryEntryModel( const QString &providerId = QString(), Qgis::HistoryProviderBackends backends = Qgis::HistoryProviderBackend::LocalProfile, QgsHistoryProviderRegistry *registry = nullptr, const QgsHistoryWidgetContext &context = QgsHistoryWidgetContext(), QObject *parent SIP_TRANSFERTHIS = nullptr );
60
61 ~QgsHistoryEntryModel() override;
62 // Implementation of virtual functions from QAbstractItemModel
63
64 int rowCount( const QModelIndex &parent = QModelIndex() ) const final;
65 int columnCount( const QModelIndex &parent = QModelIndex() ) const final;
66 QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const final;
67 QModelIndex parent( const QModelIndex &child ) const final;
68 QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const override;
69 Qt::ItemFlags flags( const QModelIndex &index ) const override;
70
74 QgsHistoryEntryNode *index2node( const QModelIndex &index ) const;
75
76 private slots:
77
78 void entryAdded( long long id, const QgsHistoryEntry &entry, Qgis::HistoryProviderBackend backend );
79 void entryUpdated( long long id, const QVariantMap &entry, Qgis::HistoryProviderBackend backend );
80 void historyCleared( Qgis::HistoryProviderBackend backend, const QString &providerId );
81
82 private:
84 QModelIndex node2index( QgsHistoryEntryNode *node ) const;
85 QModelIndex indexOfParentNode( QgsHistoryEntryNode *parentNode ) const;
86
88
89 std::unique_ptr<QgsHistoryEntryRootNode> mRootNode;
90 QgsHistoryProviderRegistry *mRegistry = nullptr;
91 QString mProviderId;
93 QHash<long long, QgsHistoryEntryNode *> mIdToNodeHash;
94
96};
97
98#endif // QGSHISTORYENTRYMODEL_H
HistoryProviderBackend
History provider backends.
Definition qgis.h:3503
@ LocalProfile
Local profile.
Definition qgis.h:3504
QFlags< HistoryProviderBackend > HistoryProviderBackends
Definition qgis.h:3508
Base class for history entry "group" nodes, which contain children of their own.
QgsHistoryEntryModel(const QString &providerId=QString(), Qgis::HistoryProviderBackends backends=Qgis::HistoryProviderBackend::LocalProfile, QgsHistoryProviderRegistry *registry=nullptr, const QgsHistoryWidgetContext &context=QgsHistoryWidgetContext(), QObject *parent=nullptr)
Constructor for QgsHistoryEntryModel, with the specified parent object.
QgsHistoryEntryNode * index2node(const QModelIndex &index) const
Returns node for given index.
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
Qt::ItemFlags flags(const QModelIndex &index) const override
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const final
friend class QgsHistoryEntryRootNode
int columnCount(const QModelIndex &parent=QModelIndex()) const final
QModelIndex parent(const QModelIndex &child) const final
int rowCount(const QModelIndex &parent=QModelIndex()) const final
Base class for nodes representing a QgsHistoryEntry.
Encapsulates a history entry.
A registry for objects which track user history (i.e.
Contains settings which reflect the context in which a history widget is shown, e....
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53