Skip to content
Snippets Groups Projects
Commit d194b984 authored by Jarosław Staniek's avatar Jarosław Staniek
Browse files

Make certain views work in User mode

Summary: BUG:396875

Test Plan: See the bug description

Reviewers: piggz

Reviewed By: piggz

Subscribers: Kexi-Devel-list

Tags: #kexi

Differential Revision: https://phabricator.kde.org/D14402
parent 4260f712
No related branches found
No related tags found
No related merge requests found
......@@ -21,6 +21,7 @@
#include "kexipartinfo_p.h"
#include "kexipartmanager.h"
#include "KexiMainWindowIface.h"
#include <KexiJsonTrader.h>
#include <KDbGlobal>
......@@ -41,7 +42,7 @@ static bool isTrue(KPluginMetaData *metaData, const char* fieldName, bool defaul
return 0 == s.compare(QLatin1String("true"), Qt::CaseInsensitive);
}
Info::Private::Private(Info *info, const QJsonObject &rootObject)
Info::Private::Private(Info *info, const QPluginLoader &loader)
: untranslatedGroupName(info->value("X-Kexi-GroupName"))
, typeName(info->value("X-Kexi-TypeName"))
, supportedViewModes(0)
......@@ -53,7 +54,8 @@ Info::Private::Private(Info *info, const QJsonObject &rootObject)
, isPropertyEditorAlwaysVisibleInDesignMode(
isTrue(info, "X-Kexi-PropertyEditorAlwaysVisibleInDesignMode", true))
{
groupName = info->readTranslatedString(rootObject, "X-Kexi-GroupName", untranslatedGroupName);
const QJsonObject metaDataObject = KexiJsonTrader::metaDataObjectForPluginLoader(loader);
groupName = info->readTranslatedString(metaDataObject, "X-Kexi-GroupName", untranslatedGroupName);
const QStringList serviceTypes = info->serviceTypes();
if (serviceTypes.contains("Kexi/Viewer")) {
supportedViewModes |= Kexi::DataViewMode;
......@@ -65,14 +67,15 @@ Info::Private::Private(Info *info, const QJsonObject &rootObject)
supportedViewModes |= Kexi::TextViewMode;
}
const QJsonArray userServiceTypes = rootObject.value("X-Kexi-ServiceTypesInUserMode").toArray();
if (userServiceTypes.contains(QJsonValue("Kexi/Viewer"))) {
const QStringList userServiceTypes = metaDataObject.value("X-Kexi-ServiceTypesInUserMode")
.toString().split(QLatin1Char(',')); // NOTE: toArray() does not work
if (userServiceTypes.contains("Kexi/Viewer")) {
supportedUserViewModes |= Kexi::DataViewMode;
}
if (userServiceTypes.contains(QJsonValue("Kexi/Designer"))) {
if (userServiceTypes.contains("Kexi/Designer")) {
supportedUserViewModes |= Kexi::DesignViewMode;
}
if (userServiceTypes.contains(QJsonValue("Kexi/Editor"))) {
if (userServiceTypes.contains("Kexi/Editor")) {
supportedUserViewModes |= Kexi::TextViewMode;
}
}
......@@ -132,7 +135,7 @@ void KexiNewObjectAction::slotTriggered()
//}
Info::Info(const QPluginLoader &loader)
: KexiPluginMetaData(loader), d(new Private(this, rootObject()))
: KexiPluginMetaData(loader), d(new Private(this, loader))
{
}
......
......@@ -31,7 +31,7 @@ namespace KexiPart
class Q_DECL_HIDDEN Info::Private
{
public:
Private(Info *info, const QJsonObject &rootObject);
Private(Info *info, const QPluginLoader &loader);
//! used in StaticItem class
Private();
......
......@@ -28,8 +28,7 @@
class Q_DECL_HIDDEN KexiPluginMetaData::Private
{
public:
Private(KexiPluginMetaData *info, const QPluginLoader &loader)
: rootObject(KexiJsonTrader::rootObjectForPluginLoader(loader))
Private(KexiPluginMetaData *info)
{
QStringList v(info->version().split('.'));
bool ok = v.count() >= 2;
......@@ -45,7 +44,6 @@ public:
}
}
QJsonObject rootObject;
QString errorMessage;
int majorVersion;
int minorVersion;
......@@ -54,7 +52,7 @@ public:
//------------------------------
KexiPluginMetaData::KexiPluginMetaData(const QPluginLoader &loader)
: KPluginMetaData(loader), d(new Private(this, loader))
: KPluginMetaData(loader), d(new Private(this))
{
}
......@@ -87,8 +85,3 @@ int KexiPluginMetaData::minorVersion() const
{
return d->minorVersion;
}
QJsonObject KexiPluginMetaData::rootObject() const
{
return d->rootObject;
}
......@@ -67,12 +67,6 @@ protected:
*/
void setErrorMessage(const QString& errorMessage);
/**
* @return root object for this plugin, useful to retrieve Kexi-specific fields using
* readStringList(), readTranslatedValue() or readTranslatedString().
*/
QJsonObject rootObject() const;
private:
Q_DISABLE_COPY(KexiPluginMetaData)
class Private;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment