diff options
Diffstat (limited to 'api/logic')
-rw-r--r-- | api/logic/InstanceList.cpp | 3 | ||||
-rw-r--r-- | api/logic/InstanceList.h | 1 | ||||
-rw-r--r-- | api/logic/settings/INIFile.cpp | 16 | ||||
-rw-r--r-- | api/logic/settings/INIFile_test.cpp | 3 |
4 files changed, 19 insertions, 4 deletions
diff --git a/api/logic/InstanceList.cpp b/api/logic/InstanceList.cpp index afbebc25..c713b626 100644 --- a/api/logic/InstanceList.cpp +++ b/api/logic/InstanceList.cpp @@ -234,7 +234,7 @@ void InstanceList::deleteInstance(const InstanceId& id) auto inst = getInstanceById(id); if(!inst) { - qDebug() << "Cannot delete instance" << id << " No such instance is present."; + qDebug() << "Cannot delete instance" << id << ". No such instance is present (deleted externally?)."; return; } @@ -819,6 +819,7 @@ bool InstanceList::commitStagedInstance(const QString& path, const QString& inst instanceSet.insert(instID); m_groups.insert(groupName); emit instancesChanged(); + emit instanceSelectRequest(instID); } saveGroupList(); return true; diff --git a/api/logic/InstanceList.h b/api/logic/InstanceList.h index 50b44738..e0abd890 100644 --- a/api/logic/InstanceList.h +++ b/api/logic/InstanceList.h @@ -129,6 +129,7 @@ public: signals: void dataIsInvalid(); void instancesChanged(); + void instanceSelectRequest(QString instanceId); void groupsChanged(QSet<QString> groups); public slots: diff --git a/api/logic/settings/INIFile.cpp b/api/logic/settings/INIFile.cpp index 42244131..ff6d5cf3 100644 --- a/api/logic/settings/INIFile.cpp +++ b/api/logic/settings/INIFile.cpp @@ -36,8 +36,10 @@ QString INIFile::unescape(QString orig) { if(c == 'n') out += '\n'; - else if (c == 't') + else if(c == 't') out += '\t'; + else if(c == '#') + out += '#'; else out += c; prev = 0; @@ -67,6 +69,8 @@ QString INIFile::escape(QString orig) out += "\\t"; else if(c == '\\') out += "\\\\"; + else if(c == '#') + out += "\\#"; else out += c; } @@ -120,7 +124,15 @@ bool INIFile::loadFile(QByteArray file) { QString &lineRaw = lines[i]; // Ignore comments. - QString line = lineRaw.left(lineRaw.indexOf('#')).trimmed(); + int commentIndex = 0; + QString line = lineRaw; + // Search for comments until no more escaped # are available + while((commentIndex = line.indexOf('#', commentIndex + 1)) != -1) { + if(commentIndex > 0 && line.at(commentIndex - 1) == '\\') { + continue; + } + line = line.left(lineRaw.indexOf('#')).trimmed(); + } int eqPos = line.indexOf('='); if (eqPos == -1) diff --git a/api/logic/settings/INIFile_test.cpp b/api/logic/settings/INIFile_test.cpp index 45f70973..08c2155e 100644 --- a/api/logic/settings/INIFile_test.cpp +++ b/api/logic/settings/INIFile_test.cpp @@ -26,6 +26,7 @@ slots: QTest::newRow("Plain text") << "Lorem ipsum dolor sit amet."; QTest::newRow("Escape sequences") << "Lorem\n\t\n\\n\\tAAZ\nipsum dolor\n\nsit amet."; QTest::newRow("Escape sequences 2") << "\"\n\n\""; + QTest::newRow("Hashtags") << "some data#something"; } void test_Escape() { @@ -40,7 +41,7 @@ slots: void test_SaveLoad() { QString a = "a"; - QString b = "a\nb\t\n\\\\\\C:\\Program files\\terrible\\name\\of something\\"; + QString b = "a\nb\t\n\\\\\\C:\\Program files\\terrible\\name\\of something\\#thisIsNotAComment"; QString filename = "test_SaveLoad.ini"; // save |