22#include "moc_qgselevationprofilemanager.cpp"
68 QDomElement profilesElem = element;
69 if ( element.tagName() != QLatin1String(
"ElevationProfiles" ) )
71 profilesElem = element.firstChildElement( QStringLiteral(
"ElevationProfiles" ) );
77 const QDomNodeList profileNodes = profilesElem.childNodes();
79 for (
int i = 0; i < profileNodes.size(); ++i )
81 if ( profileNodes.at( i ).nodeName() != QLatin1String(
"ElevationProfile" ) )
84 const QString profileName = profileNodes.at( i ).toElement().attribute( QStringLiteral(
"name" ) );
87 auto l = std::make_unique< QgsElevationProfile>(
mProject );
88 if ( !l->readXml( profileNodes.at( i ).toElement(), doc, context ) )
104 QDomElement profilesElem = doc.createElement( QStringLiteral(
"ElevationProfiles" ) );
107 QDomElement profileElem = l->writeXml( doc, context );
108 profilesElem.appendChild( profileElem );
117 l->resolveReferences( project );
131 while ( name.isEmpty() || names.contains( name ) )
133 name = tr(
"Elevation Profile %1" ).arg(
id );
QgsElevationProfile * objectByName(const QString &name) const
QList< QgsElevationProfile * > mObjects
bool addObject(QgsElevationProfile *object)
bool removeObject(QgsElevationProfile *object)
QgsAbstractProjectStoredObjectManager(QgsProject *project=nullptr)
void profileRenamed(QgsElevationProfile *profile, const QString &newName)
Emitted when a profile is renamed.
void profileRemoved(const QString &name)
Emitted when a profile was removed from the manager.
QgsElevationProfile * profileByName(const QString &name) const
Returns the profile with a matching name, or nullptr if no matching profiles were found.
void setupObjectConnections(QgsElevationProfile *profile) override
bool readXml(const QDomElement &element, const QDomDocument &doc, const QgsReadWriteContext &context)
Reads the manager's state from a DOM element, restoring all profiles present in the XML document.
QString generateUniqueTitle() const
Generates a unique title for a new profile, which does not clash with any already contained by the ma...
QDomElement writeXml(QDomDocument &doc, const QgsReadWriteContext &context) const
Returns a DOM element representing the state of the manager.
~QgsElevationProfileManager() override
void profileAdded(const QString &name)
Emitted when a profile has been added to the manager.
bool removeProfile(QgsElevationProfile *profile)
Removes a profile from the manager.
void profileAboutToBeAdded(const QString &name)
Emitted when a profile is about to be added to the manager.
void clear()
Removes and deletes all profiles from the manager.
bool addProfile(QgsElevationProfile *profile)
Adds a profile to the manager.
QList< QgsElevationProfile * > profiles() const
Returns a list of all profiles contained in the manager.
void profileAboutToBeRemoved(const QString &name)
Emitted when a profile is about to be removed from the manager.
QgsElevationProfileManager(QgsProject *project=nullptr)
Constructor for QgsElevationProfileManager.
void resolveReferences(const QgsProject *project)
After reading settings from XML, resolves references to any layers in a project that have been read a...
Represents an elevation profile attached to a project.
void nameChanged(const QString &newName)
Emitted when the profile is renamed.
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.
QgsProject * mProject
Associated project.
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.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
A container for the context for various read/write operations on objects.
Scoped object for logging of the runtime for a single operation or group of operations.