From 50dd33a3dfb1ce8ace89dbd49ecb8957abc30521 Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Sun, 11 Dec 2016 22:45:05 +0100 Subject: [PATCH] Access type tables using QStandardPaths. This removes a use of KStandardDirs, which is deprecated. The new implementation must handle the former NoDuplicates option itself. For this reason, the files are collected in a std::map<> by file name such that files from later directories are ignored. --- kdbg/main.cpp | 4 ---- kdbg/typetable.cpp | 25 +++++++++++++++++-------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/kdbg/main.cpp b/kdbg/main.cpp index 4b9879e..4019cd1 100644 --- a/kdbg/main.cpp +++ b/kdbg/main.cpp @@ -7,8 +7,6 @@ #include #include /* i18n */ #include -#include -#include #include #include #include "dbgmainwnd.h" @@ -53,8 +51,6 @@ int main(int argc, char** argv) KApplication app; - KGlobal::dirs()->addResourceType("types", "data", "kdbg/types"); - DebuggerMainWnd* debugger = new DebuggerMainWnd; debugger->setObjectName("mainwindow"); diff --git a/kdbg/typetable.cpp b/kdbg/typetable.cpp index b7f74c6..ecd1461 100644 --- a/kdbg/typetable.cpp +++ b/kdbg/typetable.cpp @@ -5,9 +5,9 @@ */ #include "typetable.h" +#include #include -#include -#include +#include #include #include #include @@ -37,17 +37,26 @@ void TypeTable::loadTypeTables() { typeTablesInited = true; - const QStringList files = KGlobal::dirs()->findAllResources("types", "*.kdbgtt", - KStandardDirs::NoDuplicates); - - if (files.isEmpty()) { + std::map files; + for (const QString& dir: QStandardPaths::locateAll(QStandardPaths::AppDataLocation, "types", + QStandardPaths::LocateDirectory)) + { + for (const QString& file: QDir(dir).entryList(QStringList() << QStringLiteral("*.kdbgtt"))) + { + files.emplace(file, dir); + // this did not insert the entry if the same file name occurred earlier + // this is exactly what we want: earlier files have higher priority + } + } + + if (files.empty()) { TRACE("no type tables found"); return; } - for (QStringList::ConstIterator p = files.begin(); p != files.end(); ++p) { + for (const auto& file: files) { typeTables.push_back(TypeTable()); - typeTables.back().loadFromFile(*p); + typeTables.back().loadFromFile(file.second + '/' + file.first); } } -- 2.11.4.GIT