Skip to content

Commit 9c0a291

Browse files
committed
Deprecate QgsProject::dirty( bool ) in favor of QgsProject::setDirty
1 parent 8948607 commit 9c0a291

14 files changed

+62
-54
lines changed

python/core/qgsproject.sip

+7-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,13 @@ class QgsProject : QObject
5757
//@{
5858
bool isDirty() const;
5959

60-
// ### QGIS 3: remove in favor of setDirty(...)
61-
void dirty( bool b );
60+
/**
61+
* Flag the project as dirty (modified). If this flag is set, the user will
62+
* be asked to save changes to the project before closing the current project.
63+
*
64+
* @deprecated use setDirty instead
65+
*/
66+
void dirty( bool b ) /Deprecated/;
6267

6368
/** Set project as dirty (modified).
6469
* @note added in 2.4 */

src/app/qgisapp.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -4048,7 +4048,7 @@ void QgisApp::fileNew( bool thePromptToSaveFlag, bool forceBlank )
40484048
mMapCanvas->setCanvasColor( QColor( myRed, myGreen, myBlue ) );
40494049
mOverviewCanvas->setBackgroundColor( QColor( myRed, myGreen, myBlue ) );
40504050

4051-
prj->dirty( false );
4051+
prj->setDirty( false );
40524052

40534053
setTitleBarText_( *this );
40544054

@@ -4072,7 +4072,7 @@ void QgisApp::fileNew( bool thePromptToSaveFlag, bool forceBlank )
40724072
prj->writeEntry( "SpatialRefSys", "/ProjectCRSProj4String", srs.toProj4() );
40734073
prj->writeEntry( "SpatialRefSys", "/ProjectCrs", srs.authid() );
40744074
prj->writeEntry( "SpatialRefSys", "/ProjectCRSID", static_cast< int >( srs.srsid() ) );
4075-
prj->dirty( false );
4075+
prj->setDirty( false );
40764076
if ( srs.mapUnits() != QGis::UnknownUnit )
40774077
{
40784078
mMapCanvas->setMapUnits( srs.mapUnits() );
@@ -9577,7 +9577,7 @@ void QgisApp::showMapCanvas()
95779577
void QgisApp::markDirty()
95789578
{
95799579
// notify the project that there was a change
9580-
QgsProject::instance()->dirty( true );
9580+
QgsProject::instance()->setDirty( true );
95819581
}
95829582

95839583
void QgisApp::extentChanged()

src/app/qgsrasterlayerproperties.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -963,7 +963,7 @@ void QgsRasterLayerProperties::apply()
963963
mRasterLayer->triggerRepaint();
964964

965965
// notify the project we've made a change
966-
QgsProject::instance()->dirty( true );
966+
QgsProject::instance()->setDirty( true );
967967
}//apply
968968

969969
void QgsRasterLayerProperties::on_mLayerOrigNameLineEd_textEdited( const QString& text )

src/app/qgsvectorlayerproperties.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ void QgsVectorLayerProperties::apply()
636636

637637
layer->triggerRepaint();
638638
// notify the project we've made a change
639-
QgsProject::instance()->dirty( true );
639+
QgsProject::instance()->setDirty( true );
640640
}
641641

642642
void QgsVectorLayerProperties::onCancel()

src/core/composer/qgsaddremoveitemcommand.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,5 @@ void QgsAddRemoveItemCommand::switchState()
7676
emit itemAdded( mItem );
7777
mState = Added;
7878
}
79-
QgsProject::instance()->dirty( true );
79+
QgsProject::instance()->setDirty( true );
8080
}

src/core/composer/qgsaddremovemultiframecommand.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void QgsAddRemoveMultiFrameCommand::switchState()
7878
mComposition->addMultiFrame( mMultiFrame );
7979
mState = Added;
8080
}
81-
QgsProject::instance()->dirty( true );
81+
QgsProject::instance()->setDirty( true );
8282
}
8383
}
8484

src/core/composer/qgscomposeritemcommand.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ void QgsComposerItemCommand::restoreState( QDomDocument& stateDoc ) const
118118

