Commit 64f85c02 authored by Clement CHAVANCE's avatar Clement CHAVANCE

we can now load/save the project settings to a vlmc file

parent f94438db
......@@ -111,33 +111,43 @@ void SettingsManager::saveSettings( const QString& part, QDomDocument& xmlfile,
root.appendChild( settingsNode );
}
void SettingsManager::loadSettings( const QDomElement& settings )
void SettingsManager::loadSettings( const QString& part, const QDomElement& settings )
{
//qDebug() << "Loading settings";
//if ( settings.isNull() == true || settings.tagName() != "settings" )
//{
// qWarning() << "Invalid settings node";
// return ;
//}
////Loading all the settings
//m_globalLock.lockForWrite();
//QDomNodeList list = settings.childNodes();
//int nbChild = list.size();
//for ( int idx = 0; idx < nbChild; ++idx )
//{
// QDomNamedNodeMap attrMap = list.at( idx ).attributes();
// if ( attrMap.count() > 1 )
// {
// qWarning() << "Invalid number of attributes for" << list.at( idx ).nodeName();
// return ;
// }
// m_data.insert( list.at( idx ).toElement().tagName(),
// QVariant( attrMap.item( 0 ).nodeValue() ));
//}
//m_lock.unlock();
//emit settingsLoaded();
qDebug() << "Loading settings" << settings.tagName();
if ( settings.isNull() == true || settings.tagName() != "project" )
{
qWarning() << "Invalid settings node";
return ;
}
m_globalLock.lockForRead();
if ( !m_data.contains( part ) )
{
qWarning() << "These settings Does not exists";
return ;
}
SettingsPart* sett = m_data[part];
qDebug() << sett->m_data;
m_globalLock.unlock();
//Loading all the settings
m_globalLock.lockForWrite();
sett->m_lock.lockForWrite();
QDomNodeList list = settings.childNodes();
int nbChild = list.size();
for ( int idx = 0; idx < nbChild; ++idx )
{
QDomNamedNodeMap attrMap = list.at( idx ).attributes();
if ( attrMap.count() > 1 )
{
qWarning() << "Invalid number of attributes for" << list.at( idx ).nodeName();
return ;
}
sett->m_data.insert( list.at( idx ).toElement().tagName(),
QVariant( attrMap.item( 0 ).nodeValue() ));
}
sett->m_lock.unlock();
m_globalLock.unlock();
emit settingsLoaded();
}
void SettingsManager::addNewSettingsPart( const QString& name )
......
......@@ -57,7 +57,7 @@ class SettingsManager : public QObject, public QSingleton<SettingsManager>
void setValue( const QString& part, const QString& key, QVariant& value );
const QVariant& getValue( const QString& part, const QString& key ) const;
void saveSettings( const QString& part, QDomDocument& xmlfile, QDomElement& root );
void loadSettings( const QDomElement& settings );
void loadSettings( const QString& part, const QDomElement& settings );
void addNewSettingsPart( const QString& name );
static void loadDefaultsSettings();
......
......@@ -52,7 +52,7 @@ void ProjectManager::loadProject()
connect( Library::getInstance(), SIGNAL( projectLoaded() ), this, SLOT( loadTimeline() ) );
Library::getInstance()->loadProject( root.firstChildElement( "medias" ) );
SettingsManager::getInstance()->loadSettings( root.firstChildElement( "settings" ) );
SettingsManager::getInstance()->loadSettings( "project", root.firstChildElement( "project" ) );
}
void ProjectManager::saveProject()
......@@ -68,7 +68,7 @@ void ProjectManager::saveProject()
Library::getInstance()->saveProject( doc, rootNode );
MainWorkflow::getInstance()->saveProject( doc, rootNode );
//SettingsManager::getInstance()->saveSettings( doc, rootNode );
SettingsManager::getInstance()->saveSettings( "project", doc, rootNode );
doc.appendChild( rootNode );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment