Skip to content

Commit

Permalink
Add QgsProject::write( filename ) convenience function
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Dec 21, 2016
1 parent 4644af3 commit cbac49b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions python/core/qgsproject.sip
Expand Up @@ -144,6 +144,7 @@ class QgsProject : QObject, QgsExpressionContextGenerator
*
*/
bool read( QDomNode& layerNode );
bool write(const QString& filename);

/** Writes the project to a file.
* @param file destination file
Expand Down
7 changes: 7 additions & 0 deletions src/core/qgsproject.cpp
Expand Up @@ -1147,6 +1147,13 @@ bool QgsProject::read( QDomNode &layerNode )
return false;
}

bool QgsProject::write( const QString& filename )
{
mFile.setFileName( filename );

return write();
}

bool QgsProject::write( QFileInfo const &file )
{
mFile.setFileName( file.filePath() );
Expand Down
11 changes: 11 additions & 0 deletions src/core/qgsproject.h
Expand Up @@ -205,6 +205,17 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera
*/
bool read( QDomNode& layerNode );

/**
* Writes the project to a file.
* @param file destination file
* @note calling this implicitly sets the project's filename (see setFileName() )
* @note isDirty() will be set to false if project is successfully written
* @returns true if project was written successfully
*
* \note Added in QGIS 3.0
*/
bool write( const QString& filename );

/** Writes the project to a file.
* @param file destination file
* @note calling this implicitly sets the project's filename (see setFileName() )
Expand Down

0 comments on commit cbac49b

Please sign in to comment.