diff options
author | Liang Qi <liang.qi@qt.io> | 2017-03-22 07:10:41 +0000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2017-03-22 07:10:41 +0000 |
commit | 495f914fb58251830cc0cedea335e635a2a287c7 (patch) | |
tree | 4c169ed5a45bd8ca77fc4cf646d024b2405ffa69 /src/widgets | |
parent | c9efdfd990b2084b0e0744030be581dba679f6a9 (diff) | |
parent | 65faf4565595d91996ddec4af25af5e97c7f0317 (diff) |
Merge "Merge remote-tracking branch 'origin/5.8' into 5.9" into refs/staging/5.9
Diffstat (limited to 'src/widgets')
-rw-r--r-- | src/widgets/itemviews/qabstractitemview.cpp | 1 | ||||
-rw-r--r-- | src/widgets/widgets/qtoolbox.cpp | 10 | ||||
-rw-r--r-- | src/widgets/widgets/qwidgettextcontrol.cpp | 47 |
3 files changed, 50 insertions, 8 deletions
diff --git a/src/widgets/itemviews/qabstractitemview.cpp b/src/widgets/itemviews/qabstractitemview.cpp index 939e2a3d79..20002b1f82 100644 --- a/src/widgets/itemviews/qabstractitemview.cpp +++ b/src/widgets/itemviews/qabstractitemview.cpp @@ -1703,6 +1703,7 @@ bool QAbstractItemView::viewportEvent(QEvent *event) d->viewportEnteredNeeded = true; break; case QEvent::Leave: + d->setHoverIndex(QModelIndex()); // If we've left, no hover should be needed anymore #ifndef QT_NO_STATUSTIP if (d->shouldClearStatusTip && d->parent) { QString empty; diff --git a/src/widgets/widgets/qtoolbox.cpp b/src/widgets/widgets/qtoolbox.cpp index 2c74b5fa9d..8413827e30 100644 --- a/src/widgets/widgets/qtoolbox.cpp +++ b/src/widgets/widgets/qtoolbox.cpp @@ -117,7 +117,7 @@ public: void _q_buttonClicked(); void _q_widgetDestroyed(QObject*); - const Page *page(QWidget *widget) const; + const Page *page(const QObject *widget) const; const Page *page(int index) const; Page *page(int index); @@ -129,7 +129,7 @@ public: Page *currentPage; }; -const QToolBoxPrivate::Page *QToolBoxPrivate::page(QWidget *widget) const +const QToolBoxPrivate::Page *QToolBoxPrivate::page(const QObject *widget) const { if (!widget) return 0; @@ -449,11 +449,9 @@ void QToolBoxPrivate::relayout() void QToolBoxPrivate::_q_widgetDestroyed(QObject *object) { Q_Q(QToolBox); - // no verification - vtbl corrupted already - QWidget *p = (QWidget*)object; - const QToolBoxPrivate::Page *c = page(p); - if (!p || !c) + const QToolBoxPrivate::Page * const c = page(object); + if (!c) return; layout->removeWidget(c->sv); diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index f5672bd87a..dacb4806ce 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -2052,16 +2052,59 @@ void QWidgetTextControlPrivate::inputMethodEvent(QInputMethodEvent *e) preeditCursor = a.start; hideCursor = !a.length; } else if (a.type == QInputMethodEvent::TextFormat) { - QTextCharFormat f = qvariant_cast<QTextFormat>(a.value).toCharFormat(); + QTextCharFormat f = cursor.charFormat(); + f.merge(qvariant_cast<QTextFormat>(a.value).toCharFormat()); if (f.isValid()) { QTextLayout::FormatRange o; o.start = a.start + cursor.position() - block.position(); o.length = a.length; o.format = f; - overrides.append(o); + + // Make sure list is sorted by start index + QVector<QTextLayout::FormatRange>::iterator it = overrides.end(); + while (it != overrides.begin()) { + QVector<QTextLayout::FormatRange>::iterator previous = it - 1; + if (o.start >= previous->start) { + overrides.insert(it, o); + break; + } + it = previous; + } + + if (it == overrides.begin()) + overrides.prepend(o); } } } + + if (cursor.charFormat().isValid()) { + int start = cursor.position() - block.position(); + int end = start + e->preeditString().length(); + + QVector<QTextLayout::FormatRange>::iterator it = overrides.begin(); + while (it != overrides.end()) { + QTextLayout::FormatRange range = *it; + int rangeStart = range.start; + if (rangeStart > start) { + QTextLayout::FormatRange o; + o.start = start; + o.length = rangeStart - start; + o.format = cursor.charFormat(); + it = overrides.insert(it, o) + 1; + } + + ++it; + start = range.start + range.length; + } + + if (start < end) { + QTextLayout::FormatRange o; + o.start = start; + o.length = end - start; + o.format = cursor.charFormat(); + overrides.append(o); + } + } layout->setFormats(overrides); cursor.endEditBlock(); |