Skip to content

Commit

Permalink
save style when closing style manager only if it was modified
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@13335 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Apr 20, 2010
1 parent 2854b74 commit b2051a8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/gui/symbology-ng/qgsstylev2managerdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static QString iconPath( QString iconFile )
///////

QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* parent )
: QDialog( parent ), mStyle( style )
: QDialog( parent ), mStyle( style ), mModified( false )
{

setupUi( this );
Expand Down Expand Up @@ -64,8 +64,10 @@ QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* pa

void QgsStyleV2ManagerDialog::onFinished()
{
// TODO: save only when modified
mStyle->save();
if ( mModified )
{
mStyle->save();
}
}

void QgsStyleV2ManagerDialog::populateTypes()
Expand Down Expand Up @@ -227,6 +229,7 @@ bool QgsStyleV2ManagerDialog::addSymbol()

// add new symbol to style and re-populate the list
mStyle->addSymbol( name, symbol );
mModified = true;
return true;
}

Expand Down Expand Up @@ -292,6 +295,7 @@ bool QgsStyleV2ManagerDialog::addColorRamp()

// add new symbol to style and re-populate the list
mStyle->addColorRamp( name, ramp );
mModified = true;
return true;
}

Expand Down Expand Up @@ -332,6 +336,7 @@ bool QgsStyleV2ManagerDialog::editSymbol()

// by adding symbol to style with the same name the old effectively gets overwritten
mStyle->addSymbol( symbolName, symbol );
mModified = true;
return true;
}

Expand Down Expand Up @@ -379,6 +384,7 @@ bool QgsStyleV2ManagerDialog::editColorRamp()
}

mStyle->addColorRamp( name, ramp );
mModified = true;
return true;
}

Expand Down Expand Up @@ -410,6 +416,7 @@ bool QgsStyleV2ManagerDialog::removeSymbol()

// delete from style and update list
mStyle->removeSymbol( symbolName );
mModified = true;
return true;
}

Expand All @@ -419,5 +426,7 @@ bool QgsStyleV2ManagerDialog::removeColorRamp()
if ( rampName.isEmpty() )
return false;

return mStyle->removeColorRamp( rampName );
mStyle->removeColorRamp( rampName );
mModified = true;
return true;
}
2 changes: 2 additions & 0 deletions src/gui/symbology-ng/qgsstylev2managerdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class GUI_EXPORT QgsStyleV2ManagerDialog : public QDialog, private Ui::QgsStyleV
QgsStyleV2* mStyle;

QString mStyleFilename;

bool mModified;
};

#endif

0 comments on commit b2051a8

Please sign in to comment.