QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
qgshistoryentrynode.h
Go to the documentation of this file.
1/***************************************************************************
2 qgshistoryentrynode.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 QGSHISTORYENTRYNODE_H
17#define QGSHISTORYENTRYNODE_H
18
19#include <deque>
20#include <memory>
21
22#include "qgis.h"
23#include "qgis_gui.h"
24#include "qgis_sip.h"
25
26#include <QString>
27#include <QVariantMap>
28
29class QWidget;
30class QAction;
31class QMenu;
34
41class GUI_EXPORT QgsHistoryEntryNode
42{
43 public:
46
47 QgsHistoryEntryNode( const QgsHistoryEntryNode &other ) = delete;
49
55 QgsHistoryEntryGroup *parent() { return mParent; }
56
60 virtual QVariant data( int role = Qt::DisplayRole ) const = 0;
61
65 virtual int childCount() const;
66
75 virtual QString html( const QgsHistoryWidgetContext &context ) const;
76
85 virtual QWidget *createWidget( const QgsHistoryWidgetContext &context ) SIP_FACTORY;
86
93 virtual bool doubleClicked( const QgsHistoryWidgetContext &context );
94
100 virtual void populateContextMenu( QMenu *menu, const QgsHistoryWidgetContext &context );
101
109 virtual bool matchesString( const QString &searchString ) const;
110
111 private:
112#ifdef SIP_RUN
114#endif
115
116 QgsHistoryEntryGroup *mParent = nullptr;
117
119};
120
121
129{
130 public:
133
136
143
149 void insertChild( int index, QgsHistoryEntryNode *child SIP_TRANSFER );
150
156 int indexOf( QgsHistoryEntryNode *child ) const;
157
161 QgsHistoryEntryNode *childAt( int index );
162
166 void removeChildAt( int index );
167
171 void clear();
172
173 int childCount() const final;
174
175 protected:
176 std::deque<std::unique_ptr<QgsHistoryEntryNode>> mChildren SIP_SKIP;
177
178 private:
179#ifdef SIP_RUN
181#endif
182};
183
184#endif // QGSHISTORYENTRYNODE_H
Base class for history entry "group" nodes, which contain children of their own.
QgsHistoryEntryGroup & operator=(const QgsHistoryEntryGroup &other)=delete
QgsHistoryEntryGroup()=default
int childCount() const final
Returns the number of child nodes owned by this node.
QgsHistoryEntryGroup(const QgsHistoryEntryGroup &other)=delete
void addChild(QgsHistoryEntryNode *child)
Adds a child node to this node.
void removeChildAt(int index)
Removes the child at the specified index.
~QgsHistoryEntryGroup() override
QgsHistoryEntryNode * childAt(int index)
Returns the child at the specified index.
int indexOf(QgsHistoryEntryNode *child) const
Returns the index of the specified child node.
void insertChild(int index, QgsHistoryEntryNode *child)
Inserts a child node at the specified index.
void clear()
Clears the group, removing all its children.
std::deque< std::unique_ptr< QgsHistoryEntryNode > > mChildren
virtual QWidget * createWidget(const QgsHistoryWidgetContext &context)
Returns a new widget which should be shown to users when selecting the node.
virtual QString html(const QgsHistoryWidgetContext &context) const
Returns a HTML formatted text string which should be shown to a user when selecting the node.
QgsHistoryEntryNode & operator=(const QgsHistoryEntryNode &other)=delete
virtual ~QgsHistoryEntryNode()
virtual bool matchesString(const QString &searchString) const
Returns true if the node matches the specified searchString, and should be shown in filtered results ...
virtual QVariant data(int role=Qt::DisplayRole) const =0
Returns the node's data for the specified model role.
virtual void populateContextMenu(QMenu *menu, const QgsHistoryWidgetContext &context)
Allows the node to populate a context menu before display to the user.
QgsHistoryEntryNode()=default
friend class QgsHistoryEntryGroup
QgsHistoryEntryNode(const QgsHistoryEntryNode &other)=delete
QgsHistoryEntryGroup * parent()
Returns the node's parent node.
virtual int childCount() const
Returns the number of child nodes owned by this node.
virtual bool doubleClicked(const QgsHistoryWidgetContext &context)
Called when the node is double-clicked.
Contains settings which reflect the context in which a history widget is shown, e....
#define SIP_SKIP
Definition qgis_sip.h:134
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_FACTORY
Definition qgis_sip.h:84