Changeset View
Changeset View
Standalone View
Standalone View
src/core/kexipartinfo.cpp
Show All 15 Lines | 1 | /* This file is part of the KDE project | |||
---|---|---|---|---|---|
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to | ||
17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
18 | * Boston, MA 02110-1301, USA. | 18 | * Boston, MA 02110-1301, USA. | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | #include "kexipartinfo_p.h" | 21 | #include "kexipartinfo_p.h" | ||
22 | #include "kexipartmanager.h" | 22 | #include "kexipartmanager.h" | ||
23 | #include "KexiMainWindowIface.h" | 23 | #include "KexiMainWindowIface.h" | ||
24 | #include <KexiJsonTrader.h> | ||||
24 | 25 | | |||
25 | #include <KDbGlobal> | 26 | #include <KDbGlobal> | ||
26 | 27 | | |||
27 | #include <KActionCollection> | 28 | #include <KActionCollection> | ||
28 | 29 | | |||
29 | #include <QStringList> | 30 | #include <QStringList> | ||
30 | #include <QDebug> | 31 | #include <QDebug> | ||
31 | #include <QJsonArray> | 32 | #include <QJsonArray> | ||
32 | 33 | | |||
33 | using namespace KexiPart; | 34 | using namespace KexiPart; | ||
34 | 35 | | |||
35 | static bool isTrue(KPluginMetaData *metaData, const char* fieldName, bool defaultValue = false) | 36 | static bool isTrue(KPluginMetaData *metaData, const char* fieldName, bool defaultValue = false) | ||
36 | { | 37 | { | ||
37 | QString s = metaData->value(QLatin1String(fieldName)); | 38 | QString s = metaData->value(QLatin1String(fieldName)); | ||
38 | if (s.isEmpty()) { | 39 | if (s.isEmpty()) { | ||
39 | return defaultValue; | 40 | return defaultValue; | ||
40 | } | 41 | } | ||
41 | return 0 == s.compare(QLatin1String("true"), Qt::CaseInsensitive); | 42 | return 0 == s.compare(QLatin1String("true"), Qt::CaseInsensitive); | ||
42 | } | 43 | } | ||
43 | 44 | | |||
44 | Info::Private::Private(Info *info, const QJsonObject &rootObject) | 45 | Info::Private::Private(Info *info, const QPluginLoader &loader) | ||
45 | : untranslatedGroupName(info->value("X-Kexi-GroupName")) | 46 | : untranslatedGroupName(info->value("X-Kexi-GroupName")) | ||
46 | , typeName(info->value("X-Kexi-TypeName")) | 47 | , typeName(info->value("X-Kexi-TypeName")) | ||
47 | , supportedViewModes(0) | 48 | , supportedViewModes(0) | ||
48 | , supportedUserViewModes(0) | 49 | , supportedUserViewModes(0) | ||
49 | , isVisibleInNavigator(isTrue(info, "X-Kexi-VisibleInProjectNavigator")) | 50 | , isVisibleInNavigator(isTrue(info, "X-Kexi-VisibleInProjectNavigator")) | ||
50 | , isDataExportSupported(isTrue(info, "X-Kexi-SupportsDataExport")) | 51 | , isDataExportSupported(isTrue(info, "X-Kexi-SupportsDataExport")) | ||
51 | , isPrintingSupported(isTrue(info, "X-Kexi-SupportsPrinting")) | 52 | , isPrintingSupported(isTrue(info, "X-Kexi-SupportsPrinting")) | ||
52 | , isExecuteSupported(isTrue(info, "X-Kexi-SupportsExecution")) | 53 | , isExecuteSupported(isTrue(info, "X-Kexi-SupportsExecution")) | ||
53 | , isPropertyEditorAlwaysVisibleInDesignMode( | 54 | , isPropertyEditorAlwaysVisibleInDesignMode( | ||
54 | isTrue(info, "X-Kexi-PropertyEditorAlwaysVisibleInDesignMode", true)) | 55 | isTrue(info, "X-Kexi-PropertyEditorAlwaysVisibleInDesignMode", true)) | ||
55 | { | 56 | { | ||
56 | groupName = info->readTranslatedString(rootObject, "X-Kexi-GroupName", untranslatedGroupName); | 57 | const QJsonObject metaDataObject = KexiJsonTrader::metaDataObjectForPluginLoader(loader); | ||
58 | groupName = info->readTranslatedString(metaDataObject, "X-Kexi-GroupName", untranslatedGroupName); | ||||
57 | const QStringList serviceTypes = info->serviceTypes(); | 59 | const QStringList serviceTypes = info->serviceTypes(); | ||
58 | if (serviceTypes.contains("Kexi/Viewer")) { | 60 | if (serviceTypes.contains("Kexi/Viewer")) { | ||
59 | supportedViewModes |= Kexi::DataViewMode; | 61 | supportedViewModes |= Kexi::DataViewMode; | ||
60 | } | 62 | } | ||
61 | if (serviceTypes.contains("Kexi/Designer")) { | 63 | if (serviceTypes.contains("Kexi/Designer")) { | ||
62 | supportedViewModes |= Kexi::DesignViewMode; | 64 | supportedViewModes |= Kexi::DesignViewMode; | ||
63 | } | 65 | } | ||
64 | if (serviceTypes.contains("Kexi/Editor")) { | 66 | if (serviceTypes.contains("Kexi/Editor")) { | ||
65 | supportedViewModes |= Kexi::TextViewMode; | 67 | supportedViewModes |= Kexi::TextViewMode; | ||
66 | } | 68 | } | ||
67 | 69 | | |||
68 | const QJsonArray userServiceTypes = rootObject.value("X-Kexi-ServiceTypesInUserMode").toArray(); | 70 | const QStringList userServiceTypes = metaDataObject.value("X-Kexi-ServiceTypesInUserMode") | ||
69 | if (userServiceTypes.contains(QJsonValue("Kexi/Viewer"))) { | 71 | .toString().split(QLatin1Char(',')); // NOTE: toArray() does not work | ||
72 | if (userServiceTypes.contains("Kexi/Viewer")) { | ||||
70 | supportedUserViewModes |= Kexi::DataViewMode; | 73 | supportedUserViewModes |= Kexi::DataViewMode; | ||
71 | } | 74 | } | ||
72 | if (userServiceTypes.contains(QJsonValue("Kexi/Designer"))) { | 75 | if (userServiceTypes.contains("Kexi/Designer")) { | ||
73 | supportedUserViewModes |= Kexi::DesignViewMode; | 76 | supportedUserViewModes |= Kexi::DesignViewMode; | ||
74 | } | 77 | } | ||
75 | if (userServiceTypes.contains(QJsonValue("Kexi/Editor"))) { | 78 | if (userServiceTypes.contains("Kexi/Editor")) { | ||
76 | supportedUserViewModes |= Kexi::TextViewMode; | 79 | supportedUserViewModes |= Kexi::TextViewMode; | ||
77 | } | 80 | } | ||
78 | } | 81 | } | ||
79 | 82 | | |||
80 | Info::Private::Private() | 83 | Info::Private::Private() | ||
81 | : supportedViewModes(0) | 84 | : supportedViewModes(0) | ||
82 | , supportedUserViewModes(0) | 85 | , supportedUserViewModes(0) | ||
83 | , isVisibleInNavigator(false) | 86 | , isVisibleInNavigator(false) | ||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Line(s) | |||||
127 | // const QString &objectName) | 130 | // const QString &objectName) | ||
128 | // : KPluginMetaData(), d(new Private) | 131 | // : KPluginMetaData(), d(new Private) | ||
129 | //{ | 132 | //{ | ||
130 | // d->iconName = iconName; | 133 | // d->iconName = iconName; | ||
131 | // d->objectName = objectName; | 134 | // d->objectName = objectName; | ||
132 | //} | 135 | //} | ||
133 | 136 | | |||
134 | Info::Info(const QPluginLoader &loader) | 137 | Info::Info(const QPluginLoader &loader) | ||
135 | : KexiPluginMetaData(loader), d(new Private(this, rootObject())) | 138 | : KexiPluginMetaData(loader), d(new Private(this, loader)) | ||
136 | { | 139 | { | ||
137 | } | 140 | } | ||
138 | 141 | | |||
139 | Info::~Info() | 142 | Info::~Info() | ||
140 | { | 143 | { | ||
141 | delete d; | 144 | delete d; | ||
142 | } | 145 | } | ||
143 | 146 | | |||
▲ Show 20 Lines • Show All 66 Lines • Show Last 20 Lines |