aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-03-20 07:41:35 +0100
committerLiang Qi <liang.qi@qt.io>2017-03-20 09:02:19 +0000
commitbbc13fe6ad1de634a6d3b594220ad780583378e0 (patch)
tree7cb3fafd9cf4c3712dd754bd2f8daf89814482b2
parent0d76d339929d5d3ce4ace2230e5fce9edc2e57ee (diff)
Add QTextDocumentWriter to typesystem
Task-number: PYSIDE-177 Change-Id: If83802bd5b37e4ffa3d6a5e8f1eace28f2e68834 Reviewed-by: Christian Tismer <tismer@stackless.com>
-rw-r--r--PySide2/QtGui/CMakeLists.txt1
-rw-r--r--PySide2/QtGui/typesystem_gui_common.xml1
-rw-r--r--tests/QtGui/CMakeLists.txt1
-rw-r--r--tests/QtGui/qtextdocumentwriter_test.py47
4 files changed, 50 insertions, 0 deletions
diff --git a/PySide2/QtGui/CMakeLists.txt b/PySide2/QtGui/CMakeLists.txt
index 47967e5c..6960b2cd 100644
--- a/PySide2/QtGui/CMakeLists.txt
+++ b/PySide2/QtGui/CMakeLists.txt
@@ -118,6 +118,7 @@ ${QtGui_GEN_DIR}/qtextcharformat_wrapper.cpp
${QtGui_GEN_DIR}/qtextcursor_wrapper.cpp
${QtGui_GEN_DIR}/qtextdocument_wrapper.cpp
${QtGui_GEN_DIR}/qtextdocumentfragment_wrapper.cpp
+${QtGui_GEN_DIR}/qtextdocumentwriter_wrapper.cpp
${QtGui_GEN_DIR}/qtextformat_wrapper.cpp
${QtGui_GEN_DIR}/qtextfragment_wrapper.cpp
${QtGui_GEN_DIR}/qtextframe_iterator_wrapper.cpp
diff --git a/PySide2/QtGui/typesystem_gui_common.xml b/PySide2/QtGui/typesystem_gui_common.xml
index cb5c6579..a6795f12 100644
--- a/PySide2/QtGui/typesystem_gui_common.xml
+++ b/PySide2/QtGui/typesystem_gui_common.xml
@@ -2149,6 +2149,7 @@
</modify-function>
<modify-function signature="print(QPagedPaintDevice*)const" rename="print_" />
</object-type>
+ <object-type name="QTextDocumentWriter" since="4.5" />
<object-type name="QTextTable">
<extra-includes>
<include file-name="QTextCursor" location="global"/>
diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt
index 843e597f..1d94d4f5 100644
--- a/tests/QtGui/CMakeLists.txt
+++ b/tests/QtGui/CMakeLists.txt
@@ -35,6 +35,7 @@ PYSIDE_TEST(qkeysequence_test.py)
PYSIDE_TEST(qradialgradient_test.py)
PYSIDE_TEST(qregion_test.py)
PYSIDE_TEST(qtextdocument_undoredo_test.py)
+PYSIDE_TEST(qtextdocumentwriter_test.py)
PYSIDE_TEST(qtextline_test.py)
PYSIDE_TEST(qtransform_test.py)
PYSIDE_TEST(repr_test.py)
diff --git a/tests/QtGui/qtextdocumentwriter_test.py b/tests/QtGui/qtextdocumentwriter_test.py
new file mode 100644
index 00000000..c65d0963
--- /dev/null
+++ b/tests/QtGui/qtextdocumentwriter_test.py
@@ -0,0 +1,47 @@
+#############################################################################
+##
+## Copyright (C) 2017 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of PySide2.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+
+from PySide2.QtGui import QTextDocumentWriter, QTextDocument
+from PySide2.QtCore import QBuffer
+
+class QTextDocumentWriterTest(unittest.TestCase):
+
+ def testWrite(self):
+ text = 'foobar'
+ doc = QTextDocument(text)
+ b = QBuffer()
+ b.open(QBuffer.ReadWrite)
+ writer = QTextDocumentWriter(b, "plaintext");
+ writer.write(doc);
+ b.close()
+ self.assertEqual(b.buffer(), text)
+
+if __name__ == '__main__':
+ unittest.main()