[vlmc-devel] commit: SettingsManager: Saving is functionnal again. ( Hugo Beauzee-Luyssen )
git at videolan.org
git at videolan.org
Fri Mar 12 20:49:00 CET 2010
vlmc | branch: master | Hugo Beauzee-Luyssen <beauze.h at gmail.com> | Fri Mar 12 20:48:34 2010 +0100| [a20a7eafe1635a80d2fd013d1076c019df8a4f09] | committer: Hugo Beauzee-Luyssen
SettingsManager: Saving is functionnal again.
> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=a20a7eafe1635a80d2fd013d1076c019df8a4f09
---
src/Project/ProjectManager.cpp | 2 +-
src/Settings/SettingsManager.cpp | 43 ++++++++++---------------------------
src/Settings/SettingsManager.h | 3 +-
3 files changed, 14 insertions(+), 34 deletions(-)
diff --git a/src/Project/ProjectManager.cpp b/src/Project/ProjectManager.cpp
index 7bf4314..175e0ff 100644
--- a/src/Project/ProjectManager.cpp
+++ b/src/Project/ProjectManager.cpp
@@ -231,7 +231,7 @@ void ProjectManager::__saveProject( const QString &fileName )
Library::getInstance()->saveProject( project );
MainWorkflow::getInstance()->saveProject( project );
-// SettingsManager::getInstance()->save( doc, rootNode );
+ SettingsManager::getInstance()->save( project );
project.writeEndElement();
project.writeEndDocument();
diff --git a/src/Settings/SettingsManager.cpp b/src/Settings/SettingsManager.cpp
index a164560..687e606 100644
--- a/src/Settings/SettingsManager.cpp
+++ b/src/Settings/SettingsManager.cpp
@@ -25,13 +25,13 @@
#include "SettingValue.h"
#include <QSettings>
-#include <QDomDocument>
#include <QWriteLocker>
#include <QReadLocker>
#include <QXmlStreamWriter>
#include <QStringList>
#include <QtDebug>
+#include <QDomElement>
void
SettingsManager::setValue( const QString &key,
@@ -175,40 +175,21 @@ SettingsManager::save() const
}
void
-SettingsManager::save( QDomDocument &xmlfile, QDomElement &root ) const
+SettingsManager::save( QXmlStreamWriter& project ) const
{
- typedef QPair<QString, SettingValue*> settingPair;
- QMultiHash<QString, settingPair> parts;
+ SettingHash::const_iterator it = m_xmlSettings.begin();
+ SettingHash::const_iterator end = m_xmlSettings.end();
- QReadLocker rl( &m_rwLock );
- SettingHash::const_iterator it;
- SettingHash::const_iterator ed = m_xmlSettings.end();
-
- for ( it = m_xmlSettings.begin(); it != ed; ++it )
+ project.writeStartElement( "project" );
+ while ( it != end )
{
- QString key = it.key();
- if ( key.count( "/" ) == 1 )
- {
- int idx = key.indexOf( "/" );
- QString part = key.left( idx );
- QString name = key.right( key.size() - idx - 1 );
-
- parts.insert( part, settingPair( name, it.value() ) );
- }
- }
- QList<QString> keys = parts.uniqueKeys();
- foreach( QString xmlKey, keys )
- {
- QDomElement node = xmlfile.createElement( xmlKey );
- QList<settingPair> pairs = parts.values( xmlKey );
- foreach( settingPair pair, pairs )
- {
- QDomElement item = xmlfile.createElement( pair.first );
- item.setAttribute( "value", pair.second->get().toString() );
- node.appendChild( item );
- }
- root.appendChild( node );
+ project.writeStartElement( "property" );
+ project.writeAttribute( "key", it.key() );
+ project.writeAttribute( "value", it.value()->get().toString() );
+ ++it;
+ project.writeEndElement();
}
+ project.writeEndElement();
}
bool
diff --git a/src/Settings/SettingsManager.h b/src/Settings/SettingsManager.h
index 8b3cdb0..b551ce8 100644
--- a/src/Settings/SettingsManager.h
+++ b/src/Settings/SettingsManager.h
@@ -35,7 +35,6 @@
class SettingValue;
class QXmlStreamWriter;
class QDomElement;
-class QDomDocument;
//Var helpers :
@@ -115,7 +114,7 @@ class SettingsManager : public QObject, public Singleton<SettingsManager>
SettingsManager::Type type,
Qt::ConnectionType cType = Qt::AutoConnection );
void save() const;
- void save( QDomDocument &xmlfile, QDomElement& root ) const;
+ void save( QXmlStreamWriter& project ) const;
bool load( const QDomElement &element );
bool commit( SettingsManager::Type type );
More information about the Vlmc-devel
mailing list