diff options
-rw-r--r-- | PySide/CMakeLists.txt | 4 | ||||
-rw-r--r-- | PySide/QtGui/CMakeLists.txt | 7 | ||||
-rw-r--r-- | PySide/QtGui/typesystem_gui_common.xml | 3 | ||||
-rw-r--r-- | PySide/global.h.in | 1 | ||||
-rw-r--r-- | PySide/qpytextobject.h | 16 | ||||
-rw-r--r-- | tests/QtGui/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/QtGui/qabstracttextdocumentlayout_test.py | 46 |
7 files changed, 74 insertions, 4 deletions
diff --git a/PySide/CMakeLists.txt b/PySide/CMakeLists.txt index edd3b44f1..e4b6a1d8c 100644 --- a/PySide/CMakeLists.txt +++ b/PySide/CMakeLists.txt @@ -27,8 +27,8 @@ macro(create_pyside_module module_name module_include_dir module_libraries modul WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMMENT "Running generator for ${module_name}...") - include_directories(${module_name} ${${module_include_dir}}) - add_library(${module_name} MODULE ${${module_sources}}) + 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") diff --git a/PySide/QtGui/CMakeLists.txt b/PySide/QtGui/CMakeLists.txt index 902243bcf..64aa73f34 100644 --- a/PySide/QtGui/CMakeLists.txt +++ b/PySide/QtGui/CMakeLists.txt @@ -55,6 +55,8 @@ else() ) endif () +qt4_wrap_cpp(QPYTEXTOBJECT_MOC "${pyside_SOURCE_DIR}/qpytextobject.h") + set(QtGui_SRC ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qabstractbutton_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qabstractgraphicsshapeitem_wrapper.cpp @@ -227,6 +229,7 @@ ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qpolygon_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qprogressbar_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qprogressdialog_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qproxymodel_wrapper.cpp +${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qpytextobject_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qpushbutton_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qradialgradient_wrapper.cpp ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/qradiobutton_wrapper.cpp @@ -395,6 +398,7 @@ check_qt_class(QtGui QPrintEngine QtGui_SRC) set(QtGui_typesystem_path "${QtCore_SOURCE_DIR}${PATH_SEP}${QtGui_SOURCE_DIR}") set(QtGui_include_dirs ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/PySide/QtGui/ + ${pyside_SOURCE_DIR} ${QT_INCLUDE_DIR} ${SHIBOKEN_INCLUDE_DIR} ${libpyside_SOURCE_DIR} @@ -412,5 +416,6 @@ create_pyside_module(QtGui QtGui_deps QtGui_typesystem_path QtGui_SRC - "${CMAKE_CURRENT_BINARY_DIR}/typesystem_gui.xml") + "${CMAKE_CURRENT_BINARY_DIR}/typesystem_gui.xml" + QPYTEXTOBJECT_MOC) diff --git a/PySide/QtGui/typesystem_gui_common.xml b/PySide/QtGui/typesystem_gui_common.xml index 48bad7a7e..b21750987 100644 --- a/PySide/QtGui/typesystem_gui_common.xml +++ b/PySide/QtGui/typesystem_gui_common.xml @@ -1388,6 +1388,7 @@ <modify-argument index="1" invalidate-after-use="yes"/> </modify-function> </object-type> + <object-type name="QPyTextObject" /> <object-type name="QActionGroup"> <modify-function signature="addAction(QAction*)"> <modify-argument index="1"> @@ -2527,7 +2528,7 @@ <extra-includes> <include file-name="autoarraypointer.h" location="global"/> </extra-includes> - + <modify-argument index="2"> <remove-argument/> <conversion-rule class="native"> diff --git a/PySide/global.h.in b/PySide/global.h.in index 1bec8bbd9..7a4c650c6 100644 --- a/PySide/global.h.in +++ b/PySide/global.h.in @@ -353,6 +353,7 @@ QT_END_HEADER #undef qdoc #endif #include <QtGui/QtGui> +#include "qpytextobject.h" #if @ENABLE_X11@ #include <QtGui/QX11Info> #endif diff --git a/PySide/qpytextobject.h b/PySide/qpytextobject.h new file mode 100644 index 000000000..80c5b7ebd --- /dev/null +++ b/PySide/qpytextobject.h @@ -0,0 +1,16 @@ +#ifndef QPYTEXTOBJECT +#define QPYTEXTOBJECT + +#include <QObject> +#include <QTextObjectInterface> + +class QPyTextObject : public QObject, public QTextObjectInterface +{ + Q_OBJECT + Q_INTERFACES(QTextObjectInterface) +public: + QPyTextObject(QObject* parent = 0) : QObject(parent) {} + void drawObject(QPainter* painter, const QRectF& rect, QTextDocument* doc, int posInDocument, const QTextFormat& format ) = 0; + QSizeF intrinsicSize(QTextDocument* doc, int posInDocument, const QTextFormat& format ) = 0; +}; +#endif
\ No newline at end of file diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt index b73e1ce13..80d415a0d 100644 --- a/tests/QtGui/CMakeLists.txt +++ b/tests/QtGui/CMakeLists.txt @@ -14,6 +14,7 @@ PYSIDE_TEST(missing_symbols_test.py) PYSIDE_TEST(paint_event_test.py) PYSIDE_TEST(parent_method_test.py) PYSIDE_TEST(python_properties_test.py) +PYSIDE_TEST(qabstracttextdocumentlayout_test.py) PYSIDE_TEST(qapplication_exit_segfault_test.py) PYSIDE_TEST(qapplication_singleton_test.py) PYSIDE_TEST(qapp_test.py) diff --git a/tests/QtGui/qabstracttextdocumentlayout_test.py b/tests/QtGui/qabstracttextdocumentlayout_test.py new file mode 100644 index 000000000..e3fe40e31 --- /dev/null +++ b/tests/QtGui/qabstracttextdocumentlayout_test.py @@ -0,0 +1,46 @@ +import unittest +import colorsys + +from PySide.QtCore import * +from PySide.QtGui import * +from helper import UsesQApplication + +class Foo(QPyTextObject): + called = False + + def intrinsicSize(self, doc, posInDocument, format): + Foo.called = True + return QSizeF(10, 10) + + def drawObject(self, painter, rect, doc, posInDocument, format): + pass + +class QAbstractTextDocumentLayoutTest(UsesQApplication): + + objectType = QTextFormat.UserObject + 1 + + def foo(self): + fmt = QTextCharFormat() + fmt.setObjectType(QAbstractTextDocumentLayoutTest.objectType) + + cursor = self.textEdit.textCursor() + cursor.insertText(unichr(0xfffc), fmt) + self.textEdit.setTextCursor(cursor) + self.textEdit.close() + + def testIt(self): + + self.textEdit = QTextEdit() + self.textEdit.show() + + interface = Foo() + self.textEdit.document().documentLayout().registerHandler(QAbstractTextDocumentLayoutTest.objectType, interface) + + QTimer.singleShot(0, self.foo) + self.app.exec_() + + self.assertTrue(Foo.called) + +if __name__ == "__main__": + unittest.main() + |