diff options
Diffstat (limited to 'PySide')
-rw-r--r-- | PySide/CMakeLists.txt | 160 | ||||
-rw-r--r-- | PySide/QtCore/typesystem_core.xml | 230 | ||||
-rw-r--r-- | PySide/QtGui/glue/wid_conversions.h | 32 | ||||
-rw-r--r-- | PySide/QtGui/typesystem_gui_common.xml | 648 | ||||
-rw-r--r-- | PySide/QtGui/typesystem_gui_win.xml | 5 | ||||
-rw-r--r-- | PySide/QtUiTools/CMakeLists.txt | 5 | ||||
-rw-r--r-- | PySide/QtUiTools/glue/plugins.h | 47 | ||||
-rw-r--r-- | PySide/QtUiTools/glue/uitools_loadui.h | 25 | ||||
-rw-r--r-- | PySide/QtUiTools/typesystem_uitools.xml | 12 | ||||
-rw-r--r-- | PySide/phonon/typesystem_phonon.xml | 21 | ||||
-rw-r--r-- | PySide/typesystem_templates.xml | 53 |
11 files changed, 1010 insertions, 228 deletions
diff --git a/PySide/CMakeLists.txt b/PySide/CMakeLists.txt index 05191e37e..c4aaf64ad 100644 --- a/PySide/CMakeLists.txt +++ b/PySide/CMakeLists.txt @@ -2,175 +2,17 @@ project(pyside) install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/__init__.py" "${CMAKE_CURRENT_SOURCE_DIR}/private.py" DESTINATION "${SITE_PACKAGE}/${BINDING_NAME}${pyside_SUFFIX}") -macro(create_pyside_module module_name module_include_dir module_libraries module_deps module_typesystem_path module_sources typesystem_name) - string(TOLOWER ${module_name} _module) - string(REGEX REPLACE ^qt "" _module ${_module}) - if (NOT EXISTS ${typesystem_name}) - set(typesystem_path ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_${_module}.xml) - else() - set(typesystem_path ${typesystem_name}) - endif() - - add_custom_command(OUTPUT ${${module_sources}} - COMMAND ${GENERATORRUNNER_BINARY} ${GENERATOR_EXTRA_FLAGS} - ${CMAKE_BINARY_DIR}/PySide/global.h - --include-paths=${pyside_SOURCE_DIR}${PATH_SEP}${QT_INCLUDE_DIR} - --typesystem-paths=${pyside_SOURCE_DIR}${PATH_SEP}${${module_typesystem_path}} - --output-directory=${CMAKE_CURRENT_BINARY_DIR} - --license-file=${CMAKE_CURRENT_SOURCE_DIR}/../licensecomment.txt - ${typesystem_path} - --api-version=${SUPPORTED_QT_VERSION} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - COMMENT "Running generator for ${module_name}...") - - include_directories(${module_name} ${${module_include_dir}} ${pyside_SOURCE_DIR}) - add_library(${module_name} MODULE ${${module_sources}} ${${ARGN}}) - set_target_properties(${module_name} PROPERTIES PREFIX "" LIBRARY_OUTPUT_DIRECTORY ${pyside_BINARY_DIR}) - if(WIN32) - set_target_properties(${module_name} PROPERTIES SUFFIX ".pyd") - set(${module_name}_suffix ".pyd") - else() - set(${module_name}_suffix ".so") - endif() - target_link_libraries(${module_name} ${${module_libraries}}) - if(${module_deps}) - add_dependencies(${module_name} ${${module_deps}}) - endif() - - - # install - install(TARGETS ${module_name} LIBRARY DESTINATION ${SITE_PACKAGE}/PySide) - string(TOLOWER ${module_name} lower_module_name) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide/${module_name}/pyside_${lower_module_name}_python.h - DESTINATION include/PySide${pyside_SUFFIX}/${module_name}/) - file(GLOB typesystem_files ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_*.xml ${typesystem_path}) - install(FILES ${typesystem_files} DESTINATION share/PySide${pyside_SUFFIX}/typesystems) -endmacro() - -#macro(check_qt_class_with_namespace module namespace class global_sources [namespace]) -macro(check_qt_class module class global_sources) - if (${ARGC} GREATER 3) - set (namespace ${ARGV3}) - string(TOLOWER ${namespace} _namespace) - else () - set (namespace "") - endif () - if (${ARGC} GREATER 4) - set (include_file ${ARGV4}) - else () - set (include_file ${module}) - endif () - string(TOLOWER ${class} _class) - string(TOUPPER ${module} _module) - if (${namespace}) - set(_cppfile ${CMAKE_CURRENT_BINARY_DIR}/PySide/${module}/${_namespace}_${_class}_wrapper.cpp) - else () - set(_cppfile ${CMAKE_CURRENT_BINARY_DIR}/PySide/${module}/${_class}_wrapper.cpp) - endif () - if (DEFINED PYSIDE_${class}) - if (PYSIDE_${class}) - list(APPEND ${global_sources} ${_cppfile}) - endif() - else() - if (NOT ${namespace} STREQUAL "" ) - set (NAMESPACE_USE "using namespace ${namespace};") - else () - set (NAMESPACE_USE "") - endif () - set(SRC_FILE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/test${class}.cxx) - file(WRITE ${SRC_FILE} - "#include <${include_file}>\n" - "#include <typeinfo>\n" - "${NAMESPACE_USE}\n" - "int main() { typeid(${class}); }\n" - ) - try_compile(Q_WORKS ${CMAKE_BINARY_DIR} - ${SRC_FILE} - CMAKE_FLAGS - "-DLINK_LIBRARIES=${QT_${_module}_LIBRARY}" - "-DLINK_DIRECTORIES=${QT_LIBRARY_DIR}" - "-DINCLUDE_DIRECTORIES=${QT_INCLUDE_DIR};${QT_${_module}_INCLUDE_DIR}" - OUTPUT_VARIABLE OUTPUT) - file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeCheckQtClassTest.log ${OUTPUT}) - - set("PYSIDE_${class}" ${Q_WORKS} CACHE STRING "Has ${class} class been found?") - if(Q_WORKS) - message(STATUS "Checking for ${class} in ${module} -- found") - list(APPEND ${global_sources} ${_cppfile}) - else() - message(STATUS "Checking for ${class} in ${module} -- not found") - endif() - endif() -endmacro() +include(PySideModules) # Configure include based on platform configure_file("${CMAKE_CURRENT_SOURCE_DIR}/global.h.in" "${CMAKE_CURRENT_BINARY_DIR}/global.h" @ONLY) -# Only add subdirectory if the associated Qt module is found. -macro(HAS_QT_MODULE var name) - if (NOT DISABLE_${name} AND ${var}) - add_subdirectory(${name}) - else() - set("if_${name}" "<!--" PARENT_SCOPE) - set("end_${name}" "-->" PARENT_SCOPE) - endif() -endmacro() - execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/__init__.py" "${CMAKE_BINARY_DIR}/PySide/__init__.py") execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_SOURCE_DIR}/private.py" "${CMAKE_BINARY_DIR}/PySide/private.py") -# -# Try to find QtMultimedia -# TODO: Remove this hack when cmake support QtMultimedia module -if (NOT QT_QTMULTIMEDIA_FOUND AND ${QTVERSION} VERSION_GREATER 4.5.9) - find_path(QT_QTMULTIMEDIA_INCLUDE_DIR QtMultimedia - PATHS ${QT_HEADERS_DIR}/QtMultimedia - ${QT_LIBRARY_DIR}/QtMultimedia.framework/Headers - NO_DEFAULT_PATH) - find_library(QT_QTMULTIMEDIA_LIBRARY QtMultimedia PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - if (QT_QTMULTIMEDIA_INCLUDE_DIR AND QT_QTMULTIMEDIA_LIBRARY) - set(QT_QTMULTIMEDIA_FOUND ON) - else() - set(if_QtMultimedia "<!--" PARENT_SCOPE) - set(end_QtMultimedia "-->" PARENT_SCOPE) - endif() -endif () - -# Try to find QtMaemo5 - it has to be done before QtGui to enable some QtMaemo5 flags -# TODO: Remove this hack when cmake support QtMaemo5 module -if (NOT QT_QTMAEMO5_FOUND AND ${QTVERSION} VERSION_GREATER 4.5.9) - find_path(QT_QTMAEMO5_INCLUDE_DIR QtMaemo5 - PATHS ${QT_HEADERS_DIR}/QtMaemo5 - ${QT_LIBRARY_DIR}/QtMaemo5.framework/Headers - NO_DEFAULT_PATH) - find_library(QT_QTMAEMO5_LIBRARY QtMaemo5 PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - if (QT_QTMAEMO5_INCLUDE_DIR AND QT_QTMAEMO5_LIBRARY) - set(QT_QTMAEMO5_FOUND ON) - set(Q_WS_MAEMO_5 ON) - else() - set(if_Maemo5 "<!--" PARENT_SCOPE) - set(end_Maemo5 "-->" PARENT_SCOPE) - endif() -endif () - -# Try to find QtDeclarative -# TODO: Remove this hack when cmake support QtDeclarative module -if (NOT QT_QTDECLARATIVE_FOUND AND ${QTVERSION} VERSION_GREATER 4.6.0) - find_path(QT_QTDECLARATIVE_INCLUDE_DIR QtDeclarative - PATHS ${QT_HEADERS_DIR}/QtDeclarative - ${QT_LIBRARY_DIR}/QtDeclarative.framework/Headers - NO_DEFAULT_PATH) - find_library(QT_QTDECLARATIVE_LIBRARY QtDeclarative PATHS ${QT_LIBRARY_DIR} NO_DEFAULT_PATH) - if (QT_QTDECLARATIVE_INCLUDE_DIR AND QT_QTDECLARATIVE_LIBRARY) - set(QT_QTDECLARATIVE_FOUND ON) - else() - set(if_QtDeclarative "<!--" PARENT_SCOPE) - set(end_QtDeclarative "-->" PARENT_SCOPE) - endif() -endif () HAS_QT_MODULE(QT_QTCORE_FOUND QtCore) HAS_QT_MODULE(QT_QTGUI_FOUND QtGui) diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml index 9d36c3f8a..9b95f6d7b 100644 --- a/PySide/QtCore/typesystem_core.xml +++ b/PySide/QtCore/typesystem_core.xml @@ -671,6 +671,14 @@ </extra-includes> </object-type> <value-type name="QLine" hash-function="PySide::hash"> + <add-function signature="__reduce__" return-type="PyObject*"> + <inject-code class="target" position="beginning"> + <insert-template name="reduce_code"> + <replace from="%REDUCE_FORMAT" to="(iiii)" /> + <replace from="%REDUCE_ARGS" to="%CPPSELF.x1(), %CPPSELF.y1(), %CPPSELF.x2(), %CPPSELF.y2()" /> + </insert-template> + </inject-code> + </add-function> <inject-code class="native" position="beginning"> namespace PySide { template<> inline uint hash(const QLine& v) { @@ -681,6 +689,14 @@ </value-type> <value-type name="QLineF"> <enum-type name="IntersectType" /> + <add-function signature="__reduce__" return-type="PyObject*"> + <inject-code class="target" position="beginning"> + <insert-template name="reduce_code"> + <replace from="%REDUCE_FORMAT" to="(dddd)" /> + <replace from="%REDUCE_ARGS" to="%CPPSELF.x1(), %CPPSELF.y1(), %CPPSELF.x2(), %CPPSELF.y2()" /> + </insert-template> + </inject-code> + </add-function> <modify-function signature="intersect(QLineF, QPointF*)const"> <modify-argument index="2"> <remove-argument /> @@ -726,7 +742,14 @@ <include file-name="datetime.h" location="global"/> </extra-includes> <enum-type name="MonthNameType"/> - <modify-function signature="julianToGregorian(uint,int&,int&,int&)" remove="all"/> + <add-function signature="__reduce__" return-type="PyObject*"> + <inject-code class="target" position="beginning"> + <insert-template name="reduce_code"> + <replace from="%REDUCE_FORMAT" to="(iii)" /> + <replace from="%REDUCE_ARGS" to="%CPPSELF.year(), %CPPSELF.month(), %CPPSELF.day()" /> + </insert-template> + </inject-code> + </add-function> <modify-function signature="getDate(int*,int*,int*)" > <modify-argument index="1"> <remove-argument/> @@ -759,22 +782,56 @@ %PYARG_0 = Shiboken::makeTuple(week, yearNumber); </inject-code> </modify-function> + <modify-function signature="julianToGregorian(uint,int&,int&,int&)" remove="all"/> </value-type> - <value-type name="QDateTime" hash-function="PySide::hash"> <conversion-rule class="target" file="qdatetime_conversions.h"/> <extra-includes> <include file-name="datetime.h" location="global"/> </extra-includes> + <!-- Somewhat internal constructor used to pickle QDateTime --> + <add-function signature="QDateTime(int, int, int, int, int, int, int, int)"> + <modify-argument index="8"> + <replace-default-expression with="Qt::LocalTime"/> + </modify-argument> + <inject-code class="target" position="beginning"> + QDate date(%1, %2, %3); + QTime time(%4, %5, %6, %7); + %0 = new %TYPE(date, time, Qt::TimeSpec(%8)); + </inject-code> + </add-function> + <add-function signature="__reduce__" return-type="PyObject*"> + <inject-code class="target" position="beginning"> + <insert-template name="reduce_code"> + <replace from="%REDUCE_FORMAT" to="(iiiiiiii)" /> + <replace from="%REDUCE_ARGS" to="%CPPSELF.date().year(), %CPPSELF.date().month(), %CPPSELF.date().day(), %CPPSELF.time().hour(), %CPPSELF.time().minute(), %CPPSELF.time().second(), %CPPSELF.time().msec(), (int)%CPPSELF.timeSpec()" /> + </insert-template> + </inject-code> + </add-function> </value-type> - <value-type name="QDir"> <enum-type name="Filter" flags="QDir::Filters"/> <enum-type name="SortFlag" flags="QDir::SortFlags" /> + <add-function signature="__reduce__" return-type="PyObject*"> + <inject-code class="target" position="beginning"> + <insert-template name="reduce_code"> + <replace from="%REDUCE_FORMAT" to="(s)" /> + <replace from="%REDUCE_ARGS" to="qPrintable(%CPPSELF.path())" /> + </insert-template> + </inject-code> + </add-function> <modify-function signature="QDir(QString,QString,QFlags<QDir::SortFlag>,QFlags<QDir::Filter>)" remove="all" /> </value-type> <value-type name="QPoint" hash-function="PySide::hash"> + <add-function signature="__reduce__" return-type="PyObject*"> + <inject-code class="target" position="beginning"> + <insert-template name="reduce_code"> + <replace from="%REDUCE_FORMAT" to="(ii)" /> + <replace from="%REDUCE_ARGS" to="%CPPSELF.x(), %CPPSELF.y()" /> + </insert-template> + </inject-code> + </add-function> <inject-code class="native" position="beginning"> namespace PySide { template<> inline uint hash(const QPoint& v) { @@ -786,10 +843,26 @@ <modify-function signature="ry()" remove="all"/> </value-type> <value-type name="QPointF"> + <add-function signature="__reduce__" return-type="PyObject*"> + <inject-code class="target" position="beginning"> + <insert-template name="reduce_code"> + <replace from="%REDUCE_FORMAT" to="(dd)" /> + <replace from="%REDUCE_ARGS" to="%CPPSELF.x(), %CPPSELF.y()" /> + </insert-template> + </inject-code> + </add-function> <modify-function signature="rx()" remove="all"/> <modify-function signature="ry()" remove="all"/> </value-type> <value-type name="QRect" hash-function="PySide::hash"> + <add-function signature="__reduce__" return-type="PyObject*"> + <inject-code class="target" position="beginning"> + <insert-template name="reduce_code"> + <replace from="%REDUCE_FORMAT" to="(iiii)" /> + <replace from="%REDUCE_ARGS" to="%CPPSELF.x(), %CPPSELF.y(), %CPPSELF.width(), %CPPSELF.height()" /> + </insert-template> + </inject-code> + </add-function> <inject-code class="native" position="beginning"> namespace PySide { template<> inline uint hash(const QRect& v) { @@ -805,15 +878,30 @@ </modify-function> </value-type> <value-type name="QRectF"> - <modify-function signature="getCoords(qreal*,qreal*,qreal*,qreal*)const"> - <remove/> - </modify-function> - <modify-function signature="getRect(qreal*,qreal*,qreal*,qreal*)const"> - <remove/> - </modify-function> + <!-- + FIXME These functions return qreal. Will convert to double (format + string) mess things up in other architectures? + --> + <add-function signature="__reduce__" return-type="PyObject*"> + <inject-code class="target" position="beginning"> + <insert-template name="reduce_code"> + <replace from="%REDUCE_FORMAT" to="(dddd)" /> + <replace from="%REDUCE_ARGS" to="%CPPSELF.x(), %CPPSELF.y(), %CPPSELF.width(), %CPPSELF.height()" /> + </insert-template> + </inject-code> + </add-function> + <modify-function signature="getCoords(qreal*,qreal*,qreal*,qreal*)const" remove="all" /> + <modify-function signature="getRect(qreal*,qreal*,qreal*,qreal*)const" remove="all" /> </value-type> - <value-type name="QSize" hash-function="PySide::hash"> + <add-function signature="__reduce__" return-type="PyObject*"> + <inject-code class="target" position="beginning"> + <insert-template name="reduce_code"> + <replace from="%REDUCE_FORMAT" to="(ii)" /> + <replace from="%REDUCE_ARGS" to="%CPPSELF.width(), %CPPSELF.height()" /> + </insert-template> + </inject-code> + </add-function> <inject-code class="native" position="beginning"> namespace PySide { template<> inline uint hash(const QSize& v) { @@ -825,11 +913,27 @@ <modify-function signature="rwidth()" remove="all"/> </value-type> <value-type name="QSizeF"> + <add-function signature="__reduce__" return-type="PyObject*"> + <inject-code class="target" position="beginning"> + <insert-template name="reduce_code"> + <replace from="%REDUCE_FORMAT" to="(dd)" /> + <replace from="%REDUCE_ARGS" to="%CPPSELF.width(), %CPPSELF.height()" /> + </insert-template> + </inject-code> + </add-function> <modify-function signature="rheight()" remove="all" /> <modify-function signature="rwidth()" remove="all" /> </value-type> <value-type name="QTime" hash-function="PySide::hash"> + <add-function signature="__reduce__" return-type="PyObject*"> + <inject-code class="target" position="beginning"> + <insert-template name="reduce_code"> + <replace from="%REDUCE_FORMAT" to="(iiii)" /> + <replace from="%REDUCE_ARGS" to="%CPPSELF.hour(), %CPPSELF.minute(), %CPPSELF.second(), %CPPSELF.msec()" /> + </insert-template> + </inject-code> + </add-function> <conversion-rule class="target" file="qtime_conversions.h"/> <extra-includes> <include file-name="datetime.h" location="global"/> @@ -842,6 +946,14 @@ <value-type name="QUuid"> <enum-type name="Variant"/> <enum-type name="Version"/> + <add-function signature="__reduce__" return-type="PyObject*"> + <inject-code class="target" position="beginning"> + <insert-template name="reduce_code"> + <replace from="%REDUCE_FORMAT" to="(s)" /> + <replace from="%REDUCE_ARGS" to="qPrintable(%CPPSELF.toString())" /> + </insert-template> + </inject-code> + </add-function> <modify-function signature="QUuid(const char*)" remove="all" /> </value-type> @@ -937,7 +1049,7 @@ </modify-function> </value-type> <value-type name="QBitArray" hash-function="qHash" > - <modify-function signature="fill(bool,int)" remove="all"/> <!-- FIXME Removed due to a shiboken bug--> + <modify-function signature="fill(bool,int)" remove="all"/> <!-- FIXME Removed due to a shiboken bug--> <add-function signature="__len__"> <inject-code class="target" position="beginning"> return %CPPSELF.size(); @@ -1165,6 +1277,9 @@ <modify-argument index="return"> <parent index="this" action="add"/> </modify-argument> + <modify-argument index="2"> + <replace-default-expression with="QString()" /> + </modify-argument> </add-function> <add-function signature="findChildren(PyTypeObject*, const QString&)" return-type="PySequence*" > <inject-code class="target" position="beginning"> @@ -1262,6 +1377,14 @@ <extra-includes> <include file-name="QStringList" location="global"/> </extra-includes> + <add-function signature="__reduce__" return-type="PyObject*"> + <inject-code class="target" position="beginning"> + <insert-template name="reduce_code"> + <replace from="%REDUCE_FORMAT" to="(s)" /> + <replace from="%REDUCE_ARGS" to="qPrintable(%CPPSELF.toString())" /> + </insert-template> + </inject-code> + </add-function> </value-type> <value-type name="QRegExp"> <enum-type name="CaretMode"/> @@ -1269,17 +1392,41 @@ <extra-includes> <include file-name="QStringList" location="global"/> </extra-includes> + <add-function signature="__reduce__" return-type="PyObject*"> + <inject-code class="target" position="beginning"> + <insert-template name="reduce_code"> + <replace from="%REDUCE_FORMAT" to="(sii)" /> + <replace from="%REDUCE_ARGS" to="qPrintable(%CPPSELF.pattern()), (int)%CPPSELF.caseSensitivity(), (int)%CPPSELF.patternSyntax()" /> + </insert-template> + </inject-code> + </add-function> </value-type> <value-type name="QFileInfo"> <extra-includes> <include file-name="QDateTime" location="global"/> <include file-name="QDir" location="global"/> </extra-includes> + <add-function signature="__reduce__" return-type="PyObject*"> + <inject-code class="target" position="beginning"> + <insert-template name="reduce_code"> + <replace from="%REDUCE_FORMAT" to="(s)" /> + <replace from="%REDUCE_ARGS" to="qPrintable(%CPPSELF.filePath())" /> + </insert-template> + </inject-code> + </add-function> </value-type> <value-type name="QByteArray" hash-function="qHash"> <extra-includes> <include file-name="QNoImplicitBoolCast" location="global"/> </extra-includes> + <add-function signature="__reduce__" return-type="PyObject*"> + <inject-code class="target" position="beginning"> + <insert-template name="reduce_code"> + <replace from="%REDUCE_FORMAT" to="(s)" /> + <replace from="%REDUCE_ARGS" to="%CPPSELF.constData()" /> + </insert-template> + </inject-code> + </add-function> <modify-function signature="QByteArray(const char *)"> <!-- Keep \x00 bytes passed in python strings --> <inject-code class="target" position="beginning"> @@ -1295,6 +1442,7 @@ Shiboken::SbkType<QByteArray>()->tp_flags |= Py_TPFLAGS_HAVE_GETCHARBUFFER; #endif </inject-code> + <!-- removed functions --> <modify-function signature="begin()" remove="all"/> <modify-function signature="begin()const" remove="all"/> @@ -1619,8 +1767,6 @@ <modify-function signature="waitForBytesWritten(int)" allow-thread="yes"/> <modify-function signature="peek(char *,qint64)" remove="all"/> <modify-function signature="read(char *,qint64)" remove="all"/> -<!-- Needed by QNetworkReply class on QtNetwork module --> -<!-- <modify-function signature="readData(char *,qint64)" remove="all"/> --> <modify-function signature="readLine(char *,qint64)" remove="all"/> <modify-function signature="write(const char *,qint64)" remove="all"/> <modify-function signature="getChar(char *)"> @@ -1632,6 +1778,44 @@ <insert-template name="fix_char*" /> </inject-code> </modify-function> + <modify-function signature="readData(char *,qint64)"> + <inject-code class="target"> + QByteArray ba; + ba.resize(%2); + %CPPSELF.%FUNCTION_NAME(ba.data(), ba.size()); + %PYARG_0 = %CONVERTTOPYTHON[QByteArray](ba); + </inject-code> + <modify-argument index="1"> + <remove-argument /> + </modify-argument> + <modify-argument index="return"> + <replace-type modified-type="QByteArray"/> + <conversion-rule class="native"> + const QByteArray ba(%CONVERTTOCPP[QByteArray](%PYARG_0)); + memcpy(data, ba.data(), ba.size()); + long long %out = ba.size(); + </conversion-rule> + </modify-argument> + </modify-function> + <modify-function signature="readLineData(char *,qint64)"> + <inject-code class="target"> + QByteArray ba; + ba.resize(%2); + %CPPSELF.%FUNCTION_NAME(ba.data(), ba.size()); + %PYARG_0 = %CONVERTTOPYTHON[QByteArray](ba); + </inject-code> + <modify-argument index="1"> + <remove-argument /> + </modify-argument> + <modify-argument index="return"> + <replace-type modified-type="QByteArray"/> + <conversion-rule class="native"> + const QByteArray ba(%CONVERTTOCPP[QByteArray](%PYARG_0)); + memcpy(data, ba.data(), ba.size()); + long long %out = ba.size(); + </conversion-rule> + </modify-argument> + </modify-function> </object-type> <object-type name="QCryptographicHash"> <enum-type name="Algorithm"/> @@ -2442,7 +2626,24 @@ <object-type name="QSequentialAnimationGroup"/> - <object-type name="QSignalTransition"/> + <object-type name="QSignalTransition"> + <add-function signature="QSignalTransition(PyObject*, QState*)" return-type="QSignalTransition*"> + <modify-argument index="2"> + <replace-default-expression with="0" /> + </modify-argument> + <inject-code> + if (PyObject_TypeCheck(%1, &PySide::SignalInstance_Type)) { + PySide::SignalInstanceData* data = (PySide::SignalInstanceData*) %PYARG_1; + Shiboken::AutoDecRef obType(PyObject_Type(data->source)); + QObject* sender = %CONVERTTOCPP[QObject*](data->source); + if (sender) { + QByteArray signature(data->signature); // Append SIGNAL flag (2) + %0 = new QSignalTransitionWrapper(sender, "2" + signature, %2); + } + } + </inject-code> + </add-function> + </object-type> <object-type name="QState"> <enum-type name="ChildMode"/> @@ -2465,7 +2666,6 @@ } </inject-code> </modify-function> - <modify-function signature="addTransition(QAbstractState*)"> <modify-argument index="1"> <parent index="this" action="add"/> diff --git a/PySide/QtGui/glue/wid_conversions.h b/PySide/QtGui/glue/wid_conversions.h new file mode 100644 index 000000000..9901218a1 --- /dev/null +++ b/PySide/QtGui/glue/wid_conversions.h @@ -0,0 +1,32 @@ +namespace Shiboken { +template <> +struct Converter<WId> +{ + static bool checkType(PyObject* pyObj) + { + return false; + } + + static bool isConvertible(PyObject* pyobj) + { + return PyCObject_Check(pyobj); + } + + static inline PyObject* toPython(void* cppobj) + { + // not supported + Q_ASSERT(true); + return 0; + } + + static PyObject* toPython(WId cppobj) + { + return PyCObject_FromVoidPtr(cppobj, 0); + } + + static WId toCpp(PyObject* pyobj) + { + return (WId) PyCObject_AsVoidPtr(pyobj); + } +}; +} diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index 68d5c0d8c..09f66d939 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -149,6 +149,16 @@ <rejection class="*" enum-name="enum_1"/> <value-type name="QTransform"> <enum-type name="TransformationType"/> + <add-function signature="__reduce__" return-type="PyObject*"> + <inject-code class="target" position="beginning"> + <insert-template name="reduce_code"> + <replace from="%REDUCE_FORMAT" to="ddddddddd" /> + <replace from="%REDUCE_ARGS" to="%CPPSELF.m11(), %CPPSELF.m12(), %CPPSELF.m13(), %CPPSELF.m21(), %CPPSELF.m22(), %CPPSELF.m23(), %CPPSELF.m31(), %CPPSELF.m32(), %CPPSELF.m33()" /> + </insert-template> + </inject-code> + </add-function> + + <modify-function signature="map(int,int,int*,int*)const" remove="all"/> <modify-function signature="map(qreal,qreal,qreal*,qreal*)const" remove="all"/> <modify-function signature="inverted(bool*)const"> @@ -384,6 +394,15 @@ <enum-type name="SequenceFormat"/> <enum-type name="SequenceMatch"/> <enum-type name="StandardKey"/> + <add-function signature="__reduce__" return-type="PyObject*"> + <inject-code class="target" position="beginning"> + <insert-template name="reduce_code"> + <replace from="%REDUCE_FORMAT" to="iiii" /> + <replace from="%REDUCE_ARGS" to="(*%CPPSELF)[0], (*%CPPSELF)[1], (*%CPPSELF)[2], (*%CPPSELF)[3]" /> + </insert-template> + </inject-code> + </add-function> + <modify-function signature="operator QVariant()const" remove="all"/> <modify-function signature="operator int()const" remove="all"/> <modify-function signature="operator[](uint)const" remove="all"/> @@ -452,6 +471,22 @@ <include file-name="QMatrix" location="global"/> <include file-name="QTransform" location="global"/> </extra-includes> + <add-function signature="__reduce__" return-type="PyObject*"> + <inject-code class="target" position="beginning"> + PyObject *points = PyList_New(%CPPSELF.count()); + for (int i = 0; i < %CPPSELF.count(); ++i){ + int x, y; + %CPPSELF.point(i, &x, &y); + PyList_SET_ITEM(points, i, %CONVERTTOPYTHON[QPoint](QPoint(x, y))); + } + <insert-template name="reduce_code"> + <replace from="%REDUCE_FORMAT" to="(N)" /> + <replace from="%REDUCE_ARGS" to="points" /> + </insert-template> + </inject-code> + </add-function> + + <modify-function signature="QPolygon(int, const int *)" remove="all"/> <modify-function signature="operator+(QVector<QPoint>)const" remove="all"/> <modify-function signature="operator<<(QPoint)" remove="all"/> @@ -483,11 +518,20 @@ </modify-function> </value-type> <value-type name="QTreeWidgetItemIterator" > + <modify-function signature="QTreeWidgetItemIterator(QTreeWidget *, QFlags<QTreeWidgetItemIterator::IteratorFlag>)"> + <inject-code class="target" position="end"> + Shiboken::setParent(%PYARG_1, (PyObject*)sbkSelf); + </inject-code> + </modify-function> + <add-function signature="value()" return-type="QTreeWidgetItem*"> + <inject-code> + %PYARG_0 = %CONVERTTOPYTHON[QTreeWidgetItem*](%CPPSELF.operator*()); + SbkBaseWrapper_setOwnership(%PYARG_0, false); + </inject-code> + </add-function> <enum-type name="IteratorFlag" flags="QTreeWidgetItemIterator::IteratorFlags"/> <modify-function signature="operator++(int)" remove="all"/> <modify-function signature="operator--(int)" remove="all"/> - <modify-function signature="operator+=(int)" remove="all"/> - <modify-function signature="operator-=(int)" remove="all"/> <modify-function signature="operator++()" remove="all"/> <modify-function signature="operator--()" remove="all"/> <modify-function signature="operator*()const" remove="all"/> @@ -564,6 +608,14 @@ <extra-includes> <include file-name="QPainterPath" location="global"/> </extra-includes> + <add-function signature="__reduce__" return-type="PyObject*"> + <inject-code class="target" position="beginning"> + <insert-template name="reduce_code"> + <replace from="%REDUCE_FORMAT" to="dddddd" /> + <replace from="%REDUCE_ARGS" to="%CPPSELF.m11(), %CPPSELF.m12(), %CPPSELF.m21(), %CPPSELF.m22(), %CPPSELF.dx(), %CPPSELF.dy()" /> + </insert-template> + </inject-code> + </add-function> <modify-function signature="map(int,int,int*,int*)const" remove="all"/> <modify-function signature="map(qreal,qreal,qreal*,qreal*)const" remove="all"/> <modify-function signature="inverted(bool*)const"> @@ -668,6 +720,14 @@ <extra-includes> <include file-name="QVariant" location="global"/> </extra-includes> + <add-function signature="__reduce__" return-type="PyObject*"> + <inject-code class="target" position="beginning"> + <insert-template name="reduce_code"> + <replace from="%REDUCE_FORMAT" to="iiii" /> + <replace from="%REDUCE_ARGS" to="%CPPSELF.red(), %CPPSELF.green(), %CPPSELF.blue(), %CPPSELF.alpha()" /> + </insert-template> + </inject-code> + </add-function> <modify-function signature="QColor(QColor::Spec)" remove="all"/> <modify-function signature="QColor(const char*)" remove="all" /> <add-function signature="QColor(QVariant)"> @@ -2882,11 +2942,6 @@ <parent index="this" action="add"/> </modify-argument> </modify-function> - <modify-function signature="takeTopLevelItem(int)"> - <modify-argument index="return"> - <parent index="this" action="add"/> - </modify-argument> - </modify-function> <modify-function signature="addTopLevelItems(const QList<QTreeWidgetItem*> &)"> <modify-argument index="1"> <parent index="this" action="add"/> @@ -2914,11 +2969,7 @@ </modify-function> <modify-function signature="takeTopLevelItem(int)"> <modify-argument index="return"> - <parent index="this" action="remove"/> - </modify-argument> - </modify-function> - <modify-function signature="removeItemWidget(QTreeWidgetItem*,int)"> - <modify-argument index="1"> + <define-ownership owner="default"/> <parent index="this" action="remove"/> </modify-argument> </modify-function> @@ -3147,11 +3198,6 @@ <parent index="this" action="add"/> </modify-argument> </modify-function> - <modify-function signature="removeItemWidget(QListWidgetItem*)"> - <modify-argument index="1"> - <parent index="this" action="remove"/> - </modify-argument> - </modify-function> <modify-function signature="setItemHidden(const QListWidgetItem*,bool)" remove="all"/> <modify-function signature="isItemHidden(const QListWidgetItem*)const" remove="all"/> <modify-function signature="setItemSelected(const QListWidgetItem*,bool)" remove="all"/> @@ -3159,6 +3205,7 @@ <modify-function signature="takeItem(int)"> <modify-argument index="return"> <define-ownership owner="default"/> + <parent index="this" action="remove"/> </modify-argument> </modify-function> <modify-function signature="mimeData(const QList<QListWidgetItem*>)const" remove="all"/> @@ -4828,17 +4875,505 @@ </modify-function> </object-type> - <value-type name="QMatrix2x2"/> - <value-type name="QMatrix2x3"/> - <value-type name="QMatrix2x4"/> - <value-type name="QMatrix3x2"/> - <value-type name="QMatrix3x3"/> - <value-type name="QMatrix3x4"/> - <value-type name="QMatrix4x2"/> - <value-type name="QMatrix4x3"/> + <value-type name="QMatrix2x2"> + <add-function signature="__reduce__" return-type="PyObject*"> + <inject-code class="target" position="beginning"> + <insert-template name="reduce_code_matrix"> + <replace from="%MATRIX_TYPE" to="qreal" /> + <replace from="%MATRIX_SIZE" to="4" /> + </insert-template> + </inject-code> + </add-function> + <add-function signature="QMatrix2x2(PySequence*)"> + <inject-code class="target" position="beginning"> + <insert-template name="matrix_constructor"> + <replace from="%SIZE" to="4" /> + </insert-template> + </inject-code> + </add-function> + <add-function signature="data()" return-type="qreal"> + <inject-code class="target" position="beginning"> + <insert-template name="matrix_data_function"> + <replace from="%MATRIX_SIZE" to="4" /> + </insert-template> + </inject-code> + </add-function> + <add-function signature="fill(PyObject*)"> + <inject-code class="target" position="beginning"> + <insert-template name="matrix_fill_function"> + <replace from="%MATRIX_SIZE" to="4" /> + </insert-template> + </inject-code> + </add-function> + <add-function signature="transposed()" return-type="PyObject"> + <inject-code class="target" position="beginning"> + <insert-template name="matrix_transposed_function"> + <replace from="%TRANSPOSED_TYPE" to="QMatrix2x2" /> + </insert-template> + </inject-code> + </add-function> + <add-function signature="operator!=(const QMatrix2x2&)" return-type="bool" /> + <add-function signature="operator*=(qreal)" return-type="QMatrix2x2" > + <inject-code class="target" position="beginning"> + return %CONVERTTOPYTHON[QMatrix2x2](*%CPPSELF *= %1); + </inject-code> + </add-function> + <add-function signature="operator+=(const QMatrix2x2&)" return-type="QMatrix2x2" > + <inject-code class="target" position="beginning"> + return %CONVERTTOPYTHON[QMatrix2x2](*%CPPSELF += %1); + </inject-code> + </add-function> + <add-function signature="operator-=(const QMatrix2x2&)" return-type="QMatrix2x2" > + <inject-code class="target" position="beginning"> + return %CONVERTTOPYTHON[QMatrix2x2](*%CPPSELF -= %1); + </inject-code> + </add-function> + <add-function signature="operator/=(qreal)" return-type="QMatrix2x2" > + <inject-code class="target" position="beginning"> + return %CONVERTTOPYTHON[QMatrix2x2](*%CPPSELF /= %1); + </inject-code> + </add-function> + <add-function signature="operator==(const QMatrix2x2&)" return-type="bool" /> + </value-type> + + <value-type name="QMatrix2x3"> + <add-function signature="__reduce__" return-type="PyObject*"> + <inject-code class="target" position="beginning"> + <insert-template name="reduce_code_matrix"> + <replace from="%MATRIX_TYPE" to="qreal" /> + <replace from="%MATRIX_SIZE" to="6" /> + </insert-template> + </inject-code> + </add-function> + <add-function signature="QMatrix2x3(PySequence*)"> + <inject-code class="target" position="beginning"> + <insert-template name="matrix_constructor"> + <replace from="%SIZE" to="6" /> + </insert-template> + </inject-code> + </add-function> + <add-function signature="data()" return-type="qreal"> + <inject-code class="target" position="beginning"> + <insert-template name="matrix_data_function"> + <replace from="%MATRIX_SIZE" to="6" /> + </insert-template> + </inject-code> + </add-function> + <add-function signature="fill(PyObject*)"> + <inject-code class="target" position="beginning"> + <insert-template name="matrix_fill_function"> + <replace from="%MATRIX_SIZE" to="6" /> + </insert-template> + </inject-code> + </add-function> + <add-function signature="transposed()" return-type="PyObject"> + <inject-code class="target" position="beginning"> + <insert-template name="matrix_transposed_function"> + <replace from="%TRANSPOSED_TYPE" to="QMatrix3x2" /> + </insert-template> + </inject-code> + </add-function> + <add-function signature="operator!=(const QMatrix2x3&)" return-type="bool" /> + <add-function signature="operator*=(qreal)" return-type="QMatrix2x3" > + <inject-code class="target" position="beginning"> + return %CONVERTTOPYTHON[QMatrix2x3](*%CPPSELF *= %1); + </inject-code> + </add-function> + <add-function signature="operator+=(const QMatrix2x3&)" return-type="QMatrix2x3" > + <inject-code class="target" position="beginning"> + return %CONVERTTOPYTHON[QMatrix2x3](*%CPPSELF += %1); + </inject-code> + </add-function> + <add-function signature="operator-=(const QMatrix2x3&)" return-type="QMatrix2x3" > + <inject-code class="target" position="beginning"> + return %CONVERTTOPYTHON[QMatrix2x3](*%CPPSELF -= %1); + </inject-code> + </add-function> + <add-function signature="operator/=(qreal)" return-type="QMatrix2x3" > + <inject-code class="target" position="beginning"> + return %CONVERTTOPYTHON[QMatrix2x3](*%CPPSELF /= %1); + </inject-code> + </add-function> + <add-function signature="operator==(const QMatrix2x3&)" return-type="bool" /> + </value-type> + + <value-type name="QMatrix2x4"> + <add-function signature="__reduce__" return-type="PyObject*"> + <inject-code class="target" position="beginning"> + <insert-template name="reduce_code_matrix"> + <replace from="%MATRIX_TYPE" to="qreal" /> + <replace from="%MATRIX_SIZE" to="8" /> + </insert-template> + </inject-code> + </add-function> + <add-function signature="QMatrix2x4(PySequence*)"> + <inject-code class="target" position="beginning"> + <insert-template name="matrix_constructor"> + <replace from="%SIZE" to="8" /> + </insert-template> + </inject-code> + </add-function> + <add-function signature="data()" return-type="qreal"> + <inject-code class="target" position="beginning"> + <insert-template name="matrix_data_function"> + <replace from="%MATRIX_SIZE" to="8" /> + </insert-template> + </inject-code> + </add-function> + <add-function signature="fill(PyObject*)"> + <inject-code class="target" position="beginning"> + <insert-template name="matrix_fill_function"> + <replace from="%MATRIX_SIZE" to="8" /> + </insert-template> + </inject-code> + </add-function> + <add-function signature="transposed()" return-type="PyObject"> + <inject-code class="target" position="beginning"> + <insert-template name="matrix_transposed_function"> + <replace from="%TRANSPOSED_TYPE" to="QMatrix4x2" /> + </insert-template> + </inject-code> + </add-function> + <add-function signature="operator!=(const QMatrix2x4&)" return-type="bool" /> + <add-function signature="operator*=(qreal)" return-type="QMatrix2x4" > + <inject-code class="target" position="beginning"> + return %CONVERTTOPYTHON[QMatrix2x4](*%CPPSELF *= %1); + </inject-code> + </add-function> + <add-function signature="operator+=(const QMatrix2x4&)" return-type="QMatrix2x4" > + <inject-code class="target" position="beginning"> + return %CONVERTTOPYTHON[QMatrix2x4](*%CPPSELF += %1); + </inject-code> + </add-function> + <add-function signature="operator-=(const QMatrix2x4&)" return-type="QMatrix2x4" > + <inject-code class="target" position="beginning"> + return %CONVERTTOPYTHON[QMatrix2x4](*%CPPSELF -= %1); + </inject-code> + </add-function> + <add-function signature="operator/=(qreal)" return-type="QMatrix2x4" > + <inject-code class="target" position="beginning"> + return %CONVERTTOPYTHON[QMatrix2x4](*%CPPSELF /= %1); + </inject-code> + </add-function> + <add-function signature="operator==(const QMatrix2x4&)" return-type="bool" /> + </value-type> + + <value-type name="QMatrix3x2"> + <add-function signature="__reduce__" return-type="PyObject*"> + <inject-code class="target" position="beginning"> + <insert-template name="reduce_code_matrix"> + <replace from="%MATRIX_TYPE" to="qreal" /> + <replace from="%MATRIX_SIZE" to="6" /> + </insert-template> + </inject-code> + </add-function> + <add-function signature="QMatrix3x2(PySequence*)"> + <inject-code class="target" position="beginning"> + <insert-template name="matrix_constructor"> + <replace from="%SIZE" to="6" /> + </insert-template> + </inject-code> + </add-function> + <add-function signature="data()" return-type="qreal"> + <inject-code class="target" position="beginning"> + <insert-template name="matrix_data_function"> + <replace from="%MATRIX_SIZE" to="6" /> + </insert-template> + </inject-code> + </add-function> + <add-function signature="fill(PyObject*)"> + <inject-code class="target" position="beginning"> + <insert-template name="matrix_fill_function"> + <replace from="%MATRIX_SIZE" to="6" /> + </insert-template> + </inject-code> + </add-function> + <add-function signature="transposed()" return-type="PyObject"> + <inject-code class="target" position="beginning"> + <insert-template name="matrix_transposed_function"> + <replace from="%TRANSPOSED_TYPE" to="QMatrix2x3" /> + </insert-template> + </inject-code> + </add-function> + <add-function signature="operator!=(const QMatrix3x2&)" return-type="bool" /> + <add-function signature="operator*=(qreal)" return-type="QMatrix3x2" > + <inject-code class="target" position="beginning"> + return %CONVERTTOPYTHON[QMatrix3x2](*%CPPSELF *= %1); + </inject-code> + </add-function> + <add-function signature="operator+=(const QMatrix3x2&)" return-type="QMatrix3x2" > + <inject-code class="target" position="beginning"> + return %CONVERTTOPYTHON[QMatrix3x2](*%CPPSELF += %1); + </inject-code> + </add-function> + <add-function signature="operator-=(const QMatrix3x2&)" return-type="QMatrix3x2" > + <inject-code class="target" position="beginning"> + return %CONVERTTOPYTHON[QMatrix3x2](*%CPPSELF -= %1); + </inject-code> + </add-function> + <add-function signature="operator/=(qreal)" return-type="QMatrix3x2" > + <inject-code class="target" position="beginning"> + return %CONVERTTOPYTHON[QMatrix3x2](*%CPPSELF /= %1); + </inject-code> + </add-function> + <add-function signature="operator==(const QMatrix3x2&)" return-type="bool" /> + </value-type> + + <value-type name="QMatrix3x3"> + <add-function signature="__reduce__" return-type="PyObject*"> + <inject-code class="target" position="beginning"> + <insert-template name="reduce_code_matrix"> + <replace from="%MATRIX_TYPE" to="qreal" /> + <replace from="%MATRIX_SIZE" to="9" /> + </insert-template> + </inject-code> + </add-function> + <add-function signature="QMatrix3x3(PySequence*)"> + <inject-code class="target" position="beginning"> + <insert-template name="matrix_constructor"> + <replace from="%SIZE" to="9" /> + </insert-template> + </inject-code> + </add-function> + <add-function signature="data()" return-type="qreal"> + <inject-code class="target" position="beginning"> + <insert-template name="matrix_data_function"> + <replace from="%MATRIX_SIZE" to="9" /> + </insert-template> + </inject-code> + </add-function> + <add-function signature="fill(PyObject*)"> + <inject-code class="target" position="beginning"> + <insert-template name="matrix_fill_function"> + <replace from="%MATRIX_SIZE" to="9" /> + </insert-template> + </inject-code> + </add-function> + <add-function signature="transposed()" return-type="PyObject"> + <inject-code class="target" position="beginning"> + <insert-template name="matrix_transposed_function"> + <replace from="%TRANSPOSED_TYPE" to="QMatrix3x3" /> + </insert-template> + </inject-code> + </add-function> + <add-function signature="operator!=(const QMatrix3x3&)" return-type="bool" /> + <add-function signature="operator*=(qreal)" return-type="QMatrix3x3" > + <inject-code class="target" position="beginning"> + return %CONVERTTOPYTHON[QMatrix3x3](*%CPPSELF *= %1); + </inject-code> + </add-function> + <add-function signature="operator+=(const QMatrix3x3&)" return-type="QMatrix3x3" > + <inject-code class="target" position="beginning"> + return %CONVERTTOPYTHON[QMatrix3x3](*%CPPSELF += %1); + </inject-code> + </add-function> + <add-function signature="operator-=(const QMatrix3x3&)" return-type="QMatrix3x3" > + <inject-code class="target" position="beginning"> + return %CONVERTTOPYTHON[QMatrix3x3](*%CPPSELF -= %1); + </inject-code> + </add-function> + <add-function signature="operator/=(qreal)" return-type="QMatrix3x3" > + <inject-code class="target" position="beginning"> + return %CONVERTTOPYTHON[QMatrix3x3](*%CPPSELF /= %1); + </inject-code> + </add-function> + <add-function signature="operator==(const QMatrix3x3&)" return-type="bool" /> + </value-type> + + <value-type name="QMatrix3x4"> + <add-function signature="__reduce__" return-type="PyObject*"> + <inject-code class="target" position="beginning"> + <insert-template name="reduce_code_matrix"> + <replace from="%MATRIX_TYPE" to="qreal" /> + <replace from="%MATRIX_SIZE" to="12" /> + </insert-template> + </inject-code> + </add-function> + <add-function signature="QMatrix3x4(PySequence*)"> + <inject-code class="target" position="beginning"> + <insert-template name="matrix_constructor"> + <replace from="%SIZE" to="12" /> + </insert-template> + </inject-code> + </add-function> + <add-function signature="data()" return-type="qreal"> + <inject-code class="target" position="beginning"> + <insert-template name="matrix_data_function"> + <replace from="%MATRIX_SIZE" to="12" /> + </insert-template> + </inject-code> + </add-function> + <add-function signature="fill(PyObject*)"> + <inject-code class="target" position="beginning"> + <insert-template name="matrix_fill_function"> + <replace from="%MATRIX_SIZE" to="12" /> + </insert-template> + </inject-code> + </add-function> + <add-function signature="transposed()" return-type="PyObject"> + <inject-code class="target" position="beginning"> + <insert-template name="matrix_transposed_function"> + <replace from="%TRANSPOSED_TYPE" to="QMatrix4x3" /> + </insert-template> + </inject-code> + </add-function> + <add-function signature="operator!=(const QMatrix3x4&)" return-type="bool" /> + <add-function signature="operator*=(qreal)" return-type="QMatrix3x4" > + <inject-code class="target" position="beginning"> + return %CONVERTTOPYTHON[QMatrix3x4](*%CPPSELF *= %1); + </inject-code> + </add-function> + <add-function signature="operator+=(const QMatrix3x4&)" return-type="QMatrix3x4" > + <inject-code class="target" position="beginning"> + return %CONVERTTOPYTHON[QMatrix3x4](*%CPPSELF += %1); + </inject-code> + </add-function> + <add-function signature="operator-=(const QMatrix3x4&)" return-type="QMatrix3x4" > + <inject-code class="target" position="beginning"> + return %CONVERTTOPYTHON[QMatrix3x4](*%CPPSELF -= %1); + </inject-code> + </add-function> + <add-function signature="operator/=(qreal)" return-type="QMatrix3x4" > + <inject-code class="target" position="beginning"> + return %CONVERTTOPYTHON[QMatrix3x4](*%CPPSELF /= %1); + </inject-code> + </add-function> + <add-function signature="operator==(const QMatrix3x4&)" return-type="bool" /> + </value-type> + + <value-type name="QMatrix4x2"> + <add-function signature="__reduce__" return-type="PyObject*"> + <inject-code class="target" position="beginning"> + <insert-template name="reduce_code_matrix"> + <replace from="%MATRIX_TYPE" to="qreal" /> + <replace from="%MATRIX_SIZE" to="8" /> + </insert-template> + </inject-code> + </add-function> + <add-function signature="QMatrix4x2(PySequence*)"> + <inject-code class="target" position="beginning"> + <insert-template name="matrix_constructor"> + <replace from="%SIZE" to="8" /> + </insert-template> + </inject-code> + </add-function> + <add-function signature="data()" return-type="qreal"> + <inject-code class="target" position="beginning"> + <insert-template name="matrix_data_function"> + <replace from="%MATRIX_SIZE" to="8" /> + </insert-template> + </inject-code> + </add-function> + <add-function signature="fill(PyObject*)"> + <inject-code class="target" position="beginning"> + <insert-template name="matrix_fill_function"> + <replace from="%MATRIX_SIZE" to="8" /> + </insert-template> + </inject-code> + </add-function> + <add-function signature="transposed()" return-type="PyObject"> + <inject-code class="target" position="beginning"> + <insert-template name="matrix_transposed_function"> + <replace from="%TRANSPOSED_TYPE" to="QMatrix2x4" /> + </insert-template> + </inject-code> + </add-function> + <add-function signature="operator!=(const QMatrix4x2&)" return-type="bool" /> + <add-function signature="operator*=(qreal)" return-type="QMatrix4x2" > + <inject-code class="target" position="beginning"> + return %CONVERTTOPYTHON[QMatrix4x2](*%CPPSELF *= %1); + </inject-code> + </add-function> + <add-function signature="operator+=(const QMatrix4x2&)" return-type="QMatrix4x2" > + <inject-code class="target" position="beginning"> + return %CONVERTTOPYTHON[QMatrix4x2](*%CPPSELF += %1); + </inject-code> + </add-function> + <add-function signature="operator-=(const QMatrix4x2&)" return-type="QMatrix4x2" > + <inject-code class="target" position="beginning"> + return %CONVERTTOPYTHON[QMatrix4x2](*%CPPSELF -= %1); + </inject-code> + </add-function> + <add-function signature="operator/=(qreal)" return-type="QMatrix4x2" > + <inject-code class="target" position="beginning"> + return %CONVERTTOPYTHON[QMatrix4x2](*%CPPSELF /= %1); + </inject-code> + </add-function> + <add-function signature="operator==(const QMatrix4x2&)" return-type="bool" /> + </value-type> + + <value-type name="QMatrix4x3"> + <add-function signature="__reduce__" return-type="PyObject*"> + <inject-code class="target" position="beginning"> + <insert-template name="reduce_code_matrix"> + <replace from="%MATRIX_TYPE" to="qreal" /> + <replace from="%MATRIX_SIZE" to="12" /> + </insert-template> + </inject-code> + </add-function> + <add-function signature="QMatrix4x3(PySequence*)"> + <inject-code class="target" position="beginning"> + <insert-template name="matrix_constructor"> + <replace from="%SIZE" to="12" /> + </insert-template> + </inject-code> + </add-function> + <add-function signature="data()" return-type="qreal"> + <inject-code class="target" position="beginning"> + <insert-template name="matrix_data_function"> + <replace from="%MATRIX_SIZE" to="12" /> + </insert-template> + </inject-code> + </add-function> + <add-function signature="fill(PyObject*)"> + <inject-code class="target" position="beginning"> + <insert-template name="matrix_fill_function"> + <replace from="%MATRIX_SIZE" to="12" /> + </insert-template> + </inject-code> + </add-function> + <add-function signature="transposed()" return-type="PyObject"> + <inject-code class="target" position="beginning"> + <insert-template name="matrix_transposed_function"> + <replace from="%TRANSPOSED_TYPE" to="QMatrix3x4" /> + </insert-template> + </inject-code> + </add-function> + <add-function signature="operator!=(const QMatrix4x3&)" return-type="bool" /> + <add-function signature="operator*=(qreal)" return-type="QMatrix4x3" > + <inject-code class="target" position="beginning"> + return %CONVERTTOPYTHON[QMatrix4x3](*%CPPSELF *= %1); + </inject-code> + </add-function> + <add-function signature="operator+=(const QMatrix4x3&)" return-type="QMatrix4x3" > + <inject-code class="target" position="beginning"> + return %CONVERTTOPYTHON[QMatrix4x3](*%CPPSELF += %1); + </inject-code> + </add-function> + <add-function signature="operator-=(const QMatrix4x3&)" return-type="QMatrix4x3" > + <inject-code class="target" position="beginning"> + return %CONVERTTOPYTHON[QMatrix4x3](*%CPPSELF -= %1); + </inject-code> + </add-function> + <add-function signature="operator/=(qreal)" return-type="QMatrix4x3" > + <inject-code class="target" position="beginning"> + return %CONVERTTOPYTHON[QMatrix4x3](*%CPPSELF /= %1); + </inject-code> + </add-function> + <add-function signature="operator==(const QMatrix4x3&)" return-type="bool" /> + </value-type> + + <value-type name="QMatrix4x4"> + <add-function signature="__reduce__" return-type="PyObject*"> + <inject-code class="target" position="beginning"> + <insert-template name="reduce_code_matrix"> + <replace from="%MATRIX_TYPE" to="qreal" /> + <replace from="%MATRIX_SIZE" to="16" /> + </insert-template> + </inject-code> + </add-function> <modify-function signature="QMatrix4x4(const qreal*,int,int)" remove="all"/> - <modify-function signature="QMatrix4x4(const qreal*)"> <modify-argument index="1"> <replace-type modified-type="PySequence" /> @@ -4858,21 +5393,13 @@ } </inject-code> </modify-function> - - <modify-function signature="constData() const" rename="data"> - <modify-argument index="return"> - <replace-type modified-type="PyTupleObject*"/> - </modify-argument> + <modify-function signature="data()"> <inject-code class="target" position="beginning"> - const qreal* values = %CPPSELF.constData(); - %PYARG_0 = PyTuple_New(16); - for(int i=0; i < 16; i++) { - PyObject *v = PyFloat_FromDouble(values[i]); - PyTuple_SET_ITEM(%PYARG_0, i, v); - } + <insert-template name="matrix_data_function"> + <replace from="%MATRIX_SIZE" to="16" /> + </insert-template> </inject-code> </modify-function> - <modify-function signature="copyDataTo(qreal *) const"> <modify-argument index="1"> <remove-argument/> @@ -4880,7 +5407,6 @@ <modify-argument index="return"> <replace-type modified-type="PyTupleObject*"/> </modify-argument> - <inject-code class="target" position="beginning"> qreal values[16]; %CPPSELF.%FUNCTION_NAME(values); @@ -4891,11 +5417,10 @@ } </inject-code> </modify-function> - <modify-function signature="operator()(int, int)" remove="all"/> <modify-function signature="operator()(int, int)const" remove="all"/> - <modify-function signature="data()" remove="all"/> <modify-function signature="data() const" remove="all"/> + <modify-function signature="constData() const" remove="all"/> </value-type> <object-type name="QGesture"> @@ -4934,7 +5459,17 @@ <object-type name="QPinchGesture"> <enum-type name="ChangeFlag" flags="QPinchGesture::ChangeFlags"/> </object-type> - <value-type name="QQuaternion"/> + <value-type name="QQuaternion"> + <add-function signature="__reduce__" return-type="PyObject*"> + <inject-code class="target" position="beginning"> + <insert-template name="reduce_code"> + <replace from="%REDUCE_FORMAT" to="dddd" /> + <replace from="%REDUCE_ARGS" to="%CPPSELF.scalar(), %CPPSELF.x(), %CPPSELF.y(), %CPPSELF.z()" /> + </insert-template> + </inject-code> + </add-function> + </value-type> + <!-- Symbian <value-type name="QS60MainApplication"/> @@ -4958,16 +5493,41 @@ <value-type name="TouchPoint"/> </value-type> - <value-type name="QVector2D"/> + <value-type name="QVector2D"> + <add-function signature="__reduce__" return-type="PyObject*"> + <inject-code class="target" position="beginning"> + <insert-template name="reduce_code"> + <replace from="%REDUCE_FORMAT" to="dd" /> + <replace from="%REDUCE_ARGS" to="%CPPSELF.x(), %CPPSELF.y()" /> + </insert-template> + </inject-code> + </add-function> + </value-type> <value-type name="QVector3D"> <extra-includes> <include file-name="QMatrix4x4" location="global"/> </extra-includes> + <add-function signature="__reduce__" return-type="PyObject*"> + <inject-code class="target" position="beginning"> + <insert-template name="reduce_code"> + <replace from="%REDUCE_FORMAT" to="ddd" /> + <replace from="%REDUCE_ARGS" to="%CPPSELF.x(), %CPPSELF.y(), %CPPSELF.z()" /> + </insert-template> + </inject-code> + </add-function> </value-type> <value-type name="QVector4D"> <extra-includes> <include file-name="QMatrix4x4" location="global"/> </extra-includes> + <add-function signature="__reduce__" return-type="PyObject*"> + <inject-code class="target" position="beginning"> + <insert-template name="reduce_code"> + <replace from="%REDUCE_FORMAT" to="dddd" /> + <replace from="%REDUCE_ARGS" to="%CPPSELF.x(), %CPPSELF.y(), %CPPSELF.z(), %CPPSELF.w()" /> + </insert-template> + </inject-code> + </add-function> </value-type> <suppress-warning text="template baseclass 'QGenericMatrix<qreal>' of '*' is not known"/> @@ -4982,6 +5542,6 @@ <suppress-warning text="unhandled enum value: ~FlagMask in QMessageBox::StandardButton"/> <suppress-warning text="unmatched enum ~FlagMask"/> <suppress-warning text="Argument 1 on function 'QTabWidget::setUpLayout(bool)' has default expressiont but does not have name."/> - + <suppress-warning text="enum 'QMatrix4x4::enum_1' is specified in typesystem, but not declared"/> <suppress-warning text="type 'QGtkStyle' is specified in typesystem, but not defined. This could potentially lead to compilation errors."/> </typesystem> diff --git a/PySide/QtGui/typesystem_gui_win.xml b/PySide/QtGui/typesystem_gui_win.xml index bc4690925..124929674 100644 --- a/PySide/QtGui/typesystem_gui_win.xml +++ b/PySide/QtGui/typesystem_gui_win.xml @@ -19,6 +19,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA --> <typesystem package="PySide.QtGui"> - <primitive-type name="Qt::HANDLE" target-lang-api-name="PyObject"/> + <primitive-type name="Qt::HANDLE" target-lang-api-name="PyObject" /> + <primitive-type name="WId" target-lang-api-name="PyObject"> + <conversion-rule file="glue/wid_conversions.h"/> + </primitive-type> <enum-type name="QPixmap::HBitmapFormat" /> </typesystem> diff --git a/PySide/QtUiTools/CMakeLists.txt b/PySide/QtUiTools/CMakeLists.txt index 9922e9d10..4054ffc9b 100644 --- a/PySide/QtUiTools/CMakeLists.txt +++ b/PySide/QtUiTools/CMakeLists.txt @@ -10,18 +10,22 @@ set(QtUiTools_include_dirs ${CMAKE_CURRENT_SOURCE_DIR} ${QT_QTCORE_INCLUDE_DIR} ${QT_QTGUI_INCLUDE_DIR} ${QT_QTXML_INCLUDE_DIR} + ${QT_QTDESIGNER_INCLUDE_DIR} ${QT_QTUITOOLS_INCLUDE_DIR} ${PYTHON_INCLUDE_PATH} ${SHIBOKEN_INCLUDE_DIR} ${libpyside_SOURCE_DIR} + ${plugins_SOURCE_DIR} ${QtCore_BINARY_DIR}/PySide/QtCore/ ${QtXml_BINARY_DIR}/PySide/QtXml/ ${QtGui_BINARY_DIR}/PySide/QtGui/ ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtUiTools) set(QtUiTools_libraries pyside + uiplugin ${PYSIDE_PYTHON_LIBRARIES} ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} + ${QT_QTDESIGNER_LIBRARY} ${QT_QTUITOOLS_LIBRARY}) set(QtUiTools_deps QtGui QtXml) create_pyside_module(QtUiTools @@ -31,3 +35,4 @@ create_pyside_module(QtUiTools QtUiTools_typesystem_path QtUiTools_SRC "") + diff --git a/PySide/QtUiTools/glue/plugins.h b/PySide/QtUiTools/glue/plugins.h new file mode 100644 index 000000000..09070bf19 --- /dev/null +++ b/PySide/QtUiTools/glue/plugins.h @@ -0,0 +1,47 @@ +/* + * This file is part of the PySide project. + * + * Copyright (C) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). + * + * Contact: PySide team <contact@pyside.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef _PLUGIN_H_ +#define _PLUGIN_H_ + +#include <QPluginLoader> +#include "customwidgets.h" + +inline void registerCustomWidget(PyObject* obj) +{ + static PyCustomWidgets* plugin = 0; + + if (plugin == 0) { + foreach(QObject* o, QPluginLoader::staticInstances()) { + plugin = qobject_cast<PyCustomWidgets*>(o); + if (o) + break; + } + } + + if (!plugin) + qDebug() << "Fail to load uiloader plugin"; + else + plugin->registerWidgetType(obj); +} + +#endif diff --git a/PySide/QtUiTools/glue/uitools_loadui.h b/PySide/QtUiTools/glue/uitools_loadui.h index bce1367c1..8f6df633c 100644 --- a/PySide/QtUiTools/glue/uitools_loadui.h +++ b/PySide/QtUiTools/glue/uitools_loadui.h @@ -18,7 +18,7 @@ _populate_parent(PyObject* pyParent, QObject *parent) bool has_attr = PyObject_HasAttrString(pyParent, qPrintable(name)); Shiboken::AutoDecRef pyChild(Shiboken::Converter<QObject*>::toPython(child)); if (!has_attr) - PyObject_SetAttrString(pyParent, qPrintable(name), pyChild); + PyObject_SetAttrString(pyParent, qPrintable(name), pyChild); Shiboken::setParent(pyParent, pyChild); _populate_parent(pyChild, qobject_cast<QObject*>(child)); @@ -31,16 +31,21 @@ quiloader_load_ui_from_device(QUiLoader* self, QIODevice* dev, QWidget *parent) { QWidget *w = self->load(dev, parent); if (w) { + QObject* _parent = parent; + if (!_parent) + _parent = w; + if (parent && parent->layout()) parent->layout()->deleteLater(); PyObject* pyParent = Shiboken::Converter<QWidget*>::toPython(w); - _populate_parent(pyParent, w); + _populate_parent(pyParent, _parent); return pyParent; } - PyErr_SetString(PyExc_RuntimeError, "Unable to open ui file"); + if (!PyErr_Occurred()) + PyErr_SetString(PyExc_RuntimeError, "Unable to open ui file"); return 0; } @@ -53,16 +58,20 @@ quiloader_load_ui(QUiLoader* self, const QString &ui_file, QWidget *parent) QWidget* w = self->load(&fd, parent); fd.close(); if (w != 0) { - PyObject* pyParent = Shiboken::Converter<QWidget*>::toPython(w); + QObject *_parent = parent; + if (!_parent) + _parent = w; + Shiboken::AutoDecRef pyParent(Shiboken::Converter<QWidget*>::toPython(_parent)); if (parent && parent->layout()) parent->layout()->deleteLater(); - _populate_parent(pyParent, w); + _populate_parent(pyParent, _parent); - return pyParent; + return Shiboken::Converter<QWidget*>::toPython(w); } } - PyErr_SetString(PyExc_RuntimeError, "Unable to open ui file"); - return 0; + if (!PyErr_Occurred()) + PyErr_SetString(PyExc_RuntimeError, "Unable to open ui file"); + return 0; } diff --git a/PySide/QtUiTools/typesystem_uitools.xml b/PySide/QtUiTools/typesystem_uitools.xml index a188aa34b..0abc6957c 100644 --- a/PySide/QtUiTools/typesystem_uitools.xml +++ b/PySide/QtUiTools/typesystem_uitools.xml @@ -23,6 +23,18 @@ <load-typesystem name="typesystem_xml.xml" generate="no" /> <object-type name="QUiLoader"> + <extra-includes> + <include file-name="glue/plugins.h" location="local"/> + </extra-includes> + <inject-code> + Q_IMPORT_PLUGIN(uiplugin); + </inject-code> + <add-function signature="registerCustomWidget(PyObject*)" return-type="void"> + <inject-code class="target" position="beginning"> + registerCustomWidget(%PYARG_1); + %CPPSELF.addPluginPath(""); // force reload widgets + </inject-code> + </add-function> <modify-function signature="createAction(QObject *, const QString&)"> <modify-argument index="return"> <parent index="1" action="add"/> diff --git a/PySide/phonon/typesystem_phonon.xml b/PySide/phonon/typesystem_phonon.xml index ef05c2665..3df71d69d 100644 --- a/PySide/phonon/typesystem_phonon.xml +++ b/PySide/phonon/typesystem_phonon.xml @@ -54,6 +54,27 @@ <!-- ### causes moc-related linker error --> <!-- <object-type name="Notifier"/> --> <object-type name="NotifierWrapper" target-lang-name="Notifier"> + <inject-documentation format="target" mode="append"> +.. class: Notifier + + Notifications about backend capabilities + +.. method:: capabilitiesChanged() + + This signal is emitted if the capabilities have changed. This can happen if the user has requested a backend change. + +.. method:: availableAudioOutputDevicesChanged() + + This signal is emitted when audio capture devices were plugged or unplugged. + + Check :meth:`PySide.phonon.BackendCapabilities.availableAudioOutputDevices` to get the current list of available devices. + +.. method:: availableAudioCaptureDevicesChanged() + + This signal is emitted when audio capture devices were plugged or unplugged. + + Check :meth:`PySide.phonon.BackendCapabilities.availableAudioCaptureDevices` to get the current list of available devices. + </inject-documentation> <include file-name="backendcapabilities.h" location="global"/> <include file-name="pyside_phonon.h" location="local"/> diff --git a/PySide/typesystem_templates.xml b/PySide/typesystem_templates.xml index 959fe7e20..576343473 100644 --- a/PySide/typesystem_templates.xml +++ b/PySide/typesystem_templates.xml @@ -181,11 +181,62 @@ %RETURN_TYPE retval_ = %CPPSELF.%FUNCTION_NAME(%1, %2, %3, %4, %5); %PYARG_0 = Shiboken::makeTuple(retval_, %4); </template> - <template name="set_qapp_parent_for_orphan"> Shiboken::SbkBaseWrapper* _pySelf = reinterpret_cast<Shiboken::SbkBaseWrapper*>(%PYARG_0); if (!_pySelf->parentInfo) Shiboken::setParent(%CONVERTTOPYTHON[QApplication*](qApp), %PYARG_0); </template> + <!-- templates for __reduce__ --> + <template name="reduce_code"> + PyObject *type = PyObject_Type(%PYSELF); + PyObject *args = NULL; + args = Py_BuildValue("%REDUCE_FORMAT", %REDUCE_ARGS); + %PYARG_0 = Py_BuildValue("(NN)", type, args); + </template> + <template name="reduce_code_matrix"> + QList< %MATRIX_TYPE > cppArgs; + %MATRIX_TYPE data[%MATRIX_SIZE]; + %CPPSELF.copyDataTo(data); + int matrixSize = %MATRIX_SIZE; + for(int size=0; size < matrixSize; size++) + cppArgs.append(data[size]); + + PyObject *type = PyObject_Type(%PYSELF); + PyObject *args = Py_BuildValue("(N)", %CONVERTTOPYTHON[QList<%MATRIX_TYPE> ](cppArgs)); + %PYARG_0 = Py_BuildValue("(NN)", type, args); + </template> + + <!-- Matrix Aux functions --> + <template name="matrix_constructor"> + if (PySequence_Size(%PYARG_1) == %SIZE) { + Shiboken::AutoDecRef fast(PySequence_Fast(%PYARG_1, "Fail to parse sequnce on %TYPE constructor.")); + qreal values[%SIZE]; + for(int i=0; i < %SIZE; i++) { + PyObject *pv = PySequence_Fast_GET_ITEM(fast.object(), i); + values[i] = %CONVERTTOCPP[qreal](pv); + } + %0 = new %TYPE(values); + } + </template> + + <template name="matrix_data_function"> + const qreal* data = %CPPSELF.constData(); + PyObject *pyData = PyTuple_New(%MATRIX_SIZE); + if (data) { + for(int i=0; i < %MATRIX_SIZE; i++) + PyTuple_SET_ITEM(pyData, i, %CONVERTTOPYTHON[qreal](data[i])); + } + return pyData; + </template> + + <template name="matrix_fill_function"> + qreal value = %CONVERTTOCPP[qreal](%PYARG_1); + %CPPSELF.fill(value); + </template> + + <template name="matrix_transposed_function"> + return %CONVERTTOPYTHON[%TRANSPOSED_TYPE](%CPPSELF.transposed()); + </template> + </typesystem> |