Skip to content

Commit

Permalink
Deprecate QgsProject::dirty( bool ) in favor of QgsProject::setDirty
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Apr 5, 2016
1 parent 8948607 commit 9c0a291
Show file tree
Hide file tree
Showing 14 changed files with 62 additions and 54 deletions.
9 changes: 7 additions & 2 deletions python/core/qgsproject.sip
Expand Up @@ -57,8 +57,13 @@ class QgsProject : QObject
//@{
bool isDirty() const;

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

/** Set project as dirty (modified).
* @note added in 2.4 */
Expand Down
6 changes: 3 additions & 3 deletions src/app/qgisapp.cpp
Expand Up @@ -4048,7 +4048,7 @@ void QgisApp::fileNew( bool thePromptToSaveFlag, bool forceBlank )
mMapCanvas->setCanvasColor( QColor( myRed, myGreen, myBlue ) );
mOverviewCanvas->setBackgroundColor( QColor( myRed, myGreen, myBlue ) );

prj->dirty( false );
prj->setDirty( false );

setTitleBarText_( *this );

Expand All @@ -4072,7 +4072,7 @@ void QgisApp::fileNew( bool thePromptToSaveFlag, bool forceBlank )
prj->writeEntry( "SpatialRefSys", "/ProjectCRSProj4String", srs.toProj4() );
prj->writeEntry( "SpatialRefSys", "/ProjectCrs", srs.authid() );
prj->writeEntry( "SpatialRefSys", "/ProjectCRSID", static_cast< int >( srs.srsid() ) );
prj->dirty( false );
prj->setDirty( false );
if ( srs.mapUnits() != QGis::UnknownUnit )
{
mMapCanvas->setMapUnits( srs.mapUnits() );
Expand Down Expand Up @@ -9577,7 +9577,7 @@ void QgisApp::showMapCanvas()
void QgisApp::markDirty()
{
// notify the project that there was a change
QgsProject::instance()->dirty( true );
QgsProject::instance()->setDirty( true );
}

void QgisApp::extentChanged()
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsrasterlayerproperties.cpp
Expand Up @@ -963,7 +963,7 @@ void QgsRasterLayerProperties::apply()
mRasterLayer->triggerRepaint();

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

void QgsRasterLayerProperties::on_mLayerOrigNameLineEd_textEdited( const QString& text )
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsvectorlayerproperties.cpp
Expand Up @@ -636,7 +636,7 @@ void QgsVectorLayerProperties::apply()

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

void QgsVectorLayerProperties::onCancel()
Expand Down
2 changes: 1 addition & 1 deletion src/core/composer/qgsaddremoveitemcommand.cpp
Expand Up @@ -76,5 +76,5 @@ void QgsAddRemoveItemCommand::switchState()
emit itemAdded( mItem );
mState = Added;
}
QgsProject::instance()->dirty( true );
QgsProject::instance()->setDirty( true );
}
2 changes: 1 addition & 1 deletion src/core/composer/qgsaddremovemultiframecommand.cpp
Expand Up @@ -78,7 +78,7 @@ void QgsAddRemoveMultiFrameCommand::switchState()
mComposition->addMultiFrame( mMultiFrame );
mState = Added;
}
QgsProject::instance()->dirty( true );
QgsProject::instance()->setDirty( true );
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/composer/qgscomposeritemcommand.cpp
Expand Up @@ -118,7 +118,7 @@ void QgsComposerItemCommand::restoreState( QDomDocument& stateDoc ) const

destItem->readXML( stateDoc.documentElement().firstChild().toElement(), stateDoc );
destItem->repaint();
QgsProject::instance()->dirty( true );
QgsProject::instance()->setDirty( true );
}

//
Expand Down
4 changes: 2 additions & 2 deletions src/core/composer/qgscomposermousehandles.cpp
Expand Up @@ -624,7 +624,7 @@ void QgsComposerMouseHandles::mouseReleaseEvent( QGraphicsSceneMouseEvent* event
subcommand->saveAfterState();
}
mComposition->undoStack()->push( parentCommand );
QgsProject::instance()->dirty( true );
QgsProject::instance()->setDirty( true );
}
else if ( mCurrentMouseMoveAction != QgsComposerMouseHandles::NoAction )
{
Expand Down Expand Up @@ -664,7 +664,7 @@ void QgsComposerMouseHandles::mouseReleaseEvent( QGraphicsSceneMouseEvent* event
subcommand->saveAfterState();
}
mComposition->undoStack()->push( parentCommand );
QgsProject::instance()->dirty( true );
QgsProject::instance()->setDirty( true );
}

