From 61f0437212832b0f9e2ca81b932a414394ef43f0 Mon Sep 17 00:00:00 2001 From: Andrey Paskal Date: Wed, 23 Dec 2009 18:26:03 +0300 Subject: [PATCH] First successful build of project --- src/admin/admin.pro | 4 +- src/ananas/ananas.pro | 5 +- src/ananas/mainform.cpp | 10 +- src/ananas/mainform.h | 2 +- src/designer/deditaction.cpp | 11 +- src/designer/deditaction.ui | 8 +- src/designer/deditcat.cpp | 14 +- src/designer/deditcat.ui | 11 +- src/designer/deditcfg.cpp | 14 +- src/designer/deditcfg.ui | 9 +- src/designer/deditdialog.cpp | 16 +- src/designer/deditdialog.ui | 8 +- src/designer/deditdoc.cpp | 16 +- src/designer/deditdoc.ui | 11 +- src/designer/deditfield.ui | 2 +- src/designer/deditreport.cpp | 10 +- src/designer/deditreport.ui | 8 +- src/designer/deditwebform.cpp | 16 +- src/designer/deditwebform.ui | 11 +- src/designer/designer.pro | 8 +- src/designer/formdesigner.cpp | 2 +- .../formdesigner/private/deviceprofile_p.h | 152 +++++++++++++++ .../formdesigner/private/formscriptrunner_p.h | 59 +++++-- .../formdesigner/private/pluginmanager_p.h | 107 ++++++++--- .../formdesigner/private/qdesigner_formbuilder_p.h | 100 ++++++++--- .../formdesigner/private/qdesigner_integration_p.h | 96 ++++++++-- .../formdesigner/private/shared_global_p.h | 44 +++-- .../formdesigner/private/sheet_delegate_p.h | 52 ++++-- src/designer/formdesigner/qrc_designer.cpp | 45 +++-- src/designer/formdesigner/qtdesigner.pro | 2 +- src/editor/editor.pro | 2 +- src/plugins/actionbutton/eactionbutton.cpp | 2 +- src/plugins/aform.cpp | 195 +++++++++++--------- src/plugins/engine.cpp | 193 ++++++++++++++------ src/plugins/engine.h | 3 +- src/src.pro | 1 + 36 files changed, 884 insertions(+), 365 deletions(-) create mode 100644 src/designer/formdesigner/private/deviceprofile_p.h diff --git a/src/admin/admin.pro b/src/admin/admin.pro index a2d06e4..3f97650 100644 --- a/src/admin/admin.pro +++ b/src/admin/admin.pro @@ -3,6 +3,8 @@ TARGET = ananas4-administrator include ( ../lib/lib.pri ) include ( ../plugins/plugins.pri ) include ( ../ananas.pri ) +QT += script +QT += scripttools TEMPLATE = app @@ -10,7 +12,7 @@ LANGUAGE = C++ DESTDIR = ../../bin LIBS += -L../../lib -lananas4 -LIBS += -L../../lib/designer -lananasplugin4 -lqt4-qdataschema -L$(QTDIR)/lib -lqsa +LIBS += -L../../lib/designer -lananasplugin4 -lqt4-qdataschema -L$(QTDIR)/lib INCLUDEPATH += ../lib ../lib/tmp/ui ../lib/.ui diff --git a/src/ananas/ananas.pro b/src/ananas/ananas.pro index 612e70c..7189737 100644 --- a/src/ananas/ananas.pro +++ b/src/ananas/ananas.pro @@ -1,7 +1,10 @@ include (../plugins/plugins.pri) include (../lib/lib.pri) include (../ananas.pri) -load(qsa) +#load(qsa) +QT += script +QT += scripttools + TARGET = ananas4 TEMPLATE = app diff --git a/src/ananas/mainform.cpp b/src/ananas/mainform.cpp index 9993de2..1245007 100644 --- a/src/ananas/mainform.cpp +++ b/src/ananas/mainform.cpp @@ -99,9 +99,13 @@ MainForm::init() if ( !initEngine() ) return false; connect( menubar, SIGNAL(activated(int)), &engine, SLOT(on_MenuBar(int)) ); languageChange(); - engine.project.addObject(menubar); - engine.project.addObject(this); - engine.project.addObject(statusBar()); +// engine.project.addObject(menubar); +// engine.project.addObject(this); +// engine.project.addObject(statusBar()); + engine.code->newQObject(menubar); + engine.code->newQObject(this); + engine.code->newQObject(statusBar()); + languageChange(); engine.on_systemstart(); return true; diff --git a/src/ananas/mainform.h b/src/ananas/mainform.h index 9f0d7ec..d54a85b 100644 --- a/src/ananas/mainform.h +++ b/src/ananas/mainform.h @@ -33,7 +33,7 @@ #define ANANASMAINFORM_H #include #include -#include +//#include #include #include #include diff --git a/src/designer/deditaction.cpp b/src/designer/deditaction.cpp index 337b344..0b5156f 100644 --- a/src/designer/deditaction.cpp +++ b/src/designer/deditaction.cpp @@ -9,8 +9,9 @@ #include #include "acfg.h" #include -#include -#include +//#include +//#include +#include /* * Constructs a dEditAction as a child of 'parent', with the @@ -71,7 +72,7 @@ void dEditAction::setData( ActionListViewItem * o ) st = md->attr ( obj, mda_type); if ( st == "0" ) cbType->setCurrentItem( 0 ); else if ( st == "1" ) cbType->setCurrentItem( 1 ); - eModule->setText( md->sText( obj, md_sourcecode ) ); + eModule->setPlainText( md->sText( obj, md_sourcecode ) ); active = md->findChild( obj, md_active_picture, 0 ); if ( !active.isNull() ) { // set active mode picture if exists bRemoveActive->setEnabled( TRUE ); @@ -176,7 +177,7 @@ void dEditAction::updateMD() if ( cbType->currentItem() == 1 ) { md->setAttr( obj, mda_type, "1" ); - md->setSText( obj, md_sourcecode, eModule->text() ); + md->setSText( obj, md_sourcecode, eModule->toPlainText() ); } } @@ -185,7 +186,7 @@ void dEditAction::init() { delete statusBar(); - eModule->setInterpreter(new QSInterpreter()); + //eModule->setInterpreter(new QSInterpreter()); // tabWidget2->page(1)->hide() ; // tabWidget2->setTabEnabled ( tabWidget2->page(1), FALSE ); } diff --git a/src/designer/deditaction.ui b/src/designer/deditaction.ui index 9465248..ef49705 100644 --- a/src/designer/deditaction.ui +++ b/src/designer/deditaction.ui @@ -393,7 +393,7 @@ - + true @@ -549,9 +549,9 @@
q3textedit.h
- QSEditor + ScriptEdit QWidget -
qseditor.h
+
scriptedit.h
@@ -559,7 +559,7 @@ aliaseditor.h pixmappreview.h mainform.h - qseditor.h + scriptedit.h diff --git a/src/designer/deditcat.cpp b/src/designer/deditcat.cpp index 3c99a5e..3918572 100644 --- a/src/designer/deditcat.cpp +++ b/src/designer/deditcat.cpp @@ -5,8 +5,8 @@ #include #include -#include -#include +//#include +//#include #include "acfg.h" /* @@ -62,7 +62,7 @@ void dEditCat::setData( aListViewItem *o ) e = md->find( obj, md_element ); // Find Element context sv = md->find( g, md_string_view ); // Group string view //==================================== - eStrViewFG->setText( md->sText( sv, md_svfunction ) ); + eStrViewFG->setPlainText( md->sText( sv, md_svfunction ) ); eSvG->insertItem( "[ standart function ]" ); eSvG->insertItem( "[ user function ]" ); fid = md->sText( sv, md_fieldid ).toInt(); @@ -85,7 +85,7 @@ void dEditCat::setData( aListViewItem *o ) //==================================== sv = md->find( e, md_string_view ); - eStrViewF->setText( md->sText( sv, md_svfunction ) ); + eStrViewF->setPlainText( md->sText( sv, md_svfunction ) ); eSv->insertItem( "[ standart function ]" ); eSv->insertItem( "[ user function ]" ); fid = md->sText( sv, md_fieldid ).toInt(); @@ -111,7 +111,7 @@ void dEditCat::setData( aListViewItem *o ) void dEditCat::init() { delete statusBar(); - eStrViewF->setInterpreter( new QSInterpreter() ); +// eStrViewF->setInterpreter( new QSInterpreter() ); eStrViewF->setEnabled( FALSE ); } @@ -131,7 +131,7 @@ void dEditCat::updateMD() //======== Element view save sv = md->find( e, md_string_view ); if ( sv.isNull() ) sv = md->insert( e, md_string_view ); - md->setSText( sv, md_svfunction, eStrViewF->text() ); + md->setSText( sv, md_svfunction, eStrViewF->toPlainText() ); if ( eSv->currentItem() == 0 ) md->setAttr( sv, mda_stdf, "1" ); else { md->setAttr( sv, mda_stdf, "0" ); @@ -141,7 +141,7 @@ void dEditCat::updateMD() //======== Group view save sv = md->find( g, md_string_view ); if ( sv.isNull() ) sv = md->insert( g, md_string_view ); - md->setSText( sv, md_svfunction, eStrViewFG->text() ); + md->setSText( sv, md_svfunction, eStrViewFG->toPlainText() ); if ( eSvG->currentItem() == 0 ) md->setAttr( sv, mda_stdf, "1" ); else { md->setAttr( sv, mda_stdf, "0" ); diff --git a/src/designer/deditcat.ui b/src/designer/deditcat.ui index f2cf761..6c5103c 100644 --- a/src/designer/deditcat.ui +++ b/src/designer/deditcat.ui @@ -97,7 +97,7 @@ - + true @@ -114,7 +114,7 @@ - + true @@ -183,9 +183,9 @@
q3textedit.h
- QSEditor + ScriptEdit QWidget -
qseditor.h
+
scriptedit.h
@@ -193,8 +193,7 @@ aliaseditor.h mainform.h roleeditor.h - qseditor.h - qseditor.h + scriptedit.h diff --git a/src/designer/deditcfg.cpp b/src/designer/deditcfg.cpp index 223bc1d..d973af4 100644 --- a/src/designer/deditcfg.cpp +++ b/src/designer/deditcfg.cpp @@ -6,14 +6,14 @@ #include "acfg.h" #include "qlayout.h" -#include "qsproject.h" -#include "qsscript.h" +//#include "qsproject.h" +//#include "qsscript.h" //#include "qseditor.h" -#include +//#include #include #ifndef QSA_NO_IDE -#include "qsworkbench.h" +//#include "qsworkbench.h" #endif /* @@ -60,7 +60,7 @@ void dEditCfg::init() // eModule=NULL; // eModule = new QSEditor(tabWidget->page(2), "global module"); // l->addWidget(eModule, 5, 5, 0); - eModule->setInterpreter(new QSInterpreter()); +// eModule->setInterpreter(new QSInterpreter()); } @@ -105,7 +105,7 @@ void dEditCfg::setData( aListViewItem *o ) eDate->setText( md->info( md_info_date ) ); eDescription->setText( md->info( md_info_remark ) ); globals = md->find( obj, md_globals, 0 ); - eModule->setText( md->sText( globals, md_sourcecode ) ); + eModule->setPlainText( md->sText( globals, md_sourcecode ) ); /* n=cfgobj_count(context, aot_remark); @@ -147,7 +147,7 @@ void dEditCfg::updateMD() if (eDBType->currentItem()==1) md->rc.setValue( "dbtype", "mysql" ); if (eDBType->currentItem()==2) md->rc.setValue( "dbtype", "postgres" ); globals = md->find( obj, md_globals, 0 ); - md->setSText( globals, md_sourcecode, eModule->text() ); + md->setSText( globals, md_sourcecode, eModule->toPlainText() ); /* if (cancelupdate) return; diff --git a/src/designer/deditcfg.ui b/src/designer/deditcfg.ui index 6c0d3e7..e84ca8b 100644 --- a/src/designer/deditcfg.ui +++ b/src/designer/deditcfg.ui @@ -408,7 +408,7 @@ - +
@@ -432,17 +432,16 @@
q3textedit.h
- QSEditor + ScriptEdit QWidget -
qseditor.h
+
scriptedit.h
mdtree.h acfg.h - qseditor.h mainform.h - qseditor.h + scriptedit.h diff --git a/src/designer/deditdialog.cpp b/src/designer/deditdialog.cpp index 9580d6a..22844c2 100644 --- a/src/designer/deditdialog.cpp +++ b/src/designer/deditdialog.cpp @@ -10,17 +10,17 @@ #include #include #include "acfg.h" -#include "qsproject.h" -#include "qsscript.h" -#include +//#include "qsproject.h" +//#include "qsscript.h" +//#include #include //--#include #include #include #include #include -#include -#include +//#include +//#include #include #include @@ -68,7 +68,7 @@ void dEditDialog::languageChange() void dEditDialog::init() { delete statusBar(); - eModule->setInterpreter(new QSInterpreter()); +// eModule->setInterpreter(new QSInterpreter()); // fd = new aFormDesigner(); } @@ -94,7 +94,7 @@ void dEditDialog::setData( aListViewItem *o ) al->setData(); eName->setText( md->attr( obj, mda_name ) ); eDescription->setText( md->sText( obj, md_description ) ); - eModule->setText( md->sText( obj, md_sourcecode ) ); + eModule->setPlainText( md->sText( obj, md_sourcecode ) ); eFormFile->setText( QString("inputform_")+QString::number(item->id)+QString(".ui")); setCaption( tr("Form:") + eName->text() ); parentClass = md->objClass( md->parent ( md->parent( obj ) ) ); @@ -268,7 +268,7 @@ void dEditDialog::updateMD() md->setAttr( obj, mda_type, cbFormMode->currentItem() ); md->setAttr( obj, mda_readonly, cbReadOnly->isChecked() ); md->setSText( obj, md_description, eDescription->text() ); - md->setSText( obj, md_sourcecode, eModule->text() ); + md->setSText( obj, md_sourcecode, eModule->toPlainText() ); // ui.arg(cbDefault->currentItem()); // md->setSText( obj, md_defaultmod, QString( "%1" ).arg( cbDefault->currentItem() ) ); int i = (1<isChecked() + \ diff --git a/src/designer/deditdialog.ui b/src/designer/deditdialog.ui index 6b1a01d..c997f9b 100644 --- a/src/designer/deditdialog.ui +++ b/src/designer/deditdialog.ui @@ -262,7 +262,7 @@ - +
@@ -324,9 +324,9 @@
q3textedit.h
- QSEditor + ScriptEdit QWidget -
qseditor.h
+
scriptedit.h
@@ -334,7 +334,7 @@ formdesigner.h aliaseditor.h mainform.h - qseditor.h + scriptedit.h diff --git a/src/designer/deditdoc.cpp b/src/designer/deditdoc.cpp index a1a383e..f9f3931 100644 --- a/src/designer/deditdoc.cpp +++ b/src/designer/deditdoc.cpp @@ -6,8 +6,8 @@ #include #include "acfg.h" -#include -#include +//#include +//#include /* * Constructs a dEditDoc as a child of 'parent', with the @@ -44,8 +44,8 @@ void dEditDoc::languageChange() void dEditDoc::init() { delete statusBar(); - eModule->setInterpreter( new QSInterpreter() ); - eStrViewF->setInterpreter( new QSInterpreter() ); +// eModule->setInterpreter( new QSInterpreter() ); +// eStrViewF->setInterpreter( new QSInterpreter() ); eStrViewF->setEnabled( FALSE ); } @@ -76,9 +76,9 @@ void dEditDoc::setData( aListViewItem *o ) setCaption( tr("Document:") + md->attr( obj, mda_name ) ); eName->setText( md->attr( obj, mda_name ) ); eDescription->setText( md->sText( obj, md_description ) ); - eModule->setText( md->sText( obj, md_sourcecode ) ); + eModule->setPlainText( md->sText( obj, md_sourcecode ) ); sv = md->find( obj, md_string_view ); - eStrViewF->setText( md->sText( sv, md_svfunction ) ); + eStrViewF->setPlainText( md->sText( sv, md_svfunction ) ); eSv->insertItem( "[ standart function ]" ); eSv->insertItem( "[ user function ]" ); fid = md->sText( sv, md_fieldid ).toInt(); @@ -110,10 +110,10 @@ void dEditDoc::updateMD() item->setText( 0, eName->text().stripWhiteSpace() ); md->setAttr( obj, mda_name, eName->text().stripWhiteSpace() ); md->setSText( obj, md_description, eDescription->text() ); - md->setSText( obj, md_sourcecode, eModule->text() ); + md->setSText( obj, md_sourcecode, eModule->toPlainText() ); sv = md->find( obj, md_string_view ); if ( sv.isNull() ) sv = md->insert( obj, md_string_view ); - md->setSText( sv, md_svfunction, eStrViewF->text() ); + md->setSText( sv, md_svfunction, eStrViewF->toPlainText() ); if ( eSv->currentItem() == 0 ) md->setAttr( sv, mda_stdf, "1" ); else { md->setAttr( sv, mda_stdf, "0" ); diff --git a/src/designer/deditdoc.ui b/src/designer/deditdoc.ui index 4444461..c4b8744 100644 --- a/src/designer/deditdoc.ui +++ b/src/designer/deditdoc.ui @@ -73,7 +73,7 @@ - +
@@ -108,7 +108,7 @@
- + false @@ -174,9 +174,9 @@
q3textedit.h
- QSEditor + ScriptEdit QWidget -
qseditor.h
+
scriptedit.h
@@ -184,8 +184,7 @@ aliaseditor.h mainform.h roleeditor.h - qseditor.h - qseditor.h + scriptedit.h diff --git a/src/designer/deditfield.ui b/src/designer/deditfield.ui index 94b4872..8c76538 100644 --- a/src/designer/deditfield.ui +++ b/src/designer/deditfield.ui @@ -297,7 +297,7 @@ acfg.h mdtree.h - qseditor.h + scriptedit.h aliaseditor.h mainform.h diff --git a/src/designer/deditreport.cpp b/src/designer/deditreport.cpp index d500557..fe4f96a 100644 --- a/src/designer/deditreport.cpp +++ b/src/designer/deditreport.cpp @@ -6,8 +6,8 @@ #include #include "acfg.h" -#include -#include +//#include +//#include /* * Constructs a dEditReport as a child of 'parent', with the @@ -52,14 +52,14 @@ void dEditReport::setData( aListViewItem *o ) setCaption( tr("Report:") + md->attr( obj, mda_name ) ); eName->setText( md->attr( obj, mda_name ) ); eDescription->setText( md->sText( obj, md_description ) ); - eModule->setText( md->sText( obj, md_sourcecode ) ); + eModule->setPlainText( md->sText( obj, md_sourcecode ) ); } void dEditReport::init() { delete statusBar(); - eModule->setInterpreter(new QSInterpreter()); +// eModule->setInterpreter(new QSInterpreter()); } @@ -72,7 +72,7 @@ void dEditReport::updateMD() item->setText( 0, eName->text().stripWhiteSpace() ); md->setAttr( obj, mda_name, eName->text().stripWhiteSpace() ); md->setSText( obj, md_description, eDescription->text() ); - md->setSText( obj, md_sourcecode, eModule->text() ); + md->setSText( obj, md_sourcecode, eModule->toPlainText() ); } void dEditReport::destroy() diff --git a/src/designer/deditreport.ui b/src/designer/deditreport.ui index 646975f..6e071b8 100644 --- a/src/designer/deditreport.ui +++ b/src/designer/deditreport.ui @@ -70,7 +70,7 @@ - +
@@ -126,16 +126,16 @@
q3textedit.h
- QSEditor + ScriptEdit QWidget -
qseditor.h
+
scriptedit.h
mdtree.h aliaseditor.h mainform.h - qseditor.h + scriptedit.h diff --git a/src/designer/deditwebform.cpp b/src/designer/deditwebform.cpp index 5339192..cf55bfa 100644 --- a/src/designer/deditwebform.cpp +++ b/src/designer/deditwebform.cpp @@ -6,8 +6,8 @@ #include #include "acfg.h" -#include -#include +//#include +//#include /* * Constructs a dEditWebForm as a child of 'parent', with the @@ -44,8 +44,8 @@ void dEditWebForm::languageChange() void dEditWebForm::init() { delete statusBar(); - eServerModule->setInterpreter(new QSInterpreter()); - eClientModule->setInterpreter(new QSInterpreter()); +// eServerModule->setInterpreter(new QSInterpreter()); +// eClientModule->setInterpreter(new QSInterpreter()); } void dEditWebForm::destroy() @@ -69,8 +69,8 @@ void dEditWebForm::setData( aListViewItem *o ) setCaption( tr("Web form:") + md->attr( obj, mda_name ) ); eName->setText( md->attr( obj, mda_name ) ); eDescription->setText( md->sText( obj, md_description ) ); - eServerModule->setText( md->sText( obj, md_servermodule ) ); - eClientModule->setText( md->sText( obj, md_clientmodule ) ); + eServerModule->setPlainText( md->sText( obj, md_servermodule ) ); + eClientModule->setPlainText( md->sText( obj, md_clientmodule ) ); eFormSource->setText( md->sText( obj, md_formsource ) ); } @@ -83,7 +83,7 @@ void dEditWebForm::updateMD() item->setText( 0, eName->text().stripWhiteSpace() ); md->setAttr( obj, mda_name, eName->text().stripWhiteSpace() ); md->setSText( obj, md_description, eDescription->text() ); - md->setSText( obj, md_servermodule, eServerModule->text() ); - md->setSText( obj, md_clientmodule, eClientModule->text() ); + md->setSText( obj, md_servermodule, eServerModule->toPlainText() ); + md->setSText( obj, md_clientmodule, eClientModule->toPlainText() ); md->setSText( obj, md_formsource, eFormSource->text() ); } diff --git a/src/designer/deditwebform.ui b/src/designer/deditwebform.ui index b95aaaa..f2f551b 100644 --- a/src/designer/deditwebform.ui +++ b/src/designer/deditwebform.ui @@ -81,7 +81,7 @@ - +
@@ -91,7 +91,7 @@ - +
@@ -137,17 +137,16 @@
q3textedit.h
- QSEditor + ScriptEdit QWidget -
qseditor.h
+
scriptedit.h
aliaseditor.h mdtree.h mainform.h - qseditor.h - qseditor.h + scriptedit.h diff --git a/src/designer/designer.pro b/src/designer/designer.pro index f1dd5b3..a3d88e8 100644 --- a/src/designer/designer.pro +++ b/src/designer/designer.pro @@ -7,8 +7,8 @@ CONFIG += designer DESTDIR = ../../bin -INCLUDEPATH += . ./formdesigner ../lib ../../tmp/ui/ananas ../plugins -LIBS += -L../../lib -lananas4 -L../../lib/designer -lananasplugin4 -lqt4-qdataschema +INCLUDEPATH += . ./formdesigner ./formdesigner/private ../lib ../../tmp/ui/ananas ../plugins ../editor +LIBS += -L../../lib -lananas4 -lqt4designer -L../../lib/designer -lananasplugin4 -lqt4-qdataschema -L../editor -lqtscriptedit unix { #LIBS += -L$(QTINC)/QtDesigner LIBS += -lQtDesignerComponents @@ -28,7 +28,9 @@ UI_DIR = ../../tmp/ui/$$TARGET #INCLUDEPATH += ../lib ../lib/tmp/ui ../lib/.ui ./formdesigner /usr/lib include ( ../ananas.pri ) -load(qsa) +#load(qsa) +QT += script +QT += scripttools HEADERS = \ actiontree.h \ diff --git a/src/designer/formdesigner.cpp b/src/designer/formdesigner.cpp index bf9c067..5ce195e 100644 --- a/src/designer/formdesigner.cpp +++ b/src/designer/formdesigner.cpp @@ -153,7 +153,7 @@ aFormDesigner::fileSaveAll() for (i=0; i< workbench()->formWindowCount(); i++){ w = workbench()->formWindow( i ); workbench()->saveForm(w->editor()); - printf("w=%s\n", w->windowTitle().toUtf8().data()); + //printf("w=%s\n", w->windowTitle().toUtf8().data()); } } diff --git a/src/designer/formdesigner/private/deviceprofile_p.h b/src/designer/formdesigner/private/deviceprofile_p.h new file mode 100644 index 0000000..1ef7144 --- /dev/null +++ b/src/designer/formdesigner/private/deviceprofile_p.h @@ -0,0 +1,152 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Designer of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. +** +** GNU Lesser General Public License Usage +** Alternatively, 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.0, 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. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $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 DEVICEPROFILE_H +#define DEVICEPROFILE_H + +#include "shared_global_p.h" + +#include +#include + +QT_BEGIN_NAMESPACE + +class QDesignerFormEditorInterface; +class QWidget; +class QStyle; + +namespace qdesigner_internal { + +class DeviceProfileData; + +/* DeviceProfile for embedded design. They influence + * default properties (for example, fonts), dpi and + * style of the form. This class represents a device + * profile. */ + +class QDESIGNER_SHARED_EXPORT DeviceProfile { +public: + DeviceProfile(); + + DeviceProfile(const DeviceProfile&); + DeviceProfile& operator=(const DeviceProfile&); + ~DeviceProfile(); + + void clear(); + + // Device name + QString name() const; + void setName(const QString &); + + // System settings active + bool isEmpty() const; + + // Default font family of the embedded system + QString fontFamily() const; + void setFontFamily(const QString &); + + // Default font size of the embedded system + int fontPointSize() const; + void setFontPointSize(int p); + + // Display resolution of the embedded system + int dpiX() const; + void setDpiX(int d); + int dpiY() const; + void setDpiY(int d); + + // Style + QString style() const; + void setStyle(const QString &); + + // Initialize from desktop system + void fromSystem(); + + static void systemResolution(int *dpiX, int *dpiY); + static void widgetResolution(const QWidget *w, int *dpiX, int *dpiY); + + bool equals(const DeviceProfile& rhs) const; + + // Apply to form/preview (using font inheritance) + enum ApplyMode { + /* Pre-Apply to parent widget of form being edited: Apply font + * and make use of property inheritance to be able to modify the + * font property freely. */ + ApplyFormParent, + /* Post-Apply to preview widget: Change only inherited font + * sub properties. */ + ApplyPreview + }; + void apply(const QDesignerFormEditorInterface *core, QWidget *widget, ApplyMode am) const; + + static void applyDPI(int dpiX, int dpiY, QWidget *widget); + + QString toString() const; + + QString toXml() const; + bool fromXml(const QString &xml, QString *errorMessage); + +private: + QSharedDataPointer m_d; +}; + +inline bool operator==(const DeviceProfile &s1, const DeviceProfile &s2) + { return s1.equals(s2); } +inline bool operator!=(const DeviceProfile &s1, const DeviceProfile &s2) + { return !s1.equals(s2); } + +} + + +QT_END_NAMESPACE + +#endif // DEVICEPROFILE_H diff --git a/src/designer/formdesigner/private/formscriptrunner_p.h b/src/designer/formdesigner/private/formscriptrunner_p.h index 627ee21..58b7c4f 100644 --- a/src/designer/formdesigner/private/formscriptrunner_p.h +++ b/src/designer/formdesigner/private/formscriptrunner_p.h @@ -1,34 +1,65 @@ /**************************************************************************** ** -** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved. +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the Qt Designer of the Qt Toolkit. ** -** This file may be used under the terms of the GNU General Public -** License version 2.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 GNU -** General Public Licensing requirements will be met: -** http://www.trolltech.com/products/qt/opensource.html +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. ** -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://www.trolltech.com/products/qt/licensing.html or contact the -** sales department at sales@trolltech.com. +** GNU Lesser General Public License Usage +** Alternatively, 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. ** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** 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. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $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 #include #include #include +QT_BEGIN_NAMESPACE + class QWidget; #ifdef QFORMINTERNAL_NAMESPACE @@ -84,4 +115,6 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(QFormScriptRunner::Options) } #endif +QT_END_NAMESPACE + #endif // FORMSCRIPTRUNNER_H diff --git a/src/designer/formdesigner/private/pluginmanager_p.h b/src/designer/formdesigner/private/pluginmanager_p.h index e970b04..962ed0c 100644 --- a/src/designer/formdesigner/private/pluginmanager_p.h +++ b/src/designer/formdesigner/private/pluginmanager_p.h @@ -1,23 +1,41 @@ /**************************************************************************** ** -** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved. +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the Qt Designer of the Qt Toolkit. ** -** This file may be used under the terms of the GNU General Public -** License version 2.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 GNU -** General Public Licensing requirements will be met: -** http://www.trolltech.com/products/qt/opensource.html +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. ** -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://www.trolltech.com/products/qt/licensing.html or contact the -** sales department at sales@trolltech.com. +** GNU Lesser General Public License Usage +** Alternatively, 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.0, 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. ** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -37,18 +55,56 @@ #include "shared_global_p.h" +#include #include #include -#include + +QT_BEGIN_NAMESPACE class QDesignerFormEditorInterface; class QDesignerCustomWidgetInterface; +class QDesignerPluginManagerPrivate; + +class QDesignerCustomWidgetSharedData; + +/* Information contained in the Dom XML of a custom widget. */ +class QDESIGNER_SHARED_EXPORT QDesignerCustomWidgetData { +public: + explicit QDesignerCustomWidgetData(const QString &pluginPath = QString()); + + enum ParseResult { ParseOk, ParseWarning, ParseError }; + ParseResult parseXml(const QString &xml, const QString &name, QString *errorMessage); + + QDesignerCustomWidgetData(const QDesignerCustomWidgetData&); + QDesignerCustomWidgetData& operator=(const QDesignerCustomWidgetData&); + ~QDesignerCustomWidgetData(); + + bool isNull() const; + + QString pluginPath() const; + + // Data as parsed from the widget's domXML(). + QString xmlClassName() const; + // Optional. The language the plugin is supposed to be used with. + QString xmlLanguage() const; + // Optional. method used to add pages to a container with a container extension + QString xmlAddPageMethod() const; + // Optional. Base class + QString xmlExtends() const; + // Optional. The name to be used in the widget box. + QString xmlDisplayName() const; + +private: + QSharedDataPointer m_d; +}; class QDESIGNER_SHARED_EXPORT QDesignerPluginManager: public QObject { Q_OBJECT public: - QDesignerPluginManager(QDesignerFormEditorInterface *core); + typedef QList CustomWidgetList; + + explicit QDesignerPluginManager(QDesignerFormEditorInterface *core); virtual ~QDesignerPluginManager(); QDesignerFormEditorInterface *core() const; @@ -68,8 +124,10 @@ public: QStringList failedPlugins() const; QString failureReason(const QString &pluginName) const; - QList instances() const; - QList registeredCustomWidgets() const; + QObjectList instances() const; + + CustomWidgetList registeredCustomWidgets() const; + QDesignerCustomWidgetData customWidgetData(QDesignerCustomWidgetInterface *w) const; bool registerNewPlugins(); @@ -83,18 +141,11 @@ private: void registerPlugin(const QString &plugin); private: - QDesignerFormEditorInterface *m_core; - QStringList m_pluginPaths; - QStringList m_registeredPlugins; - QStringList m_disabledPlugins; - - typedef QMap FailedPluginMap; - FailedPluginMap m_failedPlugins; + static QStringList defaultPluginPaths(); - typedef QList CustomWidgetList; - CustomWidgetList m_customWidgets; - - QStringList defaultPluginPaths() const; + QDesignerPluginManagerPrivate *m_d; }; +QT_END_NAMESPACE + #endif // PLUGINMANAGER_H diff --git a/src/designer/formdesigner/private/qdesigner_formbuilder_p.h b/src/designer/formdesigner/private/qdesigner_formbuilder_p.h index 028c595..7b70def 100644 --- a/src/designer/formdesigner/private/qdesigner_formbuilder_p.h +++ b/src/designer/formdesigner/private/qdesigner_formbuilder_p.h @@ -1,23 +1,41 @@ /**************************************************************************** ** -** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved. +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the Qt Designer of the Qt Toolkit. ** -** This file may be used under the terms of the GNU General Public -** License version 2.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 GNU -** General Public Licensing requirements will be met: -** http://www.trolltech.com/products/qt/opensource.html +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. ** -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://www.trolltech.com/products/qt/licensing.html or contact the -** sales department at sales@trolltech.com. +** GNU Lesser General Public License Usage +** Alternatively, 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. ** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** 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. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -36,32 +54,42 @@ #define QDESIGNER_FORMBUILDER_H #include "shared_global_p.h" +#include "deviceprofile_p.h" -#include +//#include +#include #include #include #include +QT_BEGIN_NAMESPACE + class QDesignerFormEditorInterface; class QDesignerFormWindowInterface; +class QPixmap; +class QtResourceSet; + namespace qdesigner_internal { -// Form builder used for previewing forms +class DesignerPixmapCache; +class DesignerIconCache; + +/* Form builder used for previewing forms, widget box and new form dialog. + * It applies the system settings to its toplevel window. */ + class QDESIGNER_SHARED_EXPORT QDesignerFormBuilder: public QFormBuilder { public: enum Mode { - // Use container extension to populate containers. Disable scripts. DisableScripts, - // Use container extension to populate containers as well as scripts - UseScriptAndContainerExtension, - // Experimental: Use scripts to populate the container - UseScriptForContainerExtension + EnableScripts }; - QDesignerFormBuilder(QDesignerFormEditorInterface *core, Mode mode); + QDesignerFormBuilder(QDesignerFormEditorInterface *core, + Mode mode, + const DeviceProfile &deviceProfile = DeviceProfile()); QWidget *createWidgetFromContents(const QString &contents, QWidget *parentWidget = 0); @@ -71,13 +99,25 @@ public: inline QDesignerFormEditorInterface *core() const { return m_core; } + 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); // 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); + + // Create a preview image + static QPixmap createPreviewPixmap(const QDesignerFormWindowInterface *fw, const QString &styleName = QString(), const QString &appStyleSheet = QString()); protected: using QFormBuilder::createDom; @@ -87,6 +127,7 @@ protected: virtual DomWidget *createDom(QWidget *widget, DomWidget *ui_parentWidget, bool recursive = true); virtual QWidget *create(DomWidget *ui_widget, QWidget *parentWidget); virtual QLayout *create(DomLayout *ui_layout, QLayout *layout, QWidget *parentWidget); + virtual void createResources(DomResources *resources); virtual QWidget *createWidget(const QString &widgetName, QWidget *parentWidget, const QString &name); virtual bool addItem(DomWidget *ui_widget, QWidget *widget, QWidget *parentWidget); @@ -99,15 +140,28 @@ protected: virtual void loadExtraInfo(DomWidget *ui_widget, QWidget *widget, QWidget *parentWidget); + QtResourceSet *internalResourceSet() const { return m_tempResourceSet; } + + DeviceProfile deviceProfile() const { return m_deviceProfile; } + private: - bool addItemContainerExtension(QWidget *widget, QWidget *parentWidget); QDesignerFormEditorInterface *m_core; const Mode m_mode; - + typedef QSet WidgetSet; WidgetSet m_customWidgetsWithScript; + + const DeviceProfile m_deviceProfile; + + DesignerPixmapCache *m_pixmapCache; + DesignerIconCache *m_iconCache; + bool m_ignoreCreateResources; + QtResourceSet *m_tempResourceSet; + bool m_mainWidget; }; } // namespace qdesigner_internal +QT_END_NAMESPACE + #endif // QDESIGNER_FORMBUILDER_H diff --git a/src/designer/formdesigner/private/qdesigner_integration_p.h b/src/designer/formdesigner/private/qdesigner_integration_p.h index 3ac94bd..9c2db38 100644 --- a/src/designer/formdesigner/private/qdesigner_integration_p.h +++ b/src/designer/formdesigner/private/qdesigner_integration_p.h @@ -1,23 +1,41 @@ /**************************************************************************** ** -** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved. +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the Qt Designer of the Qt Toolkit. ** -** This file may be used under the terms of the GNU General Public -** License version 2.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 GNU -** General Public Licensing requirements will be met: -** http://www.trolltech.com/products/qt/opensource.html +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. ** -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://www.trolltech.com/products/qt/licensing.html or contact the -** sales department at sales@trolltech.com. +** GNU Lesser General Public License Usage +** Alternatively, 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. ** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** 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. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -36,13 +54,15 @@ #define QDESIGNER_INTEGRATION_H #include "shared_global_p.h" -#include "abstractintegration.h" +#include #include +QT_BEGIN_NAMESPACE + class QDesignerFormEditorInterface; class QDesignerFormWindowInterface; -class QDesignerFormWindowManagerInterface; +class QDesignerResourceBrowserInterface; class QVariant; class QWidget; @@ -50,31 +70,62 @@ class QWidget; namespace qdesigner_internal { struct Selection; +class QDesignerIntegrationPrivate; class QDESIGNER_SHARED_EXPORT QDesignerIntegration: public QDesignerIntegrationInterface { Q_OBJECT public: - QDesignerIntegration(QDesignerFormEditorInterface *core, QObject *parent = 0); + explicit QDesignerIntegration(QDesignerFormEditorInterface *core, QObject *parent = 0); virtual ~QDesignerIntegration(); + static void requestHelp(const QDesignerFormEditorInterface *core, const QString &manual, const QString &document); + virtual QWidget *containerWindow(QWidget *widget) const; // Load plugins into widget database and factory. static void initializePlugins(QDesignerFormEditorInterface *formEditor); + void emitObjectNameChanged(QDesignerFormWindowInterface *formWindow, QObject *object, + const QString &newName, const QString &oldName); + void emitNavigateToSlot(const QString &objectName, const QString &signalSignature, const QStringList ¶meterNames); + void emitNavigateToSlot(const QString &slotSignature); + + // Create a resource browser specific to integration. Language integration takes precedence + virtual QDesignerResourceBrowserInterface *createResourceBrowser(QWidget *parent = 0); + + enum ResourceFileWatcherBehaviour { + NoWatcher, + ReloadSilently, + PromptAndReload + }; + + ResourceFileWatcherBehaviour resourceFileWatcherBehaviour() const; + bool isResourceEditingEnabled() const; + bool isSlotNavigationEnabled() const; + + QString contextHelpId() const; + +protected: + + void setResourceFileWatcherBehaviour(ResourceFileWatcherBehaviour behaviour); // PromptAndReload by default + void setResourceEditingEnabled(bool enable); // true by default + void setSlotNavigationEnabled(bool enable); // false by default signals: void propertyChanged(QDesignerFormWindowInterface *formWindow, const QString &name, const QVariant &value); + void objectNameChanged(QDesignerFormWindowInterface *formWindow, QObject *object, const QString &newName, const QString &oldName); + void helpRequested(const QString &manual, const QString &document); + + void navigateToSlot(const QString &objectName, const QString &signalSignature, const QStringList ¶meterNames); + void navigateToSlot(const QString &slotSignature); public slots: - virtual void updateProperty(const QString &name, const QVariant &value); + virtual void updateProperty(const QString &name, const QVariant &value, bool enableSubPropertyHandling); // Additional signals of designer property editor - virtual void updatePropertyComment(const QString &name, const QString &value); virtual void resetProperty(const QString &name); virtual void addDynamicProperty(const QString &name, const QVariant &value); virtual void removeDynamicProperty(const QString &name); - virtual void updateActiveFormWindow(QDesignerFormWindowInterface *formWindow); virtual void setupFormWindow(QDesignerFormWindowInterface *formWindow); virtual void updateSelection(); @@ -83,14 +134,19 @@ public slots: void updateCustomWidgetPlugins(); +private slots: + void updatePropertyPrivate(const QString &name, const QVariant &value); + private: void initialize(); void getSelection(Selection &s); QObject *propertyEditorObject(); - QDesignerFormWindowManagerInterface *m_formWindowManager; + QDesignerIntegrationPrivate *m_d; }; } // namespace qdesigner_internal +QT_END_NAMESPACE + #endif // QDESIGNER_INTEGRATION_H diff --git a/src/designer/formdesigner/private/shared_global_p.h b/src/designer/formdesigner/private/shared_global_p.h index 32fb525..abbc8bc 100644 --- a/src/designer/formdesigner/private/shared_global_p.h +++ b/src/designer/formdesigner/private/shared_global_p.h @@ -1,23 +1,41 @@ /**************************************************************************** ** -** Copyright (C) 1992-2006 Trolltech ASA. All rights reserved. +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the Qt Designer of the Qt Toolkit. ** -** This file may be used under the terms of the GNU General Public -** License version 2.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 GNU -** General Public Licensing requirements will be met: -** http://www.trolltech.com/products/qt/opensource.html +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. ** -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://www.trolltech.com/products/qt/licensing.html or contact the -** sales department at sales@trolltech.com. +** GNU Lesser General Public License Usage +** Alternatively, 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. ** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** 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. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ ** ****************************************************************************/ diff --git a/src/designer/formdesigner/private/sheet_delegate_p.h b/src/designer/formdesigner/private/sheet_delegate_p.h index f260f03..532f4e3 100644 --- a/src/designer/formdesigner/private/sheet_delegate_p.h +++ b/src/designer/formdesigner/private/sheet_delegate_p.h @@ -1,23 +1,41 @@ /**************************************************************************** ** -** Copyright (C) 1992-2006 Trolltech ASA. All rights reserved. +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) ** ** This file is part of the Qt Designer of the Qt Toolkit. ** -** This file may be used under the terms of the GNU General Public -** License version 2.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 GNU -** General Public Licensing requirements will be met: -** http://www.trolltech.com/products/qt/opensource.html +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial Usage +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Nokia. ** -** If you are unsure which license is appropriate for your use, please -** review the following information: -** http://www.trolltech.com/products/qt/licensing.html or contact the -** sales department at sales@trolltech.com. +** GNU Lesser General Public License Usage +** Alternatively, 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.0, 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. ** -** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE -** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ ** ****************************************************************************/ @@ -38,8 +56,10 @@ #include "shared_global_p.h" -#include -#include +#include +#include + +QT_BEGIN_NAMESPACE class QTreeView; @@ -60,4 +80,6 @@ private: } // namespace qdesigner_internal +QT_END_NAMESPACE + #endif // SHEET_DELEGATE_H diff --git a/src/designer/formdesigner/qrc_designer.cpp b/src/designer/formdesigner/qrc_designer.cpp index c4f3c91..308a35a 100644 --- a/src/designer/formdesigner/qrc_designer.cpp +++ b/src/designer/formdesigner/qrc_designer.cpp @@ -1,8 +1,8 @@ /**************************************************************************** ** Resource object code ** -** Created: Sun Oct 26 23:47:57 2008 -** by: The Resource Compiler for Qt version 4.3.0 +** Created: Wed Dec 23 14:39:47 2009 +** by: The Resource Compiler for Qt version 4.5.2 ** ** WARNING! All changes made in this file will be lost! *****************************************************************************/ @@ -10,7 +10,7 @@ #include static const unsigned char qt_resource_data[] = { - // /home/user/src/ananas-qt4/src/designer/formdesigner/images/designer.png + // /home/app/devel/clones/ananas-qt4/src/designer/formdesigner/images/designer.png 0x0,0x0,0x39,0xf, 0x89, 0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0, @@ -926,7 +926,7 @@ static const unsigned char qt_resource_data[] = { 0x24,0xf0,0x4a,0xcd,0xbc,0xb,0x59,0xd8,0x21,0xea,0x22,0xf5,0x5a,0x2,0x75,0x29, 0x8c,0xcd,0x4,0xfc,0x31,0x2d,0x1c,0xf9,0xff,0x1,0x1f,0xdc,0x76,0xde,0x36,0x49, 0xe6,0xd2,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82, - // /home/user/src/ananas-qt4/src/designer/formdesigner/templates/forms/Dialog_with_Buttons_Bottom.ui + // /home/app/devel/clones/ananas-qt4/src/designer/formdesigner/templates/forms/Dialog_with_Buttons_Bottom.ui 0x0,0x0,0x2,0x72, 0x0, 0x0,0x8,0xb0,0x78,0x9c,0xb5,0x55,0x4d,0x8f,0xd3,0x30,0x10,0xbd,0x23,0xf1,0x1f, @@ -969,7 +969,7 @@ static const unsigned char qt_resource_data[] = { 0x2,0x7e,0xa9,0xac,0x2f,0x94,0x35,0xbb,0xbc,0x79,0x75,0x59,0x57,0x57,0x31,0xe7, 0xf5,0xfa,0xef,0x75,0x9d,0xfa,0x3a,0x2,0xa5,0x1d,0x55,0x9f,0x3f,0x70,0x8d,0x7e, 0x64, - // /home/user/src/ananas-qt4/src/designer/formdesigner/templates/forms/Dialog_with_Buttons_Right.ui + // /home/app/devel/clones/ananas-qt4/src/designer/formdesigner/templates/forms/Dialog_with_Buttons_Right.ui 0x0,0x0,0x2,0x78, 0x0, 0x0,0x8,0xab,0x78,0x9c,0xb5,0x55,0x4d,0x6f,0xd4,0x30,0x10,0xbd,0x23,0xf1,0x1f, @@ -1012,7 +1012,7 @@ static const unsigned char qt_resource_data[] = { 0xaa,0x4a,0xf8,0xa9,0x4f,0x7d,0xa9,0xaa,0x9b,0xd1,0x6f,0x61,0xb7,0x7b,0xa9,0xaa, 0xab,0xcb,0xfd,0x30,0xe5,0x6a,0x7d,0xf1,0x7c,0x59,0x63,0xdf,0xac,0xc0,0x49,0xc3, 0xf4,0xe7,0xf,0xe0,0x1d,0x7c,0xd5, - // /home/user/src/ananas-qt4/src/designer/formdesigner/templates/forms/Main_Window.ui + // /home/app/devel/clones/ananas-qt4/src/designer/formdesigner/templates/forms/Main_Window.ui 0x0,0x0,0x2,0xc7, 0x3c, 0x75,0x69,0x20,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x3d,0x22,0x34,0x2e,0x30,0x22, @@ -1060,7 +1060,7 @@ static const unsigned char qt_resource_data[] = { 0x6d,0x61,0x70,0x66,0x75,0x6e,0x63,0x74,0x69,0x6f,0x6e,0x3e,0xd,0xa,0x20,0x3c, 0x63,0x6f,0x6e,0x6e,0x65,0x63,0x74,0x69,0x6f,0x6e,0x73,0x2f,0x3e,0xd,0xa,0x3c, 0x2f,0x75,0x69,0x3e,0xd,0xa, - // /home/user/src/ananas-qt4/src/designer/formdesigner/templates/forms/Widget.ui + // /home/app/devel/clones/ananas-qt4/src/designer/formdesigner/templates/forms/Widget.ui 0x0,0x0,0x2,0x18, 0x3c, 0x75,0x69,0x20,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x3d,0x22,0x34,0x2e,0x30,0x22, @@ -1182,17 +1182,32 @@ static const unsigned char qt_resource_struct[] = { }; -int qInitResources_designer() +QT_BEGIN_NAMESPACE + +extern bool qRegisterResourceData + (int, const unsigned char *, const unsigned char *, const unsigned char *); + +extern bool qUnregisterResourceData + (int, const unsigned char *, const unsigned char *, const unsigned char *); + +QT_END_NAMESPACE + + +int QT_MANGLE_NAMESPACE(qInitResources_designer)() { - extern bool qRegisterResourceData(int, const unsigned char *, const unsigned char *, const unsigned char *); - qRegisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data); + QT_PREPEND_NAMESPACE(qRegisterResourceData) + (0x01, qt_resource_struct, qt_resource_name, qt_resource_data); return 1; } -Q_CONSTRUCTOR_FUNCTION(qInitResources_designer) -int qCleanupResources_designer() + +Q_CONSTRUCTOR_FUNCTION(QT_MANGLE_NAMESPACE(qInitResources_designer)) + +int QT_MANGLE_NAMESPACE(qCleanupResources_designer)() { - extern bool qUnregisterResourceData(int, const unsigned char *, const unsigned char *, const unsigned char *); - qUnregisterResourceData(0x01, qt_resource_struct, qt_resource_name, qt_resource_data); + QT_PREPEND_NAMESPACE(qUnregisterResourceData) + (0x01, qt_resource_struct, qt_resource_name, qt_resource_data); return 1; } -Q_DESTRUCTOR_FUNCTION(qCleanupResources_designer) + +Q_DESTRUCTOR_FUNCTION(QT_MANGLE_NAMESPACE(qCleanupResources_designer)) + diff --git a/src/designer/formdesigner/qtdesigner.pro b/src/designer/formdesigner/qtdesigner.pro index 680e3da..f4e63d1 100644 --- a/src/designer/formdesigner/qtdesigner.pro +++ b/src/designer/formdesigner/qtdesigner.pro @@ -4,7 +4,7 @@ include ( ../../ananas.pri ) TEMPLATE = lib TARGET = qt4designer -INCLUDEPATH += +INCLUDEPATH += ./private DEFINES += diff --git a/src/editor/editor.pro b/src/editor/editor.pro index 00f34c1..285c49a 100644 --- a/src/editor/editor.pro +++ b/src/editor/editor.pro @@ -1,5 +1,5 @@ TEMPLATE = lib #DESTDIR = ../lib -TARGET = qtscripteditor +TARGET = qtscriptedit #DEFINES += Q_SCRIPTDEBUG_BUILD_LIB include(editor.pri) diff --git a/src/plugins/actionbutton/eactionbutton.cpp b/src/plugins/actionbutton/eactionbutton.cpp index 76d9263..ef7a9fc 100644 --- a/src/plugins/actionbutton/eactionbutton.cpp +++ b/src/plugins/actionbutton/eactionbutton.cpp @@ -4,7 +4,7 @@ #include #include -#include +//#include #include /* diff --git a/src/plugins/aform.cpp b/src/plugins/aform.cpp index 017549e..38ba41f 100644 --- a/src/plugins/aform.cpp +++ b/src/plugins/aform.cpp @@ -43,6 +43,8 @@ #include #include //#include +#include +#include //--#include #include @@ -337,14 +339,14 @@ aForm::init() connectSlots(); if ( !sModule.isEmpty() ) { - // engine->project.addObject(this); - engine->project.interpreter()->evaluate(sModule,this ); +// engine->project.interpreter()->evaluate(sModule,this ); + engine->code->evaluate(sModule); aLog::print(aLog::Debug, tr("aForm load form module script")); - QStringList lst = engine->project.interpreter()->functions(this); - for(uint i=0; iproject.interpreter()->functions(this); +// for(uint i=0; iproject.interpreter()->functions( this ).findIndex("on_formstart")!=-1) - { - engine->project.interpreter()->call("on_formstart", QVariantList(), this); - } +// if ( engine->project.interpreter()->functions( this ).findIndex("on_formstart")!=-1) +// { +// engine->project.interpreter()->call("on_formstart", QVariantList(), this); +// } + if ( engine->code->globalObject().property("on_formstart").isValid() ){ + engine->code->globalObject().property("on_formstart").call(); + } + form->show(); ((QWidget*)form->parent())->move(0,0); connect( form, SIGNAL(destroyed()), this, SLOT(close()) ); @@ -485,23 +491,24 @@ aForm::turn_on(){ */ int aForm::SignIn(){ - QVariant res; + QScriptValue res; if ( form && !mainWidget->dataObject()->IsConducted()) { - if ( engine->project.interpreter()->functions( this ).findIndex("on_conduct")!=-1) - { - res = engine->project.interpreter()->call("on_conduct",QVariantList(), this); - } - } - //--if(res.type()==QSArgument::Variant) - { - // if return false - if(res.toBool()==false && res.type()!=QVariant::Invalid) - { - aLog::print(aLog::Info, tr("aForm conduct: function on_conduct() return false, document not conducted")); - return 0; - } +// if ( engine->project.interpreter()->functions( this ).findIndex("on_conduct")!=-1) +// { +// res = engine->project.interpreter()->call("on_conduct",QVariantList(), this); +// } + if ( engine->code->globalObject().property("on_conduct").isValid() ){ + res = engine->code->globalObject().property("on_conduct").call(); + } + } + // if return false + if(res.isValid() && res.toBool() == false ) + { + aLog::print(aLog::Info, tr("aForm conduct: function on_conduct() return false, document not conducted")); + return 0; + } return mainWidget->TurnOn(); } @@ -1266,11 +1273,14 @@ aForm::SetFocus(){ void aForm::on_button(){ - if ( engine->project.interpreter()->functions(this).findIndex("on_button")!=-1) - { - engine->project.interpreter()->call("on_button",QVariantList()<name(),this); -// engine->code->evaluate("on_button(\""+sender()->name()+"\")", this); - } +// if ( engine->project.interpreter()->functions(this).findIndex("on_button")!=-1) +// { +// engine->project.interpreter()->call("on_button",QVariantList()<name(),this); +// } + if ( engine->code->globalObject().property("on_button").isValid() ){ + engine->code->globalObject().property("on_button").call(); + } + } @@ -1326,9 +1336,12 @@ aForm::on_lostfocus(){ void aForm::on_form_close(){ if(!engine) return; - if ( engine->project.interpreter()->functions(this).findIndex("on_formstop")!=-1) { - engine->project.interpreter()->call("on_formstop", QVariantList(),this); - } +// if ( engine->project.interpreter()->functions(this).findIndex("on_formstop")!=-1) { +// engine->project.interpreter()->call("on_formstop", QVariantList(),this); +// } + if ( engine->code->globalObject().property("on_formstop").isValid() ){ + engine->code->globalObject().property("on_formstop").call(); + } } @@ -1374,15 +1387,21 @@ void aForm::on_valueChanged( const QString & name, const QVariant & val ) { - if ( engine->project.interpreter()->functions(this).findIndex("on_valuechanged")!=-1) - { - Q3ValueList lst; - lst << name; - lst << val; -// if(!val.isNull() && !val.isValid()) v = val; - engine->project.interpreter()->call("on_valuechanged",QVariantList(lst), this); - // printf("aForm change value field %s to %s\n",(const char*)name.local8Bit(), val.toString().ascii()); - } +// if ( engine->project.interpreter()->functions(this).findIndex("on_valuechanged")!=-1) +// { +// Q3ValueList lst; +// lst << name; +// lst << val; +// engine->project.interpreter()->call("on_valuechanged",QVariantList(lst), this); +// } + if ( engine->code->globalObject().property("on_valuechanged").isValid() ){ + QScriptValueList list; + list.append(QScriptValue(name)); + list.append( engine->code->newVariant(val)); + engine->code->globalObject().property("on_valuechanged") + .call(QScriptValue(),list); + } + } @@ -1390,33 +1409,23 @@ void aForm::on_tabvalueChanged(int row, int col) { - if ( engine->project.interpreter()->functions(this).findIndex("on_tabupdate")!=-1) - { - Q3ValueList lst; - lst << row; - lst << col; - lst << sender()->name(); - - engine->project.interpreter()->call("on_tabupdate",QVariantList(lst), this); - } -/* - const QObject *sobj=sender(); - QString objName=widgetName((QObject *) sobj); - cfg_message(0, "value changed %s (%s)\n", (const char *) objName.utf8(), (const char *) dbobject->className()); - cfg_message(0, "classname %s\n", (const char *) sobj->className()); - if (strcmp(sobj->className(),"QAnanasDBTable")==0) { -// if (sobj->className()=="QAnanasDBField") { -*/ -/* cfg_message(0,"OK"); - if (dbobject->className()=="QAdoc"){ - ((QAdoc *)dbobject)->setfield(objName, s); - } - if (dbobject->className()=="QAcat"){ - cfg_message(0,"Поле справочника %s=%s\n",(const char *) objName.utf8(), (const char *) s.utf8()); - ((QAcat *)dbobject)->setfield(objName, s); - } -*/ +// if ( engine->project.interpreter()->functions(this).findIndex("on_tabupdate")!=-1) +// { +// Q3ValueList lst; +// lst << row; +// lst << col; +// lst << sender()->name(); +// +// engine->project.interpreter()->call("on_tabupdate",QVariantList(lst), this); // } + if ( engine->code->globalObject().property("on_tabupdate").isValid() ){ + QScriptValueList list; + list << row; + list << col; + list << sender()->name(); + engine->code->globalObject().property("on_tabupdate") + .call(QScriptValue(),list); + } } @@ -1432,20 +1441,33 @@ aForm::on_dbtablerow( QSqlRecord *r ) aSQLTable *t = o->table(); id = t->value(0).toULongLong(); } - if ( engine->project.interpreter()->functions(this).findIndex("on_tablerow")!=-1) { - engine->project.interpreter()->call("on_tablerow", QVariantList()<name(), this); - } +// if ( engine->project.interpreter()->functions(this).findIndex("on_tablerow")!=-1) { +// engine->project.interpreter()->call("on_tablerow", QVariantList()<name(), this); +// } + if ( engine->code->globalObject().property("on_tablerow").isValid() ){ + QScriptValueList list; + list << sender()->name(); + engine->code->globalObject().property("on_tablerow") + .call(QScriptValue(),list); + } } void aForm::on_event( const QString &source, const QString &data ) { - Q3ValueList lst; - lst << source; - lst << data; - if ( engine->project.interpreter()->functions(this).findIndex("on_event")!=-1) { - engine->project.interpreter()->call("on_event", QVariantList(lst), this); - } +// Q3ValueList lst; +// lst << source; +// lst << data; +// if ( engine->project.interpreter()->functions(this).findIndex("on_event")!=-1) { +// engine->project.interpreter()->call("on_event", QVariantList(lst), this); +// } + if ( engine->code->globalObject().property("on_event").isValid() ){ + QScriptValueList list; + list << source; + list << data; + engine->code->globalObject().property("on_event") + .call(QScriptValue(),list); + } } @@ -1465,12 +1487,19 @@ aForm::on_tabselected( qulonglong uid ) void aForm::on_tablerow( qulonglong uid ) { - Q3ValueList lst; - lst << sender()->name(); - lst << QString("%1").arg(uid); - if ( engine->project.interpreter()->functions(this).findIndex("on_tabrowselected")!=-1) { - engine->project.interpreter()->call("on_tabrowselected", QVariantList(lst), this); - } +// Q3ValueList lst; +// lst << sender()->name(); +// lst << QString("%1").arg(uid); +// if ( engine->project.interpreter()->functions(this).findIndex("on_tabrowselected")!=-1) { +// engine->project.interpreter()->call("on_tabrowselected", QVariantList(lst), this); +// } + if ( engine->code->globalObject().property("on_tabrowselected").isValid() ){ + QScriptValueList list; + list << sender()->name(); + list << QString("%1").arg(uid); + engine->code->globalObject().property("on_tabrowselected") + .call(QScriptValue(),list); + } } int diff --git a/src/plugins/engine.cpp b/src/plugins/engine.cpp index 3690b96..220154e 100644 --- a/src/plugins/engine.cpp +++ b/src/plugins/engine.cpp @@ -27,21 +27,29 @@ ** not clear to you. ** **********************************************************************/ -#include -#include +//#include +//#include + #include #include #include #include #include #include -#include -#include +//#include +//#include + +#include +#include +#include + #include //--#include #include -#include -#include +//#include +//#include + + #include //Added by qt3to4: #include @@ -55,6 +63,14 @@ #include "ametaobject.h" +static QScriptValue +createObject(QScriptContext *context, QScriptEngine *engine) { + QObject *parent = context->argument(0).toQObject(); + QObject *object = new QObject(parent); + return engine->newQObject(object, QScriptEngine::ScriptOwnership); +} + + /*! * \~english * Constructor @@ -79,43 +95,77 @@ aObjectsFactory::aObjectsFactory( aEngine *e ) if ( ! db ) return; - registerClass("MetaObject",&AMetaObject::staticMetaObject); - registerClass("MetaGroup",&AMetaGroup::staticMetaObject); - registerClass("Documents",&AMetaDocuments::staticMetaObject); - registerClass("Catalogues",&AMetaCatalogues::staticMetaObject); - registerClass("MetaInfo",&AMetaInfo::staticMetaObject); - registerClass("MetaGlobal",&AMetaGlobal::staticMetaObject); - - - registerClass("PopupMenu",&Q3PopupMenu::staticMetaObject); -// registerClass("PopupMenu","QApopupmenu"); - registerClass("Document",&aDocument::staticMetaObject); - registerClass("Catalogue",&aCatalogue::staticMetaObject); - registerClass("CatalogEditor",&wCatalogEditor::staticMetaObject); - registerClass("Report",&aReport::staticMetaObject); - registerClass("ARegister",&aARegister::staticMetaObject); - registerClass("IRegister",&aIRegister::staticMetaObject); - registerClass("ATime",&aTime::staticMetaObject); - registerClass("DataField",&aDataField::staticMetaObject); -// registerClass("reg","QAreg"); - registerClass("Journal",&aDocJournal::staticMetaObject); - registerClass("ComboBox",&AComboBox::staticMetaObject); -//registerClass("djournalview","QAjournview"); -// registerClass("djournalview","QAdocjournal"); -// registerClass("form","AForms"); -// registerClass("report","QAreport"); -// registerClass("table","QAnanasTable"); + QScriptValue ctor = engine->code->newFunction( &createObject); + + engine->code->globalObject().setProperty("QObject", + engine->code->newQMetaObject(&QObject::staticMetaObject, ctor)); + engine->code->globalObject().setProperty("MetaObject", + engine->code->newQMetaObject(&AMetaObject::staticMetaObject, ctor)); + engine->code->globalObject().setProperty("MetaGroup", + engine->code->newQMetaObject(&AMetaGroup::staticMetaObject, ctor)); + engine->code->globalObject().setProperty("Documents", + engine->code->newQMetaObject(&AMetaDocuments::staticMetaObject, ctor)); + engine->code->globalObject().setProperty("Catalogues", + engine->code->newQMetaObject(&AMetaCatalogues::staticMetaObject, ctor)); + engine->code->globalObject().setProperty("MetaInfo", + engine->code->newQMetaObject(&AMetaInfo::staticMetaObject, ctor)); + engine->code->globalObject().setProperty("MetaGlobal", + engine->code->newQMetaObject(&AMetaGlobal::staticMetaObject, ctor)); + engine->code->globalObject().setProperty("PopupMenu", + engine->code->newQMetaObject(&Q3PopupMenu::staticMetaObject, ctor)); + engine->code->globalObject().setProperty("Document", + engine->code->newQMetaObject(&aDocument::staticMetaObject, ctor)); + engine->code->globalObject().setProperty("Catalogue", + engine->code->newQMetaObject(&aCatalogue::staticMetaObject, ctor)); + engine->code->globalObject().setProperty("CatalogEditor", + engine->code->newQMetaObject(&wCatalogEditor::staticMetaObject, ctor)); + engine->code->globalObject().setProperty("Report", + engine->code->newQMetaObject(&aReport::staticMetaObject, ctor)); + engine->code->globalObject().setProperty("ARegister", + engine->code->newQMetaObject(&aARegister::staticMetaObject, ctor)); + engine->code->globalObject().setProperty("IRegister", + engine->code->newQMetaObject(&aIRegister::staticMetaObject, ctor)); + engine->code->globalObject().setProperty("Time", + engine->code->newQMetaObject(&aTime::staticMetaObject, ctor)); + engine->code->globalObject().setProperty("DataField", + engine->code->newQMetaObject(&aDataField::staticMetaObject, ctor)); + engine->code->globalObject().setProperty("DocJournal", + engine->code->newQMetaObject(&aDocJournal::staticMetaObject, ctor)); + engine->code->globalObject().setProperty("ComboBox", + engine->code->newQMetaObject(&AComboBox::staticMetaObject, ctor)); + + +// registerClass("MetaObject",&AMetaObject::staticMetaObject); +// registerClass("MetaGroup",&AMetaGroup::staticMetaObject); +// registerClass("Documents",&AMetaDocuments::staticMetaObject); +// registerClass("Catalogues",&AMetaCatalogues::staticMetaObject); +// registerClass("MetaInfo",&AMetaInfo::staticMetaObject); +// registerClass("MetaGlobal",&AMetaGlobal::staticMetaObject); +// +// +// registerClass("PopupMenu",&Q3PopupMenu::staticMetaObject); +// registerClass("Document",&aDocument::staticMetaObject); +// registerClass("Catalogue",&aCatalogue::staticMetaObject); +// registerClass("CatalogEditor",&wCatalogEditor::staticMetaObject); +// registerClass("Report",&aReport::staticMetaObject); +// registerClass("ARegister",&aARegister::staticMetaObject); +// registerClass("IRegister",&aIRegister::staticMetaObject); +// registerClass("ATime",&aTime::staticMetaObject); +// registerClass("DataField",&aDataField::staticMetaObject); +// registerClass("Journal",&aDocJournal::staticMetaObject); +// registerClass("ComboBox",&AComboBox::staticMetaObject); //Register extensions classes QStringList extlist = AExtensionFactory::keys(); for ( int i=0; icode->globalObject().setProperty(extlist[i], + engine->code->newQMetaObject(AExtensionFactory::metaObject( extlist[i] ), ctor)); + } } - /*! * \~english * Creates script object. Mapping Script name to real name. @@ -270,24 +320,24 @@ aEngine::init( const QString &rcfile ) debugger->attachTo(code); //окно дебагера появится при ошибке выполнении скрипта //code->addObjectFactory( new QSInputDialogFactory ); - code->addObjectFactory( new aObjectsFactory( this ) ); + //code->addObjectFactory( new aObjectsFactory( this ) ); //code->addObjectFactory( new QSUtilFactory ); //project.addObject( this ); // Объект sys часто используется для вывода сообщений в окно сообщений - QScriptValue ananasEngineObject = code.newQObject(this); - code.globalObject().setProperty("sys", ananasEngineObject); + QScriptValue ananasEngineObject = code->newQObject(this); + code->globalObject().setProperty("sys", ananasEngineObject); //project.addObject( md ); // Похоже не используется - QScriptValue ananasMetadataObject = code.newQObject(md*); - code.globalObject().setProperty("Metadata", ananasMetadataObject); + QScriptValue ananasMetadataObject = code->newQObject(md); + code->globalObject().setProperty("Metadata", ananasMetadataObject); // project.addObject( AMetaData::metadata() ); - QScriptValue ananasMetadataData = code.newQObject(md*); - code.globalObject().setProperty("MetaData", ananasMetadataData); + QScriptValue ananasMetadataData = code->newQObject(md); + code->globalObject().setProperty("MetaData", ananasMetadataData); mGlobal = md->sText( md->find( md->find( mdc_metadata ), md_globals, 0 ), md_sourcecode ); if ( ! mGlobal.isEmpty() ) { code->evaluate(sysf+sourcePreprocessor(mGlobal)); @@ -326,9 +376,13 @@ aEngine::done() int aEngine::on_systemstart(){ - if (project.interpreter()->functions().findIndex("on_systemstart")!=-1) { - project.interpreter()->call("on_systemstart",QVariantList()); - } +// if (project.interpreter()->functions().findIndex("on_systemstart")!=-1) { +// project.interpreter()->call("on_systemstart",QVariantList()); +// } + if ( code->globalObject().property("on_systemstart").isValid() ){ + code->globalObject().property("on_systemstart").call(); + } + return 0; } @@ -336,12 +390,21 @@ aEngine::on_systemstart(){ void aEngine::on_event( const QString &data ) { - Q3ValueList lst; - lst << sender()->name(); - lst << data; - if (project.interpreter()->functions().findIndex("on_event")!=-1) { - project.interpreter()->call("on_event", QVariantList(lst)); - } +// Q3ValueList lst; +// lst << sender()->name(); +// lst << data; +// if (project.interpreter()->functions().findIndex("on_event")!=-1) { +// project.interpreter()->call("on_event", QVariantList(lst)); +// } + if ( code->globalObject().property("on_event").isValid() ){ + QScriptValueList list; + list.append(QScriptValue(sender()->name())); +// list.append( engine->code->newVariant(val)); + list.append(QScriptValue(data)); + code->globalObject().property("on_event") + .call(QScriptValue(),list); + } + emit event( sender()->name(), data ); } @@ -359,9 +422,13 @@ aEngine::on_event( const QString &data ) */ int aEngine::on_systemstop(){ - if (project.interpreter()->functions().findIndex("on_systemstop")!=-1) { - project.interpreter()->call("on_systemstop",QVariantList()); - } +// if (project.interpreter()->functions().findIndex("on_systemstop")!=-1) { +// project.interpreter()->call("on_systemstop",QVariantList()); +// } + if ( code->globalObject().property("on_systemstop").isValid() ){ + code->globalObject().property("on_systemstop").call(); + } + return 0; } @@ -590,8 +657,10 @@ void aEngine::execAction( aCfgItem &act, QObject *context ) case 1: aModule = md->sText( act, md_sourcecode ); if ( !aModule.isEmpty() ) { - code->evaluate( sourcePreprocessor(aModule), context, md->attr( act, mda_name ) ); - } +// code->evaluate( sourcePreprocessor(aModule), +// context, md->attr( act, mda_name ) ); + code->evaluate( sourcePreprocessor(aModule)); + } break; case 2: break; @@ -788,7 +857,17 @@ aEngine::openEmbedCatalogueEditor(int oid, QWidget* parent,const bool toSelect) void aEngine::error ( const QString & message, QObject * context, const QString & scriptName, int lineNumber ) { - Message( 2, tr("Line:%1 Message:%2 Stack:(%3)").arg(lineNumber).arg(message).arg(code->stackTraceString()) ); + if (code->uncaughtException().isValid()) { + Message( 2, tr("Line:%1 Message:%2 Stack:(%3)") + .arg(lineNumber) + .arg(message) + .arg(code->uncaughtException().toString()) ); + } else { + Message( 2, tr("Line:%1 Message:%2") + .arg(lineNumber) + .arg(message) + ); + } } diff --git a/src/plugins/engine.h b/src/plugins/engine.h index 155c73f..0208e99 100644 --- a/src/plugins/engine.h +++ b/src/plugins/engine.h @@ -39,6 +39,7 @@ //#include #include #include +#include //Added by qt3to4: #include @@ -138,7 +139,7 @@ public: * \~ */ QScriptEngine* code; - QScriptEngineDebugger debugger; + QScriptEngineDebugger* debugger; /*! * \~english * link to script project. diff --git a/src/src.pro b/src/src.pro index e32d287..0238814 100644 --- a/src/src.pro +++ b/src/src.pro @@ -2,6 +2,7 @@ TEMPLATE = subdirs SUBDIRS += lib plugins SUBDIRS += designer ananas admin SUBDIRS += extensions +SUBDIRS += editor #TRANSLATIONS = \ # ../translations/ananas-en.ts \ -- 1.7.1