diff options
Diffstat (limited to 'data')
-rw-r--r-- | data/inst/instance.cpp | 34 | ||||
-rw-r--r-- | data/inst/instanceloader.cpp | 5 | ||||
-rw-r--r-- | data/inst/instanceloader.h | 2 |
3 files changed, 38 insertions, 3 deletions
diff --git a/data/inst/instance.cpp b/data/inst/instance.cpp index d2240bc5..8561ed9f 100644 --- a/data/inst/instance.cpp +++ b/data/inst/instance.cpp @@ -15,7 +15,41 @@ #include "instance.h" +#include <QFileInfo> + +#include "util/pathutils.h" + Instance::Instance(const QString &rootDir, QObject *parent) : SettingsBase(parent) { + m_rootDir = rootDir; + config.loadFile(PathCombine(rootDir, "instance.cfg")); +} + +QString Instance::id() +{ + return QFileInfo(rootDir()).baseName(); +} + +QString Instance::rootDir() +{ + return m_rootDir; +} + +InstanceList *Instance::instList() +{ + if (parent()->inherits("InstanceList")) + return (InstanceList *)parent(); + else + return NULL; +} + +QVariant Instance::getField(const QString &name, QVariant defVal) const +{ + return config.get(name, defVal); +} + +void Instance::setField(const QString &name, QVariant val) +{ + config.set(name, val); } diff --git a/data/inst/instanceloader.cpp b/data/inst/instanceloader.cpp index bc43c061..1a53bfa7 100644 --- a/data/inst/instanceloader.cpp +++ b/data/inst/instanceloader.cpp @@ -17,9 +17,10 @@ #include "instancetype.h" -InstanceLoader::InstanceLoader(QObject *parent) : - QObject(parent) +InstanceLoader::InstanceLoader() : + QObject(NULL) { + } diff --git a/data/inst/instanceloader.h b/data/inst/instanceloader.h index 1a8a598f..b7092edc 100644 --- a/data/inst/instanceloader.h +++ b/data/inst/instanceloader.h @@ -109,7 +109,7 @@ public: InstTypeList typeList(); private: - explicit InstanceLoader(QObject *parent = 0); + InstanceLoader(); QMap<QString, InstanceType *> m_typeMap; }; |