Skip to content

Commit adb8ab9

Browse files
author
wonder
committedNov 17, 2009
Save style file name inside the style.
Fixed saving of symbols added in symbol selector git-svn-id: http://svn.osgeo.org/qgis/trunk@12161 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 1d626d4 commit adb8ab9

File tree

8 files changed

+25
-13
lines changed

8 files changed

+25
-13
lines changed
 

‎python/core/symbology-ng-core.sip

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -670,11 +670,15 @@ public:
670670
//! load a file into the style
671671
bool load(QString filename);
672672

673-
//! save style into a file
674-
bool save(QString filename);
673+
//! save style into a file (will use current filename if empty string is passed)
674+
bool save(QString filename = QString());
675675

676676
//! return last error from load/save operation
677677
QString errorString();
678+
679+
//! return current file name of the style
680+
QString fileName();
681+
678682
};
679683

680684
//////////

‎python/gui/symbology-ng-gui.sip

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class QgsStyleV2ManagerDialog : QDialog //, private Ui::QgsStyleV2ManagerDialogB
5959
%End
6060

6161
public:
62-
QgsStyleV2ManagerDialog(QgsStyleV2* style, QString styleFilename, QWidget* parent = NULL);
62+
QgsStyleV2ManagerDialog(QgsStyleV2* style, QWidget* parent = NULL);
6363

6464
public slots:
6565
void addItem();

‎src/app/qgisapp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1068,7 +1068,7 @@ void QgisApp::createActions()
10681068

10691069
void QgisApp::showStyleManagerV2()
10701070
{
1071-
QgsStyleV2ManagerDialog dlg( QgsStyleV2::defaultStyle(), QgsApplication::userStyleV2Path(), this );
1071+
QgsStyleV2ManagerDialog dlg( QgsStyleV2::defaultStyle(), this );
10721072
dlg.exec();
10731073
}
10741074

‎src/core/symbology-ng/qgsstylev2.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ bool QgsStyleV2::load(QString filename)
216216
e = e.nextSiblingElement();
217217
}
218218

219+
mFileName = filename;
219220
return true;
220221
}
221222

@@ -224,8 +225,8 @@ bool QgsStyleV2::load(QString filename)
224225
bool QgsStyleV2::save(QString filename)
225226
{
226227
mErrorString = QString();
227-
//if (filename.isEmpty())
228-
// filename = mFilename;
228+
if (filename.isEmpty())
229+
filename = mFileName;
229230

230231
QDomDocument doc("qgis_style");
231232
QDomElement root = doc.createElement("qgis_style");
@@ -257,5 +258,6 @@ bool QgsStyleV2::save(QString filename)
257258
doc.save(ts, 2);
258259
f.close();
259260

261+
mFileName = filename;
260262
return true;
261263
}

‎src/core/symbology-ng/qgsstylev2.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,22 @@ class CORE_EXPORT QgsStyleV2
7070
//! load a file into the style
7171
bool load( QString filename );
7272

73-
//! save style into a file
74-
bool save( QString filename );
73+
//! save style into a file (will use current filename if empty string is passed)
74+
bool save( QString filename = QString() );
7575

7676
//! return last error from load/save operation
7777
QString errorString() { return mErrorString; }
7878

79+
//! return current file name of the style
80+
QString fileName() { return mFileName; }
81+
7982
protected:
8083

8184
QgsSymbolV2Map mSymbols;
8285
QgsVectorColorRampV2Map mColorRamps;
8386

8487
QString mErrorString;
88+
QString mFileName;
8589

8690
static QgsStyleV2* mDefaultStyle;
8791
};

‎src/gui/symbology-ng/qgsstylev2managerdialog.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ static QString iconPath( QString iconFile )
3232

3333
///////
3434

35-
QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QString styleFilename, QWidget* parent )
36-
: QDialog( parent ), mStyle( style ), mStyleFilename( styleFilename )
35+
QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* parent )
36+
: QDialog( parent ), mStyle( style )
3737
{
3838

3939
setupUi( this );
@@ -65,8 +65,7 @@ QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QString sty
6565
void QgsStyleV2ManagerDialog::onFinished()
6666
{
6767
// TODO: save only when modified
68-
if ( !mStyleFilename.isEmpty() )
69-
mStyle->save( mStyleFilename );
68+
mStyle->save();
7069
}
7170

7271
void QgsStyleV2ManagerDialog::populateTypes()

‎src/gui/symbology-ng/qgsstylev2managerdialog.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class GUI_EXPORT QgsStyleV2ManagerDialog : public QDialog, private Ui::QgsStyleV
1313
Q_OBJECT
1414

1515
public:
16-
QgsStyleV2ManagerDialog( QgsStyleV2* style, QString styleFilename, QWidget* parent = NULL );
16+
QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* parent = NULL );
1717

1818
public slots:
1919
void addItem();

‎src/gui/symbology-ng/qgssymbolv2selectordialog.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,9 @@ void QgsSymbolV2SelectorDialog::addSymbolToStyle()
206206
// add new symbol to style and re-populate the list
207207
mStyle->addSymbol(name, mSymbol->clone());
208208

209+
// make sure the symbol is stored
210+
mStyle->save();
211+
209212
populateSymbolView();
210213
}
211214

0 commit comments

Comments
 (0)
Please sign in to comment.