Changeset View
Changeset View
Standalone View
Standalone View
libdiscover/Category/CategoriesReader.cpp
Show All 18 Lines | |||||
19 | ***************************************************************************/ | 19 | ***************************************************************************/ | ||
20 | 20 | | |||
21 | #include "CategoriesReader.h" | 21 | #include "CategoriesReader.h" | ||
22 | #include "Category.h" | 22 | #include "Category.h" | ||
23 | #include <QDomNode> | 23 | #include <QDomNode> | ||
24 | #include <QFile> | 24 | #include <QFile> | ||
25 | #include "libdiscover_debug.h" | 25 | #include "libdiscover_debug.h" | ||
26 | #include <QStandardPaths> | 26 | #include <QStandardPaths> | ||
27 | #include <QCoreApplication> | ||||
27 | 28 | | |||
28 | #include <DiscoverBackendsFactory.h> | 29 | #include <DiscoverBackendsFactory.h> | ||
29 | #include <resources/AbstractResourcesBackend.h> | 30 | #include <resources/AbstractResourcesBackend.h> | ||
30 | 31 | | |||
31 | QVector<Category*> CategoriesReader::loadCategoriesFile(AbstractResourcesBackend* backend) | 32 | QVector<Category*> CategoriesReader::loadCategoriesFile(AbstractResourcesBackend* backend) | ||
32 | { | 33 | { | ||
33 | QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("libdiscover/categories/")+backend->name()+QStringLiteral("-categories.xml")); | 34 | QString path = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("libdiscover/categories/")+backend->name()+QStringLiteral("-categories.xml")); | ||
34 | if (path.isEmpty()) { | 35 | if (path.isEmpty()) { | ||
Show All 24 Lines | 59 | if(!correct) | |||
59 | qCWarning(LIBDISCOVER_LOG) << "error while parsing the categories file:" << error << " at: " << path << ':' << line; | 60 | qCWarning(LIBDISCOVER_LOG) << "error while parsing the categories file:" << error << " at: " << path << ':' << line; | ||
60 | 61 | | |||
61 | QDomElement root = menuDocument.documentElement(); | 62 | QDomElement root = menuDocument.documentElement(); | ||
62 | 63 | | |||
63 | QDomNode node = root.firstChild(); | 64 | QDomNode node = root.firstChild(); | ||
64 | while(!node.isNull()) | 65 | while(!node.isNull()) | ||
65 | { | 66 | { | ||
66 | if (node.nodeType() == QDomNode::ElementNode) { | 67 | if (node.nodeType() == QDomNode::ElementNode) { | ||
67 | ret << new Category( {path} ); | 68 | ret << new Category( {path}, qApp ); | ||
68 | ret.last()->parseData(path, node); | 69 | ret.last()->parseData(path, node); | ||
69 | } | 70 | } | ||
70 | 71 | | |||
71 | node = node.nextSibling(); | 72 | node = node.nextSibling(); | ||
72 | } | 73 | } | ||
73 | Category::sortCategories(ret); | 74 | Category::sortCategories(ret); | ||
74 | return ret; | 75 | return ret; | ||
75 | } | 76 | } |