From e79e720ed70675b1833f28817c92bc65e8a6348d 2009-04-09 10:04:19 From: florianlink Date: 2009-04-09 10:04:19 Subject: [PATCH] - added quitools - fixed examples to work with new API git-svn-id: svn://svn.code.sf.net/p/pythonqt/code/trunk@48 ea8d5007-eb21-0410-b261-ccb3ea6e24a9 --- diff --git a/examples/PyCPPWrapperExample/main.cpp b/examples/PyCPPWrapperExample/main.cpp index 57dbc98..dea8ee3 100644 --- a/examples/PyCPPWrapperExample/main.cpp +++ b/examples/PyCPPWrapperExample/main.cpp @@ -58,10 +58,8 @@ int main( int argc, char **argv ) // Alternative 1: make CustomObject known and use decorators for wrapping: // ----------------------------------------------------------------- - // register the new object as a known classname - PythonQt::self()->registerCPPClassNames(QStringList() << "CustomObject"); - // add a decorator which can access CustomObject instances - PythonQt::self()->addDecorators(new CustomObjectWrapper()); + // register the new object as a known classname and add it's wrapper object + PythonQt::self()->registerCPPClass("CustomObject", "","", PythonQtCreateObject); // ----------------------------------------------------------------- // Alternative 2: make CustomObject2 known and use a wrapper factory for wrapping: @@ -72,7 +70,7 @@ int main( int argc, char **argv ) // the following is optional and only needed if you want a constructor: // register the new object as a known classname - PythonQt::self()->registerCPPClassNames(QStringList() << "CustomObject2"); + PythonQt::self()->registerCPPClass("CustomObject2"); // add a constructor for CustomObject2 PythonQt::self()->addClassDecorators(new CustomObject2Constructor()); diff --git a/examples/PyCustomMetaTypeExample/main.cpp b/examples/PyCustomMetaTypeExample/main.cpp index 61aa810..ffe8295 100644 --- a/examples/PyCustomMetaTypeExample/main.cpp +++ b/examples/PyCustomMetaTypeExample/main.cpp @@ -57,7 +57,7 @@ int main( int argc, char **argv ) // register the type with QMetaType qRegisterMetaType("CustomObject"); // add a wrapper object for the new variant type - PythonQt::self()->registerCPPWrapper("CustomObject","","", PythonQtCreateObject); + PythonQt::self()->registerCPPClass("CustomObject","","", PythonQtCreateObject); mainContext.evalFile(":example.py"); diff --git a/examples/PyDecoratorsExample/main.cpp b/examples/PyDecoratorsExample/main.cpp index aea563d..7fbcdfd 100644 --- a/examples/PyDecoratorsExample/main.cpp +++ b/examples/PyDecoratorsExample/main.cpp @@ -56,7 +56,7 @@ int main( int argc, char **argv ) PythonQt::self()->addDecorators(new PyExampleDecorators()); PythonQt::self()->registerClass(&QPushButton::staticMetaObject); - PythonQt::self()->registerCPPClassNames(QStringList() << "YourCPPObject"); + PythonQt::self()->registerCPPClass("YourCPPObject"); mainContext.evalFile(":example.py"); diff --git a/extensions/PythonQt_QtAll/PythonQt_QtAll.cpp b/extensions/PythonQt_QtAll/PythonQt_QtAll.cpp index 19ebdf9..ef26b6e 100644 --- a/extensions/PythonQt_QtAll/PythonQt_QtAll.cpp +++ b/extensions/PythonQt_QtAll/PythonQt_QtAll.cpp @@ -41,6 +41,7 @@ void PythonQt_init_QtWebKit(); void PythonQt_init_QtOpenGL(); void PythonQt_init_QtXml(); void PythonQt_init_QtXmlPatterns(); +void PythonQt_init_QtUiTools(); //void PythonQt_init_QtPhonon(); namespace PythonQt_QtAll @@ -55,6 +56,7 @@ namespace PythonQt_QtAll PythonQt_init_QtSql(); PythonQt_init_QtWebKit(); PythonQt_init_QtOpenGL(); + PythonQt_init_QtUiTools(); // PythonQt_init_QtPhonon(); }; }; diff --git a/extensions/PythonQt_QtAll/PythonQt_QtAll.pro b/extensions/PythonQt_QtAll/PythonQt_QtAll.pro index fb60beb..afc28b6 100644 --- a/extensions/PythonQt_QtAll/PythonQt_QtAll.pro +++ b/extensions/PythonQt_QtAll/PythonQt_QtAll.pro @@ -3,7 +3,6 @@ TARGET = PythonQt_QtAll TEMPLATE = lib DESTDIR = ../../lib -DLLDESTDIR = ../../lib include ( ../../build/common.prf ) include ( ../../build/PythonQt.prf ) @@ -18,6 +17,7 @@ HEADERS += \ SOURCES += \ PythonQt_QtAll.cpp +CONFIG += uitools QT += webkit gui svg sql network xml xmlpatterns opengl #QT += phonon @@ -30,5 +30,6 @@ include (../../generated_cpp/com_trolltech_qt_opengl/com_trolltech_qt_opengl.pri include (../../generated_cpp/com_trolltech_qt_webkit/com_trolltech_qt_webkit.pri) include (../../generated_cpp/com_trolltech_qt_xml/com_trolltech_qt_xml.pri) include (../../generated_cpp/com_trolltech_qt_xmlpatterns/com_trolltech_qt_xmlpatterns.pri) +include (../../generated_cpp/com_trolltech_qt_uitools/com_trolltech_qt_uitools.pri) #include (../../generated_cpp/com_trolltech_qt_phonon/com_trolltech_qt_phonon.pri) diff --git a/generator/setupgenerator.cpp b/generator/setupgenerator.cpp index 9ab41db..b99140a 100644 --- a/generator/setupgenerator.cpp +++ b/generator/setupgenerator.cpp @@ -28,7 +28,7 @@ //#define Q_SCRIPT_LAZY_GENERATOR -void SetupGenerator::addClass(const AbstractMetaClass *cls) +void SetupGenerator::addClass(const AbstractMetaClass *cls) { packHash[cls->package()].append(cls); } @@ -59,7 +59,7 @@ void SetupGenerator::generate() } packName.replace(".", "_"); packKey.replace(".", "_"); - + QString shortPackName; foreach (QString comp, components) { comp[0] = comp[0].toUpper(); @@ -72,26 +72,28 @@ void SetupGenerator::generate() shortPackName = "QtXmlPatterns"; } else if (shortPackName == "QtOpengl") { shortPackName = "QtOpenGL"; - } - - + } else if (shortPackName == "QtUitools") { + shortPackName = "QtUiTools"; + } + + { FileOut initFile(m_out_dir + "/generated_cpp/" + packName + "/" + packKey + "_init.cpp"); QTextStream &s = initFile.stream; if (FileOut::license) writeQtScriptQtBindingsLicense(s); - + s << "#include " << endl; foreach (const AbstractMetaClass *cls, list) { s << "#include \"PythonQtWrapper_" << cls->name() << ".h\"" << endl; } s << endl; - + // declare individual class creation functions s << "void PythonQt_init_" << shortPackName << "() {" << endl; - QStringList cppClassNames; + QStringList cppClassNames; foreach (const AbstractMetaClass *cls, list) { if (ClassGenerator::isBuiltIn(cls->name())) { continue; } @@ -103,7 +105,7 @@ void SetupGenerator::generate() } } s << endl; - + s << "}"; s << endl; }