mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-15 00:07:25 -05:00
Add QgsProject::dirtySet signal (#43595)
This commit is contained in:
parent
bb0dfb6ba3
commit
6aa0cbed91
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user