aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2018-04-18 06:46:11 +0200
committerJoerg Bornemann <joerg.bornemann@qt.io>2018-04-19 11:59:05 +0000
commit560b3ea28aa34471ea7aacfeb6e7acf7a3cd4a27 (patch)
treef05f6bd9c7ed9e4e806ac7b26b2ac797bc2db077
parent929ac40c78792594b4651c3adaad5aceb9e123a9 (diff)
Make sure we can build qbs without item models
Have separate files for the Settings representation. Change-Id: I01c646652d2572d107ffc5bc2ea347ff9c058532 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-rw-r--r--src/app/config/configcommandexecutor.cpp2
-rw-r--r--src/app/qbs/parser/commandlineparser.cpp2
-rw-r--r--src/lib/corelib/corelib.qbs2
-rw-r--r--src/lib/corelib/tools/settingsmodel.cpp31
-rw-r--r--src/lib/corelib/tools/settingsmodel.h3
-rw-r--r--src/lib/corelib/tools/settingsrepresentation.cpp75
-rw-r--r--src/lib/corelib/tools/settingsrepresentation.h55
-rw-r--r--src/lib/corelib/tools/tools.pri2
8 files changed, 137 insertions, 35 deletions
diff --git a/src/app/config/configcommandexecutor.cpp b/src/app/config/configcommandexecutor.cpp
index 3169a6f24..365997043 100644
--- a/src/app/config/configcommandexecutor.cpp
+++ b/src/app/config/configcommandexecutor.cpp
@@ -41,7 +41,7 @@
#include "configcommand.h"
#include "../shared/logging/consolelogger.h"
-#include <tools/settingsmodel.h>
+#include <tools/settingsrepresentation.h>
#include <tools/error.h>
#include <QtCore/qdir.h>
diff --git a/src/app/qbs/parser/commandlineparser.cpp b/src/app/qbs/parser/commandlineparser.cpp
index feb69b207..92c43c8c6 100644
--- a/src/app/qbs/parser/commandlineparser.cpp
+++ b/src/app/qbs/parser/commandlineparser.cpp
@@ -57,7 +57,7 @@
#include <tools/qbsassert.h>
#include <tools/qttools.h>
#include <tools/settings.h>
-#include <tools/settingsmodel.h>
+#include <tools/settingsrepresentation.h>
#include <QtCore/qcoreapplication.h>
#include <QtCore/qdir.h>
diff --git a/src/lib/corelib/corelib.qbs b/src/lib/corelib/corelib.qbs
index 6c0671e25..13c20c2c8 100644
--- a/src/lib/corelib/corelib.qbs
+++ b/src/lib/corelib/corelib.qbs
@@ -432,6 +432,8 @@ QbsLibrary {
"settingscreator.cpp",
"settingscreator.h",
"settingsmodel.cpp",
+ "settingsrepresentation.cpp",
+ "settingsrepresentation.h",
"setupprojectparameters.cpp",
"shellutils.cpp",
"shellutils.h",
diff --git a/src/lib/corelib/tools/settingsmodel.cpp b/src/lib/corelib/tools/settingsmodel.cpp
index bb98c3512..4defb46b9 100644
--- a/src/lib/corelib/tools/settingsmodel.cpp
+++ b/src/lib/corelib/tools/settingsmodel.cpp
@@ -37,8 +37,8 @@
**
****************************************************************************/
#include "settingsmodel.h"
+#include "settingsrepresentation.h"
-#include <tools/jsliterals.h>
#include <tools/profile.h>
#include <tools/qttools.h>
#include <tools/settings.h>
@@ -51,9 +51,6 @@
#include <QtGui/qbrush.h>
#endif
-#include <QtScript/qscriptengine.h>
-#include <QtScript/qscriptvalue.h>
-
#include <memory>
namespace qbs {
@@ -394,30 +391,4 @@ Node *SettingsModel::SettingsModelPrivate::indexToNode(const QModelIndex &index)
}
-QString settingsValueToRepresentation(const QVariant &value)
-{
- return toJSLiteral(value);
-}
-
-static QVariant variantFromString(const QString &str, bool &ok)
-{
- // ### use Qt5's JSON reader at some point.
- QScriptEngine engine;
- QScriptValue sv = engine.evaluate(QLatin1String("(function(){return ")
- + str + QLatin1String(";})()"));
- ok = !sv.isError();
- return sv.toVariant();
-}
-
-QVariant representationToSettingsValue(const QString &representation)
-{
- bool ok;
- const QVariant variant = variantFromString(representation, ok);
- if (ok)
- return variant;
-
- // If it's not valid JavaScript, interpret the value as a string.
- return representation;
-}
-
} // namespace qbs
diff --git a/src/lib/corelib/tools/settingsmodel.h b/src/lib/corelib/tools/settingsmodel.h
index 94f163438..adcc2a826 100644
--- a/src/lib/corelib/tools/settingsmodel.h
+++ b/src/lib/corelib/tools/settingsmodel.h
@@ -81,9 +81,6 @@ private:
SettingsModelPrivate * const d;
};
-QBS_EXPORT QString settingsValueToRepresentation(const QVariant &value);
-QBS_EXPORT QVariant representationToSettingsValue(const QString &representation);
-
} // namespace qbs
#endif // QBS_SETTINGSMODEL_H
diff --git a/src/lib/corelib/tools/settingsrepresentation.cpp b/src/lib/corelib/tools/settingsrepresentation.cpp
new file mode 100644
index 000000000..f977fbd9f
--- /dev/null
+++ b/src/lib/corelib/tools/settingsrepresentation.cpp
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qbs.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "settingsrepresentation.h"
+
+#include "jsliterals.h"
+
+#include <QtScript/qscriptengine.h>
+#include <QtScript/qscriptvalue.h>
+
+namespace qbs {
+
+QString settingsValueToRepresentation(const QVariant &value)
+{
+ return toJSLiteral(value);
+}
+
+static QVariant variantFromString(const QString &str, bool &ok)
+{
+ // ### use Qt5's JSON reader at some point.
+ QScriptEngine engine;
+ QScriptValue sv = engine.evaluate(QLatin1String("(function(){return ")
+ + str + QLatin1String(";})()"));
+ ok = !sv.isError();
+ return sv.toVariant();
+}
+
+QVariant representationToSettingsValue(const QString &representation)
+{
+ bool ok;
+ const QVariant variant = variantFromString(representation, ok);
+ if (ok)
+ return variant;
+
+ // If it's not valid JavaScript, interpret the value as a string.
+ return representation;
+}
+
+} // namespace qbs
diff --git a/src/lib/corelib/tools/settingsrepresentation.h b/src/lib/corelib/tools/settingsrepresentation.h
new file mode 100644
index 000000000..9ebd64d3d
--- /dev/null
+++ b/src/lib/corelib/tools/settingsrepresentation.h
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2018 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of Qbs.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QBS_SETTINGSREPRESENTATION_H
+#define QBS_SETTINGSREPRESENTATION_H
+
+#include <tools/qbs_export.h>
+
+#include <QtCore/qstring.h>
+#include <QtCore/qvariant.h>
+
+namespace qbs {
+
+QBS_EXPORT QString settingsValueToRepresentation(const QVariant &value);
+QBS_EXPORT QVariant representationToSettingsValue(const QString &representation);
+
+} // namespace qbs
+
+#endif // QBS_SETTINGSREPRESENTATION_H
diff --git a/src/lib/corelib/tools/tools.pri b/src/lib/corelib/tools/tools.pri
index e128e5c92..b6dbebc86 100644
--- a/src/lib/corelib/tools/tools.pri
+++ b/src/lib/corelib/tools/tools.pri
@@ -27,6 +27,7 @@ HEADERS += \
$$PWD/set.h \
$$PWD/settings.h \
$$PWD/settingsmodel.h \
+ $$PWD/settingsrepresentation.h \
$$PWD/pathutils.h \
$$PWD/preferences.h \
$$PWD/profile.h \
@@ -79,6 +80,7 @@ SOURCES += \
$$PWD/scripttools.cpp \
$$PWD/settings.cpp \
$$PWD/settingsmodel.cpp \
+ $$PWD/settingsrepresentation.cpp \
$$PWD/preferences.cpp \
$$PWD/processresult.cpp \
$$PWD/processutils.cpp \