QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
gui
history
qgshistoryentrynode.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgshistoryentrynode.cpp
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
#include "
qgshistoryentrynode.h
"
17
18
//
19
// QgsHistoryEntryNode
20
//
21
22
QgsHistoryEntryNode::~QgsHistoryEntryNode
() =
default
;
23
24
int
QgsHistoryEntryNode::childCount
()
const
25
{
26
return
0;
27
}
28
29
QString
QgsHistoryEntryNode::html
(
const
QgsHistoryWidgetContext
& )
const
30
{
31
return
QString();
32
}
33
34
QWidget *
QgsHistoryEntryNode::createWidget
(
const
QgsHistoryWidgetContext
& )
35
{
36
return
nullptr
;
37
}
38
39
bool
QgsHistoryEntryNode::doubleClicked
(
const
QgsHistoryWidgetContext
& )
40
{
41
return
false
;
42
}
43
44
void
QgsHistoryEntryNode::populateContextMenu
( QMenu *,
const
QgsHistoryWidgetContext
& )
45
{}
46
47
bool
QgsHistoryEntryNode::matchesString
(
const
QString &
string
)
const
48
{
49
if
(
string
.isEmpty() )
50
return
true
;
51
52
return
data
( Qt::DisplayRole ).toString().contains(
string
, Qt::CaseInsensitive );
53
}
54
55
56
//
57
// QgsHistoryEntryGroup
58
//
59
60
QgsHistoryEntryGroup::~QgsHistoryEntryGroup
() =
default
;
61
62
void
QgsHistoryEntryGroup::addChild
(
QgsHistoryEntryNode
*child )
63
{
64
if
( !child )
65
return
;
66
67
Q_ASSERT( !child->mParent );
68
child->mParent =
this
;
69
70
mChildren
.emplace_back( child );
71
}
72
73
void
QgsHistoryEntryGroup::insertChild
(
int
index,
QgsHistoryEntryNode
*child )
74
{
75
if
( !child )
76
return
;
77
78
Q_ASSERT( !child->mParent );
79
child->mParent =
this
;
80
81
mChildren
.insert(
mChildren
.begin() + index, std::unique_ptr<QgsHistoryEntryNode>( child ) );
82
}
83
84
int
QgsHistoryEntryGroup::indexOf
(
QgsHistoryEntryNode
*child )
const
85
{
86
if
( child->mParent !=
this
)
87
return
-1;
88
89
auto
it = std::find_if(
mChildren
.begin(),
mChildren
.end(), [&](
const
std::unique_ptr<QgsHistoryEntryNode> &p ) { return p.get() == child; } );
90
if
( it !=
mChildren
.end() )
91
return
static_cast<
int
>
( std::distance(
mChildren
.begin(), it ) );
92
return
-1;
93
}
94
95
QgsHistoryEntryNode
*
QgsHistoryEntryGroup::childAt
(
int
index )
96
{
97
if
(
static_cast<
std::size_t
>
( index ) >=
mChildren
.size() )
98
return
nullptr
;
99
100
return
mChildren
[index].get();
101
}
102
103
void
QgsHistoryEntryGroup::removeChildAt
(
int
index )
104
{
105
if
(
static_cast<
std::size_t
>
( index ) >=
mChildren
.size() )
106
return
;
107
108
mChildren
.erase(
mChildren
.begin() + index );
109
}
110
111
void
QgsHistoryEntryGroup::clear
()
112
{
113
mChildren
.clear();
114
}
115
116
int
QgsHistoryEntryGroup::childCount
()
const
117
{
118
return
static_cast<
int
>
(
mChildren
.size() );
119
}
QgsHistoryEntryGroup::childCount
int childCount() const final
Returns the number of child nodes owned by this node.
Definition
qgshistoryentrynode.cpp:116
QgsHistoryEntryGroup::addChild
void addChild(QgsHistoryEntryNode *child)
Adds a child node to this node.
Definition
qgshistoryentrynode.cpp:62
QgsHistoryEntryGroup::removeChildAt
void removeChildAt(int index)
Removes the child at the specified index.
Definition
qgshistoryentrynode.cpp:103
QgsHistoryEntryGroup::~QgsHistoryEntryGroup
~QgsHistoryEntryGroup() override
QgsHistoryEntryGroup::childAt
QgsHistoryEntryNode * childAt(int index)
Returns the child at the specified index.
Definition
qgshistoryentrynode.cpp:95
QgsHistoryEntryGroup::indexOf
int indexOf(QgsHistoryEntryNode *child) const
Returns the index of the specified child node.
Definition
qgshistoryentrynode.cpp:84
QgsHistoryEntryGroup::insertChild
void insertChild(int index, QgsHistoryEntryNode *child)
Inserts a child node at the specified index.
Definition
qgshistoryentrynode.cpp:73
QgsHistoryEntryGroup::clear
void clear()
Clears the group, removing all its children.
Definition
qgshistoryentrynode.cpp:111
QgsHistoryEntryGroup::mChildren
std::deque< std::unique_ptr< QgsHistoryEntryNode > > mChildren
Definition
qgshistoryentrynode.h:176
QgsHistoryEntryNode::createWidget
virtual QWidget * createWidget(const QgsHistoryWidgetContext &context)
Returns a new widget which should be shown to users when selecting the node.
Definition
qgshistoryentrynode.cpp:34
QgsHistoryEntryNode::html
virtual QString html(const QgsHistoryWidgetContext &context) const
Returns a HTML formatted text string which should be shown to a user when selecting the node.
Definition
qgshistoryentrynode.cpp:29
QgsHistoryEntryNode::~QgsHistoryEntryNode
virtual ~QgsHistoryEntryNode()
QgsHistoryEntryNode::matchesString
virtual bool matchesString(const QString &searchString) const
Returns true if the node matches the specified searchString, and should be shown in filtered results ...
Definition
qgshistoryentrynode.cpp:47
QgsHistoryEntryNode::data
virtual QVariant data(int role=Qt::DisplayRole) const =0
Returns the node's data for the specified model role.
QgsHistoryEntryNode::populateContextMenu
virtual void populateContextMenu(QMenu *menu, const QgsHistoryWidgetContext &context)
Allows the node to populate a context menu before display to the user.
Definition
qgshistoryentrynode.cpp:44
QgsHistoryEntryNode::QgsHistoryEntryNode
QgsHistoryEntryNode()=default
QgsHistoryEntryNode::childCount
virtual int childCount() const
Returns the number of child nodes owned by this node.
Definition
qgshistoryentrynode.cpp:24
QgsHistoryEntryNode::doubleClicked
virtual bool doubleClicked(const QgsHistoryWidgetContext &context)
Called when the node is double-clicked.
Definition
qgshistoryentrynode.cpp:39
QgsHistoryWidgetContext
Contains settings which reflect the context in which a history widget is shown, e....
Definition
qgshistorywidgetcontext.h:33
qgshistoryentrynode.h
Generated on
for QGIS API Documentation by
1.17.0