summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtextdocumentfragment.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix build with QT_NO_CSSPARSER / -no-feature-cssparserNils Jeisecke2019-10-041-0/+2
| | | | | | | | | Some parts of the new QTextDocument table border logic depend on the QCss namespace which is not available with -no-feature-cssparser. Change-Id: Ib8396894dc35872f22c634e1d6c38968d3dd4756 Reviewed-by: Timo Aarnipuro <timo.aarnipuro@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* Merge remote-tracking branch 'origin/dev' into 5.14Liang Qi2019-08-271-0/+26
|\ | | | | | | | | | | | | | | | | | | | | Conflicts: src/widgets/kernel/qwidget.cpp src/widgets/kernel/qwidget_p.h src/widgets/kernel/qwidgetrepaintmanager.cpp src/widgets/kernel/qwidgetwindow.cpp tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp Change-Id: Ifae457d0427be8e2465e474b055722e11b3b1e5c
| * QTextDocument: add css-styling of table cell borders to HTML import/exportNils Jeisecke2019-08-191-0/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Supported style attributes: <table> style: supports "border-collapse: collapse" and "border-color". border: width of the outer border bordercolor: basic color for all borders <tr> style: not supported <td>/</th> style: supports the "border", "border-[top|left|bottom|right]]" shorthand styles and the "border-width", "border-color" and "border-style" (and the top/left/bottom/right variants) attributes <table border=1 style="border-collapse: collapse"> will render a simple 1px table grid. Notes: The QTextDocument table model is much simpler than the HTML table model. It basically only has <table> and <td> support. So the HTML parser is forced to map markup and styling to the QTextDocument model which is not without loss. In other words: While QTextDocument -> HTML -> QTextDocument should preserve the QTextDocument structure, HTML -> QTextDocument -> HTML does not preserve the HTML DOM at all. So for now the HTML importer and writer only support border styles on the <td> and <th> nodes. In future updates, the HTML parser might be enhanced to map <tr> and <table> CSS styles to the cells. Change-Id: If9e7312fa6cbf270cf8f7b3c72ba1fa094107517 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* | QTextDocumentFragment: Fix deprecation warningFriedemann Kleint2019-08-211-1/+1
|/ | | | | | | | | Fix text/qtextdocumentfragment.cpp: In member function 'bool QTextHtmlImporter::appendNodeText()': text/qtextdocumentfragment.cpp:613:125: warning: 'constexpr QChar::QChar(char)' is deprecated: Use fromUtf8, QStringLiteral, or QLatin1String [-Wdeprecated-declarations] Change-Id: I90b23fa949e5cd979f2955b523060c8b1752f893 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* Support missing white-space:pre-line CSSAllan Sandfeld Jensen2019-08-121-1/+8
| | | | | | | A mode that only preserves new lines. Change-Id: I612347b181c6e6c41dfae0cf60b22a662cba1b7e Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* Markdown and HTML: support image alt text and titleShawn Rutledge2019-06-011-0/+4
| | | | | | | | | | | | | | | | | | | | | It's a required CommonMark feature: https://spec.commonmark.org/0.29/#images and alt text is also required in HTML: https://www.w3.org/wiki/Html/Elements/img#Requirements_for_providing_text_to_act_as_an_alternative_for_images Now we are able to read these attributes from either html or markdown and rewrite either an html or markdown document that preserves them. This patch does not add viewing or editing support in QTextEdit etc. Change-Id: I51307389f8f9fc00809808390e583a83111a7b33 Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
* Merge remote-tracking branch 'origin/5.12' into 5.13Qt Forward Merge Bot2019-02-151-1/+2
|\ | | | | | | Change-Id: I8cad26f17834dbc9f7151edc0f17786f9e32025d
| * QTextDocument: Do respect white-space:nowrapKai Koehne2019-02-131-1/+2
| | | | | | | | | | | | | | | | | | | | Prevent automatic insertion of line-breaks in blocks formatted with 'white-space:nowrap'. This follows the example of white-space:pre. Fixes: QTBUG-54787 Change-Id: If26f6a54106a02fe0e388947f6368ae4e86acf63 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Fix some QPainter-related deprecation warningsFriedemann Kleint2019-02-081-2/+4
|/ | | | | | | | | | | | | | | | text/qtextdocument.cpp:2666:48: warning: ‘QString QTextCharFormat::anchorName() const’ is deprecated: Use anchorNames() instead [-Wdeprecated-declarations] text/qtextdocumentfragment.cpp:545:87: warning: ‘QString QTextCharFormat::anchorName() const’ is deprecated: Use anchorNames() instead [-Wdeprecated-declarations] text/qtextdocumentfragment.cpp:546:68: warning: ‘QString QTextCharFormat::anchorName() const’ is deprecated: Use anchorNames() instead [-Wdeprecated-declarations] painting/qpainterpath.cpp:3321:34: warning: ‘void QPainterPath::addRoundRect(const QRectF&, int, int)’ is deprecated: Use addRoundedRect(..., Qt::RelativeSize) instead [-Wdeprecated-declarations] painting/qpainterpath.cpp:3342:48: warning: ‘void QPainterPath::addRoundRect(const QRectF&, int, int)’ is deprecated: Use addRoundedRect(..., Qt::RelativeSize) instead [-Wdeprecated-declarations] painting/qpainterpath.cpp:3366:47: warning: ‘void QPainterPath::addRoundRect(const QRectF&, int)’ is deprecated: Use addRoundedRect(..., Qt::RelativeSize) instead [-Wdeprecated-declarations] painting/qpainter.cpp:4233:49: warning: ‘void QPainter::drawRoundRect(const QRectF&, int, int)’ is deprecated: Use drawRoundedRect(..., Qt::RelativeSize) instead [-Wdeprecated-declarations] painting/qpainter.cpp:8349:27: warning: ‘void QPainter::setMatrixEnabled(bool)’ is deprecated: Use setWorldMatrixEnabled() instead [-Wdeprecated-declarations] painting/qpdf.cpp:1545:28: warning: ‘void QDataStream::unsetDevice()’ is deprecated: Use QDataStream::setDevice(nullptr) instead [-Wdeprecated-declarations] widgets/qtabbar.cpp:2096:17: warning: ‘void QPainter::initFrom(const QPaintDevice*)’ is deprecated: Use begin(QPaintDevice*) instead [-Wdeprecated-declarations] Change-Id: I76d98ea8146e7586d3763a5610781c7736d37204 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
* Merge remote-tracking branch 'origin/5.11' into 5.12Liang Qi2018-11-091-1/+0
|\ | | | | | | | | | | | | | | | | | | Conflicts: .qmake.conf qmake/Makefile.unix src/gui/text/qtextdocument.cpp src/gui/text/qtextdocument.h Change-Id: Iba26da0ecbf2aa4ff4b956391cfb373f977f88c9
| * Modernize the "textcodec" featureLiang Qi2018-11-071-1/+0
| | | | | | | | | | | | | | | | | | Also clean up QTextCodec usage in qmake build and some includes of qtextcodec.h. Change-Id: I0475b82690024054add4e85a8724c8ea3adcf62a Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
* | QTextDocumentFragment: Use logical cursor movement instead of visualSafa AlFulaij2018-07-311-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Using QTextCursor::Left and QTextCursor::Right moves the cursor visually to right or left, which does not work with Right to left text, where moving left means advancing to the next character, and vice versa. By using QTextCursor::PreviousCharacter and QTextCursor::NextCharacter we leave it up to the engine for deciding where to move depending on the context. Task-number: QTBUG-50619 Change-Id: Ibf0a886f3ff6bf9ca2c953aeff8c235612bbc01d Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
* | preserve HTML heading level in QTextBlockFormat; demonstrate in exampleShawn Rutledge2018-03-021-1/+35
|/ | | | | | | | | | | | | | | | | | When reading an HTML file with <H1> for example, we still set the font size as before (that's how it always was done), but now it remembers that it came from an H1 tag, so it writes <h1 ...><span font-size:xx-large ...> ... rather than <p ...><span ...> ... This will help with the upcoming Markdown format, where heading level is saved but the font is not. Now the style combobox in examples/widgets/richtext/textedit can set list item type, heading type or "standard" formatting, and also shows the current formatting of the line that has the cursor. It was always a shortcoming in this example that it only allowed setting the current line's block format but had no feedback to show the current format. Change-Id: I0a7849b74f23fea84d3375c487c3a6b9f43240c1 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QTextDocument: improve import of DIV tagsDavid Faure2017-04-101-3/+7
| | | | | | | | | | | | <div>1<br/></div>2 was inserting two newlines between 1 and 2, while all tested web browsers only insert one newline - as long as there is nothing between the <br/> and the </div>. This was the cause for extra newlines being inserted in KMail when replying to HTML emails, such as those generated by gmail. Change-Id: I5145d977701e68913264357bba22780e7cdd3f7d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Fix warning for -no-feature-texthtmlparserStephan Binner2017-04-041-2/+2
| | | | | | Change-Id: I6dd6e80a546a76ce3717855ebacb188254fe70d6 Reviewed-by: Tasuku Suzuki <tasuku.suzuki@qt.io> Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
* Support C++17 fallthrough attributeAllan Sandfeld Jensen2016-08-191-1/+1
| | | | | | | | | Replaces our mix of comments for annotating intended absence of break in switches with the C++17 attribute [[fallthrough]], or its earlier a clang extension counterpart. Change-Id: I4b2d0b9b5e4425819c7f1bf01608093c536b6d14 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Optimize string usageAnton Kudryavtsev2016-07-151-1/+1
| | | | | | | | Use QStringBuilder more. Use QL1S directly, without QString construction. Change-Id: Iad844391367681fc1013b9725403d009e7c346e6 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Gui: use const (and const APIs) moreAnton Kudryavtsev2016-06-011-3/+3
| | | | | | | For CoW types, prefer const methods to avoid needless detach()ing. Change-Id: I88d08d499e1be72c1f6d983fecdcee513df18aa2 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QtGui: eradicate Q_FOREACH loops [const-& returns]Marc Mutz2016-02-111-3/+6
| | | | | | | | | | | ... by replacing them with C++11 range-for loops. The function QObject::children() returns by const-reference, so they can be passed to range-for without further changes. Change-Id: I8cd2921165c45020914dd3a23b1f18b519fe7900 Reviewed-by: Gunnar Sletta <gunnar@sletta.org> Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* QtGui: eradicate Q_FOREACH loops [needing qAsConst()]Marc Mutz2016-02-111-1/+1
| | | | | | | | | | ... by replacing them with C++11 range-for loops. To avoid detaches of these mutable Qt containers, wrap the container in qAsConst(). Change-Id: I90fd517ad542ef92034403c15ebb8300a56ac693 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com> Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
* Updated license headersJani Heikkinen2016-01-151-14/+20
| | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: I046ec3e47b1876cd7b4b0353a576b352e3a946d9 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Update copyright headersJani Heikkinen2015-02-111-7/+7
| | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Outdated header.LGPL removed (use header.LGPL21 instead) Old header.LGPL3 renamed to header.LGPL3-COMM to match actual licensing combination. New header.LGPL-COMM taken in the use file which were using old header.LGPL3 (src/plugins/platforms/android/extract.cpp) Added new header.LGPL3 containing Commercial + LGPLv3 + GPLv2 license combination Change-Id: I6f49b819a8a20cc4f88b794a8f6726d975e8ffbe Reviewed-by: Matti Paaso <matti.paaso@theqtcompany.com>
* Update license headers and add new license filesMatti Paaso2014-09-241-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2 Reviewed-by: Iikka Eklund <iikka.eklund@digia.com>
* Restore -qt-block-indent on <li> elementsAllan Sandfeld Jensen2014-09-181-1/+1
| | | | | | Task-number: QTBUG-20877 Change-Id: If049065ed99eaf8ffc85c8ff54d3da892a095795 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
* Support empty inline elements in block tags in QTextDocumentEskil Abrahamsen Blomfeldt2014-02-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes the following case: <blockquote> <span />Foobar </blockquote> Qt would see the end of <span>, and consider the current block tag as closed, thus resetting the block format, thus losing the margin set for the current block (due to blockquote). If you do <blockquote> <span>Foo</span>Foobar </blockquote> instead, then the same would not happen, since hasBlock is set to false when we append text to the current inline node. [ChangeLog][QTextDocument] Add support for empty inline elements in block tags. Task-number: QTBUG-33336 Change-Id: Ic566edfec96cb8d44d1c02932bb195bc921d1580 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Doc: Adding mark-up to boolean default values.Jerome Pasion2013-10-081-1/+1
| | | | | | | | | | | | | | | | | Default values should have mark-up to denote that they are code. This commit changes: -"property is true" to "property is \c true". -"Returns true" to "Returns \c true". -"property is false" to "property is \c false". -"returns true" to "returns \c true". -"returns false" to "returns \c false". src/3rdparty and non-documentation instances were ignored. Task-number: QTBUG-33360 Change-Id: Ie87eaa57af947caa1230602b61c5c46292a4cf4e Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
* Update copyright year in Digia's license headersSergio Ahumada2013-01-181-1/+1
| | | | | Change-Id: Ic804938fc352291d011800d21e549c10acac66fb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Change copyrights from Nokia to DigiaIikka Eklund2012-09-221-24/+24
| | | | | | | | Change copyrights and license headers from Nokia to Digia Change-Id: If1cc974286d29fd01ec6c19dd4719a67f4c3f00e Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
* Get started with patching up the Qt GUI docsGunnar Sletta2012-06-281-0/+1
| | | | | | | | Primary goal, make the front page of the Qt GUI module a bit more clarifying and avoid downstream references inside the Qt GUI docs. Change-Id: Icbcfbb64b93963add889bf83711daa9575885c02 Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
* Doc: Fix \sa usageMarius Storm-Olsen2012-05-111-1/+1
| | | | | | | | | Ensure comma between elements (757 missing), single space and curly- braces around title elements, etc. Change-Id: Id16c3fda7fc47a12a0682f8720214f4990609a97 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Casper van Donderen <casper.vandonderen@nokia.com>
* Remove "All rights reserved" line from license headers.Jason McDonald2012-01-301-1/+1
| | | | | | | | | | As in the past, to avoid rewriting various autotests that contain line-number information, an extra blank line has been inserted at the end of the license text to ensure that this commit does not change the total number of lines in the license header. Change-Id: I311e001373776812699d6efc045b5f742890c689 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Update contact information in license headers.Jason McDonald2012-01-231-1/+1
| | | | | | | Replace Nokia contact email address with Qt Project website. Change-Id: I431bbbf76d7c27d8b502f87947675c116994c415 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Update copyright year in license headers.Jason McDonald2012-01-051-1/+1
| | | | | Change-Id: I02f2c620296fcd91d4967d58767ea33fc4e1e7dc Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Merge QTextDocumentFragment::toHtml() overload per Qt 5 comment.Robin Burchell2011-12-271-10/+0
| | | | | Change-Id: Ic8850684c2298b996354e27cc96ad6486d7a3679 Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
* Fix empty lines in Qt HTML when displayed in external browsers (again)Eskil Abrahamsen Blomfeldt2011-06-201-2/+7
| | | | | | | | | | | | | | | | | This redoes f541c78e1bc5b293466b40e6f10496199a4a5d73 in a way which should be more compliant with different browsers. In particular, Outlook didn't support the CSS trick in the last fix, so we need the somewhat larger patch which adds an extra line break node to the tree and then ignores it when re-importing the document. Task-number: QTBUG-3669 Reviewed-by: Simon Hausmann (cherry picked from commit cb760eaef631abd49836ae5c8dc12a61ef5eff0d) Change-Id: Ia55bf39d52461aa9445a9a5d0bfb5b4c5bf1e9bd Reviewed-on: http://codereview.qt.nokia.com/492 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
* Update licenseheader text in source files for qtbase Qt moduleJyri Tahtela2011-05-241-17/+17
| | | | | | | Updated version of LGPL and FDL licenseheaders. Apply release phase licenseheaders for all source files. Reviewed-by: Trust Me
* Initial import from the monolithic Qt.Qt by Nokia2011-04-271-0/+1224
This is the beginning of revision history for this module. If you want to look at revision history older than this, please refer to the Qt Git wiki for how to use Git history grafting. At the time of writing, this wiki is located here: http://qt.gitorious.org/qt/pages/GitIntroductionWithQt If you have already performed the grafting and you don't see any history beyond this commit, try running "git log" with the "--follow" argument. Branched from the monolithic repo, Qt master branch, at commit 896db169ea224deb96c59ce8af800d019de63f12