Subversion Repositories Projects

Rev

Rev 674 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

/***************************************************************************
 *   Copyright (C) 2008 by Manuel Schrape                                  *
 *   manuel.schrape@gmx.de                                                 *
 *                                                                         *
 *   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.        *
 *                                                                         *
 *   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.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/

#include <QSettings>
#include <QDir>

#include "cSettings.h"

cSettings::cSettings()
{
    Settings_ID = 1;

    read_Settings();
}

void cSettings::read_DebugLabels(int ID)
{
    QBitArray Def_View;
    Def_View.fill(true,MAX_DebugData);

    QString Hardware = HardwareType[ID];

    QSettings Setting("QMK", "Debug-Labels");

    Setting.beginGroup("Debug-Labels-" + Hardware);

        DebugData.Version  = Setting.value(("Version"), "0").toString();
        for (int a=0; a<MAX_DebugData; a++)
        {
            DebugData.Label[a]  = Setting.value(("Label_" + QString("%1").arg(a)), "-" + DEF_DebugNames[a]).toString();
        }
        DebugData.Show_Plotter = Setting.value("Show_Plotter", QBitArray(Def_View)).value<QBitArray>();

    Setting.endGroup();
}

void cSettings::write_DebugLabels(int ID)
{
    QString Hardware = HardwareType[ID];

    QSettings Setting("QMK", "Debug-Labels");

    Setting.beginGroup("Debug-Labels-" + Hardware);

        Setting.setValue("Version", DebugData.Version);
        for (int a=0; a<MAX_DebugData; a++)
        {
            Setting.setValue("Label_" + QString("%1").arg(a), DebugData.Label[a]);
        }
        Setting.setValue("Show_Plotter", QBitArray(DebugData.Show_Plotter));

    Setting.endGroup();
}

void cSettings::read_Settings()
{
    QSettings Setting("QMK", QA_NAME);

    Setting.beginGroup("Global");
        Settings_ID  = Setting.value("Settings ID", Settings_ID).toInt();
    Setting.endGroup();

    Setting.beginGroup("DATA");
//        DATA.Debug_Intervall  = Setting.value("Debug-Intervall", 500).toInt();
        DATA.Plotter_Count    = Setting.value("Plotter-Count", 100).toInt();
    Setting.endGroup();

    Setting.beginGroup("GUI");
        GUI.isMax       = Setting.value("IsMax",false).toBool();
        GUI.Size        = Setting.value("Size", QSize(700, 300)).toSize();
        GUI.Point       = Setting.value("Point",QPoint(1,1)).toPoint();
    Setting.endGroup();
/*
    Setting.beginGroup("SERVER");
        SERVER.Password = Setting.value("Password", QString("")).toString();
        SERVER.IP_MAX = Setting.value("IP_MAX", 1).toInt();
        SERVER.IP_ID  = Setting.value("IP_ID",  0).toInt();

        for (int z = 0; z < SERVER.IP_MAX; z++)
        {
            SERVER.IP[z] = Setting.value("IP_" + QString("%1").arg(z), QString("127.0.0.1:64400")).toString();
        }
    Setting.endGroup();
*/

}

void cSettings::write_Settings()
{
    QSettings Setting("QMK", QA_NAME);

    Setting.beginGroup("Global");
        Setting.setValue("Settings ID", Settings_ID);
    Setting.endGroup();

    Setting.beginGroup("DATA");
        Setting.setValue("Plotter-Count", DATA.Plotter_Count);
//        Setting.setValue("Debug-Intervall", DATA.Debug_Intervall);
    Setting.endGroup();

    Setting.beginGroup("GUI");
        Setting.setValue("IsMax", GUI.isMax);
        Setting.setValue("Size", GUI.Size);
        Setting.setValue("Point", GUI.Point);
    Setting.endGroup();
/*
    Setting.beginGroup("SERVER");
        Setting.setValue("Password", SERVER.Password);
        Setting.setValue("IP_MAX", SERVER.IP_MAX);
        Setting.setValue("IP_ID",  SERVER.IP_ID);

        for (int z = 0; z < SERVER.IP_MAX; z++)
        {
            Setting.setValue("IP_" + QString("%1").arg(z), SERVER.IP[z]);
        }
    Setting.endGroup();
*/

}