deleteAlignItems();
Expand Down
2 changes: 1 addition & 1 deletion src/core/composer/qgscomposermultiframecommand.cpp
Expand Up @@ -72,7 +72,7 @@ void QgsComposerMultiFrameCommand::restoreState( QDomDocument& stateDoc )
if ( mMultiFrame )
{
mMultiFrame->readXML( stateDoc.documentElement().firstChild().toElement(), stateDoc );
QgsProject::instance()->dirty( true );
QgsProject::instance()->setDirty( true );
}
}

Expand Down
32 changes: 16 additions & 16 deletions src/core/composer/qgscomposition.cpp
Expand Up @@ -416,7 +416,7 @@ void QgsComposition::setPaperSize( const double width, const double height, bool
mPages.at( i )->setSceneRect( QRectF( 0, currentY, width, height ) );
currentY += ( height + mSpaceBetweenPages );
}
QgsProject::instance()->dirty( true );
QgsProject::instance()->setDirty( true );
updateBounds();
emit paperSizeChanged();
}
Expand Down Expand Up @@ -542,7 +542,7 @@ void QgsComposition::setNumPages( const int pages )
}
}

QgsProject::instance()->dirty( true );
QgsProject::instance()->setDirty( true );
updateBounds();

emit nPagesChanged();
Expand Down Expand Up @@ -604,7 +604,7 @@ void QgsComposition::setPageStyleSymbol( QgsFillSymbolV2* symbol )
{
delete mPageStyleSymbol;
mPageStyleSymbol = static_cast<QgsFillSymbolV2*>( symbol->clone() );
QgsProject::instance()->dirty( true );
QgsProject::instance()->setDirty( true );
}

void QgsComposition::createDefaultPageStyleSymbol()
Expand Down Expand Up @@ -848,7 +848,7 @@ void QgsComposition::setPrintResolution( const int dpi )
{
mPrintResolution = dpi;
emit printResolutionChanged();
QgsProject::instance()->dirty( true );
QgsProject::instance()->setDirty( true );
}

void QgsComposition::setUseAdvancedEffects( const bool effectsEnabled )
Expand Down Expand Up @@ -1801,7 +1801,7 @@ void QgsComposition::alignSelectedItemsLeft()
subcommand->saveAfterState();
}
mUndoStack->push( parentCommand );
QgsProject::instance()->dirty( true );
QgsProject::instance()->setDirty( true );
}

void QgsComposition::alignSelectedItemsHCenter()
Expand Down Expand Up @@ -1831,7 +1831,7 @@ void QgsComposition::alignSelectedItemsHCenter()
subcommand->saveAfterState();
}
mUndoStack->push( parentCommand );
QgsProject::instance()->dirty( true );
QgsProject::instance()->setDirty( true );
}

void QgsComposition::alignSelectedItemsRight()
Expand Down Expand Up @@ -1861,7 +1861,7 @@ void QgsComposition::alignSelectedItemsRight()
subcommand->saveAfterState();
}
mUndoStack->push( parentCommand );
QgsProject::instance()->dirty( true );
QgsProject::instance()->setDirty( true );
}

void QgsComposition::alignSelectedItemsTop()
Expand Down Expand Up @@ -1890,7 +1890,7 @@ void QgsComposition::alignSelectedItemsTop()
subcommand->saveAfterState();
}
mUndoStack->push( parentCommand );
QgsProject::instance()->dirty( true );
QgsProject::instance()->setDirty( true );
}

void QgsComposition::alignSelectedItemsVCenter()
Expand Down Expand Up @@ -1918,7 +1918,7 @@ void QgsComposition::alignSelectedItemsVCenter()
subcommand->saveAfterState();
}
mUndoStack->push( parentCommand );
QgsProject::instance()->dirty( true );
QgsProject::instance()->setDirty( true );
}

void QgsComposition::alignSelectedItemsBottom()
Expand Down Expand Up @@ -1946,7 +1946,7 @@ void QgsComposition::alignSelectedItemsBottom()
subcommand->saveAfterState();
}
mUndoStack->push( parentCommand );
QgsProject::instance()->dirty( true );
QgsProject::instance()->setDirty( true );
}

void QgsComposition::lockSelectedItems()
Expand All @@ -1964,7 +1964,7 @@ void QgsComposition::lockSelectedItems()

setAllUnselected();
mUndoStack->push( parentCommand );
QgsProject::instance()->dirty( true );
QgsProject::instance()->setDirty( true );
}

