Skip to content

Commit 0f4d684

Browse files
committed
Create some properties on QgsProject
1 parent 5fc3424 commit 0f4d684

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/core/qgsproject.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,17 @@ void QgsProject::setDirty( bool b )
414414

415415
void QgsProject::setFileName( const QString& name )
416416
{
417+
if ( name == imp_->file.fileName() )
418+
return;
419+
420+
QString oldHomePath = homePath();
421+
417422
imp_->file.setFileName( name );
423+
emit fileNameChanged();
424+
425+
QString newHomePath = homePath();
426+
if ( newHomePath != oldHomePath )
427+
emit homePathChanged();
418428

419429
setDirty( true );
420430
}

src/core/qgsproject.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ class CORE_EXPORT QgsProject : public QObject
7272
{
7373
Q_OBJECT
7474
Q_PROPERTY( QStringList nonIdentifiableLayers READ nonIdentifiableLayers WRITE setNonIdentifiableLayers NOTIFY nonIdentifiableLayersChanged )
75+
Q_PROPERTY( QString fileName READ fileName WRITE setFileName NOTIFY fileNameChanged )
76+
Q_PROPERTY( QString homePath READ homePath NOTIFY homePathChanged )
7577

7678
public:
7779

@@ -455,6 +457,12 @@ class CORE_EXPORT QgsProject : public QObject
455457
//! Emitted when the list of layer which are excluded from map identification changes
456458
void nonIdentifiableLayersChanged( QStringList nonIdentifiableLayers );
457459

460+
//! Emitted when the file name of the project changes
461+
void fileNameChanged();
462+
463+
//! Emitted when the home path of the project changes
464+
void homePathChanged();
465+
458466
public slots:
459467

460468
/**

0 commit comments

Comments
 (0)