QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
qgsprojectstoredobjectmanager.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsprojectstoredobjectmanager.h
3 ------------------
4 Date : July 2025
5 Copyright : (C) 2025 Nyall Dawson
6 Email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSPROJECTSTOREDOBJECTMANAGER_H
17#define QGSPROJECTSTOREDOBJECTMANAGER_H
18
19#include "qgis_core.h"
20#include "qgis_sip.h"
21
22#include <QObject>
23
24class QgsProject;
25
40class CORE_EXPORT QgsProjectStoredObjectManagerBase : public QObject
41{
42 Q_OBJECT
43
44 public:
45
50
51 signals:
52
54 void objectAboutToBeAdded( const QString &name );
55
57 void objectAdded( const QString &name );
58
60 void objectRemoved( const QString &name );
61
63 void objectAboutToBeRemoved( const QString &name );
64
65 protected:
66
68 QgsProject *mProject = nullptr;
69
73 void markProjectDirty();
74};
75
90template<class T>
92{
93 public:
94
99
101
105 QList< T * > objects() const;
106
111 T *objectByName( const QString &name ) const;
112
113 protected:
114
116 QList< T * > mObjects;
117
122 void clearObjects();
123
131 bool addObject( T *object SIP_TRANSFER );
132
143 bool removeObject( T *object );
144
149 virtual void setupObjectConnections( T *object );
150
151};
152
153
154#endif // QGSPROJECTSTOREDOBJECTMANAGER_H
T * objectByName(const QString &name) const
Returns the object with a matching name, or nullptr if no matching objects were found.
QList< T * > objects() const
Returns the list of objects contained within the manager.
QList< T * > mObjects
Attached objects, owned by the manager.
bool addObject(T *object)
Adds an object to the manager.
bool removeObject(T *object)
Removes an object from the manager.
QgsAbstractProjectStoredObjectManager(QgsProject *project=nullptr)
Constructor for QgsAbstractProjectStoredObjectManager, for objects attached to the specified project.
virtual void setupObjectConnections(T *object)
Sets up additional connections to an object, called when the object is first added to the manager.
void clearObjects()
Removes and deletes all objects from the manager.
void objectAdded(const QString &name)
Emitted when an object has been added to the manager.
void objectRemoved(const QString &name)
Emitted when an object was removed from the manager.
void objectAboutToBeAdded(const QString &name)
Emitted when an object is about to be added to the manager.
void objectAboutToBeRemoved(const QString &name)
Emitted when an object is about to be removed from the manager.
void markProjectDirty()
Marks the project as dirty.
QgsProjectStoredObjectManagerBase(QgsProject *project=nullptr)
Constructor for QgsProjectStoredObjectManagerBase, for objects attached to the specified project.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition qgsproject.h:109
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_TRANSFER
Definition qgis_sip.h:36