119119
destItem->readXML( stateDoc.documentElement().firstChild().toElement(), stateDoc );
120120
destItem->repaint();
121-
QgsProject::instance()->dirty( true );
121+
QgsProject::instance()->setDirty( true );
122122
}
123123

124124
//

src/core/composer/qgscomposermousehandles.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ void QgsComposerMouseHandles::mouseReleaseEvent( QGraphicsSceneMouseEvent* event
624624
subcommand->saveAfterState();
625625
}
626626
mComposition->undoStack()->push( parentCommand );
627-
QgsProject::instance()->dirty( true );
627+
QgsProject::instance()->setDirty( true );
628628
}
629629
else if ( mCurrentMouseMoveAction != QgsComposerMouseHandles::NoAction )
630630
{
@@ -664,7 +664,7 @@ void QgsComposerMouseHandles::mouseReleaseEvent( QGraphicsSceneMouseEvent* event
664664
subcommand->saveAfterState();
665665
}
666666
mComposition->undoStack()->push( parentCommand );
667-
QgsProject::instance()->dirty( true );
667+
QgsProject::instance()->setDirty( true );
668668
}
669669

670670
deleteAlignItems();

src/core/composer/qgscomposermultiframecommand.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void QgsComposerMultiFrameCommand::restoreState( QDomDocument& stateDoc )
7272
if ( mMultiFrame )
7373
{
7474
mMultiFrame->readXML( stateDoc.documentElement().firstChild().toElement(), stateDoc );
75-
QgsProject::instance()->dirty( true );
75+
QgsProject::instance()->setDirty( true );
7676
}
7777
}
7878

src/core/composer/qgscomposition.cpp

+16-16
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ void QgsComposition::setPaperSize( const double width, const double height, bool
416416
mPages.at( i )->setSceneRect( QRectF( 0, currentY, width, height ) );
417417
currentY += ( height + mSpaceBetweenPages );
418418
}
419-
QgsProject::instance()->dirty( true );
419+
QgsProject::instance()->setDirty( true );
420420
updateBounds();
421421
emit paperSizeChanged();
422422
}
@@ -542,7 +542,7 @@ void QgsComposition::setNumPages( const int pages )
542542
}
543543
}
544544

545-
QgsProject::instance()->dirty( true );
545+
QgsProject::instance()->setDirty( true );
546546
updateBounds();
547547

548548
emit nPagesChanged();
@@ -604,7 +604,7 @@ void QgsComposition::setPageStyleSymbol( QgsFillSymbolV2* symbol )
604604
{
605605
delete mPageStyleSymbol;
606606
mPageStyleSymbol = static_cast<QgsFillSymbolV2*>( symbol->clone() );
607-
QgsProject::instance()->dirty( true );
607+
QgsProject::instance()->setDirty( true );
608608
}
609609

610610
void QgsComposition::createDefaultPageStyleSymbol()
@@ -848,7 +848,7 @@ void QgsComposition::setPrintResolution( const int dpi )
848848
{
849849
mPrintResolution = dpi;
850850
emit printResolutionChanged();
851-
QgsProject::instance()->dirty( true );
851+
QgsProject::instance()->setDirty( true );
852852
}
853853

854854
void QgsComposition::setUseAdvancedEffects( const bool effectsEnabled )
@@ -1801,7 +1801,7 @@ void QgsComposition::alignSelectedItemsLeft()
18011801
subcommand->saveAfterState();
18021802
}
18031803
mUndoStack->push( parentCommand );
1804-
QgsProject::instance()->dirty( true );
1804+
QgsProject::instance()->setDirty( true );
18051805
}
18061806

18071807
void QgsComposition::alignSelectedItemsHCenter()
@@ -1831,7 +1831,7 @@ void QgsComposition::alignSelectedItemsHCenter()
18311831
subcommand->saveAfterState();
18321832
}
18331833
mUndoStack->push( parentCommand );
1834-
QgsProject::instance()->dirty( true );
1834+
QgsProject::instance()->setDirty( true );
18351835
}
18361836

18371837
void QgsComposition::alignSelectedItemsRight()
@@ -1861,7 +1861,7 @@ void QgsComposition::alignSelectedItemsRight()
18611861
subcommand->saveAfterState();
18621862
}
18631863
mUndoStack->push( parentCommand );
1864-
QgsProject::instance()->dirty( true );
1864+
QgsProject::instance()->setDirty( true );
18651865
}
18661866

