diff options
author | Andrew <forkk@forkk.net> | 2013-12-01 14:28:47 -0600 |
---|---|---|
committer | Andrew <forkk@forkk.net> | 2013-12-01 14:28:47 -0600 |
commit | 613699b3626aea750093ab7eaaeccaa28c0e87c6 (patch) | |
tree | 7fd542b8f4be10359ba2aaeac9834f1b5c86a750 /logic/lists/InstanceList.cpp | |
parent | 2427ad687137bbcfc7303a931d7e0b74d5325e48 (diff) | |
parent | 75c4d97b90e39f2bda6e682def0fdda044cbcf6f (diff) | |
download | MultiMC-613699b3626aea750093ab7eaaeccaa28c0e87c6.tar MultiMC-613699b3626aea750093ab7eaaeccaa28c0e87c6.tar.gz MultiMC-613699b3626aea750093ab7eaaeccaa28c0e87c6.tar.lz MultiMC-613699b3626aea750093ab7eaaeccaa28c0e87c6.tar.xz MultiMC-613699b3626aea750093ab7eaaeccaa28c0e87c6.zip |
Merge branch 'develop' of github.com:MultiMC/MultiMC5 into develop
Diffstat (limited to 'logic/lists/InstanceList.cpp')
-rw-r--r-- | logic/lists/InstanceList.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/logic/lists/InstanceList.cpp b/logic/lists/InstanceList.cpp index 7081dc6f..b9595578 100644 --- a/logic/lists/InstanceList.cpp +++ b/logic/lists/InstanceList.cpp @@ -281,14 +281,6 @@ InstanceList::InstListError InstanceList::loadList() auto &loader = InstanceFactory::get(); auto error = loader.loadInstance(instPtr, subDir); - switch (error) - { - case InstanceFactory::NoLoadError: - break; - case InstanceFactory::NotAnInstance: - break; - } - if (error != InstanceFactory::NoLoadError && error != InstanceFactory::NotAnInstance) { QString errorMsg = QString("Failed to load instance %1: ") @@ -362,8 +354,13 @@ int InstanceList::add(InstancePtr t) return count() - 1; } -InstancePtr InstanceList::getInstanceById(QString instId) +InstancePtr InstanceList::getInstanceById(QString instId) const { + if (m_instances.isEmpty()) + { + return InstancePtr(); + } + QListIterator<InstancePtr> iter(m_instances); InstancePtr inst; while (iter.hasNext()) @@ -378,7 +375,12 @@ InstancePtr InstanceList::getInstanceById(QString instId) return iter.peekPrevious(); } -int InstanceList::getInstIndex(BaseInstance *inst) +QModelIndex InstanceList::getInstanceIndexById(const QString &id) const +{ + return index(getInstIndex(getInstanceById(id).get())); +} + +int InstanceList::getInstIndex(BaseInstance *inst) const { for (int i = 0; i < m_instances.count(); i++) { |