Skip to content
Permalink
Browse files
Save style file name inside the style.
Fixed saving of symbols added in symbol selector


git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@12161 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
wonder committed Nov 17, 2009
1 parent 25b2f95 commit 1a5cc6c0f460f85c1b206d9c1a96149f4f1cca5e
@@ -670,11 +670,15 @@ public:
//! load a file into the style
bool load(QString filename);

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

//! return last error from load/save operation
QString errorString();

//! return current file name of the style
QString fileName();

};

//////////
@@ -59,7 +59,7 @@ class QgsStyleV2ManagerDialog : QDialog //, private Ui::QgsStyleV2ManagerDialogB
%End

public:
QgsStyleV2ManagerDialog(QgsStyleV2* style, QString styleFilename, QWidget* parent = NULL);
QgsStyleV2ManagerDialog(QgsStyleV2* style, QWidget* parent = NULL);

public slots:
void addItem();
@@ -1068,7 +1068,7 @@ void QgisApp::createActions()

void QgisApp::showStyleManagerV2()
{
QgsStyleV2ManagerDialog dlg( QgsStyleV2::defaultStyle(), QgsApplication::userStyleV2Path(), this );
QgsStyleV2ManagerDialog dlg( QgsStyleV2::defaultStyle(), this );
dlg.exec();
}

@@ -216,6 +216,7 @@ bool QgsStyleV2::load(QString filename)
e = e.nextSiblingElement();
}

mFileName = filename;
return true;
}

@@ -224,8 +225,8 @@ bool QgsStyleV2::load(QString filename)
bool QgsStyleV2::save(QString filename)
{
mErrorString = QString();
//if (filename.isEmpty())
// filename = mFilename;
if (filename.isEmpty())
filename = mFileName;

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

mFileName = filename;
return true;
}
@@ -70,18 +70,22 @@ class CORE_EXPORT QgsStyleV2
//! load a file into the style
bool load( QString filename );

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

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

//! return current file name of the style
QString fileName() { return mFileName; }

protected:

QgsSymbolV2Map mSymbols;
QgsVectorColorRampV2Map mColorRamps;

QString mErrorString;
QString mFileName;

static QgsStyleV2* mDefaultStyle;
};
@@ -32,8 +32,8 @@ static QString iconPath( QString iconFile )

///////

QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QString styleFilename, QWidget* parent )
: QDialog( parent ), mStyle( style ), mStyleFilename( styleFilename )
QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* parent )
: QDialog( parent ), mStyle( style )
{

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

void QgsStyleV2ManagerDialog::populateTypes()
@@ -13,7 +13,7 @@ class GUI_EXPORT QgsStyleV2ManagerDialog : public QDialog, private Ui::QgsStyleV
Q_OBJECT

public:
QgsStyleV2ManagerDialog( QgsStyleV2* style, QString styleFilename, QWidget* parent = NULL );
QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* parent = NULL );

public slots:
void addItem();
@@ -206,6 +206,9 @@ void QgsSymbolV2SelectorDialog::addSymbolToStyle()
// add new symbol to style and re-populate the list
mStyle->addSymbol(name, mSymbol->clone());

// make sure the symbol is stored
mStyle->save();

populateSymbolView();
}

0 comments on commit 1a5cc6c

Please sign in to comment.