diff options
author | Andrew <forkk@forkk.net> | 2013-01-25 12:35:14 -0600 |
---|---|---|
committer | Andrew <forkk@forkk.net> | 2013-01-25 12:35:14 -0600 |
commit | f5ee069ea989a07915eb20c62ec4e812dfa9e701 (patch) | |
tree | 7d2895bf49925aa6ef7cc91caf9a01de694b2eee /data/instancebase.cpp | |
parent | 3b422b54aa13be4eb59c80b1f7bb2a514aac583f (diff) | |
parent | 00893b3cfc68f12c09e84643d255044a488b0eb6 (diff) | |
download | MultiMC-f5ee069ea989a07915eb20c62ec4e812dfa9e701.tar MultiMC-f5ee069ea989a07915eb20c62ec4e812dfa9e701.tar.gz MultiMC-f5ee069ea989a07915eb20c62ec4e812dfa9e701.tar.lz MultiMC-f5ee069ea989a07915eb20c62ec4e812dfa9e701.tar.xz MultiMC-f5ee069ea989a07915eb20c62ec4e812dfa9e701.zip |
Merge branch 'master' of git://github.com/peterix/MultiMC5
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; +} |