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 + +#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 m_typeMap; };