summaryrefslogtreecommitdiffstats
path: root/logic/lists
diff options
context:
space:
mode:
authorJan Dalheimer <jan@dalheimer.de>2013-11-27 15:00:44 +0100
committerPetr Mrázek <peterix@gmail.com>2013-11-30 12:28:20 +0100
commit88318561724cae6d19f892adf778d85e6c736391 (patch)
tree9e0dbcb80c49b7fc88214f82c81d85ffcb529282 /logic/lists
parenteff38858ef32239cd91044295ce7db3def857339 (diff)
downloadMultiMC-88318561724cae6d19f892adf778d85e6c736391.tar
MultiMC-88318561724cae6d19f892adf778d85e6c736391.tar.gz
MultiMC-88318561724cae6d19f892adf778d85e6c736391.tar.lz
MultiMC-88318561724cae6d19f892adf778d85e6c736391.tar.xz
MultiMC-88318561724cae6d19f892adf778d85e6c736391.zip
Remember the last selected instance and select it on startup
Diffstat (limited to 'logic/lists')
-rw-r--r--logic/lists/InstanceList.cpp9
-rw-r--r--logic/lists/InstanceList.h6
2 files changed, 11 insertions, 4 deletions
diff --git a/logic/lists/InstanceList.cpp b/logic/lists/InstanceList.cpp
index 7081dc6f..200b02df 100644
--- a/logic/lists/InstanceList.cpp
+++ b/logic/lists/InstanceList.cpp
@@ -362,7 +362,7 @@ int InstanceList::add(InstancePtr t)
return count() - 1;
}
-InstancePtr InstanceList::getInstanceById(QString instId)
+InstancePtr InstanceList::getInstanceById(QString instId) const
{
QListIterator<InstancePtr> iter(m_instances);
InstancePtr inst;
@@ -378,7 +378,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++)
{
diff --git a/logic/lists/InstanceList.h b/logic/lists/InstanceList.h
index d08501eb..8cd39746 100644
--- a/logic/lists/InstanceList.h
+++ b/logic/lists/InstanceList.h
@@ -91,7 +91,9 @@ public:
int add(InstancePtr t);
/// Get an instance by ID
- InstancePtr getInstanceById(QString id);
+ InstancePtr getInstanceById(QString id) const;
+
+ QModelIndex getInstanceIndexById(const QString &id) const;
signals:
void dataIsInvalid();
@@ -106,7 +108,7 @@ slots:
void groupChanged();
private:
- int getInstIndex(BaseInstance *inst);
+ int getInstIndex(BaseInstance *inst) const;
protected:
QString m_instDir;