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