Skip to content
Permalink
Browse files
Add QgsProject::dirtySet signal (#43595)
  • Loading branch information
manisandro committed Jun 10, 2021
1 parent bb0dfb6 commit 6aa0cbed91e5277c91aa6df0732f9d01d8fd8680
@@ -1799,6 +1799,18 @@ Emitted when the project dirty status changes.
.. versionadded:: 3.2
%End

void dirtySet();
%Docstring
Emitted when setDirty(true) is called.

.. note::

As opposed to :py:func:`~QgsProject.isDirtyChanged`, this signal is invoked every time setDirty(true)
is called, regardless of whether the project was already dirty.

.. versionadded:: 3.20
%End


void mapScalesChanged() /Deprecated/;
%Docstring
@@ -520,6 +520,9 @@ void QgsProject::setDirty( const bool dirty )
if ( dirty && mDirtyBlockCount > 0 )
return;

if ( dirty )
emit dirtySet();

if ( mDirty == dirty )
return;

@@ -1824,6 +1824,15 @@ class CORE_EXPORT QgsProject : public QObject, public QgsExpressionContextGenera
*/
void isDirtyChanged( bool dirty );

/**
* Emitted when setDirty(true) is called.
* \note As opposed to isDirtyChanged(), this signal is invoked every time setDirty(true)
* is called, regardless of whether the project was already dirty.
*
* \since QGIS 3.20
*/
void dirtySet();

/**
* Emitted whenever the project is saved to a qgz file.
* This can be used to package additional files into the qgz file by modifying the \a files map.
@@ -39,6 +39,7 @@ class TestQgsProject : public QObject
void init();// will be called before each testfunction is executed.
void cleanup();// will be called after every testfunction.

void testDirtySet();
void testReadPath();
void testPathResolver();
void testPathResolverSvg();
@@ -85,6 +86,15 @@ void TestQgsProject::cleanupTestCase()
QgsApplication::exitQgis();
}

void TestQgsProject::testDirtySet()
{
QgsProject p;
bool dirtySet = false;
connect( &p, &QgsProject::dirtySet, [&] { dirtySet = true; } );
p.setDirty( true );
QVERIFY( dirtySet );
}

void TestQgsProject::testReadPath()
{
QgsProject *prj = new QgsProject;

0 comments on commit 6aa0cbe

Please sign in to comment.