18671867
void QgsComposition::alignSelectedItemsTop()
@@ -1890,7 +1890,7 @@ void QgsComposition::alignSelectedItemsTop()
18901890
subcommand->saveAfterState();
18911891
}
18921892
mUndoStack->push( parentCommand );
1893-
QgsProject::instance()->dirty( true );
1893+
QgsProject::instance()->setDirty( true );
18941894
}
18951895

18961896
void QgsComposition::alignSelectedItemsVCenter()
@@ -1918,7 +1918,7 @@ void QgsComposition::alignSelectedItemsVCenter()
19181918
subcommand->saveAfterState();
19191919
}
19201920
mUndoStack->push( parentCommand );
1921-
QgsProject::instance()->dirty( true );
1921+
QgsProject::instance()->setDirty( true );
19221922
}
19231923

19241924
void QgsComposition::alignSelectedItemsBottom()
@@ -1946,7 +1946,7 @@ void QgsComposition::alignSelectedItemsBottom()
19461946
subcommand->saveAfterState();
19471947
}
19481948
mUndoStack->push( parentCommand );
1949-
QgsProject::instance()->dirty( true );
1949+
QgsProject::instance()->setDirty( true );
19501950
}
19511951

19521952
void QgsComposition::lockSelectedItems()
@@ -1964,7 +1964,7 @@ void QgsComposition::lockSelectedItems()
19641964

19651965
setAllUnselected();
19661966
mUndoStack->push( parentCommand );
1967-
QgsProject::instance()->dirty( true );
1967+
QgsProject::instance()->setDirty( true );
19681968
}
19691969

19701970
void QgsComposition::unlockAllItems()
@@ -1993,7 +1993,7 @@ void QgsComposition::unlockAllItems()
19931993
}
19941994
}
19951995
mUndoStack->push( parentCommand );
1996-
QgsProject::instance()->dirty( true );
1996+
QgsProject::instance()->setDirty( true );
19971997
}
19981998

19991999
QgsComposerItemGroup *QgsComposition::groupItems( QList<QgsComposerItem *> items )
@@ -2073,7 +2073,7 @@ void QgsComposition::updateZValues( const bool addUndoCommands )
20732073
if ( addUndoCommands )
20742074
{
20752075
mUndoStack->push( parentCommand );
2076-
QgsProject::instance()->dirty( true );
2076+
QgsProject::instance()->setDirty( true );
20772077
}
20782078
}
20792079

@@ -2422,7 +2422,7 @@ void QgsComposition::endCommand()
24222422
if ( mActiveItemCommand->containsChange() ) //protect against empty commands
24232423
{
24242424
mUndoStack->push( mActiveItemCommand );
2425-
QgsProject::instance()->dirty( true );
2425+
QgsProject::instance()->setDirty( true );
24262426
}
24272427
else
24282428
{
@@ -2467,7 +2467,7 @@ void QgsComposition::endMultiFrameCommand()
24672467
if ( mActiveMultiFrameCommand->containsChange() )
24682468
{
24692469
mUndoStack->push( mActiveMultiFrameCommand );
2470-
QgsProject::instance()->dirty( true );
2470+
QgsProject::instance()->setDirty( true );
24712471
}
24722472
else
24732473
{
@@ -2708,7 +2708,7 @@ void QgsComposition::pushAddRemoveCommand( QgsComposerItem* item, const QString&
27082708
QgsAddRemoveItemCommand* c = new QgsAddRemoveItemCommand( state, item, this, text );
27092709
connectAddRemoveCommandSignals( c );
27102710
undoStack()->push( c );
2711-
QgsProject::instance()->dirty( true );
2711+
QgsProject::instance()->setDirty( true );
27122712
}
27132713

27142714
void QgsComposition::connectAddRemoveCommandSignals( QgsAddRemoveItemCommand* c )

src/core/qgsproject.cpp

+13-18
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ void QgsProject::setTitle( const QString &title )
391391
{
392392
imp_->title = title;
393393

394-
dirty( true );
394+
setDirty( true );
395395
}
396396

397397

@@ -406,15 +406,9 @@ bool QgsProject::isDirty() const
406406
return imp_->dirty;
407407
} // bool QgsProject::isDirty()
408408

409-
410-
void QgsProject::dirty( bool b )
411-
{
412-
imp_->dirty = b;
413-
} // bool QgsProject::isDirty()
414-
415409
void QgsProject::setDirty( bool b )
416410
{
417-
dirty( b );
411+
imp_->dirty = b;
418412
}
419413

420414

@@ -423,7 +417,7 @@ void QgsProject::setFileName( QString const &name )
423417
{
424418
imp_->file.setFileName( name );
425419

426-
dirty( true );
420+
setDirty( true );
427421
} // void QgsProject::setFileName( QString const &name )
428422

429423

@@ -941,12 +935,13 @@ bool QgsProject::read()
941935
mVisibilityPresetCollection.reset( new QgsVisibilityPresetCollection() );
942936
mVisibilityPresetCollection->readXML( *doc );
943937

938+
944939
// read the project: used by map canvas and legend
945940
emit readProject( *doc );
946941

947942
// if all went well, we're allegedly in pristine state
948943
if ( clean )
949-
dirty( false );
944+
setDirty( false );
950945

951946
emit nonIdentifiableLayersChanged( nonIdentifiableLayers() );
952947

@@ -1194,7 +1189,7 @@ bool QgsProject::write()
11941189
return false;
11951190
}
11961191

