##// END OF EJS Templates
- added quitools...
florianlink -
r12:e79e720ed706
parent child
Show More
@@ -1,86 +1,84
1 1 /*
2 2 *
3 3 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
4 4 *
5 5 * This library is free software; you can redistribute it and/or
6 6 * modify it under the terms of the GNU Lesser General Public
7 7 * License as published by the Free Software Foundation; either
8 8 * version 2.1 of the License, or (at your option) any later version.
9 9 *
10 10 * This library is distributed in the hope that it will be useful,
11 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 13 * Lesser General Public License for more details.
14 14 *
15 15 * Further, this software is distributed without any warranty that it is
16 16 * free of the rightful claim of any third person regarding infringement
17 17 * or the like. Any license provided herein, whether implied or
18 18 * otherwise, applies only to this software file. Patent licenses, if
19 19 * any, provided herein do not apply to combinations of this program with
20 20 * other software, or any other product whatsoever.
21 21 *
22 22 * You should have received a copy of the GNU Lesser General Public
23 23 * License along with this library; if not, write to the Free Software
24 24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 25 *
26 26 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
27 27 * 28359 Bremen, Germany or:
28 28 *
29 29 * http://www.mevis.de
30 30 *
31 31 */
32 32
33 33 //----------------------------------------------------------------------------------
34 34 /*!
35 35 // \file PyGuiExample.cpp
36 36 // \author Florian Link
37 37 // \author Last changed by $Author: florian $
38 38 // \date 2007-04
39 39 */
40 40 //----------------------------------------------------------------------------------
41 41
42 42 #include "PythonQt.h"
43 43 #include "gui/PythonQtScriptingConsole.h"
44 44 #include "CustomObjects.h"
45 45
46 46 #include <QApplication>
47 47
48 48 int main( int argc, char **argv )
49 49 {
50 50 QApplication qapp(argc, argv);
51 51
52 52 PythonQt::init(PythonQt::IgnoreSiteModule | PythonQt::RedirectStdOut);
53 53
54 54 PythonQtObjectPtr mainContext = PythonQt::self()->getMainModule();
55 55 PythonQtScriptingConsole console(NULL, mainContext);
56 56
57 57 // -----------------------------------------------------------------
58 58 // Alternative 1: make CustomObject known and use decorators for wrapping:
59 59 // -----------------------------------------------------------------
60 60
61 // register the new object as a known classname
62 PythonQt::self()->registerCPPClassNames(QStringList() << "CustomObject");
63 // add a decorator which can access CustomObject instances
64 PythonQt::self()->addDecorators(new CustomObjectWrapper());
61 // register the new object as a known classname and add it's wrapper object
62 PythonQt::self()->registerCPPClass("CustomObject", "","", PythonQtCreateObject<CustomObjectWrapper>);
65 63
66 64 // -----------------------------------------------------------------
67 65 // Alternative 2: make CustomObject2 known and use a wrapper factory for wrapping:
68 66 // -----------------------------------------------------------------
69 67
70 68 // add a factory that can handle pointers to CustomObject2
71 69 PythonQt::self()->addWrapperFactory(new CustomFactory());
72 70
73 71 // the following is optional and only needed if you want a constructor:
74 72 // register the new object as a known classname
75 PythonQt::self()->registerCPPClassNames(QStringList() << "CustomObject2");
73 PythonQt::self()->registerCPPClass("CustomObject2");
76 74 // add a constructor for CustomObject2
77 75 PythonQt::self()->addClassDecorators(new CustomObject2Constructor());
78 76
79 77 mainContext.evalFile(":example.py");
80 78
81 79 console.appendCommandPrompt();
82 80 console.show();
83 81
84 82 return qapp.exec();
85 83 }
86 84
@@ -1,69 +1,69
1 1 /*
2 2 *
3 3 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
4 4 *
5 5 * This library is free software; you can redistribute it and/or
6 6 * modify it under the terms of the GNU Lesser General Public
7 7 * License as published by the Free Software Foundation; either
8 8 * version 2.1 of the License, or (at your option) any later version.
9 9 *
10 10 * This library is distributed in the hope that it will be useful,
11 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 13 * Lesser General Public License for more details.
14 14 *
15 15 * Further, this software is distributed without any warranty that it is
16 16 * free of the rightful claim of any third person regarding infringement
17 17 * or the like. Any license provided herein, whether implied or
18 18 * otherwise, applies only to this software file. Patent licenses, if
19 19 * any, provided herein do not apply to combinations of this program with
20 20 * other software, or any other product whatsoever.
21 21 *
22 22 * You should have received a copy of the GNU Lesser General Public
23 23 * License along with this library; if not, write to the Free Software
24 24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 25 *
26 26 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
27 27 * 28359 Bremen, Germany or:
28 28 *
29 29 * http://www.mevis.de
30 30 *
31 31 */
32 32
33 33 //----------------------------------------------------------------------------------
34 34 /*!
35 35 // \file PyGuiExample.cpp
36 36 // \author Florian Link
37 37 // \author Last changed by $Author: florian $
38 38 // \date 2007-04
39 39 */
40 40 //----------------------------------------------------------------------------------
41 41
42 42 #include "PythonQt.h"
43 43 #include "gui/PythonQtScriptingConsole.h"
44 44 #include "CustomObject.h"
45 45
46 46 #include <QApplication>
47 47
48 48 int main( int argc, char **argv )
49 49 {
50 50 QApplication qapp(argc, argv);
51 51
52 52 PythonQt::init(PythonQt::IgnoreSiteModule | PythonQt::RedirectStdOut);
53 53
54 54 PythonQtObjectPtr mainContext = PythonQt::self()->getMainModule();
55 55 PythonQtScriptingConsole console(NULL, mainContext);
56 56
57 57 // register the type with QMetaType
58 58 qRegisterMetaType<CustomObject>("CustomObject");
59 59 // add a wrapper object for the new variant type
60 PythonQt::self()->registerCPPWrapper("CustomObject","","", PythonQtCreateObject<CustomObjectWrapper>);
60 PythonQt::self()->registerCPPClass("CustomObject","","", PythonQtCreateObject<CustomObjectWrapper>);
61 61
62 62 mainContext.evalFile(":example.py");
63 63
64 64 console.appendCommandPrompt();
65 65 console.show();
66 66
67 67 return qapp.exec();
68 68 }
69 69
@@ -1,68 +1,68
1 1 /*
2 2 *
3 3 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
4 4 *
5 5 * This library is free software; you can redistribute it and/or
6 6 * modify it under the terms of the GNU Lesser General Public
7 7 * License as published by the Free Software Foundation; either
8 8 * version 2.1 of the License, or (at your option) any later version.
9 9 *
10 10 * This library is distributed in the hope that it will be useful,
11 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 13 * Lesser General Public License for more details.
14 14 *
15 15 * Further, this software is distributed without any warranty that it is
16 16 * free of the rightful claim of any third person regarding infringement
17 17 * or the like. Any license provided herein, whether implied or
18 18 * otherwise, applies only to this software file. Patent licenses, if
19 19 * any, provided herein do not apply to combinations of this program with
20 20 * other software, or any other product whatsoever.
21 21 *
22 22 * You should have received a copy of the GNU Lesser General Public
23 23 * License along with this library; if not, write to the Free Software
24 24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 25 *
26 26 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
27 27 * 28359 Bremen, Germany or:
28 28 *
29 29 * http://www.mevis.de
30 30 *
31 31 */
32 32
33 33 //----------------------------------------------------------------------------------
34 34 /*!
35 35 // \file PyGuiExample.cpp
36 36 // \author Florian Link
37 37 // \author Last changed by $Author: florian $
38 38 // \date 2007-04
39 39 */
40 40 //----------------------------------------------------------------------------------
41 41
42 42 #include "PythonQt.h"
43 43 #include "gui/PythonQtScriptingConsole.h"
44 44 #include "PyExampleDecorators.h"
45 45
46 46 #include <QApplication>
47 47
48 48 int main( int argc, char **argv )
49 49 {
50 50 QApplication qapp(argc, argv);
51 51
52 52 PythonQt::init(PythonQt::IgnoreSiteModule | PythonQt::RedirectStdOut);
53 53
54 54 PythonQtObjectPtr mainContext = PythonQt::self()->getMainModule();
55 55 PythonQtScriptingConsole console(NULL, mainContext);
56 56
57 57 PythonQt::self()->addDecorators(new PyExampleDecorators());
58 58 PythonQt::self()->registerClass(&QPushButton::staticMetaObject);
59 PythonQt::self()->registerCPPClassNames(QStringList() << "YourCPPObject");
59 PythonQt::self()->registerCPPClass("YourCPPObject");
60 60
61 61 mainContext.evalFile(":example.py");
62 62
63 63 console.appendCommandPrompt();
64 64 console.show();
65 65
66 66 return qapp.exec();
67 67 }
68 68
@@ -1,62 +1,64
1 1 /*
2 2 *
3 3 * Copyright (C) 2006 MeVis Research GmbH All Rights Reserved.
4 4 *
5 5 * This library is free software; you can redistribute it and/or
6 6 * modify it under the terms of the GNU Lesser General Public
7 7 * License as published by the Free Software Foundation; either
8 8 * version 2.1 of the License, or (at your option) any later version.
9 9 *
10 10 * This library is distributed in the hope that it will be useful,
11 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 13 * Lesser General Public License for more details.
14 14 *
15 15 * Further, this software is distributed without any warranty that it is
16 16 * free of the rightful claim of any third person regarding infringement
17 17 * or the like. Any license provided herein, whether implied or
18 18 * otherwise, applies only to this software file. Patent licenses, if
19 19 * any, provided herein do not apply to combinations of this program with
20 20 * other software, or any other product whatsoever.
21 21 *
22 22 * You should have received a copy of the GNU Lesser General Public
23 23 * License along with this library; if not, write to the Free Software
24 24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 25 *
26 26 * Contact information: MeVis Research GmbH, Universitaetsallee 29,
27 27 * 28359 Bremen, Germany or:
28 28 *
29 29 * http://www.mevis.de
30 30 *
31 31 */
32 32
33 33 #include "PythonQt_QtAll.h"
34 34
35 35 void PythonQt_init_QtGui();
36 36 void PythonQt_init_QtSvg();
37 37 void PythonQt_init_QtSql();
38 38 void PythonQt_init_QtNetwork();
39 39 void PythonQt_init_QtCore();
40 40 void PythonQt_init_QtWebKit();
41 41 void PythonQt_init_QtOpenGL();
42 42 void PythonQt_init_QtXml();
43 43 void PythonQt_init_QtXmlPatterns();
44 void PythonQt_init_QtUiTools();
44 45 //void PythonQt_init_QtPhonon();
45 46
46 47 namespace PythonQt_QtAll
47 48 {
48 49 PYTHONQT_QTALL_EXPORT void init() {
49 50 PythonQt_init_QtCore();
50 51 PythonQt_init_QtNetwork();
51 52 PythonQt_init_QtGui();
52 53 PythonQt_init_QtXml();
53 54 PythonQt_init_QtXmlPatterns();
54 55 PythonQt_init_QtSvg();
55 56 PythonQt_init_QtSql();
56 57 PythonQt_init_QtWebKit();
57 58 PythonQt_init_QtOpenGL();
59 PythonQt_init_QtUiTools();
58 60 // PythonQt_init_QtPhonon();
59 61 };
60 62 };
61 63
62 64
@@ -1,34 +1,35
1 1
2 2 TARGET = PythonQt_QtAll
3 3 TEMPLATE = lib
4 4
5 5 DESTDIR = ../../lib
6 DLLDESTDIR = ../../lib
7 6
8 7 include ( ../../build/common.prf )
9 8 include ( ../../build/PythonQt.prf )
10 9
11 10 CONFIG += dll qt
12 11
13 12 DEFINES += PYTHONQT_QTALL_EXPORTS
14 13
15 14 HEADERS += \
16 15 PythonQt_QtAll.h
17 16
18 17 SOURCES += \
19 18 PythonQt_QtAll.cpp
20 19
20 CONFIG += uitools
21 21 QT += webkit gui svg sql network xml xmlpatterns opengl
22 22 #QT += phonon
23 23
24 24 include (../../generated_cpp/com_trolltech_qt_core/com_trolltech_qt_core.pri)
25 25 include (../../generated_cpp/com_trolltech_qt_gui/com_trolltech_qt_gui.pri)
26 26 include (../../generated_cpp/com_trolltech_qt_svg/com_trolltech_qt_svg.pri)
27 27 include (../../generated_cpp/com_trolltech_qt_sql/com_trolltech_qt_sql.pri)
28 28 include (../../generated_cpp/com_trolltech_qt_network/com_trolltech_qt_network.pri)
29 29 include (../../generated_cpp/com_trolltech_qt_opengl/com_trolltech_qt_opengl.pri)
30 30 include (../../generated_cpp/com_trolltech_qt_webkit/com_trolltech_qt_webkit.pri)
31 31 include (../../generated_cpp/com_trolltech_qt_xml/com_trolltech_qt_xml.pri)
32 32 include (../../generated_cpp/com_trolltech_qt_xmlpatterns/com_trolltech_qt_xmlpatterns.pri)
33 include (../../generated_cpp/com_trolltech_qt_uitools/com_trolltech_qt_uitools.pri)
33 34
34 35 #include (../../generated_cpp/com_trolltech_qt_phonon/com_trolltech_qt_phonon.pri)
@@ -1,111 +1,113
1 1 /****************************************************************************
2 2 **
3 3 ** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
4 4 **
5 5 ** This file is part of the Qt Script Generator project on Trolltech Labs.
6 6 **
7 7 ** This file may be used under the terms of the GNU General Public
8 8 ** License version 2.0 as published by the Free Software Foundation
9 9 ** and appearing in the file LICENSE.GPL included in the packaging of
10 10 ** this file. Please review the following information to ensure GNU
11 11 ** General Public Licensing requirements will be met:
12 12 ** http://www.trolltech.com/products/qt/opensource.html
13 13 **
14 14 ** If you are unsure which license is appropriate for your use, please
15 15 ** review the following information:
16 16 ** http://www.trolltech.com/products/qt/licensing.html or contact the
17 17 ** sales department at sales@trolltech.com.
18 18 **
19 19 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
20 20 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 21 **
22 22 ****************************************************************************/
23 23
24 24 #include "setupgenerator.h"
25 25 #include "classgenerator.h"
26 26 #include "reporthandler.h"
27 27 #include "fileout.h"
28 28
29 29 //#define Q_SCRIPT_LAZY_GENERATOR
30 30
31 void SetupGenerator::addClass(const AbstractMetaClass *cls)
31 void SetupGenerator::addClass(const AbstractMetaClass *cls)
32 32 {
33 33 packHash[cls->package()].append(cls);
34 34 }
35 35
36 36 void writeQtScriptQtBindingsLicense(QTextStream &stream);
37 37
38 38 void maybeDeclareMetaType(QTextStream &stream, const QString &typeName,
39 39 QSet<QString> &registeredTypeNames);
40 40 bool hasDefaultConstructor(const AbstractMetaClass *meta_class);
41 41
42 42 void SetupGenerator::generate()
43 43 {
44 44 QHashIterator<QString, QList<const AbstractMetaClass*> > pack(packHash);
45 45 while (pack.hasNext()) {
46 46 pack.next();
47 47 QList<const AbstractMetaClass*> list = pack.value();
48 48 if (list.isEmpty())
49 49 continue;
50 50
51 51 QString packKey = pack.key();
52 52 QString packName = pack.key();
53 53 QStringList components = packName.split(".");
54 54 if ((components.size() > 2) && (components.at(0) == "com")
55 55 && (components.at(1) == "trolltech")) {
56 56 // kill com.trolltech in key
57 57 components.removeAt(0);
58 58 components.removeAt(0);
59 59 }
60 60 packName.replace(".", "_");
61 61 packKey.replace(".", "_");
62
62
63 63 QString shortPackName;
64 64 foreach (QString comp, components) {
65 65 comp[0] = comp[0].toUpper();
66 66 shortPackName += comp;
67 67 }
68 68 // add missing camel case (workaround..)
69 69 if (shortPackName == "QtWebkit") {
70 70 shortPackName = "QtWebKit";
71 71 } else if (shortPackName == "QtXmlpatterns") {
72 72 shortPackName = "QtXmlPatterns";
73 73 } else if (shortPackName == "QtOpengl") {
74 74 shortPackName = "QtOpenGL";
75 }
76
77
75 } else if (shortPackName == "QtUitools") {
76 shortPackName = "QtUiTools";
77 }
78
79
78 80 {
79 81 FileOut initFile(m_out_dir + "/generated_cpp/" + packName + "/" + packKey + "_init.cpp");
80 82 QTextStream &s = initFile.stream;
81 83
82 84 if (FileOut::license)
83 85 writeQtScriptQtBindingsLicense(s);
84
86
85 87 s << "#include <PythonQt.h>" << endl;
86 88
87 89 foreach (const AbstractMetaClass *cls, list) {
88 90 s << "#include \"PythonQtWrapper_" << cls->name() << ".h\"" << endl;
89 91 }
90 92 s << endl;
91
93
92 94 // declare individual class creation functions
93 95 s << "void PythonQt_init_" << shortPackName << "() {" << endl;
94 QStringList cppClassNames;
96 QStringList cppClassNames;
95 97 foreach (const AbstractMetaClass *cls, list) {
96 98 if (ClassGenerator::isBuiltIn(cls->name())) { continue; }
97 99
98 100 if (cls->isQObject()) {
99 101 s << "PythonQt::self()->registerClass(&" << cls->qualifiedCppName() << "::staticMetaObject, \"" << shortPackName <<"\", PythonQtCreateObject<PythonQtWrapper_" << cls->name() << ">);" << endl;
100 102 } else {
101 103 QString baseName = cls->baseClass()?cls->baseClass()->qualifiedCppName():"";
102 104 s << "PythonQt::self()->registerCPPClass(\""<< cls->qualifiedCppName() << "\", \"" << baseName << "\", \"" << shortPackName <<"\", PythonQtCreateObject<PythonQtWrapper_" << cls->name() << ">);" << endl;
103 105 }
104 106 }
105 107 s << endl;
106
108
107 109 s << "}";
108 110 s << endl;
109 111 }
110 112 }
111 113 }
General Comments 0
You need to be logged in to leave comments. Login now