Implemented Instance
This commit is contained in:
parent
d3c4db8f34
commit
80cd8b33aa
@ -15,7 +15,41 @@
|
|||||||
|
|
||||||
#include "instance.h"
|
#include "instance.h"
|
||||||
|
|
||||||
|
#include <QFileInfo>
|
||||||
|
|
||||||
|
#include "util/pathutils.h"
|
||||||
|
|
||||||
Instance::Instance(const QString &rootDir, QObject *parent) :
|
Instance::Instance(const QString &rootDir, QObject *parent) :
|
||||||
SettingsBase(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);
|
||||||
}
|
}
|
||||||
|
@ -17,9 +17,10 @@
|
|||||||
|
|
||||||
#include "instancetype.h"
|
#include "instancetype.h"
|
||||||
|
|
||||||
InstanceLoader::InstanceLoader(QObject *parent) :
|
InstanceLoader::InstanceLoader() :
|
||||||
QObject(parent)
|
QObject(NULL)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ public:
|
|||||||
InstTypeList typeList();
|
InstTypeList typeList();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
explicit InstanceLoader(QObject *parent = 0);
|
InstanceLoader();
|
||||||
|
|
||||||
QMap<QString, InstanceType *> m_typeMap;
|
QMap<QString, InstanceType *> m_typeMap;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user