Changeset View
Changeset View
Standalone View
Standalone View
src/lib/plugin/desktopfileparser_p.h
Show All 30 Lines | |||||
31 | class QJsonObject; | 31 | class QJsonObject; | ||
32 | class QJsonValue; | 32 | class QJsonValue; | ||
33 | 33 | | |||
34 | Q_DECLARE_LOGGING_CATEGORY(DESKTOPPARSER) | 34 | Q_DECLARE_LOGGING_CATEGORY(DESKTOPPARSER) | ||
35 | 35 | | |||
36 | struct CustomPropertyDefinition; | 36 | struct CustomPropertyDefinition; | ||
37 | struct ServiceTypeDefinition | 37 | struct ServiceTypeDefinition | ||
38 | { | 38 | { | ||
39 | ServiceTypeDefinition(); | 39 | QVector<CustomPropertyDefinition> m_propertyDefs; | ||
40 | QByteArray m_serviceTypeName; | ||||
41 | }; | ||||
40 | 42 | | |||
41 | static ServiceTypeDefinition fromFiles(const QStringList &paths); | 43 | struct ServiceTypeDefinitions | ||
44 | { | ||||
45 | static ServiceTypeDefinitions fromFiles(const QStringList &paths); | ||||
42 | /** | 46 | /** | ||
43 | * @return @p value converted to the correct JSON type. | 47 | * @return @p value converted to the correct JSON type. | ||
44 | * If there is no custom property definition for @p key this will simply return the string value | 48 | * If there is no custom property definition for @p key this will simply return the string value | ||
45 | */ | 49 | */ | ||
46 | QJsonValue parseValue(const QByteArray &key, const QString &value) const; | 50 | QJsonValue parseValue(const QByteArray &key, const QString &value) const; | ||
47 | 51 | | |||
48 | /** | 52 | /** | ||
49 | * Parses the service file in @p path and extracts its definitions | 53 | * Parses the service file in @p path and extracts its definitions | ||
50 | * | 54 | * | ||
51 | * @returns whether the action could be performed | 55 | * @returns whether the action could be performed | ||
52 | */ | 56 | */ | ||
53 | bool addFile(const QString &path); | 57 | bool addFile(const QString &path); | ||
54 | 58 | | |||
59 | bool hasServiceType(const QByteArray &serviceTypeName) const; | ||||
60 | | ||||
55 | private: | 61 | private: | ||
56 | QVector<CustomPropertyDefinition> m_definitions; | 62 | QVector<ServiceTypeDefinition> m_definitions; | ||
57 | }; | 63 | }; | ||
58 | 64 | | |||
59 | namespace DesktopFileParser | 65 | namespace DesktopFileParser | ||
60 | { | 66 | { | ||
61 | QByteArray escapeValue(const QByteArray &input); | 67 | QByteArray escapeValue(const QByteArray &input); | ||
62 | QStringList deserializeList(const QString &data, char separator = ','); | 68 | QStringList deserializeList(const QString &data, char separator = ','); | ||
63 | bool convert(const QString &src, const QStringList &serviceTypes, QJsonObject &json, QString *libraryPath); | 69 | bool convert(const QString &src, const QStringList &serviceTypes, QJsonObject &json, QString *libraryPath); | ||
64 | void convertToJson(const QByteArray &key, ServiceTypeDefinition &serviceTypes, const QString &value, | 70 | void convertToJson(const QByteArray &key, ServiceTypeDefinitions &serviceTypes, const QString &value, | ||
65 | QJsonObject &json, QJsonObject &kplugin, int lineNr); | 71 | QJsonObject &json, QJsonObject &kplugin, int lineNr); | ||
66 | #ifdef BUILDING_DESKTOPTOJSON_TOOL | 72 | #ifdef BUILDING_DESKTOPTOJSON_TOOL | ||
67 | void convertToCompatibilityJson(const QString &key, const QString &value, QJsonObject &json, int lineNr); | 73 | void convertToCompatibilityJson(const QString &key, const QString &value, QJsonObject &json, int lineNr); | ||
68 | extern bool s_verbose; | 74 | extern bool s_verbose; | ||
69 | extern bool s_compatibilityMode; | 75 | extern bool s_compatibilityMode; | ||
70 | #endif | 76 | #endif | ||
71 | } | 77 | } | ||
72 | 78 | | |||
73 | 79 | | |||
74 | #endif // DESKTOPFILEPARSER_H | 80 | #endif // DESKTOPFILEPARSER_H |