summaryrefslogtreecommitdiffstats
path: root/logic/lists/InstanceList.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2013-12-15 18:10:51 +0100
committerPetr Mrázek <peterix@gmail.com>2013-12-15 18:13:46 +0100
commitdd9e04000ccd02a868138de9276f8fb93b855550 (patch)
tree496985ef1c0d0d1ba724948b87aaf641a78c624b /logic/lists/InstanceList.cpp
parent5a3043398e45cbe39455609a42463f2e6e5d3fd2 (diff)
downloadMultiMC-dd9e04000ccd02a868138de9276f8fb93b855550.tar
MultiMC-dd9e04000ccd02a868138de9276f8fb93b855550.tar.gz
MultiMC-dd9e04000ccd02a868138de9276f8fb93b855550.tar.lz
MultiMC-dd9e04000ccd02a868138de9276f8fb93b855550.tar.xz
MultiMC-dd9e04000ccd02a868138de9276f8fb93b855550.zip
Improve group changing, update instance on version change
Gives a list of existing groups to choose from. Instances are updated as long as there is at least one valid account.
Diffstat (limited to 'logic/lists/InstanceList.cpp')
-rw-r--r--logic/lists/InstanceList.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/logic/lists/InstanceList.cpp b/logic/lists/InstanceList.cpp
index 94481fb9..15fd10ba 100644
--- a/logic/lists/InstanceList.cpp
+++ b/logic/lists/InstanceList.cpp
@@ -117,6 +117,11 @@ void InstanceList::groupChanged()
saveGroupList();
}
+QStringList InstanceList::getGroups()
+{
+ return m_groups.toList();
+}
+
void InstanceList::saveGroupList()
{
QString groupFileName = m_instDir + "/instgroups.json";
@@ -126,7 +131,7 @@ void InstanceList::saveGroupList()
if (!groupFile.open(QIODevice::WriteOnly | QIODevice::Truncate))
{
// An error occurred. Ignore it.
- QLOG_ERROR() << "Failed to read instance group file.";
+ QLOG_ERROR() << "Failed to save instance group file.";
return;
}
QTextStream out(&groupFile);
@@ -137,6 +142,10 @@ void InstanceList::saveGroupList()
QString group = instance->group();
if (group.isEmpty())
continue;
+
+ // keep a list/set of groups for choosing
+ m_groups.insert(group);
+
if (!groupMap.count(group))
{
QSet<QString> set;
@@ -253,6 +262,9 @@ void InstanceList::loadGroupList(QMap<QString, QString> &groupMap)
continue;
}
+ // keep a list/set of groups for choosing
+ m_groups.insert(groupName);
+
// Iterate through the list of instances in the group.
QJsonArray instancesArray = groupObj.value("instances").toArray();