Commit f8518822 authored by Clement CHAVANCE's avatar Clement CHAVANCE

added class SettingsManager

this class will handle all the settings of the project
parent 4e4725c8
/*****************************************************************************
* SettingsManager.cpp * : Backend settings manager
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Clement CHAVANCE <kinder@vlmc.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include <QHash>
#include "SettingsManager.h"
int SettingsManager::createNewSettings()
{
this->m_settings.append(new SettingsContainer());
return this->m_settings.size() - 1;
}
SettingsManager::SettingsManager( QObject* parent )
: QObject( parent )
{
}
SettingsManager::~SettingsManager()
{
}
void SettingsManager::saveSettings( QDomDocument& xmlfile, int index )
{
SettingsContainer* settings = m_settings[index];
settings->lock.lockForRead();
//SAVE SETTINGS TO DomDocument
settings->lock.unlock();
}
/*****************************************************************************
* SettingsManager.h: Backend settings manager
*****************************************************************************
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Clement CHAVANCE <kinder@vlmc.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef SETTINGSMANAGER_H
#define SETTINGSMANAGER_H
#include <QObject>
#include <QVector>
#include <QHash>
#include <QReadWriteLock>
#include <QString>
#include <QVariant>
#include <QDomDocument>
#include "QSingleton.hpp"
struct SettingsContainer
{
QReadWriteLock lock;
QHash<QString, QVariant> settings;
};
class SettingsManager : public QObject, public QSingleton<SettingsManager>
{
//Q_OBJECT
//
friend class QSingleton<SettingsManager>;
public:
int createNewSettings();
void setValues( QHash<QString, QVariant>, int index );
void setValue( const QString& key, QVariant& value, int index );
QVariant& getValue( const QString& key );
private:
SettingsManager( QObject* parent = 0 );
~SettingsManager();
QVector<SettingsContainer*> m_settings;
public slots:
void saveSettings( QDomDocument& xmlfile, int index );
};
#endif
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