void QgsComposition::unlockAllItems()
Expand Down Expand Up @@ -1993,7 +1993,7 @@ void QgsComposition::unlockAllItems()
}
}
mUndoStack->push( parentCommand );
QgsProject::instance()->dirty( true );
QgsProject::instance()->setDirty( true );
}

QgsComposerItemGroup *QgsComposition::groupItems( QList<QgsComposerItem *> items )
Expand Down Expand Up @@ -2073,7 +2073,7 @@ void QgsComposition::updateZValues( const bool addUndoCommands )
if ( addUndoCommands )
{
mUndoStack->push( parentCommand );
QgsProject::instance()->dirty( true );
QgsProject::instance()->setDirty( true );
}
}

Expand Down Expand Up @@ -2422,7 +2422,7 @@ void QgsComposition::endCommand()
if ( mActiveItemCommand->containsChange() ) //protect against empty commands
{
mUndoStack->push( mActiveItemCommand );
QgsProject::instance()->dirty( true );
QgsProject::instance()->setDirty( true );
}
else
{
Expand Down Expand Up @@ -2467,7 +2467,7 @@ void QgsComposition::endMultiFrameCommand()
if ( mActiveMultiFrameCommand->containsChange() )
{
mUndoStack->push( mActiveMultiFrameCommand );
QgsProject::instance()->dirty( true );
QgsProject::instance()->setDirty( true );
}
else
{
Expand Down Expand Up @@ -2708,7 +2708,7 @@ void QgsComposition::pushAddRemoveCommand( QgsComposerItem* item, const QString&
QgsAddRemoveItemCommand* c = new QgsAddRemoveItemCommand( state, item, this, text );
connectAddRemoveCommandSignals( c );
undoStack()->push( c );
QgsProject::instance()->dirty( true );
QgsProject::instance()->setDirty( true );
}

void QgsComposition::connectAddRemoveCommandSignals( QgsAddRemoveItemCommand* c )
Expand Down
31 changes: 13 additions & 18 deletions src/core/qgsproject.cpp
Expand Up @@ -391,7 +391,7 @@ void QgsProject::setTitle( const QString &title )
{
imp_->title = title;

dirty( true );
setDirty( true );
}


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


void QgsProject::dirty( bool b )
{
imp_->dirty = b;
} // bool QgsProject::isDirty()

void QgsProject::setDirty( bool b )
{
dirty( b );
imp_->dirty = b;
}


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

dirty( true );
setDirty( true );
} // void QgsProject::setFileName( QString const &name )


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


// read the project: used by map canvas and legend
emit readProject( *doc );

// if all went well, we're allegedly in pristine state
if ( clean )
dirty( false );
setDirty( false );

emit nonIdentifiableLayersChanged( nonIdentifiableLayers() );

Expand Down Expand Up @@ -1194,7 +1189,7 @@ bool QgsProject::write()
return false;
}

dirty( false ); // reset to pristine state
setDirty( false ); // reset to pristine state

emit projectSaved();

Expand All @@ -1207,15 +1202,15 @@ void QgsProject::clearProperties()
{
clear();

dirty( true );
setDirty( true );
} // QgsProject::clearProperties()



bool
QgsProject::writeEntry( QString const &scope, const QString &key, bool value )
{
dirty( true );
setDirty( true );

return addKey_( scope, key, &imp_->properties_, value );
} // QgsProject::writeEntry ( ..., bool value )
Expand All @@ -1225,7 +1220,7 @@ bool
QgsProject::writeEntry( QString const &scope, const QString &key,
double value )
{
dirty( true );
setDirty( true );

return addKey_( scope, key, &imp_->properties_, value );
} // QgsProject::writeEntry ( ..., double value )
Expand All @@ -1234,7 +1229,7 @@ QgsProject::writeEntry( QString const &scope, const QString &key,
bool
QgsProject::writeEntry( QString const &scope, const QString &key, int value )
{
dirty( true );
setDirty( true );

return addKey_( scope, key, &imp_->properties_, value );
} // QgsProject::writeEntry ( ..., int value )
Expand All @@ -1244,7 +1239,7 @@ bool
QgsProject::writeEntry( QString const &scope, const QString &key,
const QString &value )
{
dirty( true );
setDirty( true );

return addKey_( scope, key, &imp_->properties_, value );
} // QgsProject::writeEntry ( ..., const QString &value )
Expand All @@ -1254,7 +1249,7 @@ bool
QgsProject::writeEntry( QString const &scope, const QString &key,
const QStringList &value )
{
dirty( true );
setDirty( true );

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

dirty( true );
setDirty( true );

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

0 comments on commit 9c0a291

Please sign in to comment.