1197-
dirty( false ); // reset to pristine state
1192+
setDirty( false ); // reset to pristine state
11981193

11991194
emit projectSaved();
12001195

@@ -1207,15 +1202,15 @@ void QgsProject::clearProperties()
12071202
{
12081203
clear();
12091204

1210-
dirty( true );
1205+
setDirty( true );
12111206
} // QgsProject::clearProperties()
12121207

12131208

12141209

12151210
bool
12161211
QgsProject::writeEntry( QString const &scope, const QString &key, bool value )
12171212
{
1218-
dirty( true );
1213+
setDirty( true );
12191214

12201215
return addKey_( scope, key, &imp_->properties_, value );
12211216
} // QgsProject::writeEntry ( ..., bool value )
@@ -1225,7 +1220,7 @@ bool
12251220
QgsProject::writeEntry( QString const &scope, const QString &key,
12261221
double value )
12271222
{
1228-
dirty( true );
1223+
setDirty( true );
12291224

12301225
return addKey_( scope, key, &imp_->properties_, value );
12311226
} // QgsProject::writeEntry ( ..., double value )
@@ -1234,7 +1229,7 @@ QgsProject::writeEntry( QString const &scope, const QString &key,
12341229
bool
12351230
QgsProject::writeEntry( QString const &scope, const QString &key, int value )
12361231
{
1237-
dirty( true );
1232+
setDirty( true );
12381233

12391234
return addKey_( scope, key, &imp_->properties_, value );
12401235
} // QgsProject::writeEntry ( ..., int value )
@@ -1244,7 +1239,7 @@ bool
12441239
QgsProject::writeEntry( QString const &scope, const QString &key,
12451240
const QString &value )
12461241
{
1247-
dirty( true );
1242+
setDirty( true );
12481243

12491244
return addKey_( scope, key, &imp_->properties_, value );
12501245
} // QgsProject::writeEntry ( ..., const QString &value )
@@ -1254,7 +1249,7 @@ bool
12541249
QgsProject::writeEntry( QString const &scope, const QString &key,
12551250
const QStringList &value )
12561251
{
1257-
dirty( true );
1252+
setDirty( true );
12581253

12591254
return addKey_( scope, key, &imp_->properties_, value );
12601255
} // QgsProject::writeEntry ( ..., const QStringList &value )
@@ -1390,7 +1385,7 @@ bool QgsProject::removeEntry( QString const &scope, const QString &key )
13901385
{
13911386
removeKey_( scope, key, imp_->properties_ );
13921387

1393-
dirty( true );
1388+
setDirty( true );
13941389

13951390
return !findKey_( scope, key, imp_->properties_ );
13961391
} // QgsProject::removeEntry

0 commit comments

Comments
 (0)