Subversion Repositories public iLand

Rev

Rev 1221 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
671 werner 1
/********************************************************************************************
2
**    iLand - an individual based forest landscape and disturbance model
3
**    http://iland.boku.ac.at
4
**    Copyright (C) 2009-  Werner Rammer, Rupert Seidl
5
**
6
**    This program is free software: you can redistribute it and/or modify
7
**    it under the terms of the GNU General Public License as published by
8
**    the Free Software Foundation, either version 3 of the License, or
9
**    (at your option) any later version.
10
**
11
**    This program is distributed in the hope that it will be useful,
12
**    but WITHOUT ANY WARRANTY; without even the implied warranty of
13
**    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
**    GNU General Public License for more details.
15
**
16
**    You should have received a copy of the GNU General Public License
17
**    along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
********************************************************************************************/
19
 
87 Werner 20
/** @class SettingMetaData
86 Werner 21
 This is some help text for the SettingMetaData class.
22
*/
23
 
24
#include <QtCore>
94 Werner 25
#include "settingmetadata.h"
86 Werner 26
 
27
const QStringList SettingMetaData::mTypeNames = QStringList() << "invalid" <<  "species" << "model";
28
 
94 Werner 29
SettingMetaData::Type SettingMetaData::typeFromName(const QString &settingName)
86 Werner 30
{
31
    Type retType = (Type) mTypeNames.indexOf(settingName);
32
    if ( int(retType)<0)
33
        retType = SettingInvalid;
34
    return retType;
35
}
36
 
87 Werner 37
const QString SettingMetaData::typeName(const Type type) const
86 Werner 38
{
39
    return mTypeNames.value(int(type),mTypeNames[0]);
40
}
41
 
42
SettingMetaData::SettingMetaData()
43
{
44
    mType = SettingInvalid;
45
}
46
 
47
SettingMetaData::SettingMetaData(const Type type, const QString &name, const QString &description, const QString &url, const QVariant defaultValue)
48
{
87 Werner 49
    setValues(type, name, description, url, defaultValue);
50
}
51
 
52
void SettingMetaData::setValues(const Type type, const QString &name, const QString &description, const QString &url, const QVariant defaultValue)
53
{
86 Werner 54
    mType = type;
55
    mName = name;
56
    mDescription = description;
57
    mUrl = url;
87 Werner 58
    mDefaultValue = defaultValue;
86 Werner 59
}
87 Werner 60
 
61
QString SettingMetaData::dump() const
62
{
88 Werner 63
    QString res = QString("Name: %1\nType: %2 *** Default Value: %5 *** Url: %3 *** Memory address: %6 \nDescription: %4").
87 Werner 64
                  arg(mName,
65
                      typeName(mType),
88 Werner 66
                      mUrl,
67
                      mDescription).
68
                  arg(mDefaultValue.toString()).
835 werner 69
                  arg(ptrdiff_t(this), 0, 16);
87 Werner 70
    return res;
71
}
72