From 80cd8b33aa12933392bd2293a5e91ae696dbe6be Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 18 Feb 2013 16:58:53 -0600 Subject: Implemented Instance --- data/inst/instance.cpp | 34 ++++++++++++++++++++++++++++++++++ data/inst/instanceloader.cpp | 5 +++-- data/inst/instanceloader.h | 2 +- 3 files changed, 38 insertions(+), 3 deletions(-) (limited to 'data') 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; }; -- cgit v1.2.3