Skip to content

Commit cbac49b

Browse files
committedDec 21, 2016
Add QgsProject::write( filename ) convenience function
1 parent 4644af3 commit cbac49b

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed
 

‎python/core/qgsproject.sip

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ class QgsProject : QObject, QgsExpressionContextGenerator
144144
*
145145
*/
146146
bool read( QDomNode& layerNode );
147+
bool write(const QString& filename);
147148

148149
/** Writes the project to a file.
149150
* @param file destination file

‎src/core/qgsproject.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,6 +1147,13 @@ bool QgsProject::read( QDomNode &layerNode )
11471147
return false;
11481148
}
11491149

1150+
bool QgsProject::write( const QString& filename )
1151+
{
1152+
mFile.setFileName( filename );
1153+
1154+
return write();
1155+
}
1156+
11501157
bool QgsProject::write( QFileInfo const &file )
11511158
{
11521159
mFile.setFileName( file.filePath() );

‎src/core/qgsproject.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,17 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera
205205
*/
206206
bool read( QDomNode& layerNode );
207207

208+
/**
209+
* Writes the project to a file.
210+
* @param file destination file
211+
* @note calling this implicitly sets the project's filename (see setFileName() )
212+
* @note isDirty() will be set to false if project is successfully written
213+
* @returns true if project was written successfully
214+
*
215+
* \note Added in QGIS 3.0
216+
*/
217+
bool write( const QString& filename );
218+
208219
/** Writes the project to a file.
209220
* @param file destination file
210221
* @note calling this implicitly sets the project's filename (see setFileName() )

0 commit comments

Comments
 (0)
Please sign in to comment.