[vlmc-devel] commit: Settings: Project loading is functionnal again. ( Hugo Beauzee-Luyssen )
git at videolan.org
git at videolan.org
Sat Mar 13 15:23:05 CET 2010
vlmc | branch: master | Hugo Beauzee-Luyssen <beauze.h at gmail.com> | Sat Mar 13 15:22:54 2010 +0100| [b8b83ec204919ba8c849f04432986f1166dc04d2] | committer: Hugo Beauzee-Luyssen
Settings: Project loading is functionnal again.
> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=b8b83ec204919ba8c849f04432986f1166dc04d2
---
src/Project/ProjectManager.cpp | 2 +-
src/Settings/SettingsManager.cpp | 30 ++++++++++++++----------------
2 files changed, 15 insertions(+), 17 deletions(-)
diff --git a/src/Project/ProjectManager.cpp b/src/Project/ProjectManager.cpp
index ebaee83..e9c2e0f 100644
--- a/src/Project/ProjectManager.cpp
+++ b/src/Project/ProjectManager.cpp
@@ -137,7 +137,7 @@ void ProjectManager::loadTimeline()
MainWorkflow::getInstance()->loadProject( root );
emit projectUpdated( projectName(), true );
-// SettingsManager::getInstance()->load( root.firstChildElement( "project" ) );
+ SettingsManager::getInstance()->load( root );
delete m_domDocument;
}
diff --git a/src/Settings/SettingsManager.cpp b/src/Settings/SettingsManager.cpp
index 687e606..d148b8d 100644
--- a/src/Settings/SettingsManager.cpp
+++ b/src/Settings/SettingsManager.cpp
@@ -193,31 +193,29 @@ SettingsManager::save( QXmlStreamWriter& project ) const
}
bool
-SettingsManager::load( const QDomElement &element )
+SettingsManager::load( const QDomElement &root )
{
//For now it only handle a project node.
- if ( element.isNull() == true || element.tagName() != "project" )
+ QDomElement element = root.firstChildElement( "project" );
+ if ( element.isNull() == true )
{
qWarning() << "Invalid settings node";
return false ;
}
QWriteLocker wLock( &m_rwLock );
- QDomNodeList list = element.childNodes();
- int nbChild = list.size();
-
- for ( int idx = 0; idx < nbChild; ++idx )
+ QDomElement s = element.firstChild().toElement();
+ while ( s.isNull() == false )
{
- QDomNamedNodeMap attrMap = list.at( idx ).attributes();
- if ( attrMap.count() > 1 )
- {
- qWarning() << "Invalid number of attributes for" << list.at( idx ).nodeName();
- continue ;
- }
- QString key = "project/" + list.at( idx ).toElement().tagName();
- if ( m_xmlSettings.contains( key ) )
- m_xmlSettings[key]->set( QVariant( attrMap.item( 0 ).nodeValue() ) );
+ QString key = s.attribute( "key" );
+ QString value = s.attribute( "value" );
+
+ if ( key.isEmpty() == true || value.isEmpty() == true )
+ qWarning() << "Invalid setting node.";
+ else
+ setValue( key, value, SettingsManager::Project );
+ s = s.nextSibling().toElement();
}
- return true;
+ return true;
}
bool
More information about the Vlmc-devel
mailing list