From 159c3d35d41a121f9cbf55631aebbd309b683811 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 28 Oct 2011 15:29:14 +0200 Subject: [PATCH] Qt Designer: Remove QScript extension. Change-Id: I351b1437442b65a96e07de6fa633e06f3953c128 Sanity-Review: Qt Sanity Bot Reviewed-by: Friedemann Kleint --- .../components/formeditor/qdesigner_resource.cpp | 35 +- .../src/components/formeditor/qdesigner_resource.h | 1 - src/designer/src/components/lib/lib.pro | 1 - .../src/components/widgetbox/widgetbox_dnditem.cpp | 3 +- src/designer/src/designer/designer.pro | 1 - src/designer/src/lib/sdk/script.cpp | 109 ----- src/designer/src/lib/sdk/script_p.h | 83 ---- src/designer/src/lib/sdk/sdk.pri | 2 - src/designer/src/lib/shared/metadatabase.cpp | 10 - src/designer/src/lib/shared/metadatabase_p.h | 4 - src/designer/src/lib/shared/newformwidget.cpp | 2 +- .../src/lib/shared/qdesigner_formbuilder.cpp | 76 +--- .../src/lib/shared/qdesigner_formbuilder_p.h | 13 +- src/designer/src/lib/shared/qdesigner_taskmenu.cpp | 42 -- src/designer/src/lib/shared/qdesigner_taskmenu_p.h | 1 - src/designer/src/lib/shared/qscripthighlighter.cpp | 468 --------------------- src/designer/src/lib/shared/qscripthighlighter_p.h | 84 ---- src/designer/src/lib/shared/qsimpleresource.cpp | 62 +-- src/designer/src/lib/shared/qsimpleresource_p.h | 3 +- src/designer/src/lib/shared/scriptcommand.cpp | 103 ----- src/designer/src/lib/shared/scriptcommand_p.h | 93 ---- src/designer/src/lib/shared/scriptdialog.cpp | 130 ------ src/designer/src/lib/shared/scriptdialog_p.h | 90 ---- src/designer/src/lib/shared/scripterrordialog.cpp | 108 ----- src/designer/src/lib/shared/scripterrordialog_p.h | 83 ---- src/designer/src/lib/shared/shared.pri | 9 - src/designer/src/lib/uilib/abstractformbuilder.cpp | 55 --- src/designer/src/lib/uilib/abstractformbuilder.h | 10 - src/designer/src/lib/uilib/formbuilderextra.cpp | 23 - src/designer/src/lib/uilib/formbuilderextra_p.h | 13 - src/designer/src/lib/uilib/formscriptrunner.cpp | 208 --------- src/designer/src/lib/uilib/formscriptrunner_p.h | 120 ------ src/designer/src/lib/uilib/uilib.pri | 7 - src/designer/src/uitools/quiloader.cpp | 32 -- src/designer/src/uitools/uitools.pro | 2 +- 35 files changed, 18 insertions(+), 2068 deletions(-) delete mode 100644 src/designer/src/lib/sdk/script.cpp delete mode 100644 src/designer/src/lib/sdk/script_p.h delete mode 100644 src/designer/src/lib/shared/qscripthighlighter.cpp delete mode 100644 src/designer/src/lib/shared/qscripthighlighter_p.h delete mode 100644 src/designer/src/lib/shared/scriptcommand.cpp delete mode 100644 src/designer/src/lib/shared/scriptcommand_p.h delete mode 100644 src/designer/src/lib/shared/scriptdialog.cpp delete mode 100644 src/designer/src/lib/shared/scriptdialog_p.h delete mode 100644 src/designer/src/lib/shared/scripterrordialog.cpp delete mode 100644 src/designer/src/lib/shared/scripterrordialog_p.h delete mode 100644 src/designer/src/lib/uilib/formscriptrunner.cpp delete mode 100644 src/designer/src/lib/uilib/formscriptrunner_p.h diff --git a/src/designer/src/components/formeditor/qdesigner_resource.cpp b/src/designer/src/components/formeditor/qdesigner_resource.cpp index 6212831..8470814 100644 --- a/src/designer/src/components/formeditor/qdesigner_resource.cpp +++ b/src/designer/src/components/formeditor/qdesigner_resource.cpp @@ -805,20 +805,7 @@ QWidget *QDesignerResource::create(DomWidget *ui_widget, QWidget *parentWidget) } ui_widget->setAttributeClass(className); // fix the class name - applyExtensionDataFromDOM(this, core(), ui_widget, w, true); - - // store user-defined scripts - if (MetaDataBase *metaDataBase = qobject_cast(core()->metaDataBase())) { - const QString designerSource = QStringLiteral("designer"); - const DomScripts domScripts = ui_widget->elementScript(); - if (!domScripts.empty()) { - foreach (const DomScript *script, domScripts) { - if (script->hasAttributeSource() && script->attributeSource() == designerSource) { - metaDataBase->metaDataBaseItem(w)->setScript(script->text()); - } - } - } - } + applyExtensionDataFromDOM(this, core(), ui_widget, w); return w; } @@ -1150,8 +1137,6 @@ DomWidget *QDesignerResource::createDom(QWidget *widget, DomWidget *ui_parentWid w->setAttributeClass(widgetInfo->name()); } addExtensionDataToDOM(this, core(), w, widget); - - addUserDefinedScripts(widget, w); return w; } @@ -1885,10 +1870,6 @@ DomCustomWidgets *QDesignerResource::saveCustomWidgets() custom_widget->setElementAddPageMethod(addPageMethod); } - // Look up static per-class scripts of designer - if (DomScript *domScript = createScript(customWidgetScript(core, name), ScriptCustomWidgetPlugin)) - custom_widget->setElementScript(domScript); - orderedMap.insert(db->indexOfClassName(name), custom_widget); } @@ -2286,20 +2267,6 @@ void QDesignerResource::loadExtraInfo(DomWidget *ui_widget, QWidget *widget, QWi applyAttributesToPropertySheet(ui_widget, widget); } -// Add user defined scripts (dialog box) belonging to QWidget to DomWidget. -void QDesignerResource::addUserDefinedScripts(QWidget *w, DomWidget *ui_widget) -{ - QDesignerFormEditorInterface *core = m_formWindow->core(); - DomScripts domScripts = ui_widget->elementScript(); - // Look up user-defined scripts of designer - if (const qdesigner_internal::MetaDataBase *metaDataBase = qobject_cast(core->metaDataBase())) { - if (const qdesigner_internal::MetaDataBaseItem *metaItem = metaDataBase->metaDataBaseItem(w)) { - addScript(metaItem->script(), ScriptDesigner, domScripts); - } - } - if (!domScripts.empty()) - ui_widget->setElementScript(domScripts); -} } QT_END_NAMESPACE diff --git a/src/designer/src/components/formeditor/qdesigner_resource.h b/src/designer/src/components/formeditor/qdesigner_resource.h index 787d227..f1ede4f 100644 --- a/src/designer/src/components/formeditor/qdesigner_resource.h +++ b/src/designer/src/components/formeditor/qdesigner_resource.h @@ -150,7 +150,6 @@ protected: DomProperty *applyProperStdSetAttribute(QObject *object, const QString &propertyName, DomProperty *property); private: - void addUserDefinedScripts(QWidget *w, DomWidget *ui_widget); DomResources *saveResources(const QStringList &qrcPaths); bool canCompressMargins(QObject *object) const; bool canCompressSpacings(QObject *object) const; diff --git a/src/designer/src/components/lib/lib.pro b/src/designer/src/components/lib/lib.pro index 93dcf9a..05b0ff2 100644 --- a/src/designer/src/components/lib/lib.pro +++ b/src/designer/src/components/lib/lib.pro @@ -54,5 +54,4 @@ include(../../sharedcomponents.pri) unix|win32-g++* { QMAKE_PKGCONFIG_REQUIRES = QtCore QtDesigner QtGui QtXml - contains(QT_CONFIG, script): QMAKE_PKGCONFIG_REQUIRES += QtScript } diff --git a/src/designer/src/components/widgetbox/widgetbox_dnditem.cpp b/src/designer/src/components/widgetbox/widgetbox_dnditem.cpp index eebd60e..a577b5b 100644 --- a/src/designer/src/components/widgetbox/widgetbox_dnditem.cpp +++ b/src/designer/src/components/widgetbox/widgetbox_dnditem.cpp @@ -54,7 +54,6 @@ #include #include -#include #include #include @@ -90,7 +89,7 @@ protected: }; WidgetBoxResource::WidgetBoxResource(QDesignerFormEditorInterface *core) : - QDesignerFormBuilder(core, DisableScripts, currentDeviceProfile(core)) + QDesignerFormBuilder(core, currentDeviceProfile(core)) { } diff --git a/src/designer/src/designer/designer.pro b/src/designer/src/designer/designer.pro index 353fca8..92e6899 100644 --- a/src/designer/src/designer/designer.pro +++ b/src/designer/src/designer/designer.pro @@ -6,7 +6,6 @@ QT += core-private widgets xml network designer-private printsupport CONFIG += module MODULE_PRI = ../../../../modules/qt_designer.pri -contains(QT_CONFIG, script): QT += script build_all:!build_pass { CONFIG -= build_all CONFIG += release diff --git a/src/designer/src/lib/sdk/script.cpp b/src/designer/src/lib/sdk/script.cpp deleted file mode 100644 index 69b112a..0000000 --- a/src/designer/src/lib/sdk/script.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "script_p.h" - -QT_BEGIN_NAMESPACE - -/*! - \class QDesignerScriptExtension - \brief The QDesignerScriptExtension class allows you to generate a - per-widget \l{QtScript} {Qt Script} snippet to be executed while - building the form. - - \internal - \inmodule QtDesigner - \since 4.3 - - On saving the form, the extension is queried for a script snippet - to be associated with the widget while saving the UI file. - This script is then run after creating the widget by \l uic or - QUiLoader. - - As opposed to \l QDesignerCustomWidgetInterface::codeTemplate(), - it allows for applying an internal state of the widget - that can be manipulated using \QD. - - Such a state might for example be the contents of a custom item view widget, - for which an editor is provided by the QDesignerTaskMenuExtension. - - While saving the form, the state is serialized as a QVariantMap of - \QD-supported properties, which is stored in the UI file. This is - handled by data() and setData(). - - For item view contents, there might be for example a key that determines - the number of items and other keys that contain the actual items following - a naming scheme (\c numItems, \c item1, \c item2, ...). - - On saving, script() is invoked, which should return a script snippet that - applies the state to the widget while building the form. - - \sa {Creating Custom Widgets for Qt Designer#Using Qt Script to Aid in Building Forms}{Creating Custom Widgets for Qt Designer}, QtScript -*/ - -/*! - Destroys the extension. -*/ - -QDesignerScriptExtension::~QDesignerScriptExtension() -{ -} - -/*! - \fn virtual QString QDesignerScriptExtension::script() const - - Returns a script snippet to be associated with the widget. -*/ - -/*! - \fn virtual QVariantMap QDesignerScriptExtension::data() const - - Returns a map of variants describing the internal state to be - stored in the UI file. -*/ - -/*! - \fn virtual void QDesignerScriptExtension::setData(const QVariantMap &data) - - Applies the internal state stored in \a data to the widget while loading a form. -*/ - -QT_END_NAMESPACE diff --git a/src/designer/src/lib/sdk/script_p.h b/src/designer/src/lib/sdk/script_p.h deleted file mode 100644 index cd483b8..0000000 --- a/src/designer/src/lib/sdk/script_p.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of Qt Designer. This header -// file may change from version to version without notice, or even be removed. -// -// We mean it. -// - -#ifndef SCRIPT_H -#define SCRIPT_H - -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QString; // FIXME: fool syncqt - -class QDESIGNER_SDK_EXPORT QDesignerScriptExtension -{ -public: - virtual ~QDesignerScriptExtension(); - - virtual QVariantMap data() const = 0; - virtual void setData(const QVariantMap &data) = 0; - - virtual QString script() const = 0; - -}; -Q_DECLARE_EXTENSION_INTERFACE(QDesignerScriptExtension, "com.trolltech.Qt.Designer.Script") - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // SCRIPT_H diff --git a/src/designer/src/lib/sdk/sdk.pri b/src/designer/src/lib/sdk/sdk.pri index 725edeb..c0ec87d 100644 --- a/src/designer/src/lib/sdk/sdk.pri +++ b/src/designer/src/lib/sdk/sdk.pri @@ -30,7 +30,6 @@ HEADERS += $$PWD/abstractformeditor.h \ $$PWD/abstractdnditem.h \ $$PWD/abstractpromotioninterface.h \ $$PWD/abstractdialoggui_p.h \ - $$PWD/script_p.h \ $$PWD/abstractnewformwidget.h SOURCES += $$PWD/abstractformeditor.cpp \ @@ -52,5 +51,4 @@ SOURCES += $$PWD/abstractformeditor.cpp \ $$PWD/extrainfo.cpp \ $$PWD/abstractpromotioninterface.cpp \ $$PWD/abstractdialoggui.cpp \ - $$PWD/script.cpp \ $$PWD/abstractnewformwidget.cpp diff --git a/src/designer/src/lib/shared/metadatabase.cpp b/src/designer/src/lib/shared/metadatabase.cpp index 0ac2eeb..4a23504 100644 --- a/src/designer/src/lib/shared/metadatabase.cpp +++ b/src/designer/src/lib/shared/metadatabase.cpp @@ -110,16 +110,6 @@ void MetaDataBaseItem::setEnabled(bool b) m_enabled = b; } -QString MetaDataBaseItem::script() const -{ - return m_script; -} - -void MetaDataBaseItem::setScript(const QString &script) -{ - m_script = script; -} - QStringList MetaDataBaseItem::fakeSlots() const { return m_fakeSlots; diff --git a/src/designer/src/lib/shared/metadatabase_p.h b/src/designer/src/lib/shared/metadatabase_p.h index 3da0ef1..bbdedb0 100644 --- a/src/designer/src/lib/shared/metadatabase_p.h +++ b/src/designer/src/lib/shared/metadatabase_p.h @@ -84,9 +84,6 @@ public: QString customClassName() const; void setCustomClassName(const QString &customClassName); - QString script() const; - void setScript(const QString &script); - QStringList fakeSlots() const; void setFakeSlots(const QStringList &); @@ -98,7 +95,6 @@ private: TabOrder m_tabOrder; bool m_enabled; QString m_customClassName; - QString m_script; QStringList m_fakeSlots; QStringList m_fakeSignals; }; diff --git a/src/designer/src/lib/shared/newformwidget.cpp b/src/designer/src/lib/shared/newformwidget.cpp index edcdf94..af91a3e 100644 --- a/src/designer/src/lib/shared/newformwidget.cpp +++ b/src/designer/src/lib/shared/newformwidget.cpp @@ -311,7 +311,7 @@ QImage NewFormWidget::grabForm(QDesignerFormEditorInterface *core, const qdesigner_internal::DeviceProfile &dp) { qdesigner_internal::NewFormWidgetFormBuilder - formBuilder(core, qdesigner_internal::QDesignerFormBuilder::DisableScripts, dp); + formBuilder(core, dp); if (!workingDir.isEmpty()) formBuilder.setWorkingDirectory(workingDir); diff --git a/src/designer/src/lib/shared/qdesigner_formbuilder.cpp b/src/designer/src/lib/shared/qdesigner_formbuilder.cpp index f6c1bd1..c4e9d41 100644 --- a/src/designer/src/lib/shared/qdesigner_formbuilder.cpp +++ b/src/designer/src/lib/shared/qdesigner_formbuilder.cpp @@ -63,7 +63,6 @@ #include #include #include -#include #include #include @@ -83,25 +82,11 @@ QT_BEGIN_NAMESPACE -#ifndef QT_FORMBUILDER_NO_SCRIPT -static QString summarizeScriptErrors(const QFormScriptRunner::Errors &errors) -{ - QString rc = QCoreApplication::translate("QDesignerFormBuilder", "Script errors occurred:"); - foreach (QFormScriptRunner::Error error, errors) { - rc += QLatin1Char('\n'); - rc += error.errorMessage; - } - return rc; -} -#endif - namespace qdesigner_internal { QDesignerFormBuilder::QDesignerFormBuilder(QDesignerFormEditorInterface *core, - Mode mode, const DeviceProfile &deviceProfile) : m_core(core), - m_mode(mode), m_deviceProfile(deviceProfile), m_pixmapCache(0), m_iconCache(0), @@ -110,20 +95,6 @@ QDesignerFormBuilder::QDesignerFormBuilder(QDesignerFormEditorInterface *core, m_mainWidget(true) { Q_ASSERT(m_core); -#ifndef QT_FORMBUILDER_NO_SCRIPT - // Disable scripting in the editors. - QFormScriptRunner::Options options = formScriptRunner()->options(); - switch (m_mode) { - case DisableScripts: - options |= QFormScriptRunner::DisableScripts; - break; - case EnableScripts: - options |= QFormScriptRunner::DisableWarnings; - options &= ~QFormScriptRunner::DisableScripts; - break; - } - formScriptRunner()-> setOptions(options); -#endif } QString QDesignerFormBuilder::systemStyle() const @@ -332,7 +303,7 @@ QWidget *QDesignerFormBuilder::create(DomWidget *ui_widget, QWidget *parentWidge { QWidget *widget = QFormBuilder::create(ui_widget, parentWidget); // Do not apply state if scripts are to be run in preview mode - QSimpleResource::applyExtensionDataFromDOM(this, m_core, ui_widget, widget, m_mode == DisableScripts); + QSimpleResource::applyExtensionDataFromDOM(this, m_core, ui_widget, widget); return widget; } @@ -366,13 +337,10 @@ QWidget *QDesignerFormBuilder::createPreview(const QDesignerFormWindowInterface const QString &styleName, const QString &appStyleSheet, const DeviceProfile &deviceProfile, - ScriptErrors *scriptErrors, QString *errorMessage) { - scriptErrors->clear(); - // load - QDesignerFormBuilder builder(fw->core(), EnableScripts, deviceProfile); + QDesignerFormBuilder builder(fw->core(), deviceProfile); builder.setWorkingDirectory(fw->absoluteDir()); QByteArray bytes = fw->contents().toUtf8(); @@ -393,15 +361,6 @@ QWidget *QDesignerFormBuilder::createPreview(const QDesignerFormWindowInterface WidgetFactory::applyStyleToTopLevel(wf->getStyle(styleToUse), widget); } } -#ifndef QT_FORMBUILDER_NO_SCRIPT - // Check for script errors - *scriptErrors = builder.formScriptRunner()->errors(); - if (!scriptErrors->empty()) { - *errorMessage = summarizeScriptErrors(*scriptErrors); - delete widget; - return 0; - } -#endif // Fake application style sheet by prepending. (If this doesn't work, fake by nesting // into parent widget). if (!appStyleSheet.isEmpty()) { @@ -421,37 +380,21 @@ QWidget *QDesignerFormBuilder::createPreview(const QDesignerFormWindowInterface QWidget *QDesignerFormBuilder::createPreview(const QDesignerFormWindowInterface *fw, const QString &styleName, const QString &appStyleSheet, - const DeviceProfile &deviceProfile, - QString *errorMessage) -{ - ScriptErrors scriptErrors; - return createPreview(fw, styleName, appStyleSheet, deviceProfile, &scriptErrors, errorMessage); -} - -QWidget *QDesignerFormBuilder::createPreview(const QDesignerFormWindowInterface *fw, - const QString &styleName, - const QString &appStyleSheet, QString *errorMessage) { - ScriptErrors scriptErrors; - return createPreview(fw, styleName, appStyleSheet, DeviceProfile(), &scriptErrors, errorMessage); + return createPreview(fw, styleName, appStyleSheet, DeviceProfile(), errorMessage); } QWidget *QDesignerFormBuilder::createPreview(const QDesignerFormWindowInterface *fw, const QString &styleName, const QString &appStyleSheet) { - ScriptErrors scriptErrors; QString errorMessage; - QWidget *widget = createPreview(fw, styleName, appStyleSheet, DeviceProfile(), &scriptErrors, &errorMessage); - if (!widget) { + QWidget *widget = createPreview(fw, styleName, appStyleSheet, DeviceProfile(), &errorMessage); + if (!widget && !errorMessage.isEmpty()) { // Display Script errors or message box QWidget *dialogParent = fw->core()->topLevel(); - if (scriptErrors.empty()) { - fw->core()->dialogGui()->message(dialogParent, QDesignerDialogGuiInterface::PreviewFailureMessage, - QMessageBox::Warning, QCoreApplication::translate("QDesignerFormBuilder", "Designer"), errorMessage, QMessageBox::Ok); - } else { - ScriptErrorDialog scriptErrorDialog(scriptErrors, dialogParent); - scriptErrorDialog.exec(); - } + fw->core()->dialogGui()->message(dialogParent, QDesignerDialogGuiInterface::PreviewFailureMessage, + QMessageBox::Warning, QCoreApplication::translate("QDesignerFormBuilder", "Designer"), + errorMessage, QMessageBox::Ok); return 0; } return widget; @@ -471,9 +414,8 @@ QPixmap QDesignerFormBuilder::createPreviewPixmap(const QDesignerFormWindowInter // ---------- NewFormWidgetFormBuilder NewFormWidgetFormBuilder::NewFormWidgetFormBuilder(QDesignerFormEditorInterface *core, - Mode mode, const DeviceProfile &deviceProfile) : - QDesignerFormBuilder(core, mode, deviceProfile) + QDesignerFormBuilder(core, deviceProfile) { } diff --git a/src/designer/src/lib/shared/qdesigner_formbuilder_p.h b/src/designer/src/lib/shared/qdesigner_formbuilder_p.h index 9a7a767..627c1f0 100644 --- a/src/designer/src/lib/shared/qdesigner_formbuilder_p.h +++ b/src/designer/src/lib/shared/qdesigner_formbuilder_p.h @@ -56,7 +56,6 @@ #include "shared_global_p.h" #include "deviceprofile_p.h" -#include #include #include @@ -81,13 +80,7 @@ class DesignerIconCache; class QDESIGNER_SHARED_EXPORT QDesignerFormBuilder: public QFormBuilder { public: - enum Mode { - DisableScripts, - EnableScripts - }; - QDesignerFormBuilder(QDesignerFormEditorInterface *core, - Mode mode, const DeviceProfile &deviceProfile = DeviceProfile()); virtual QWidget *createWidget(DomWidget *ui_widget, QWidget *parentWidget = 0) @@ -98,18 +91,16 @@ public: QString systemStyle() const; - typedef QFormScriptRunner::Errors ScriptErrors; // Create a preview widget (for integrations) or return 0. The widget has to be embedded into a main window. // Experimental, depending on script support. static QWidget *createPreview(const QDesignerFormWindowInterface *fw, const QString &styleName /* ="" */, const QString &appStyleSheet /* ="" */, const DeviceProfile &deviceProfile, - ScriptErrors *scriptErrors, QString *errorMessage); + QString *errorMessage); // Convenience that pops up message boxes in case of failures. static QWidget *createPreview(const QDesignerFormWindowInterface *fw, const QString &styleName = QString()); // Create a preview widget (for integrations) or return 0. The widget has to be embedded into a main window. static QWidget *createPreview(const QDesignerFormWindowInterface *fw, const QString &styleName, const QString &appStyleSheet, QString *errorMessage); - static QWidget *createPreview(const QDesignerFormWindowInterface *fw, const QString &styleName, const QString &appStyleSheet, const DeviceProfile &deviceProfile, QString *errorMessage); // Convenience that pops up message boxes in case of failures. static QWidget *createPreview(const QDesignerFormWindowInterface *fw, const QString &styleName, const QString &appStyleSheet); @@ -143,7 +134,6 @@ protected: private: QDesignerFormEditorInterface *m_core; - const Mode m_mode; typedef QSet WidgetSet; WidgetSet m_customWidgetsWithScript; @@ -164,7 +154,6 @@ private: class QDESIGNER_SHARED_EXPORT NewFormWidgetFormBuilder: public QDesignerFormBuilder { public: NewFormWidgetFormBuilder(QDesignerFormEditorInterface *core, - Mode mode, const DeviceProfile &deviceProfile = DeviceProfile()); protected: diff --git a/src/designer/src/lib/shared/qdesigner_taskmenu.cpp b/src/designer/src/lib/shared/qdesigner_taskmenu.cpp index 1b5e206..c548b56 100644 --- a/src/designer/src/lib/shared/qdesigner_taskmenu.cpp +++ b/src/designer/src/lib/shared/qdesigner_taskmenu.cpp @@ -51,8 +51,6 @@ #include "textpropertyeditor_p.h" #include "promotiontaskmenu_p.h" #include "metadatabase_p.h" -#include "scriptdialog_p.h" -#include "scriptcommand_p.h" #include "signalslotdialog_p.h" #include "qdesigner_membersheet_p.h" #include "qdesigner_propertycommand_p.h" @@ -324,7 +322,6 @@ public: QAction *m_addToolBar; QAction *m_addStatusBar; QAction *m_removeStatusBar; - QAction *m_changeScript; QAction *m_containerFakeMethods; QAction *m_navigateToSlot; PromotionTaskMenu* m_promotionTaskMenu; @@ -353,7 +350,6 @@ QDesignerTaskMenuPrivate::QDesignerTaskMenuPrivate(QWidget *widget, QObject *par m_addToolBar(new QAction(QDesignerTaskMenu::tr("Add Tool Bar"), parent)), m_addStatusBar(new QAction(QDesignerTaskMenu::tr("Create Status Bar"), parent)), m_removeStatusBar(new QAction(QDesignerTaskMenu::tr("Remove Status Bar"), parent)), - m_changeScript(new QAction(QDesignerTaskMenu::tr("Change script..."), parent)), m_containerFakeMethods(new QAction(QDesignerTaskMenu::tr("Change signals/slots..."), parent)), m_navigateToSlot(new QAction(QDesignerTaskMenu::tr("Go to slot..."), parent)), m_promotionTaskMenu(new PromotionTaskMenu(widget, PromotionTaskMenu::ModeManagedMultiSelection, parent)), @@ -406,7 +402,6 @@ QDesignerTaskMenu::QDesignerTaskMenu(QWidget *widget, QObject *parent) : connect(d->m_addToolBar, SIGNAL(triggered()), this, SLOT(addToolBar())); connect(d->m_addStatusBar, SIGNAL(triggered()), this, SLOT(createStatusBar())); connect(d->m_removeStatusBar, SIGNAL(triggered()), this, SLOT(removeStatusBar())); - connect(d->m_changeScript, SIGNAL(triggered()), this, SLOT(changeScript())); connect(d->m_containerFakeMethods, SIGNAL(triggered()), this, SLOT(containerFakeMethods())); connect(d->m_navigateToSlot, SIGNAL(triggered()), this, SLOT(slotNavigateToSlot())); connect(d->m_sizeActionGroup, SIGNAL(triggered(QAction*)), this, SLOT(applySize(QAction*))); @@ -535,12 +530,6 @@ QList QDesignerTaskMenu::taskActions() const PromotionTaskMenu::ModeManagedMultiSelection : PromotionTaskMenu::ModeUnmanagedMultiSelection); d->m_promotionTaskMenu->addActions(formWindow, PromotionTaskMenu::LeadingSeparator, actions); -#ifdef WANT_SCRIPT_OPTION - if (!isMainContainer) { - actions.append(d->m_separator4); - actions.append(d->m_changeScript); - } -#endif if (isMainContainer && !qt_extension(formWindow->core()->extensionManager(), formWindow->core())) { actions.append(d->m_separator5); actions.append(d->m_containerFakeMethods); @@ -640,37 +629,6 @@ void QDesignerTaskMenu::changeStyleSheet() } } -void QDesignerTaskMenu::changeScript() -{ - QDesignerFormWindowInterface *fw = formWindow(); - if (!fw) - return; - - MetaDataBase *metaDataBase = qobject_cast(fw->core()->metaDataBase()); - if (!metaDataBase) - return; - - const MetaDataBaseItem* item = metaDataBase->metaDataBaseItem(d->m_widget); - if (!item) - return; - - const QString oldScript = item->script(); - QString newScript = oldScript; - - ScriptDialog scriptDialog(fw->core()->dialogGui(), fw); - if (!scriptDialog.editScript(newScript)) - return; - - // compile list of selected objects - ScriptCommand *scriptCommand = new ScriptCommand(fw); - if (!scriptCommand->init(applicableObjects(fw, MultiSelectionMode), newScript)) { - delete scriptCommand; - return; - } - - fw->commandHistory()->push(scriptCommand); -} - void QDesignerTaskMenu::containerFakeMethods() { QDesignerFormWindowInterface *fw = formWindow(); diff --git a/src/designer/src/lib/shared/qdesigner_taskmenu_p.h b/src/designer/src/lib/shared/qdesigner_taskmenu_p.h index 2faffbc..8ae9491 100644 --- a/src/designer/src/lib/shared/qdesigner_taskmenu_p.h +++ b/src/designer/src/lib/shared/qdesigner_taskmenu_p.h @@ -114,7 +114,6 @@ private slots: void addToolBar(); void createStatusBar(); void removeStatusBar(); - void changeScript(); void containerFakeMethods(); void slotNavigateToSlot(); void applySize(QAction *a); diff --git a/src/designer/src/lib/shared/qscripthighlighter.cpp b/src/designer/src/lib/shared/qscripthighlighter.cpp deleted file mode 100644 index 57f5be4..0000000 --- a/src/designer/src/lib/shared/qscripthighlighter.cpp +++ /dev/null @@ -1,468 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qscripthighlighter_p.h" - -#include - -QT_BEGIN_NAMESPACE - -static const QSet &qscriptKeywords() { - static QSet keywords; - if (keywords.empty()) { - keywords.insert(QStringLiteral("Infinity")); - keywords.insert(QStringLiteral("NaN")); - keywords.insert(QStringLiteral("abstract")); - keywords.insert(QStringLiteral("boolean")); - keywords.insert(QStringLiteral("break")); - keywords.insert(QStringLiteral("byte")); - keywords.insert(QStringLiteral("case")); - keywords.insert(QStringLiteral("catch")); - keywords.insert(QStringLiteral("char")); - keywords.insert(QStringLiteral("class")); - keywords.insert(QStringLiteral("const")); - keywords.insert(QStringLiteral("constructor")); - keywords.insert(QStringLiteral("continue")); - keywords.insert(QStringLiteral("debugger")); - keywords.insert(QStringLiteral("default")); - keywords.insert(QStringLiteral("delete")); - keywords.insert(QStringLiteral("do")); - keywords.insert(QStringLiteral("double")); - keywords.insert(QStringLiteral("else")); - keywords.insert(QStringLiteral("enum")); - keywords.insert(QStringLiteral("export")); - keywords.insert(QStringLiteral("extends")); - keywords.insert(QStringLiteral("false")); - keywords.insert(QStringLiteral("final")); - keywords.insert(QStringLiteral("finally")); - keywords.insert(QStringLiteral("float")); - keywords.insert(QStringLiteral("for")); - keywords.insert(QStringLiteral("function")); - keywords.insert(QStringLiteral("goto")); - keywords.insert(QStringLiteral("if")); - keywords.insert(QStringLiteral("implements")); - keywords.insert(QStringLiteral("import")); - keywords.insert(QStringLiteral("in")); - keywords.insert(QStringLiteral("instanceof")); - keywords.insert(QStringLiteral("int")); - keywords.insert(QStringLiteral("interface")); - keywords.insert(QStringLiteral("long")); - keywords.insert(QStringLiteral("native")); - keywords.insert(QStringLiteral("new")); - keywords.insert(QStringLiteral("package")); - keywords.insert(QStringLiteral("private")); - keywords.insert(QStringLiteral("protected")); - keywords.insert(QStringLiteral("public")); - keywords.insert(QStringLiteral("return")); - keywords.insert(QStringLiteral("short")); - keywords.insert(QStringLiteral("static")); - keywords.insert(QStringLiteral("super")); - keywords.insert(QStringLiteral("switch")); - keywords.insert(QStringLiteral("synchronized")); - keywords.insert(QStringLiteral("this")); - keywords.insert(QStringLiteral("throw")); - keywords.insert(QStringLiteral("throws")); - keywords.insert(QStringLiteral("transient")); - keywords.insert(QStringLiteral("true")); - keywords.insert(QStringLiteral("try")); - keywords.insert(QStringLiteral("typeof")); - keywords.insert(QStringLiteral("undefined")); - keywords.insert(QStringLiteral("var")); - keywords.insert(QStringLiteral("void")); - keywords.insert(QStringLiteral("volatile")); - keywords.insert(QStringLiteral("while")); - keywords.insert(QStringLiteral("with")); // end - } - return keywords; -} - -static QSet alphaChars() { - QSet rc; - const QString alpha = QStringLiteral("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); - foreach (QChar chr, alpha) - rc.insert(chr); - return rc; -} - -namespace qdesigner_internal { - -QScriptHighlighter::QScriptHighlighter(QTextDocument *parent) - : QSyntaxHighlighter(parent) -{ - m_numberFormat.setForeground(Qt::blue); - m_stringFormat.setForeground(Qt::darkGreen); - m_typeFormat.setForeground(Qt::darkMagenta); - m_keywordFormat.setForeground(Qt::darkYellow); - m_labelFormat.setForeground(Qt::darkRed); - m_commentFormat.setForeground(Qt::red); - //m_commentFormat.setFontFamily("times"); - m_commentFormat.setFontItalic(true); - m_preProcessorFormat.setForeground(Qt::darkBlue); -} - -void QScriptHighlighter::highlightBlock(const QString &text) -{ - // states - enum { - StateStandard, - StateCommentStart1, - StateCCommentStart2, - StateCppCommentStart2, - StateCComment, - StateCppComment, - StateCCommentEnd1, - StateCCommentEnd2, - StateStringStart, - StateString, - StateStringEnd, - StateString2Start, - StateString2, - StateString2End, - StateNumber, - StatePreProcessor, - NumStates - }; - // tokens - enum { - InputAlpha, - InputNumber, - InputAsterix, - InputSlash, - InputParen, - InputSpace, - InputHash, - InputQuotation, - InputApostrophe, - InputSep, - NumInputs - }; - - static const uchar table[NumStates][NumInputs] = { - { StateStandard, StateNumber, StateStandard, StateCommentStart1, StateStandard, StateStandard, StatePreProcessor, StateStringStart, StateString2Start, StateStandard }, // StateStandard - { StateStandard, StateNumber, StateCCommentStart2, StateCppCommentStart2, StateStandard, StateStandard, StatePreProcessor, StateStringStart, StateString2Start, StateStandard }, // StateCommentStart1 - { StateCComment, StateCComment, StateCCommentEnd1, StateCComment, StateCComment, StateCComment, StateCComment, StateCComment, StateCComment, StateCComment }, // StateCCommentStart2 - { StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment }, // CppCommentStart2 - { StateCComment, StateCComment, StateCCommentEnd1, StateCComment, StateCComment, StateCComment, StateCComment, StateCComment, StateCComment, StateCComment }, // StateCComment - { StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment, StateCppComment }, // StateCppComment - { StateCComment, StateCComment, StateCCommentEnd1, StateCCommentEnd2, StateCComment, StateCComment, StateCComment, StateCComment, StateCComment, StateCComment }, // StateCCommentEnd1 - { StateStandard, StateNumber, StateStandard, StateCommentStart1, StateStandard, StateStandard, StatePreProcessor, StateStringStart, StateString2Start, StateStandard }, // StateCCommentEnd2 - { StateString, StateString, StateString, StateString, StateString, StateString, StateString, StateStringEnd, StateString, StateString }, // StateStringStart - { StateString, StateString, StateString, StateString, StateString, StateString, StateString, StateStringEnd, StateString, StateString }, // StateString - { StateStandard, StateStandard, StateStandard, StateCommentStart1, StateStandard, StateStandard, StatePreProcessor, StateStringStart, StateString2Start, StateStandard }, // StateStringEnd - { StateString2, StateString2, StateString2, StateString2, StateString2, StateString2, StateString2, StateString2, StateString2End, StateString2 }, // StateString2Start - { StateString2, StateString2, StateString2, StateString2, StateString2, StateString2, StateString2, StateString2, StateString2End, StateString2 }, // StateString2 - { StateStandard, StateStandard, StateStandard, StateCommentStart1, StateStandard, StateStandard, StatePreProcessor, StateStringStart, StateString2Start, StateStandard }, // StateString2End - { StateNumber, StateNumber, StateStandard, StateCommentStart1, StateStandard, StateStandard, StatePreProcessor, StateStringStart, StateString2Start, StateStandard }, // StateNumber - { StatePreProcessor, StateStandard, StateStandard, StateCommentStart1, StateStandard, StateStandard, StatePreProcessor, StateStringStart, StateString2Start, StateStandard } // StatePreProcessor - }; - - QString buffer; - buffer.reserve(text.length()); - QTextCharFormat emptyFormat; - - int state = StateStandard; - const int previousState = previousBlockState(); - if (previousState != -1) - state = previousState; - - if (text.isEmpty()) { - setCurrentBlockState(previousState); - return; - } - - int input = -1; - int i = 0; - bool lastWasBackSlash = false; - bool makeLastStandard = false; - - static const QSet alphabeth = alphaChars(); - static const QString mathChars = QString::fromLatin1("xXeE"); - static const QString numbers = QString::fromLatin1("0123456789"); - bool questionMark = false; - QChar lastChar; - QString firstWord; - forever { - const QChar c = text.at(i); - - if (lastWasBackSlash) { - input = InputSep; - } else { - switch (c.toLatin1()) { - case '*': - input = InputAsterix; - break; - case '/': - input = InputSlash; - break; - case '(': case '[': case '{': - input = InputParen; - if (state == StateStandard - || state == StateNumber - || state == StatePreProcessor - || state == StateCCommentEnd2 - || state == StateCCommentEnd1 - || state == StateString2End - || state == StateStringEnd - ) - //blockData->parentheses << Parenthesis(Parenthesis::Open, c, i); - break; - case ')': case ']': case '}': - input = InputParen; - if (state == StateStandard - || state == StateNumber - || state == StatePreProcessor - || state == StateCCommentEnd2 - || state == StateCCommentEnd1 - || state == StateString2End - || state == StateStringEnd - ) { - //blockData->parentheses << Parenthesis(Parenthesis::Closed, c, i); - } - break; - case '#': - input = InputHash; - break; - case '"': - input = InputQuotation; - break; - case '\'': - input = InputApostrophe; - break; - case ' ': - input = InputSpace; - break; - case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '8': case '9': case '0': - if (alphabeth.contains(lastChar) - && (!mathChars.contains(lastChar) || !numbers.contains(text.at(i - 1)))) { - input = InputAlpha; - } else { - if (input == InputAlpha && numbers.contains(lastChar)) - input = InputAlpha; - else - input = InputNumber; - } - break; - case ':': { - input = InputAlpha; - QChar nextChar = QLatin1Char(' '); - if (i < text.length() - 1) - nextChar = text.at(i + 1); - if (state == StateStandard && !questionMark && - lastChar != QLatin1Char(':') && nextChar != QLatin1Char(':')) { - for (int j = 0; j < i; ++j) { - if (format(j) == emptyFormat) - setFormat(j, 1, m_labelFormat); - } - } - break; - } - default: { - if (!questionMark && c == QLatin1Char('?')) - questionMark = true; - if (c.isLetter() || c == QLatin1Char('_')) - input = InputAlpha; - else - input = InputSep; - } break; - } - } - - lastWasBackSlash = !lastWasBackSlash && c == QLatin1Char('\\'); - - if (input == InputAlpha) - buffer += c; - - state = table[state][input]; - - switch (state) { - case StateStandard: { - setFormat(i, 1, emptyFormat); - if (makeLastStandard) - setFormat(i - 1, 1, emptyFormat); - makeLastStandard = false; - if (!buffer.isEmpty() && input != InputAlpha ) { - highlightKeyword(i, buffer); - buffer.clear(); - } - } break; - case StateCommentStart1: - if (makeLastStandard) - setFormat(i - 1, 1, emptyFormat); - makeLastStandard = true; - buffer.resize(0); - break; - case StateCCommentStart2: - setFormat(i - 1, 2, m_commentFormat); - makeLastStandard = false; - buffer.resize(0); - break; - case StateCppCommentStart2: - setFormat(i - 1, 2, m_commentFormat); - makeLastStandard = false; - buffer.resize(0); - break; - case StateCComment: - if (makeLastStandard) - setFormat(i - 1, 1, emptyFormat); - makeLastStandard = false; - setFormat(i, 1, m_commentFormat); - buffer.resize(0); - break; - case StateCppComment: - if (makeLastStandard) - setFormat(i - 1, 1, emptyFormat); - makeLastStandard = false; - setFormat(i, 1, m_commentFormat); - buffer.resize(0); - break; - case StateCCommentEnd1: - if (makeLastStandard) - setFormat(i - 1, 1, emptyFormat); - makeLastStandard = false; - setFormat(i, 1, m_commentFormat); - buffer.resize(0); - break; - case StateCCommentEnd2: - if (makeLastStandard) - setFormat(i - 1, 1, emptyFormat); - makeLastStandard = false; - setFormat(i, 1, m_commentFormat); - buffer.resize(0); - break; - case StateStringStart: - if (makeLastStandard) - setFormat(i - 1, 1, emptyFormat); - makeLastStandard = false; - setFormat(i, 1, emptyFormat); - buffer.resize(0); - break; - case StateString: - if (makeLastStandard) - setFormat(i - 1, 1, emptyFormat); - makeLastStandard = false; - setFormat(i, 1, m_stringFormat); - buffer.resize(0); - break; - case StateStringEnd: - if (makeLastStandard) - setFormat(i - 1, 1, emptyFormat); - makeLastStandard = false; - setFormat(i, 1, emptyFormat); - buffer.resize(0); - break; - case StateString2Start: - if (makeLastStandard) - setFormat(i - 1, 1, emptyFormat); - makeLastStandard = false; - setFormat(i, 1, emptyFormat); - buffer.resize(0); - break; - case StateString2: - if (makeLastStandard) - setFormat(i - 1, 1, emptyFormat); - makeLastStandard = false; - setFormat(i, 1, m_stringFormat); - buffer.resize(0); - break; - case StateString2End: - if (makeLastStandard) - setFormat(i - 1, 1, emptyFormat); - makeLastStandard = false; - setFormat(i, 1, emptyFormat); - buffer.resize(0); - break; - case StateNumber: - if (makeLastStandard) - setFormat(i - 1, 1, emptyFormat); - makeLastStandard = false; - setFormat( i, 1, m_numberFormat); - buffer.resize(0); - break; - case StatePreProcessor: - if (makeLastStandard) - setFormat(i - 1, 1, emptyFormat); - makeLastStandard = false; - setFormat(i, 1, m_preProcessorFormat); - buffer.resize(0); - break; - } - - lastChar = c; - i++; - if (i >= text.length()) - break; - } - - highlightKeyword(text.length(), buffer); - - if (state == StateCComment - || state == StateCCommentEnd1 - || state == StateCCommentStart2 - ) { - state = StateCComment; - } else if (state == StateString) { - state = StateString; - } else if (state == StateString2) { - state = StateString2; - } else { - state = StateStandard; - } - - setCurrentBlockState(state); -} - -void QScriptHighlighter::highlightKeyword(int currentPos, const QString &buffer) -{ - if (buffer.isEmpty()) - return; - - if (buffer.at(0) == QLatin1Char('Q')) { - setFormat(currentPos - buffer.length(), buffer.length(), m_typeFormat); - } else { - if (qscriptKeywords().contains(buffer)) { - setFormat(currentPos - buffer.length(), buffer.length(), m_keywordFormat); - } - } -} -} - -QT_END_NAMESPACE diff --git a/src/designer/src/lib/shared/qscripthighlighter_p.h b/src/designer/src/lib/shared/qscripthighlighter_p.h deleted file mode 100644 index 9decfa2..0000000 --- a/src/designer/src/lib/shared/qscripthighlighter_p.h +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of Qt Designer. This header -// file may change from version to version without notice, or even be removed. -// -// We mean it. -// - -#ifndef QSCRIPTSYNTAXHIGHLIGHTER_H -#define QSCRIPTSYNTAXHIGHLIGHTER_H - -#include - -QT_BEGIN_NAMESPACE - -namespace qdesigner_internal { - -class QScriptHighlighter : public QSyntaxHighlighter -{ -public: - explicit QScriptHighlighter(QTextDocument *parent); - virtual void highlightBlock(const QString &text); - -private: - void highlightKeyword(int currentPos, const QString &buffer); - - QTextCharFormat m_numberFormat; - QTextCharFormat m_stringFormat; - QTextCharFormat m_typeFormat; - QTextCharFormat m_keywordFormat; - QTextCharFormat m_labelFormat; - QTextCharFormat m_commentFormat; - QTextCharFormat m_preProcessorFormat; -}; - -} // namespace qdesigner_internal - -QT_END_NAMESPACE - -#endif diff --git a/src/designer/src/lib/shared/qsimpleresource.cpp b/src/designer/src/lib/shared/qsimpleresource.cpp index 3cc17f2..fd24d6b 100644 --- a/src/designer/src/lib/shared/qsimpleresource.cpp +++ b/src/designer/src/lib/shared/qsimpleresource.cpp @@ -43,13 +43,11 @@ #include "widgetfactory_p.h" #include "widgetdatabase_p.h" -#include #include #include #include #include -#include #include #include #include @@ -81,10 +79,6 @@ QSimpleResource::QSimpleResource(QDesignerFormEditorInterface *core) : workingDirectory += QDir::separator(); workingDirectory += QStringLiteral(".designer"); setWorkingDirectory(QDir(workingDirectory)); -#ifndef QT_FORMBUILDER_NO_SCRIPT - // Disable scripting in the editors. - formScriptRunner()-> setOptions(QFormScriptRunner::DisableScripts); -#endif } QSimpleResource::~QSimpleResource() @@ -131,7 +125,7 @@ void QSimpleResource::addScript(const QString &script, ScriptSource source, DomS } } -void QSimpleResource::addExtensionDataToDOM(QAbstractFormBuilder *afb, +void QSimpleResource::addExtensionDataToDOM(QAbstractFormBuilder * /* afb */, QDesignerFormEditorInterface *core, DomWidget *ui_widget, QWidget *widget) { @@ -139,66 +133,16 @@ void QSimpleResource::addExtensionDataToDOM(QAbstractFormBuilder *afb, if (QDesignerExtraInfoExtension *extra = qt_extension(emgr, widget)) { extra->saveWidgetExtraInfo(ui_widget); } - if (QDesignerScriptExtension *scriptExt = qt_extension(emgr, widget)) { - // Add internal state - const QVariantMap data = scriptExt->data(); - if (!data.empty()) { - // Convert the map to a DomState. - // We pass on the widget for property introspection. Thus, non-designable properties - // that have to be converted using QMetaObject (enums and the like) will work. - DomPropertyList properties; - const QVariantMap::const_iterator vcend = data.constEnd(); - for (QVariantMap::const_iterator it = data.constBegin(); it != vcend; ++it) { - if (DomProperty *prop = variantToDomProperty(afb, widget->metaObject(), it.key(), it.value())) - properties += prop; - } - if (!properties.empty()) { - DomWidgetData *domData = new DomWidgetData; - domData->setElementProperty(properties); - DomWidgetDataList domDataList; - domDataList += domData; - ui_widget->setElementWidgetData(domDataList); - } - - } - // Add script - const QString script = scriptExt->script(); - if (!script.isEmpty()) { - DomScripts domScripts = ui_widget->elementScript(); - addScript(script, ScriptExtension, domScripts); - ui_widget->setElementScript(domScripts); - } - } } -void QSimpleResource::applyExtensionDataFromDOM(QAbstractFormBuilder *afb, +void QSimpleResource::applyExtensionDataFromDOM(QAbstractFormBuilder * /* afb */, QDesignerFormEditorInterface *core, - DomWidget *ui_widget, QWidget *widget, bool applyState) + DomWidget *ui_widget, QWidget *widget) { QExtensionManager *emgr = core->extensionManager(); if (QDesignerExtraInfoExtension *extra = qt_extension(emgr, widget)) { extra->loadWidgetExtraInfo(ui_widget); } - if (applyState) { - if (QDesignerScriptExtension *scriptExt = qt_extension(emgr, widget)) { - // Apply the state. - // We pass on the widget for property introspection. Thus, non-designable properties - // that have to be converted using QMetaObject (enums and the like) will work. - QVariantMap data; - DomWidgetDataList domDataList = ui_widget->elementWidgetData(); - if (!domDataList.empty()) { - foreach (const DomWidgetData *domData, domDataList) { - const DomPropertyList properties = domData->elementProperty(); - foreach(const DomProperty *prop, properties) { - const QVariant vprop = domPropertyToVariant(afb, widget->metaObject(), prop); - if (vprop.type() != QVariant::Invalid) - data.insert(prop->attributeName(), vprop); - } - } - } - scriptExt->setData(data); - } - } } QString QSimpleResource::customWidgetScript(QDesignerFormEditorInterface *core, QObject *object) diff --git a/src/designer/src/lib/shared/qsimpleresource_p.h b/src/designer/src/lib/shared/qsimpleresource_p.h index bdc63ce..ec3c2fc 100644 --- a/src/designer/src/lib/shared/qsimpleresource_p.h +++ b/src/designer/src/lib/shared/qsimpleresource_p.h @@ -88,8 +88,7 @@ public: DomWidget *ui_widget, QWidget *widget); static void applyExtensionDataFromDOM(QAbstractFormBuilder *afb, QDesignerFormEditorInterface *core, - DomWidget *ui_widget, QWidget *widget, - bool applyState); + DomWidget *ui_widget, QWidget *widget); // Return the script returned by the CustomWidget codeTemplate API static QString customWidgetScript(QDesignerFormEditorInterface *core, QObject *object); static QString customWidgetScript(QDesignerFormEditorInterface *core, const QString &className); diff --git a/src/designer/src/lib/shared/scriptcommand.cpp b/src/designer/src/lib/shared/scriptcommand.cpp deleted file mode 100644 index 3e19837..0000000 --- a/src/designer/src/lib/shared/scriptcommand.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "scriptcommand_p.h" -#include "metadatabase_p.h" - -#include -#include - -#include - -QT_BEGIN_NAMESPACE - -namespace qdesigner_internal { - -ScriptCommand::ScriptCommand(QDesignerFormWindowInterface *formWindow) : - QDesignerFormWindowCommand(QCoreApplication::translate("Command", "Change script"), formWindow) -{ -} - -bool ScriptCommand::init(const ObjectList &list, const QString &script) -{ - MetaDataBase *metaDataBase = qobject_cast(formWindow()->core()->metaDataBase()); - if (!metaDataBase) - return false; - - // Save old values - m_oldValues.clear(); - foreach (QObject *obj, list) { - const MetaDataBaseItem* item = metaDataBase->metaDataBaseItem(obj); - if (!item) - return false; - m_oldValues.push_back(ObjectScriptPair(obj, item->script())); - } - m_script = script; - return true; -} - -void ScriptCommand::redo() -{ - MetaDataBase *metaDataBase = qobject_cast(formWindow()->core()->metaDataBase()); - Q_ASSERT(metaDataBase); - - ObjectScriptList::const_iterator cend = m_oldValues.constEnd(); - for (ObjectScriptList::const_iterator it = m_oldValues.constBegin();it != cend; ++it ) { - if (it->first) - metaDataBase->metaDataBaseItem(it->first)->setScript(m_script); - } -} - -void ScriptCommand::undo() -{ - MetaDataBase *metaDataBase = qobject_cast(formWindow()->core()->metaDataBase()); - Q_ASSERT(metaDataBase); - - ObjectScriptList::const_iterator cend = m_oldValues.constEnd(); - for (ObjectScriptList::const_iterator it = m_oldValues.constBegin();it != cend; ++it ) { - if (it->first) - metaDataBase->metaDataBaseItem(it->first)->setScript(it->second); - } -} - -} // namespace qdesigner_internal - -QT_END_NAMESPACE diff --git a/src/designer/src/lib/shared/scriptcommand_p.h b/src/designer/src/lib/shared/scriptcommand_p.h deleted file mode 100644 index 41e6628..0000000 --- a/src/designer/src/lib/shared/scriptcommand_p.h +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of Qt Designer. This header -// file may change from version to version without notice, or even be removed. -// -// We mean it. -// - -#ifndef QDESIGNER_SCRIPTCOMMAND_H -#define QDESIGNER_SCRIPTCOMMAND_H - -#include "qdesigner_formwindowcommand_p.h" - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QDesignerFormWindowInterface; - -namespace qdesigner_internal { - -class QDESIGNER_SHARED_EXPORT ScriptCommand: public QDesignerFormWindowCommand -{ - ScriptCommand(const ScriptCommand &); - ScriptCommand& operator=(const ScriptCommand &); - -public: - explicit ScriptCommand(QDesignerFormWindowInterface *formWindow); - - typedef QList ObjectList; - bool init(const ObjectList &list, const QString &script); - - virtual void redo(); - virtual void undo(); - -private: - typedef QPair, QString> ObjectScriptPair; - typedef QList ObjectScriptList; - ObjectScriptList m_oldValues; - QString m_script; -}; - -} // namespace qdesigner_internal - -QT_END_NAMESPACE - -#endif // QDESIGNER_SCRIPTCOMMAND_H diff --git a/src/designer/src/lib/shared/scriptdialog.cpp b/src/designer/src/lib/shared/scriptdialog.cpp deleted file mode 100644 index a8a811d..0000000 --- a/src/designer/src/lib/shared/scriptdialog.cpp +++ /dev/null @@ -1,130 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "scriptdialog_p.h" -#include "qscripthighlighter_p.h" - -#include - -#include -#include -#include -#include -#include -#ifdef QT_SCRIPT_LIB -#include -#endif - -QT_BEGIN_NAMESPACE - -namespace qdesigner_internal { - - // ScriptDialog - ScriptDialog::ScriptDialog(QDesignerDialogGuiInterface *m_dialogGui, QWidget *parent) : - QDialog(parent), - m_dialogGui(m_dialogGui), - m_textEdit(new QTextEdit) - { - setWindowTitle(tr("Edit script")); - setModal(true); - - QVBoxLayout *vboxLayout = new QVBoxLayout(this); - - const QString textHelp = tr("\ -Enter a Qt Script snippet to be executed while loading the form.
\ -The widget and its children are accessible via the \ -variables widget and childWidgets, respectively."); - m_textEdit->setToolTip(textHelp); - m_textEdit->setWhatsThis(textHelp); - m_textEdit->setMinimumSize(QSize(600, 400)); - vboxLayout->addWidget(m_textEdit); - new QScriptHighlighter(m_textEdit->document()); - // button box - QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel); - connect(buttonBox , SIGNAL(rejected()), this, SLOT(reject())); - connect(buttonBox , SIGNAL(accepted()), this, SLOT(slotAccept())); - vboxLayout->addWidget(buttonBox); - } - - bool ScriptDialog::editScript(QString &script) - { - m_textEdit->setText(script); - if (exec() != Accepted) - return false; - - script = trimmedScript(); - return true; - } - - void ScriptDialog::slotAccept() - { - if (checkScript()) - accept(); - } - - QString ScriptDialog::trimmedScript() const - { - // Ensure a single newline - QString rc = m_textEdit->toPlainText().trimmed(); - if (!rc.isEmpty()) - rc += QLatin1Char('\n'); - return rc; - } - - bool ScriptDialog::checkScript() - { - const QString script = trimmedScript(); - if (script.isEmpty()) - return true; -#ifdef QT_SCRIPT_LIB - QScriptEngine scriptEngine; - if (scriptEngine.canEvaluate(script)) - return true; - m_dialogGui->message(this, QDesignerDialogGuiInterface::ScriptDialogMessage, QMessageBox::Warning, - windowTitle(), tr("Syntax error"), QMessageBox::Ok); - return false; -#else - return true; -#endif - } -} // namespace qdesigner_internal - -QT_END_NAMESPACE diff --git a/src/designer/src/lib/shared/scriptdialog_p.h b/src/designer/src/lib/shared/scriptdialog_p.h deleted file mode 100644 index 4aea348..0000000 --- a/src/designer/src/lib/shared/scriptdialog_p.h +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of Qt Designer. This header -// file may change from version to version without notice, or even be removed. -// -// We mean it. -// - -#ifndef SCRIPTDIALOG_H -#define SCRIPTDIALOG_H - -#include "shared_global_p.h" - -#include - -QT_BEGIN_NAMESPACE - -class QDesignerDialogGuiInterface; - -class QTextEdit; - -namespace qdesigner_internal { - - // Dialog for showing script errors - class QDESIGNER_SHARED_EXPORT ScriptDialog : public QDialog { - Q_OBJECT - - public: - explicit ScriptDialog(QDesignerDialogGuiInterface *dialogGui, QWidget *parent); - bool editScript(QString &script); - - private slots: - void slotAccept(); - - private: - QString trimmedScript() const; - bool checkScript(); - - QDesignerDialogGuiInterface *m_dialogGui; - QTextEdit *m_textEdit; - }; -} // namespace qdesigner_internal - -QT_END_NAMESPACE - -#endif // SCRIPTDIALOG_H diff --git a/src/designer/src/lib/shared/scripterrordialog.cpp b/src/designer/src/lib/shared/scripterrordialog.cpp deleted file mode 100644 index da98abc..0000000 --- a/src/designer/src/lib/shared/scripterrordialog.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "scripterrordialog_p.h" - -#include -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -static void formatError(const QFormScriptRunner::Error &error, - QTextCursor &cursor) -{ - const QTextCharFormat oldFormat = cursor.charFormat(); - // Message - cursor.insertText(QCoreApplication::translate("ScriptErrorDialog", "An error occurred while running the scripts for \"%1\":\n").arg(error.objectName)); - - QTextCharFormat format(oldFormat); - - // verbatim listing - format.setFontFamily(QStringLiteral("Courier")); - cursor.insertText(error.script, format); - - const QString newLine(QLatin1Char('\n')); - - cursor.insertText(newLine); - - // red error - format = oldFormat; - format.setTextOutline(QPen(Qt::red)); - cursor.insertText(error.errorMessage, format); - cursor.insertText(newLine); - cursor.setCharFormat (oldFormat); -} - -namespace qdesigner_internal { - - // ScriptErrorDialog - ScriptErrorDialog::ScriptErrorDialog(const Errors& errors, QWidget *parent) : - QDialog(parent), - m_textEdit(new QTextEdit) - { - setWindowTitle(tr("Script errors")); - setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint); - setModal(true); - - QVBoxLayout *vboxLayout = new QVBoxLayout(this); - - m_textEdit->setReadOnly(true); - m_textEdit->setMinimumSize(QSize(600, 400)); - vboxLayout->addWidget(m_textEdit); - // button box - QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Close); - connect(buttonBox , SIGNAL(rejected()), this, SLOT(reject())); - vboxLayout->addWidget(buttonBox); - - // Generate text - QTextCursor cursor = m_textEdit->textCursor(); - cursor.movePosition (QTextCursor::End); - foreach (const QFormScriptRunner::Error error, errors) - formatError(error, cursor); - } -} // namespace qdesigner_internal - -QT_END_NAMESPACE diff --git a/src/designer/src/lib/shared/scripterrordialog_p.h b/src/designer/src/lib/shared/scripterrordialog_p.h deleted file mode 100644 index 938220a..0000000 --- a/src/designer/src/lib/shared/scripterrordialog_p.h +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists for the convenience -// of Qt Designer. This header -// file may change from version to version without notice, or even be removed. -// -// We mean it. -// - -#ifndef SCRIPTERRORDIALOG_H -#define SCRIPTERRORDIALOG_H - -#include "shared_global_p.h" -#include - -#include - -QT_BEGIN_NAMESPACE - -class QTextEdit; - -namespace qdesigner_internal { - - // Dialog for showing script errors - class QDESIGNER_SHARED_EXPORT ScriptErrorDialog : public QDialog { - Q_OBJECT - - public: - typedef QFormScriptRunner::Errors Errors; - ScriptErrorDialog(const Errors& errors, QWidget *parent); - - private: - QTextEdit *m_textEdit; - - }; -} // namespace qdesigner_internal - -QT_END_NAMESPACE - -#endif // SCRIPTERRORDIALOG_H diff --git a/src/designer/src/lib/shared/shared.pri b/src/designer/src/lib/shared/shared.pri index fd7d9ec..e78fa77 100644 --- a/src/designer/src/lib/shared/shared.pri +++ b/src/designer/src/lib/shared/shared.pri @@ -1,6 +1,5 @@ INCLUDEPATH += $$PWD -contains(QT_CONFIG, script): QT += script include(../../../../shared/qtpropertybrowser/qtpropertybrowserutils.pri) include(../../../../shared/deviceskin/deviceskin.pri) @@ -75,10 +74,6 @@ HEADERS += \ $$PWD/textpropertyeditor_p.h \ $$PWD/propertylineedit_p.h \ $$PWD/promotiontaskmenu_p.h \ - $$PWD/scripterrordialog_p.h \ - $$PWD/scriptcommand_p.h \ - $$PWD/scriptdialog_p.h \ - $$PWD/qscripthighlighter_p.h \ $$PWD/gridpanel_p.h \ $$PWD/grid_p.h \ $$PWD/formwindowbase_p.h \ @@ -155,10 +150,6 @@ SOURCES += \ $$PWD/textpropertyeditor.cpp \ $$PWD/propertylineedit.cpp \ $$PWD/promotiontaskmenu.cpp \ - $$PWD/scripterrordialog.cpp \ - $$PWD/scriptcommand.cpp \ - $$PWD/scriptdialog.cpp \ - $$PWD/qscripthighlighter.cpp\ $$PWD/gridpanel.cpp \ $$PWD/grid.cpp \ $$PWD/formwindowbase.cpp \ diff --git a/src/designer/src/lib/uilib/abstractformbuilder.cpp b/src/designer/src/lib/uilib/abstractformbuilder.cpp index f069b60..6294619 100644 --- a/src/designer/src/lib/uilib/abstractformbuilder.cpp +++ b/src/designer/src/lib/uilib/abstractformbuilder.cpp @@ -363,12 +363,6 @@ QWidget *QAbstractFormBuilder::create(DomWidget *ui_widget, QWidget *parentWidge } loadExtraInfo(ui_widget, w, parentWidget); -#ifndef QT_FORMBUILDER_NO_SCRIPT - QString scriptErrorMessage; - d->formScriptRunner().run(ui_widget, - d->customWidgetScript(ui_widget->attributeClass()), - w, children, &scriptErrorMessage); -#endif addItem(ui_widget, w, parentWidget); if (qobject_cast(w) && parentWidget) @@ -3098,55 +3092,6 @@ QPixmap QAbstractFormBuilder::domPropertyToPixmap(const DomProperty* p) */ /*! - \fn QFormScriptRunner *QAbstractFormBuilder::formScriptRunner() const - \internal - \since 4.3 -*/ -#ifndef QT_FORMBUILDER_NO_SCRIPT -QFormScriptRunner *QAbstractFormBuilder::formScriptRunner() const -{ - return &(d->formScriptRunner()); -} -#endif - -/*! - Sets whether the execution of scripts is enabled to \a enabled. - \since 4.3 - \internal -*/ - -void QAbstractFormBuilder::setScriptingEnabled(bool enabled) -{ -#ifdef QT_FORMBUILDER_NO_SCRIPT - if (enabled) - uiLibWarning(QCoreApplication::translate("QAbstractFormBuilder", "This version of the uitools library is linked without script support.")); -#else - QFormScriptRunner::Options options = formScriptRunner()->options(); - if (enabled) - options &= ~QFormScriptRunner::DisableScripts; - else - options |= QFormScriptRunner::DisableScripts; - formScriptRunner()->setOptions(options); -#endif -} - -/*! - Returns whether the execution of scripts is enabled. - \sa setScriptingEnabled() - \since 4.3 - \internal -*/ - -bool QAbstractFormBuilder::isScriptingEnabled() const -{ -#ifdef QT_FORMBUILDER_NO_SCRIPT - return false; -#else - return !(formScriptRunner()->options() & QFormScriptRunner::DisableScripts); -#endif -} - -/*! Returns a human-readable description of the last error occurred in load(). \since 5.0 diff --git a/src/designer/src/lib/uilib/abstractformbuilder.h b/src/designer/src/lib/uilib/abstractformbuilder.h index d088250..cc7372b 100644 --- a/src/designer/src/lib/uilib/abstractformbuilder.h +++ b/src/designer/src/lib/uilib/abstractformbuilder.h @@ -108,10 +108,6 @@ class QResourceBuilder; class QTextBuilder; class QFormBuilderExtra; -#ifndef QT_FORMBUILDER_NO_SCRIPT -class QFormScriptRunner; -#endif - class QDESIGNER_UILIB_EXPORT QAbstractFormBuilder { public: @@ -124,9 +120,6 @@ public: virtual QWidget *load(QIODevice *dev, QWidget *parentWidget=0); virtual void save(QIODevice *dev, QWidget *widget); - void setScriptingEnabled(bool enabled); - bool isScriptingEnabled() const; - QString errorString() const; protected: @@ -229,9 +222,6 @@ protected: void reset(); void initialize(const DomUI *ui); -#ifndef QT_FORMBUILDER_NO_SCRIPT - QFormScriptRunner *formScriptRunner() const; -#endif // // utils // diff --git a/src/designer/src/lib/uilib/formbuilderextra.cpp b/src/designer/src/lib/uilib/formbuilderextra.cpp index 1c27b70..08b7126 100644 --- a/src/designer/src/lib/uilib/formbuilderextra.cpp +++ b/src/designer/src/lib/uilib/formbuilderextra.cpp @@ -78,10 +78,6 @@ QFormBuilderExtra::CustomWidgetData::CustomWidgetData(const DomCustomWidget *dcw baseClass(dcw->elementExtends()), isContainer(dcw->hasElementContainer() && dcw->elementContainer() != 0) { -#ifndef QT_FORMBUILDER_NO_SCRIPT - if (const DomScript *domScript = dcw->elementScript()) - script = domScript->text(); -#endif } QFormBuilderExtra::QFormBuilderExtra() : @@ -105,9 +101,6 @@ void QFormBuilderExtra::clear() m_buddies.clear(); m_parentWidget = 0; m_parentWidgetIsSet = false; -#ifndef QT_FORMBUILDER_NO_SCRIPT - m_FormScriptRunner.clearErrors(); -#endif m_customWidgetDataHash.clear(); m_buttonGroups.clear(); } @@ -176,22 +169,6 @@ void QFormBuilderExtra::setParentWidget(const QPointer &w) m_parentWidgetIsSet = true; } -#ifndef QT_FORMBUILDER_NO_SCRIPT -QFormScriptRunner &QFormBuilderExtra::formScriptRunner() -{ - return m_FormScriptRunner; -} - -QString QFormBuilderExtra::customWidgetScript(const QString &className) const -{ - const QHash::const_iterator it = m_customWidgetDataHash.constFind(className); - if (it != m_customWidgetDataHash.constEnd()) - return it.value().script; - return QString(); -} - -#endif - void QFormBuilderExtra::storeCustomWidgetData(const QString &className, const DomCustomWidget *d) { if (d) diff --git a/src/designer/src/lib/uilib/formbuilderextra_p.h b/src/designer/src/lib/uilib/formbuilderextra_p.h index 20516a5..85c81a6 100644 --- a/src/designer/src/lib/uilib/formbuilderextra_p.h +++ b/src/designer/src/lib/uilib/formbuilderextra_p.h @@ -55,10 +55,6 @@ #include "uilib_global.h" -#ifndef QT_FORMBUILDER_NO_SCRIPT -# include "formscriptrunner_p.h" -#endif - #include #include #include @@ -121,11 +117,6 @@ public: bool parentWidgetIsSet() const; void setParentWidget(const QPointer &w); -#ifndef QT_FORMBUILDER_NO_SCRIPT - QFormScriptRunner &formScriptRunner(); - QString customWidgetScript(const QString &className) const; -#endif - void setProcessingLayoutWidget(bool processing); bool processingLayoutWidget() const; @@ -190,10 +181,6 @@ private: typedef QHash BuddyHash; BuddyHash m_buddies; -#ifndef QT_FORMBUILDER_NO_SCRIPT - QFormScriptRunner m_FormScriptRunner; -#endif - QHash m_customWidgetDataHash; ButtonGroupHash m_buttonGroups; diff --git a/src/designer/src/lib/uilib/formscriptrunner.cpp b/src/designer/src/lib/uilib/formscriptrunner.cpp deleted file mode 100644 index 7ee6b3a..0000000 --- a/src/designer/src/lib/uilib/formscriptrunner.cpp +++ /dev/null @@ -1,208 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "formscriptrunner_p.h" -#include "formbuilderextra_p.h" -#include "ui4_p.h" - -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -namespace { - enum { debugFormScriptRunner = 0 }; -} - -#ifdef QFORMINTERNAL_NAMESPACE -namespace QFormInternal { -#endif - -class QFormScriptRunner::QFormScriptRunnerPrivate { -public: - QFormScriptRunnerPrivate() : m_options(DisableScripts) {} - void clearErrors() { m_errors.clear(); } - - bool run(const QString &script, QWidget *widget, const WidgetList &children, QString *errorMessage); - - static void initializeEngine(QWidget *w, const WidgetList &children, QScriptEngine &scriptEngine); - static QString engineError(QScriptEngine &scriptEngine); - - Options options() const { return m_options; } - void setOptions(Options options) { m_options = options; } - - Errors errors() const { return m_errors; } -private: - QScriptEngine m_scriptEngine; - Options m_options; - Errors m_errors; -}; - -bool QFormScriptRunner::QFormScriptRunnerPrivate::run(const QString &script, QWidget *widget, const WidgetList &children, QString *errorMessage) { - bool rc = false; - initializeEngine(widget, children, m_scriptEngine); - - do { - m_scriptEngine.evaluate(script); - if (m_scriptEngine.hasUncaughtException ()) { - *errorMessage = QCoreApplication::tr("Exception at line %1: %2").arg(m_scriptEngine.uncaughtExceptionLineNumber()).arg(engineError(m_scriptEngine)); - break; - } - rc = true; - } while (false); - m_scriptEngine.popContext(); - - if (!rc) { - Error error; - error.objectName = widget->objectName(); - error.script = script; - error.errorMessage = *errorMessage; - m_errors.push_back(error); - } - return rc; -} - -void QFormScriptRunner::QFormScriptRunnerPrivate::initializeEngine(QWidget *w, const WidgetList &children, QScriptEngine &scriptEngine) { - // Populate the script variables. This pushes a context which must be popped. - QScriptContext *ctx = scriptEngine.pushContext(); - QScriptValue widgetObject = scriptEngine.newQObject(w); - QScriptValue childrenArray = scriptEngine.newArray (children.size()); - - for(int i = 0; i < children.size(); i++) { - childrenArray.setProperty(i, scriptEngine.newQObject(children[i])); - } - - const QFormBuilderStrings &strings = QFormBuilderStrings::instance(); - ctx ->activationObject().setProperty(strings.scriptWidgetVariable, widgetObject); - ctx ->activationObject().setProperty(strings.scriptChildWidgetsVariable, childrenArray); -} - -QString QFormScriptRunner::QFormScriptRunnerPrivate::engineError(QScriptEngine &scriptEngine) { - QScriptValue error = scriptEngine.evaluate(QStringLiteral("Error")); - if (error.isValid()) - return error.toString(); - return QCoreApplication::tr("Unknown error"); -} -// -- QFormScriptRunner - -QFormScriptRunner::QFormScriptRunner() : m_impl(new QFormScriptRunnerPrivate) -{ -} - -QFormScriptRunner::~QFormScriptRunner() -{ - delete m_impl; -} - -bool QFormScriptRunner::run(const DomWidget *domWidget, - const QString &customWidgetScript, - QWidget *widget, const WidgetList &children, - QString *errorMessage) -{ - typedef QList DomScripts; - - const Options scriptOptions = m_impl->options(); - if (scriptOptions & DisableScripts) - return true; - // get list - const DomScripts domScripts = domWidget->elementScript(); - // Concatenate snippets, starting with custom widget script - QString script = customWidgetScript; - if (script.isEmpty() && domScripts.empty()) - return true; - - foreach (const DomScript *scriptSnippet, domScripts) { - // Ensure new line - if (!script.isEmpty() && !script.endsWith(QLatin1Char('\n'))) - script += QLatin1Char('\n'); - script += scriptSnippet->text(); - } - - if (script.isEmpty()) - return true; - - const bool rc = m_impl->run(script, widget, children, errorMessage); - - if (debugFormScriptRunner) { - qDebug() << "For " << widget << " with " << children.size() << " children, ran: " << script; - if (!rc) - qDebug() << *errorMessage; - } - - if (!rc) { - if (!(scriptOptions & DisableWarnings)) { - const QString message = QCoreApplication::tr("An error occurred while running the script for %1: %2\nScript: %3"). - arg(widget->objectName()).arg(*errorMessage).arg(script); - qWarning() << message; - } - } - return rc; -} - -QFormScriptRunner::Options QFormScriptRunner::options() const -{ - return m_impl->options(); -} - -void QFormScriptRunner::setOptions(Options options) -{ - m_impl->setOptions(options); -} - - -QFormScriptRunner::Errors QFormScriptRunner::errors() const -{ - return m_impl->errors(); -} - -void QFormScriptRunner::clearErrors() -{ - m_impl->clearErrors(); -} - - -#ifdef QFORMINTERNAL_NAMESPACE -} // namespace QFormInternal -#endif - -QT_END_NAMESPACE diff --git a/src/designer/src/lib/uilib/formscriptrunner_p.h b/src/designer/src/lib/uilib/formscriptrunner_p.h deleted file mode 100644 index f0a6a36..0000000 --- a/src/designer/src/lib/uilib/formscriptrunner_p.h +++ /dev/null @@ -1,120 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt Designer of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef FORMSCRIPTRUNNER_H -#define FORMSCRIPTRUNNER_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "uilib_global.h" -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QWidget; - -#ifdef QFORMINTERNAL_NAMESPACE -namespace QFormInternal -{ -#endif - -class DomWidget; - -class QDESIGNER_UILIB_EXPORT QFormScriptRunner -{ -public: - QFormScriptRunner(); - ~QFormScriptRunner(); - - typedef QList WidgetList; - - bool run(const DomWidget *domWidget, - const QString &customWidgetScript, - QWidget *widget, const WidgetList &children, - QString *errorMessage); - - struct Error { - QString objectName; - QString script; - QString errorMessage; - }; - typedef QList Errors; - Errors errors() const; - void clearErrors(); - - enum Option { - NoOptions = 0x0, - DisableWarnings = 0x1, - DisableScripts = 02 - }; - Q_DECLARE_FLAGS(Options, Option) - - Options options() const; - void setOptions(Options options); - -private: - class QFormScriptRunnerPrivate; - QFormScriptRunnerPrivate *m_impl; - - QFormScriptRunner(const QFormScriptRunner &); - void operator = (const QFormScriptRunner &); -}; - -Q_DECLARE_OPERATORS_FOR_FLAGS(QFormScriptRunner::Options) - -#ifdef QFORMINTERNAL_NAMESPACE -} -#endif - -QT_END_NAMESPACE - -#endif // FORMSCRIPTRUNNER_H diff --git a/src/designer/src/lib/uilib/uilib.pri b/src/designer/src/lib/uilib/uilib.pri index 75904c2..a84d4a5 100644 --- a/src/designer/src/lib/uilib/uilib.pri +++ b/src/designer/src/lib/uilib/uilib.pri @@ -2,7 +2,6 @@ INCLUDEPATH += $$PWD DEFINES += QT_DESIGNER -!contains(QT_CONFIG, script): DEFINES += QT_FORMBUILDER_NO_SCRIPT QT += gui widgets @@ -26,9 +25,3 @@ SOURCES += \ $$PWD/formbuilderextra.cpp \ $$PWD/resourcebuilder.cpp \ $$PWD/textbuilder.cpp - -!contains(DEFINES, QT_FORMBUILDER_NO_SCRIPT) { - QT += script - HEADERS += $$PWD/formscriptrunner_p.h - SOURCES += $$PWD/formscriptrunner.cpp -} diff --git a/src/designer/src/uitools/quiloader.cpp b/src/designer/src/uitools/quiloader.cpp index 2e4f079..b734e9a 100644 --- a/src/designer/src/uitools/quiloader.cpp +++ b/src/designer/src/uitools/quiloader.cpp @@ -840,38 +840,6 @@ QDir QUiLoader::workingDirectory() const Q_D(const QUiLoader); return d->builder.workingDirectory(); } - -/*! - \internal - \since 4.3 - - If \a enabled is true, the loader will be able to execute scripts. - Otherwise, execution of scripts will be disabled. - - \sa isScriptingEnabled() -*/ - -void QUiLoader::setScriptingEnabled(bool enabled) -{ - Q_D(QUiLoader); - d->builder.setScriptingEnabled(enabled); -} - -/*! - \internal - \since 4.3 - - Returns true if execution of scripts is enabled; returns false otherwise. - - \sa setScriptingEnabled() -*/ - -bool QUiLoader::isScriptingEnabled() const -{ - Q_D(const QUiLoader); - return d->builder.isScriptingEnabled(); -} - /*! \since 4.5 diff --git a/src/designer/src/uitools/uitools.pro b/src/designer/src/uitools/uitools.pro index ccecf9a..34f0df9 100644 --- a/src/designer/src/uitools/uitools.pro +++ b/src/designer/src/uitools/uitools.pro @@ -11,7 +11,7 @@ DESTDIR = $$QMAKE_LIBDIR_QT win32|mac:!macx-xcode:CONFIG += debug_and_release build_all -DEFINES += QFORMINTERNAL_NAMESPACE QT_DESIGNER_STATIC QT_FORMBUILDER_NO_SCRIPT +DEFINES += QFORMINTERNAL_NAMESPACE QT_DESIGNER_STATIC isEmpty(QT_MAJOR_VERSION) { VERSION=4.3.0 } else { -- 2.7.4