diff options
author | Petr Mrázek <peterix@gmail.com> | 2013-01-22 05:56:12 +0100 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2013-01-22 05:56:12 +0100 |
commit | 00893b3cfc68f12c09e84643d255044a488b0eb6 (patch) | |
tree | 229762a1cc56827b7bbfedd237dbf5c3bd57808c /data/instancebase.cpp | |
parent | f33ab9beb17bd11cb55951cb04d24cef34f6dec0 (diff) | |
download | MultiMC-00893b3cfc68f12c09e84643d255044a488b0eb6.tar MultiMC-00893b3cfc68f12c09e84643d255044a488b0eb6.tar.gz MultiMC-00893b3cfc68f12c09e84643d255044a488b0eb6.tar.lz MultiMC-00893b3cfc68f12c09e84643d255044a488b0eb6.tar.xz MultiMC-00893b3cfc68f12c09e84643d255044a488b0eb6.zip |
Instance model (or at least something like it)
Diffstat (limited to 'data/instancebase.cpp')
-rw-r--r-- | data/instancebase.cpp | 64 |
1 files changed, 62 insertions, 2 deletions
diff --git a/data/instancebase.cpp b/data/instancebase.cpp index 15dc54f4..a5ef35a2 100644 --- a/data/instancebase.cpp +++ b/data/instancebase.cpp @@ -16,6 +16,7 @@ #include "instancebase.h" #include <QFileInfo> +#include <QDir> #include "../util/pathutils.h" @@ -23,10 +24,27 @@ InstanceBase::InstanceBase(QString dir, QObject *parent) : QObject(parent), rootDir(dir) { - QFileInfo cfgFile; + QFileInfo cfgFile(PathCombine(rootDir, "instance.cfg")); if (cfgFile.exists()) - config.loadFile(PathCombine(rootDir, "instance.cfg")); + { + if(!config.loadFile(cfgFile.absoluteFilePath())) + { + QString debugmsg("Can't load instance config file for instance "); + debugmsg+= getInstID(); + qDebug(debugmsg.toLocal8Bit()); + } + } + else + { + QString debugmsg("Can't find instance config file for instance "); + debugmsg+= getInstID(); + debugmsg += " : "; + debugmsg += + debugmsg+=" ... is this an instance even?"; + qDebug(debugmsg.toLocal8Bit()); + } + currentGroup = nullptr; } QString InstanceBase::getRootDir() const @@ -47,3 +65,45 @@ void InstanceBase::setInstName(QString name) { config.set("name", name); } + +QString InstanceBase::getInstID() const +{ + return QDir(rootDir).dirName(); +} + +InstanceModelItem* InstanceBase::getParent() const +{ + return currentGroup; +} + +QVariant InstanceBase::data ( int role ) const +{ + switch(role) + { + case Qt::DisplayRole: + return getInstName(); + default: + return QVariant(); + } +} +int InstanceBase::getRow() const +{ + return currentGroup->getIndexOf((InstanceBase*)this); +} + +InstanceModelItem* InstanceBase::getChild ( int index ) const +{ + return nullptr; +} +InstanceModel* InstanceBase::getModel() const +{ + return currentGroup->getModel(); +} +IMI_type InstanceBase::getModelItemType() const +{ + return IMI_Instance; +} +int InstanceBase::numChildren() const +{ + return 0; +} |