From 432ec7417499c6fa6b0c2935c96ad5f3d1d097c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Mon, 11 Apr 2016 01:30:50 +0200 Subject: GH-1404 allow deleting groups and creating instances in groups directly using context menu --- logic/InstanceList.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'logic/InstanceList.cpp') diff --git a/logic/InstanceList.cpp b/logic/InstanceList.cpp index 8197fe24..741b8611 100644 --- a/logic/InstanceList.cpp +++ b/logic/InstanceList.cpp @@ -133,8 +133,43 @@ QStringList InstanceList::getGroups() return m_groups.toList(); } +void InstanceList::suspendGroupSaving() +{ + suspendedGroupSave = true; +} + +void InstanceList::resumeGroupSaving() +{ + if(suspendedGroupSave) + { + suspendedGroupSave = false; + if(queuedGroupSave) + { + saveGroupList(); + } + } +} + +void InstanceList::deleteGroup(const QString& name) +{ + for(auto & instance: m_instances) + { + auto instGroupName = instance->group(); + if(instGroupName == name) + { + instance->setGroupPost(QString()); + } + } +} + void InstanceList::saveGroupList() { + if(suspendedGroupSave) + { + queuedGroupSave = true; + return; + } + QString groupFileName = m_instDir + "/instgroups.json"; QMap> groupMap; for (auto instance : m_instances) -- cgit v1.2.3