diff options
Diffstat (limited to 'src/widgets')
37 files changed, 375 insertions, 437 deletions
diff --git a/src/widgets/accessible/qaccessiblewidget.cpp b/src/widgets/accessible/qaccessiblewidget.cpp index ae050ac643..796ce42118 100644 --- a/src/widgets/accessible/qaccessiblewidget.cpp +++ b/src/widgets/accessible/qaccessiblewidget.cpp @@ -100,16 +100,14 @@ static QString buddyString(const QWidget *widget) return QString(); } -QString Q_WIDGETS_EXPORT qt_accStripAmp(const QString &text) -{ - return QString(text).remove(QLatin1Char('&')); -} - -QString Q_WIDGETS_EXPORT qt_accHotKey(const QString &text) +/* This function will return the offset of the '&' in the text that would be + preceding the accelerator character. + If this text does not have an accelerator, -1 will be returned. */ +static int qt_accAmpIndex(const QString &text) { #ifndef QT_NO_SHORTCUT if (text.isEmpty()) - return text; + return -1; int fa = 0; QChar ac; @@ -118,23 +116,42 @@ QString Q_WIDGETS_EXPORT qt_accHotKey(const QString &text) if (fa < text.length()) { // ignore "&&" if (text.at(fa) == QLatin1Char('&')) { + ++fa; continue; } else { - ac = text.at(fa); + return fa - 1; break; } } } - if (ac.isNull()) - return QString(); - return QKeySequence(Qt::ALT).toString(QKeySequence::NativeText) + ac.toUpper(); + + return -1; #else Q_UNUSED(text); - return QString(); + return -1; #endif } +QString Q_WIDGETS_EXPORT qt_accStripAmp(const QString &text) +{ + QString newText(text); + int ampIndex = qt_accAmpIndex(newText); + if (ampIndex != -1) + newText.remove(ampIndex, 1); + + return newText.replace(QLatin1String("&&"), QLatin1String("&")); +} + +QString Q_WIDGETS_EXPORT qt_accHotKey(const QString &text) +{ + int ampIndex = qt_accAmpIndex(text); + if (ampIndex != -1) + return (QString)QKeySequence(Qt::ALT) + text.at(ampIndex + 1); + + return QString(); +} + class QAccessibleWidgetPrivate { public: diff --git a/src/widgets/dialogs/qwizard.h b/src/widgets/dialogs/qwizard.h index caa9d5e648..c9d791653b 100644 --- a/src/widgets/dialogs/qwizard.h +++ b/src/widgets/dialogs/qwizard.h @@ -130,7 +130,7 @@ public: void removePage(int id); QWizardPage *page(int id) const; bool hasVisitedPage(int id) const; - QList<int> visitedPages() const; // ### visitedIds()? + QList<int> visitedPages() const; // ### Qt 6: visitedIds()? QList<int> pageIds() const; void setStartId(int id); int startId() const; diff --git a/src/widgets/graphicsview/qgraphicslayoutitem.h b/src/widgets/graphicsview/qgraphicslayoutitem.h index ef391f01a0..38f09743c0 100644 --- a/src/widgets/graphicsview/qgraphicslayoutitem.h +++ b/src/widgets/graphicsview/qgraphicslayoutitem.h @@ -96,13 +96,12 @@ public: QSizeF effectiveSizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const; - virtual void updateGeometry(); //### rename to sizeHintChanged() + virtual void updateGeometry(); QGraphicsLayoutItem *parentLayoutItem() const; void setParentLayoutItem(QGraphicsLayoutItem *parent); bool isLayout() const; - // ###Qt5: Make automatic reparenting work regardless of item/object/widget type. QGraphicsItem *graphicsItem() const; bool ownedByLayout() const; diff --git a/src/widgets/graphicsview/qgraphicswidget.h b/src/widgets/graphicsview/qgraphicswidget.h index e0bb591231..01e3efcc58 100644 --- a/src/widgets/graphicsview/qgraphicswidget.h +++ b/src/widgets/graphicsview/qgraphicswidget.h @@ -171,7 +171,6 @@ public: void dumpFocusChain(); #endif - // ### Qt 5: Disambiguate #ifdef Q_NO_USING_KEYWORD const QObjectList &children() const { return QObject::children(); } #else diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index 95c5edca6f..9b6b2368c9 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -67,15 +67,15 @@ QT_BEGIN_NAMESPACE #ifndef QT_NO_DATASTREAM -QDataStream &operator<<(QDataStream &out, const QHeaderViewPrivate::SectionSpan &span) +QDataStream &operator<<(QDataStream &out, const QHeaderViewPrivate::SectionItem §ion) { - span.write(out); + section.write(out); return out; } -QDataStream &operator>>(QDataStream &in, QHeaderViewPrivate::SectionSpan &span) +QDataStream &operator>>(QDataStream &in, QHeaderViewPrivate::SectionItem §ion) { - span.read(in); + section.read(in); return in; } #endif // QT_NO_DATASTREAM @@ -777,18 +777,18 @@ void QHeaderView::moveSection(int from, int to) //Q_ASSERT(oldHeaderLength == length()); // move sizes - // ### check for spans of section sizes here + // ### check for items of section sizes here if (to > from) { for (visual = from; visual <= to; ++visual) { int size = sizes[visual - from]; ResizeMode mode = modes[visual - from]; - d->createSectionSpan(visual, visual, size, mode); + d->createSectionItems(visual, visual, size, mode); } } else { for (visual = to; visual <= from; ++visual) { int size = sizes[visual - to]; ResizeMode mode = modes[visual - to]; - d->createSectionSpan(visual, visual, size, mode); + d->createSectionItems(visual, visual, size, mode); } } //Q_ASSERT(d->headerLength() == length()); @@ -827,8 +827,8 @@ void QHeaderView::swapSections(int first, int second) ResizeMode secondMode = d->headerSectionResizeMode(second); int secondLogical = d->logicalIndex(second); - d->createSectionSpan(second, second, firstSize, firstMode); - d->createSectionSpan(first, first, secondSize, secondMode); + d->createSectionItems(second, second, firstSize, firstMode); + d->createSectionItems(first, first, secondSize, secondMode); d->initializeIndexMapping(); @@ -886,7 +886,7 @@ void QHeaderView::resizeSection(int logical, int size) if (stretchLastSection() && visual == d->lastVisibleVisualIndex()) d->lastSectionSize = size; - d->createSectionSpan(visual, visual, size, d->headerSectionResizeMode(visual)); + d->createSectionItems(visual, visual, size, d->headerSectionResizeMode(visual)); if (!updatesEnabled()) { if (d->hasAutoResizeSections()) @@ -1707,18 +1707,18 @@ void QHeaderView::sectionsInserted(const QModelIndex &parent, int insertAt = logicalFirst; int insertCount = logicalLast - logicalFirst + 1; - QHeaderViewPrivate::SectionSpan span(d->defaultSectionSize, d->globalResizeMode); + QHeaderViewPrivate::SectionItem section(d->defaultSectionSize, d->globalResizeMode); d->sectionStartposRecalc = true; - if (d->sectionSpans.isEmpty() || insertAt >= d->sectionSpans.count()) { + if (d->sectionItems.isEmpty() || insertAt >= d->sectionItems.count()) { int insertLength = d->defaultSectionSize * insertCount; d->length += insertLength; - d->sectionSpans.insert(d->sectionSpans.count(), insertCount, span); // append + d->sectionItems.insert(d->sectionItems.count(), insertCount, section); // append } else { - // separate them out into their own spans + // separate them out into their own sections int insertLength = d->defaultSectionSize * insertCount; d->length += insertLength; - d->sectionSpans.insert(insertAt, insertCount, span); + d->sectionItems.insert(insertAt, insertCount, section); } // update sorting column @@ -1840,7 +1840,7 @@ void QHeaderViewPrivate::_q_sectionsRemoved(const QModelIndex &parent, if (visualIndices.isEmpty() && logicalIndices.isEmpty()) { //Q_ASSERT(headerSectionCount() == sectionCount); - removeSectionsFromSpans(logicalFirst, logicalLast); + removeSectionsFromSectionItems(logicalFirst, logicalLast); } else { if (logicalFirst == logicalLast) { // Remove just one index. int l = logicalFirst; @@ -1857,21 +1857,21 @@ void QHeaderViewPrivate::_q_sectionsRemoved(const QModelIndex &parent, logicalIndices.remove(visual); visualIndices.remove(l); //Q_ASSERT(headerSectionCount() == sectionCount); - removeSectionsFromSpans(visual, visual); + removeSectionsFromSectionItems(visual, visual); } else { sectionStartposRecalc = true; // We will need to recalc positions after removing items - for (int u = 0; u < sectionSpans.count(); ++u) // Store spans info - sectionSpans.at(u).tmpLogIdx = logicalIndices.at(u); - for (int v = sectionSpans.count() - 1; v >= 0; --v) { // Remove the sections - if (logicalFirst <= sectionSpans.at(v).tmpLogIdx && sectionSpans.at(v).tmpLogIdx <= logicalLast) - removeSectionsFromSpans(v, v); // Invalidates the spans variable + for (int u = 0; u < sectionItems.count(); ++u) // Store section info + sectionItems.at(u).tmpLogIdx = logicalIndices.at(u); + for (int v = sectionItems.count() - 1; v >= 0; --v) { // Remove the sections + if (logicalFirst <= sectionItems.at(v).tmpLogIdx && sectionItems.at(v).tmpLogIdx <= logicalLast) + removeSectionsFromSectionItems(v, v); } - visualIndices.resize(sectionSpans.count()); - logicalIndices.resize(sectionSpans.count()); + visualIndices.resize(sectionItems.count()); + logicalIndices.resize(sectionItems.count()); int* visual_data = visualIndices.data(); int* logical_data = logicalIndices.data(); - for (int w = 0; w < sectionSpans.count(); ++w) { // Restore visual and logical indexes - int logindex = sectionSpans.at(w).tmpLogIdx; + for (int w = 0; w < sectionItems.count(); ++w) { // Restore visual and logical indexes + int logindex = sectionItems.at(w).tmpLogIdx; if (logindex > logicalFirst) logindex -= changeCount; visual_data[logindex] = w; @@ -1993,7 +1993,7 @@ void QHeaderView::initializeSections(int start, int end) if (end + 1 < d->sectionCount()) { int newCount = end + 1; - d->removeSectionsFromSpans(newCount, d->sectionCount() - 1); + d->removeSectionsFromSectionItems(newCount, d->sectionCount() - 1); if (!d->hiddenSectionSize.isEmpty()) { if (oldCount - newCount > d->hiddenSectionSize.count()) { for (int i = end + 1; i < d->sectionCount(); ++i) @@ -2043,7 +2043,7 @@ void QHeaderView::initializeSections(int start, int end) d->sectionHidden.resize(newSectionCount); if (newSectionCount > oldCount) - d->createSectionSpan(start, end, (end - start + 1) * d->defaultSectionSize, d->globalResizeMode); + d->createSectionItems(start, end, (end - start + 1) * d->defaultSectionSize, d->globalResizeMode); //Q_ASSERT(d->headerLength() == d->length); if (d->sectionCount() != oldCount) @@ -2212,14 +2212,14 @@ void QHeaderView::paintEvent(QPaintEvent *e) } #if 0 - // ### visualize section spans - for (int a = 0, i = 0; i < d->sectionSpans.count(); ++i) { + // ### visualize sections + for (int a = 0, i = 0; i < d->sectionItems.count(); ++i) { QColor color((i & 4 ? 255 : 0), (i & 2 ? 255 : 0), (i & 1 ? 255 : 0)); if (d->orientation == Qt::Horizontal) - painter.fillRect(a - d->offset, 0, d->sectionSpans.at(i).size, 4, color); + painter.fillRect(a - d->offset, 0, d->sectionItems.at(i).size, 4, color); else - painter.fillRect(0, a - d->offset, 4, d->sectionSpans.at(i).size, color); - a += d->sectionSpans.at(i).size; + painter.fillRect(0, a - d->offset, 4, d->sectionItems.at(i).size, color); + a += d->sectionItems.at(i).size; } #endif @@ -3096,6 +3096,7 @@ void QHeaderViewPrivate::resizeSections(QHeaderView::ResizeMode globalMode, bool pixelReminder = lengthToStrech % numberOfStretchedSections; } + // ### The code below would be nicer if it was cleaned up a bit (since spans has been replaced with items) int spanStartSection = 0; int previousSectionLength = 0; @@ -3137,7 +3138,7 @@ void QHeaderViewPrivate::resizeSections(QHeaderView::ResizeMode globalMode, bool if ((previousSectionResizeMode != newSectionResizeMode || previousSectionLength != newSectionLength) && i > 0) { int spanLength = (i - spanStartSection) * previousSectionLength; - createSectionSpan(spanStartSection, i - 1, spanLength, previousSectionResizeMode); + createSectionItems(spanStartSection, i - 1, spanLength, previousSectionResizeMode); //Q_ASSERT(headerLength() == length); spanStartSection = i; } @@ -3149,7 +3150,7 @@ void QHeaderViewPrivate::resizeSections(QHeaderView::ResizeMode globalMode, bool previousSectionResizeMode = newSectionResizeMode; } - createSectionSpan(spanStartSection, sectionCount() - 1, + createSectionItems(spanStartSection, sectionCount() - 1, (sectionCount() - spanStartSection) * previousSectionLength, previousSectionResizeMode); //Q_ASSERT(headerLength() == length); @@ -3157,14 +3158,14 @@ void QHeaderViewPrivate::resizeSections(QHeaderView::ResizeMode globalMode, bool viewport->update(); } -void QHeaderViewPrivate::createSectionSpan(int start, int end, int size, QHeaderView::ResizeMode mode) +void QHeaderViewPrivate::createSectionItems(int start, int end, int size, QHeaderView::ResizeMode mode) { int sizePerSection = size / (end - start + 1); - if (end >= sectionSpans.count()) { - sectionSpans.resize(end + 1); + if (end >= sectionItems.count()) { + sectionItems.resize(end + 1); sectionStartposRecalc = true; } - SectionSpan *sectiondata = sectionSpans.data(); + SectionItem *sectiondata = sectionItems.data(); for (int i = start; i <= end; ++i) { length += (sizePerSection - sectiondata[i].size); sectionStartposRecalc |= (sectiondata[i].size != sizePerSection); @@ -3173,15 +3174,15 @@ void QHeaderViewPrivate::createSectionSpan(int start, int end, int size, QHeader } } -void QHeaderViewPrivate::removeSectionsFromSpans(int start, int end) +void QHeaderViewPrivate::removeSectionsFromSectionItems(int start, int end) { // remove sections - sectionStartposRecalc |= (end != sectionSpans.count() - 1); + sectionStartposRecalc |= (end != sectionItems.count() - 1); int removedlength = 0; for (int u = start; u <= end; ++u) - removedlength += sectionSpans.at(u).size; + removedlength += sectionItems.at(u).size; length -= removedlength; - sectionSpans.remove(start, end - start + 1); + sectionItems.remove(start, end - start + 1); } void QHeaderViewPrivate::clear() @@ -3193,7 +3194,7 @@ void QHeaderViewPrivate::clear() sectionSelected.clear(); sectionHidden.clear(); hiddenSectionSize.clear(); - sectionSpans.clear(); + sectionItems.clear(); } } @@ -3230,7 +3231,7 @@ void QHeaderViewPrivate::cascadingResize(int visual, int newSize) int originalSectionSize = cascadingSectionSize.value(i); if (currentSectionSize < originalSectionSize) { int newSectionSize = currentSectionSize + delta; - resizeSectionSpan(i, currentSectionSize, newSectionSize); + resizeSectionItem(i, currentSectionSize, newSectionSize); if (newSectionSize >= originalSectionSize && false) cascadingSectionSize.remove(i); // the section is now restored sectionResized = true; @@ -3244,7 +3245,7 @@ void QHeaderViewPrivate::cascadingResize(int visual, int newSize) if (!sectionResized) { newSize = qMax(newSize, minimumSize); if (oldSize != newSize) - resizeSectionSpan(visual, oldSize, newSize); + resizeSectionItem(visual, oldSize, newSize); } // cascade the section size change @@ -3256,7 +3257,7 @@ void QHeaderViewPrivate::cascadingResize(int visual, int newSize) continue; int newSectionSize = qMax(currentSectionSize - delta, minimumSize); //qDebug() << "### cascading to" << i << newSectionSize - currentSectionSize << delta; - resizeSectionSpan(i, currentSectionSize, newSectionSize); + resizeSectionItem(i, currentSectionSize, newSectionSize); saveCascadingSectionSize(i, currentSectionSize); delta = delta - (currentSectionSize - newSectionSize); //qDebug() << "new delta" << delta; @@ -3276,7 +3277,7 @@ void QHeaderViewPrivate::cascadingResize(int visual, int newSize) if (currentSectionSize >= originalSectionSize) continue; int newSectionSize = currentSectionSize - delta; - resizeSectionSpan(i, currentSectionSize, newSectionSize); + resizeSectionItem(i, currentSectionSize, newSectionSize); if (newSectionSize >= originalSectionSize && false) { //qDebug() << "section" << i << "restored to" << originalSectionSize; cascadingSectionSize.remove(i); // the section is now restored @@ -3286,7 +3287,7 @@ void QHeaderViewPrivate::cascadingResize(int visual, int newSize) } // resize the section - resizeSectionSpan(visual, oldSize, qMax(newSize, minimumSize)); + resizeSectionItem(visual, oldSize, qMax(newSize, minimumSize)); // cascade the section size change if (delta < 0 && newSize < minimumSize) { @@ -3296,7 +3297,7 @@ void QHeaderViewPrivate::cascadingResize(int visual, int newSize) int sectionSize = headerSectionSize(i); if (sectionSize <= minimumSize) continue; - resizeSectionSpan(i, sectionSize, qMax(sectionSize + delta, minimumSize)); + resizeSectionItem(i, sectionSize, qMax(sectionSize + delta, minimumSize)); saveCascadingSectionSize(i, sectionSize); break; } @@ -3309,7 +3310,7 @@ void QHeaderViewPrivate::cascadingResize(int visual, int newSize) continue; int currentSectionSize = headerSectionSize(i); int newSectionSize = qMax(currentSectionSize - delta, minimumSize); - resizeSectionSpan(i, currentSectionSize, newSectionSize); + resizeSectionItem(i, currentSectionSize, newSectionSize); break; } } @@ -3325,14 +3326,14 @@ void QHeaderViewPrivate::setDefaultSectionSize(int size) { Q_Q(QHeaderView); defaultSectionSize = size; - for (int i = 0; i < sectionSpans.count(); ++i) { - QHeaderViewPrivate::SectionSpan &span = sectionSpans[i]; + for (int i = 0; i < sectionItems.count(); ++i) { + QHeaderViewPrivate::SectionItem §ion = sectionItems[i]; if (sectionHidden.isEmpty() || !sectionHidden.testBit(i)) { // resize on not hidden. const int newSize = size; - if (newSize != span.size) { - length += newSize - span.size; //the whole length is changed - const int oldSectionSize = span.sectionSize(); - span.size = size; + if (newSize != section.size) { + length += newSize - section.size; //the whole length is changed + const int oldSectionSize = section.sectionSize(); + section.size = size; emit q->sectionResized(logicalIndex(i), oldSectionSize, size); } } @@ -3342,25 +3343,25 @@ void QHeaderViewPrivate::setDefaultSectionSize(int size) void QHeaderViewPrivate::recalcSectionStartPos() const // linear (but fast) { int pixelpos = 0; - for (QVector<SectionSpan>::const_iterator i = sectionSpans.constBegin(); i != sectionSpans.constEnd(); ++i) { + for (QVector<SectionItem>::const_iterator i = sectionItems.constBegin(); i != sectionItems.constEnd(); ++i) { i->calculated_startpos = pixelpos; // write into const mutable pixelpos += i->size; } sectionStartposRecalc = false; } -void QHeaderViewPrivate::resizeSectionSpan(int visualIndex, int oldSize, int newSize) +void QHeaderViewPrivate::resizeSectionItem(int visualIndex, int oldSize, int newSize) { Q_Q(QHeaderView); QHeaderView::ResizeMode mode = headerSectionResizeMode(visualIndex); - createSectionSpan(visualIndex, visualIndex, newSize, mode); + createSectionItems(visualIndex, visualIndex, newSize, mode); emit q->sectionResized(logicalIndex(visualIndex), oldSize, newSize); } int QHeaderViewPrivate::headerSectionSize(int visual) const { if (visual < sectionCount() && visual >= 0) - return sectionSpans.at(visual).sectionSize(); + return sectionItems.at(visual).sectionSize(); return -1; } @@ -3369,7 +3370,7 @@ int QHeaderViewPrivate::headerSectionPosition(int visual) const if (visual < sectionCount() && visual >= 0) { if (sectionStartposRecalc) recalcSectionStartPos(); - return sectionSpans.at(visual).calculated_startpos; + return sectionItems.at(visual).calculated_startpos; } return -1; } @@ -3379,13 +3380,13 @@ int QHeaderViewPrivate::headerVisualIndexAt(int position) const if (sectionStartposRecalc) recalcSectionStartPos(); int startidx = 0; - int endidx = sectionSpans.count() - 1; + int endidx = sectionItems.count() - 1; while (startidx <= endidx) { int middle = (endidx + startidx) / 2; - if (sectionSpans.at(middle).calculated_startpos > position) { + if (sectionItems.at(middle).calculated_startpos > position) { endidx = middle - 1; } else { - if (sectionSpans.at(middle).calculatedEndPos() <= position) + if (sectionItems.at(middle).calculatedEndPos() <= position) startidx = middle + 1; else // we found it. return middle; @@ -3397,22 +3398,21 @@ int QHeaderViewPrivate::headerVisualIndexAt(int position) const void QHeaderViewPrivate::setHeaderSectionResizeMode(int visual, QHeaderView::ResizeMode mode) { int size = headerSectionSize(visual); - createSectionSpan(visual, visual, size, mode); + createSectionItems(visual, visual, size, mode); } QHeaderView::ResizeMode QHeaderViewPrivate::headerSectionResizeMode(int visual) const { - int span = sectionSpanIndex(visual); - if (span == -1) + if (visual < 0 || visual >= sectionItems.count()) return globalResizeMode; - return sectionSpans.at(span).resizeMode; + return sectionItems.at(visual).resizeMode; } void QHeaderViewPrivate::setGlobalHeaderResizeMode(QHeaderView::ResizeMode mode) { globalResizeMode = mode; - for (int i = 0; i < sectionSpans.count(); ++i) - sectionSpans[i].resizeMode = mode; + for (int i = 0; i < sectionItems.count(); ++i) + sectionItems[i].resizeMode = mode; } int QHeaderViewPrivate::viewSectionSizeHint(int logical) const @@ -3430,7 +3430,7 @@ int QHeaderViewPrivate::adjustedVisualIndex(int visualIndex) const if (!sectionHidden.isEmpty()) { int adjustedVisualIndex = visualIndex; int currentVisualIndex = 0; - for (int i = 0; i < sectionSpans.count(); ++i) { + for (int i = 0; i < sectionItems.count(); ++i) { if (sectionHidden.testBit(i)) ++adjustedVisualIndex; else @@ -3472,7 +3472,7 @@ void QHeaderViewPrivate::write(QDataStream &out) const out << int(defaultAlignment); out << int(globalResizeMode); - out << sectionSpans; + out << sectionItems; } bool QHeaderViewPrivate::read(QDataStream &in) @@ -3512,15 +3512,17 @@ bool QHeaderViewPrivate::read(QDataStream &in) in >> global; globalResizeMode = (QHeaderView::ResizeMode)global; - in >> sectionSpans; - // Spans in Qt5 only contains one element - but for backward compability with Qt4 we do the following - QVector<SectionSpan> newSectionSpans; - for (int u = 0; u < sectionSpans.count(); ++u) { - int count = sectionSpans.at(u).tmpDataStreamSectionCount; + in >> sectionItems; + // In Qt4 we had a vector of spans where one span could hold information on more sections. + // Now we have an itemvector where one items contains information about one section + // For backward compability with Qt4 we do the following + QVector<SectionItem> newSectionItems; + for (int u = 0; u < sectionItems.count(); ++u) { + int count = sectionItems.at(u).tmpDataStreamSectionCount; for (int n = 0; n < count; ++n) - newSectionSpans.append(sectionSpans[u]); + newSectionItems.append(sectionItems[u]); } - sectionSpans = newSectionSpans; + sectionItems = newSectionItems; recalcSectionStartPos(); return true; } diff --git a/src/widgets/itemviews/qheaderview_p.h b/src/widgets/itemviews/qheaderview_p.h index a2b0ef2180..cca81b0c22 100644 --- a/src/widgets/itemviews/qheaderview_p.h +++ b/src/widgets/itemviews/qheaderview_p.h @@ -141,7 +141,7 @@ public: else sectionSelected.fill(false); } - inline int sectionCount() const {return sectionSpans.count();} + inline int sectionCount() const {return sectionItems.count();} inline bool reverse() const { return orientation == Qt::Horizontal && q_func()->isRightToLeft(); @@ -195,7 +195,7 @@ public: } inline void clearCascadingSections() { - firstCascadingSection = sectionSpans.count(); + firstCascadingSection = sectionItems.count(); lastCascadingSection = 0; cascadingSectionSize.clear(); } @@ -283,9 +283,9 @@ public: QHeaderView::ResizeMode globalResizeMode; QList<QPersistentModelIndex> persistentHiddenSections; mutable bool sectionStartposRecalc; - // header section spans + // header sections - struct SectionSpan { + struct SectionItem { int size; union { // This union is made in order to save space and ensure good vector performance (on remove) mutable int calculated_startpos; // <- this is the primary used member. @@ -293,8 +293,8 @@ public: int tmpDataStreamSectionCount; // recalcSectionStartPos() or set sectionStartposRecalc to true }; // to ensure that calculated_startpos will be calculated afterwards. QHeaderView::ResizeMode resizeMode; - inline SectionSpan() : size(0), resizeMode(QHeaderView::Interactive) {} - inline SectionSpan(int length, QHeaderView::ResizeMode mode) + inline SectionItem() : size(0), resizeMode(QHeaderView::Interactive) {} + inline SectionItem(int length, QHeaderView::ResizeMode mode) : size(length), calculated_startpos(-1), resizeMode(mode) {} inline int sectionSize() const { return size; } inline int calculatedEndPos() const { return calculated_startpos + size; } @@ -306,39 +306,21 @@ public: #endif }; - QVector<SectionSpan> sectionSpans; + QVector<SectionItem> sectionItems; - void createSectionSpan(int start, int end, int size, QHeaderView::ResizeMode mode); - void removeSectionsFromSpans(int start, int end); - void resizeSectionSpan(int visualIndex, int oldSize, int newSize); + void createSectionItems(int start, int end, int size, QHeaderView::ResizeMode mode); + void removeSectionsFromSectionItems(int start, int end); + void resizeSectionItem(int visualIndex, int oldSize, int newSize); void setDefaultSectionSize(int size); void recalcSectionStartPos() const; // not really const - inline int headerSectionCount() const { // for debugging - return sectionSpans.count(); - } - inline int headerLength() const { // for debugging int len = 0; - for (int i = 0; i < sectionSpans.count(); ++i) - len += sectionSpans.at(i).size; + for (int i = 0; i < sectionItems.count(); ++i) + len += sectionItems.at(i).size; return len; } - inline void removeSpans(const QList<int> &spans) { - for (int i = spans.count() - 1; i >= 0; --i) { - length -= sectionSpans.at(spans.at(i)).size; - sectionSpans.remove(spans.at(i)); - } - } - - inline int sectionSpanIndex(int visual) const { - if (visual < sectionSpans.count() && visual >= 0) { - return visual; - } - return -1; - } - int headerSectionSize(int visual) const; int headerSectionPosition(int visual) const; int headerVisualIndexAt(int position) const; diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index b910d21cb8..ee4f9bd6bb 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -440,8 +440,6 @@ FontHash *qt_app_fonts_hash() QWidgetList *QApplicationPrivate::popupWidgets = 0; // has keyboard input focus QDesktopWidget *qt_desktopWidget = 0; // root window widgets -QWidgetList * qt_modal_stack = 0; // stack of modal widgets -bool app_do_modal = false; /*! \internal @@ -743,7 +741,8 @@ QWidget *QApplication::activePopupWidget() QWidget *QApplication::activeModalWidget() { - return qt_modal_stack && !qt_modal_stack->isEmpty() ? qt_modal_stack->first() : 0; + QWidgetWindow *widgetWindow = qobject_cast<QWidgetWindow *>(modalWindow()); + return widgetWindow ? widgetWindow->widget() : 0; } /*! @@ -2303,31 +2302,52 @@ Q_WIDGETS_EXPORT bool qt_tryModalHelper(QWidget *widget, QWidget **rettop) bool QApplicationPrivate::isBlockedByModal(QWidget *widget) { widget = widget->window(); - if (!modalState()) + return self->isWindowBlocked(widget->windowHandle()); +} + +bool QApplicationPrivate::isWindowBlocked(QWindow *window, QWindow **blockingWindow) const +{ + QWindow *unused = 0; + if (!blockingWindow) + blockingWindow = &unused; + + if (modalWindowList.isEmpty()) { + *blockingWindow = 0; return false; - if (QApplication::activePopupWidget() == widget) + } + QWidget *popupWidget = QApplication::activePopupWidget(); + QWindow *popupWindow = popupWidget ? popupWidget->windowHandle() : 0; + if (popupWindow == window) { + *blockingWindow = 0; return false; + } - for (int i = 0; i < qt_modal_stack->size(); ++i) { - QWidget *modalWidget = qt_modal_stack->at(i); + for (int i = 0; i < modalWindowList.count(); ++i) { + QWindow *modalWindow = modalWindowList.at(i); { - // check if the active modal widget is our widget or a parent of our widget - QWidget *w = widget; + // check if the modal window is our window or a (transient) parent of our window + QWindow *w = window; while (w) { - if (w == modalWidget) + if (w == modalWindow) { + *blockingWindow = 0; return false; - w = w->parentWidget(); + } + QWindow *p = w->parent(); + if (!p) + p = w->transientParent(); + w = p; } } - Qt::WindowModality windowModality = modalWidget->windowModality(); + Qt::WindowModality windowModality = modalWindow->windowModality(); + QWidgetWindow *modalWidgetWindow = qobject_cast<QWidgetWindow *>(modalWindow); if (windowModality == Qt::NonModal) { // determine the modality type if it hasn't been set on the - // modalWidget, this normally happens when waiting for a - // native dialog. use WindowModal if we are the child of a - // group leader; otherwise use ApplicationModal. - QWidget *m = modalWidget; + // modalWindow's widget, this normally happens when waiting for a + // native dialog. use WindowModal if we are the child of a group + // leader; otherwise use ApplicationModal. + QWidget *m = modalWidgetWindow ? modalWidgetWindow->widget() : 0; while (m && !m->testAttribute(Qt::WA_GroupLeader)) { m = m->parentWidget(); if (m) @@ -2340,98 +2360,59 @@ bool QApplicationPrivate::isBlockedByModal(QWidget *widget) switch (windowModality) { case Qt::ApplicationModal: - { - QWidget *groupLeaderForWidget = widget; - while (groupLeaderForWidget && !groupLeaderForWidget->testAttribute(Qt::WA_GroupLeader)) - groupLeaderForWidget = groupLeaderForWidget->parentWidget(); - - if (groupLeaderForWidget) { - // if \a widget has WA_GroupLeader, it can only be blocked by ApplicationModal children - QWidget *m = modalWidget; - while (m && m != groupLeaderForWidget && !m->testAttribute(Qt::WA_GroupLeader)) - m = m->parentWidget(); - if (m == groupLeaderForWidget) - return true; - } else if (modalWidget != widget) { + { + QWidgetWindow *widgetWindow = qobject_cast<QWidgetWindow *>(window); + QWidget *groupLeaderForWidget = widgetWindow ? widgetWindow->widget() : 0; + while (groupLeaderForWidget && !groupLeaderForWidget->testAttribute(Qt::WA_GroupLeader)) + groupLeaderForWidget = groupLeaderForWidget->parentWidget(); + + if (groupLeaderForWidget) { + // if \a widget has WA_GroupLeader, it can only be blocked by ApplicationModal children + QWidget *m = modalWidgetWindow ? modalWidgetWindow->widget() : 0; + while (m && m != groupLeaderForWidget && !m->testAttribute(Qt::WA_GroupLeader)) + m = m->parentWidget(); + if (m == groupLeaderForWidget) { + *blockingWindow = m->windowHandle(); return true; } - break; + } else if (modalWindow != window) { + *blockingWindow = modalWindow; + return true; } + break; + } case Qt::WindowModal: - { - QWidget *w = widget; + { + QWindow *w = window; + do { + QWindow *m = modalWindow; do { - QWidget *m = modalWidget; - do { - if (m == w) - return true; - m = m->parentWidget(); - if (m) - m = m->window(); - } while (m); - w = w->parentWidget(); - if (w) - w = w->window(); - } while (w); - break; - } + if (m == w) { + *blockingWindow = m; + return true; + } + QWindow *p = m->parent(); + if (!p) + p = m->transientParent(); + m = p; + } while (m); + QWindow *p = w->parent(); + if (!p) + p = w->transientParent(); + w = p; + } while (w); + break; + } default: - Q_ASSERT_X(false, "QApplication", "internal error, a modal widget cannot be modeless"); + Q_ASSERT_X(false, "QApplication", "internal error, a modal window cannot be modeless"); break; } } + *blockingWindow = 0; return false; } /*!\internal - */ -void QApplicationPrivate::enterModal(QWidget *widget) -{ - QSet<QWidget*> blocked; - QList<QWidget*> windows = QApplication::topLevelWidgets(); - for (int i = 0; i < windows.count(); ++i) { - QWidget *window = windows.at(i); - if (window->windowType() != Qt::Tool && isBlockedByModal(window)) - blocked.insert(window); - } - - enterModal_sys(widget); - - windows = QApplication::topLevelWidgets(); - QEvent e(QEvent::WindowBlocked); - for (int i = 0; i < windows.count(); ++i) { - QWidget *window = windows.at(i); - if (!blocked.contains(window) && window->windowType() != Qt::Tool && isBlockedByModal(window)) - QApplication::sendEvent(window, &e); - } -} - -/*!\internal - */ -void QApplicationPrivate::leaveModal(QWidget *widget) -{ - QSet<QWidget*> blocked; - QList<QWidget*> windows = QApplication::topLevelWidgets(); - for (int i = 0; i < windows.count(); ++i) { - QWidget *window = windows.at(i); - if (window->windowType() != Qt::Tool && isBlockedByModal(window)) - blocked.insert(window); - } - - leaveModal_sys(widget); - - windows = QApplication::topLevelWidgets(); - QEvent e(QEvent::WindowUnblocked); - for (int i = 0; i < windows.count(); ++i) { - QWidget *window = windows.at(i); - if(blocked.contains(window) && window->windowType() != Qt::Tool && !isBlockedByModal(window)) - QApplication::sendEvent(window, &e); - } -} - - - -/*!\internal Called from qapplication_\e{platform}.cpp, returns true if the widget should accept the event. diff --git a/src/widgets/kernel/qapplication.h b/src/widgets/kernel/qapplication.h index 7a57a913bd..206692e6d4 100644 --- a/src/widgets/kernel/qapplication.h +++ b/src/widgets/kernel/qapplication.h @@ -173,8 +173,6 @@ public: static bool isEffectEnabled(Qt::UIEffect); static void setEffectEnabled(Qt::UIEffect, bool enable = true); - static QPlatformNativeInterface *platformNativeInterface(); - #ifndef QT_NO_SESSIONMANAGER // session management bool isSessionRestored() const; diff --git a/src/widgets/kernel/qapplication_p.h b/src/widgets/kernel/qapplication_p.h index 74af3bca6d..8f67a29d84 100644 --- a/src/widgets/kernel/qapplication_p.h +++ b/src/widgets/kernel/qapplication_p.h @@ -198,10 +198,7 @@ public: static void dispatchEnterLeave(QWidget *enter, QWidget *leave); //modality - static void enterModal(QWidget*); - static void leaveModal(QWidget*); - static void enterModal_sys(QWidget*); - static void leaveModal_sys(QWidget*); + Q_DECL_OVERRIDE bool isWindowBlocked(QWindow *window, QWindow **blockingWindow = 0) const; static bool isBlockedByModal(QWidget *widget); static bool modalState(); static bool tryModalHelper(QWidget *widget, QWidget **rettop = 0); @@ -279,10 +276,6 @@ public: static bool widgetCount; // Coupled with -widgetcount switch static bool load_testability; // Coupled with -testability switch -#ifdef Q_WS_MAC - static bool native_modal_dialog_active; -#endif - static void setSystemPalette(const QPalette &pal); static void setPalette_helper(const QPalette &palette, const char* className, bool clearWidgetPaletteHash); static void initializeWidgetPaletteHash(); diff --git a/src/widgets/kernel/qapplication_qpa.cpp b/src/widgets/kernel/qapplication_qpa.cpp index 74a299ba54..0651d5bf44 100644 --- a/src/widgets/kernel/qapplication_qpa.cpp +++ b/src/widgets/kernel/qapplication_qpa.cpp @@ -75,8 +75,6 @@ QT_BEGIN_NAMESPACE static QString appName; static QString appFont; static bool popupGrabOk; -extern bool app_do_modal; -extern QWidgetList *qt_modal_stack; extern QWidget *qt_button_down; extern QWidget *qt_popup_down; extern bool qt_replay_popup_mouse_event; @@ -126,28 +124,9 @@ bool qt_try_modal(QWidget *widget, QEvent::Type type) return !block_event; } -void QApplicationPrivate::enterModal_sys(QWidget *widget) -{ - if (!qt_modal_stack) - qt_modal_stack = new QWidgetList; - qt_modal_stack->insert(0, widget); - app_do_modal = true; -} - -void QApplicationPrivate::leaveModal_sys(QWidget *widget) -{ - if (qt_modal_stack && qt_modal_stack->removeAll(widget)) { - if (qt_modal_stack->isEmpty()) { - delete qt_modal_stack; - qt_modal_stack = 0; - } - } - app_do_modal = qt_modal_stack != 0; -} - bool QApplicationPrivate::modalState() { - return app_do_modal; + return !self->modalWindowList.isEmpty(); } QWidget *qt_tlw_for_window(QWindow *wnd) @@ -453,12 +432,6 @@ void QApplication::alert(QWidget *, int) { } -QPlatformNativeInterface *QApplication::platformNativeInterface() -{ - QPlatformIntegration *pi = QGuiApplicationPrivate::platformIntegration(); - return pi->nativeInterface(); -} - void qt_init(QApplicationPrivate *priv, int type) { Q_UNUSED(priv); diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 3ab777ad60..648b78dbf6 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -2137,7 +2137,15 @@ void QWidgetPrivate::paintBackground(QPainter *painter, const QRegion &rgn, int if ((flags & DrawAsRoot) && !(q->autoFillBackground() && autoFillBrush.isOpaque())) { const QBrush bg = q->palette().brush(QPalette::Window); - fillRegion(painter, rgn, bg); + if (!(flags & DontSetCompositionMode)) { + //copy alpha straight in + QPainter::CompositionMode oldMode = painter->compositionMode(); + painter->setCompositionMode(QPainter::CompositionMode_Source); + fillRegion(painter, rgn, bg); + painter->setCompositionMode(oldMode); + } else { + fillRegion(painter, rgn, bg); + } } if (q->autoFillBackground()) @@ -5229,6 +5237,8 @@ void QWidgetPrivate::render(QPaintDevice *target, const QPoint &targetOffset, else flags |= DontSubtractOpaqueChildren; + flags |= DontSetCompositionMode; + if (target->devType() == QInternal::Printer) { QPainter p(target); render_helper(&p, targetOffset, paintRegion, renderFlags); @@ -6730,7 +6740,6 @@ void QWidget::setContentsMargins(int left, int top, int right, int bottom) else updateGeometry(); - // ### Qt 5: compat, remove if (isVisible()) { update(); QResizeEvent e(data->crect.size(), data->crect.size()); @@ -7080,12 +7089,6 @@ void QWidgetPrivate::show_helper() QShowEvent showEvent; QApplication::sendEvent(q, &showEvent); - if (!isEmbedded && q->isModal() && q->isWindow()) - // QApplicationPrivate::enterModal *before* show, otherwise the initial - // stacking might be wrong - QApplicationPrivate::enterModal(q); - - show_sys(); if (!isEmbedded && q->windowType() == Qt::Popup) @@ -7141,12 +7144,6 @@ void QWidgetPrivate::hide_helper() if (!isEmbedded && (q->windowType() == Qt::Popup)) qApp->d_func()->closePopup(q); - // Move test modal here. Otherwise, a modal dialog could get - // destroyed and we lose all access to its parent because we haven't - // left modality. (Eg. modal Progress Dialog) - if (!isEmbedded && q->isModal() && q->isWindow()) - QApplicationPrivate::leaveModal(q); - #if defined(Q_WS_WIN) if (q->isWindow() && !(q->windowType() == Qt::Popup) && q->parentWidget() && !q->parentWidget()->isHidden() && q->isActiveWindow()) @@ -10047,9 +10044,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) break; case Qt::WA_ShowModal: if (!on) { - if (isVisible()) - QApplicationPrivate::leaveModal(this); - // reset modality type to Modeless when clearing WA_ShowModal + // reset modality type to NonModal when clearing WA_ShowModal data->window_modality = Qt::NonModal; } else if (data->window_modality == Qt::NonModal) { // determine the modality type if it hasn't been set prior @@ -10067,10 +10062,9 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) data->window_modality = (w && w->testAttribute(Qt::WA_GroupLeader)) ? Qt::WindowModal : Qt::ApplicationModal; - // Some window managers does not allow us to enter modal after the - // window is showing. Therefore, to be consistent, we cannot call - // QApplicationPrivate::enterModal(this) here. The window must be - // hidden before changing modality. + // Some window managers do not allow us to enter modality after the + // window is visible.The window must be hidden before changing the + // windowModality property and then reshown. } if (testAttribute(Qt::WA_WState_Created)) { // don't call setModal_sys() before create_sys() diff --git a/src/widgets/kernel/qwidget.h b/src/widgets/kernel/qwidget.h index cf907e14cd..b7a5e26690 100644 --- a/src/widgets/kernel/qwidget.h +++ b/src/widgets/kernel/qwidget.h @@ -606,7 +606,6 @@ public: QBackingStore *backingStore() const; - void setWindowHandle(QWindow *window); QWindow *windowHandle() const; friend class QDesktopScreenWidget; diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h index 8107b6ca74..d3fcdce6a8 100644 --- a/src/widgets/kernel/qwidget_p.h +++ b/src/widgets/kernel/qwidget_p.h @@ -284,7 +284,8 @@ public: DrawInvisible = 0x08, DontSubtractOpaqueChildren = 0x10, DontDrawOpaqueChildren = 0x20, - DontDrawNativeChildren = 0x40 + DontDrawNativeChildren = 0x40, + DontSetCompositionMode = 0x80 }; enum CloseMode { diff --git a/src/widgets/kernel/qwidget_qpa.cpp b/src/widgets/kernel/qwidget_qpa.cpp index 0f55646958..63c02a557c 100644 --- a/src/widgets/kernel/qwidget_qpa.cpp +++ b/src/widgets/kernel/qwidget_qpa.cpp @@ -440,9 +440,16 @@ static inline QRect positionTopLevelWindow(QRect geometry, const QScreen *screen void QWidgetPrivate::show_sys() { Q_Q(QWidget); + + QWindow *window = q->windowHandle(); + if (q->testAttribute(Qt::WA_DontShowOnScreen)) { invalidateBuffer(q->rect()); q->setAttribute(Qt::WA_Mapped); + if (q->isWindow() && q->windowModality() != Qt::NonModal && window) { + // add our window to the modal window list + QGuiApplicationPrivate::showModalWindow(window); + } return; } @@ -451,7 +458,6 @@ void QWidgetPrivate::show_sys() if (!q->isWindow() && !q->testAttribute(Qt::WA_NativeWindow)) return; - QWindow *window = q->windowHandle(); if (window) { QRect geomRect = q->geometry(); if (q->isWindow()) { @@ -473,9 +479,7 @@ void QWidgetPrivate::show_sys() } invalidateBuffer(q->rect()); - - if (window) - window->setVisible(true); + window->setVisible(true); } } @@ -483,6 +487,17 @@ void QWidgetPrivate::show_sys() void QWidgetPrivate::hide_sys() { Q_Q(QWidget); + + QWindow *window = q->windowHandle(); + + if (q->testAttribute(Qt::WA_DontShowOnScreen) + && q->isWindow() + && q->windowModality() != Qt::NonModal + && window) { + // remove our window from the modal window list + QGuiApplicationPrivate::hideModalWindow(window); + } + deactivateWidgetCleanup(); if (!q->isWindow()) { @@ -497,7 +512,7 @@ void QWidgetPrivate::hide_sys() if (q->testAttribute(Qt::WA_DontShowOnScreen)) { q->setAttribute(Qt::WA_Mapped, false); - } else if (QWindow *window = q->windowHandle()) { + } else if (window) { window->setVisible(false); } } diff --git a/src/widgets/kernel/qwidgetbackingstore.cpp b/src/widgets/kernel/qwidgetbackingstore.cpp index 93c64133d6..2c9ad14bcf 100644 --- a/src/widgets/kernel/qwidgetbackingstore.cpp +++ b/src/widgets/kernel/qwidgetbackingstore.cpp @@ -57,11 +57,6 @@ #include <private/qpaintengine_raster_p.h> #include <private/qgraphicseffect_p.h> -#ifdef Q_WS_QWS -#include <QtGui/qwsmanager_qws.h> -#include <private/qwsmanager_p.h> -#endif - QT_BEGIN_NAMESPACE extern QRegion qt_dirtyRegion(QWidget *); @@ -153,13 +148,6 @@ static void showYellowThing_win(QWidget *widget, const QRegion ®ion, int msec void QWidgetBackingStore::showYellowThing(QWidget *widget, const QRegion &toBePainted, int msec, bool unclipped) { -#ifdef Q_WS_QWS - Q_UNUSED(widget); - Q_UNUSED(unclipped); - static QWSYellowSurface surface(true); - surface.setDelay(msec); - surface.flush(widget, toBePainted, QPoint()); -#else QRegion paintRegion = toBePainted; QRect widgetRect = widget->rect(); @@ -224,7 +212,6 @@ void QWidgetBackingStore::showYellowThing(QWidget *widget, const QRegion &toBePa ::usleep(1000 * msec); #endif #endif // Q_WS_WIN -#endif // Q_WS_QWS } bool QWidgetBackingStore::flushPaint(QWidget *widget, const QRegion &rgn) @@ -633,7 +620,7 @@ void QWidgetBackingStore::markDirtyOnScreen(const QRegion ®ion, QWidget *widg if (!widget || widget->d_func()->paintOnScreen() || region.isEmpty()) return; -#if defined(Q_WS_QWS) || defined(Q_WS_MAC) +#if defined(Q_WS_MAC) if (!widget->testAttribute(Qt::WA_WState_InPaintEvent)) dirtyOnScreen += region.translated(topLevelOffset); return; @@ -709,8 +696,7 @@ void QWidgetBackingStore::updateLists(QWidget *cur) } QWidgetBackingStore::QWidgetBackingStore(QWidget *topLevel) - : tlw(topLevel), dirtyOnScreenWidgets(0), hasDirtyFromPreviousSync(false) - , fullUpdatePending(0) + : tlw(topLevel), dirtyOnScreenWidgets(0), fullUpdatePending(0) { store = tlw->backingStore(); Q_ASSERT(store); @@ -751,11 +737,6 @@ void QWidgetPrivate::moveRect(const QRect &rect, int dx, int dy) QPoint toplevelOffset = pw->mapTo(tlw, QPoint()); QWidgetPrivate *pd = pw->d_func(); QRect clipR(pd->clipRect()); -#ifdef Q_WS_QWS - QWidgetBackingStore *wbs = x->backingStore.data(); - QWSWindowSurface *surface = static_cast<QWSWindowSurface*>(wbs->windowSurface); - clipR = clipR.intersected(surface->clipRegion().translated(-toplevelOffset).boundingRect()); -#endif const QRect newRect(rect.translated(dx, dy)); QRect destRect = rect.intersected(clipR); if (destRect.isValid()) @@ -839,26 +820,6 @@ void QWidgetPrivate::scrollRect(const QRect &rect, int dx, int dy) bool accelerateScroll = accelEnv && isOpaque && !(overlapped = isOverlapped(scrollRect.translated(data.crect.topLeft()))); -#if defined(Q_WS_QWS) - QWSWindowSurface *surface; - surface = static_cast<QWSWindowSurface*>(wbs->windowSurface); - - if (accelerateScroll && !surface->isBuffered()) { - const QRegion surfaceClip = surface->clipRegion(); - const QRegion outsideClip = QRegion(rect) - surfaceClip; - if (!outsideClip.isEmpty()) { - const QVector<QRect> clipped = (surfaceClip & rect).rects(); - if (clipped.size() < 8) { - for (int i = 0; i < clipped.size(); ++i) - this->scrollRect(clipped.at(i), dx, dy); - return; - } else { - accelerateScroll = false; - } - } - } -#endif // Q_WS_QWS - if (!accelerateScroll) { if (overlapped) { QRegion region(scrollRect); @@ -869,12 +830,6 @@ void QWidgetPrivate::scrollRect(const QRect &rect, int dx, int dy) } } else { const QPoint toplevelOffset = q->mapTo(tlw, QPoint()); -#ifdef Q_WS_QWS - QWSWindowSurface *surface = static_cast<QWSWindowSurface*>(wbs->windowSurface); - const QRegion clip = surface->clipRegion().translated(-toplevelOffset) & scrollRect; - const QRect clipBoundingRect = clip.boundingRect(); - scrollRect &= clipBoundingRect; -#endif const QRect destRect = scrollRect.translated(dx, dy) & scrollRect; const QRect sourceRect = destRect.translated(-dx, -dy); @@ -1004,9 +959,6 @@ void QWidgetBackingStore::sync() if (updatesDisabled) return; - if (hasDirtyFromPreviousSync) - dirty += dirtyFromPreviousSync; - // Contains everything that needs repaint. QRegion toClean(dirty); diff --git a/src/widgets/kernel/qwidgetbackingstore_p.h b/src/widgets/kernel/qwidgetbackingstore_p.h index 7befdbeb78..7c350932ea 100644 --- a/src/widgets/kernel/qwidgetbackingstore_p.h +++ b/src/widgets/kernel/qwidgetbackingstore_p.h @@ -85,12 +85,7 @@ public: inline bool isDirty() const { - return !(dirtyWidgets.isEmpty() && dirty.isEmpty() && !hasDirtyFromPreviousSync - && !fullUpdatePending -#if defined(Q_WS_QWS) && !defined(QT_NO_QWS_MANAGER) - && !hasDirtyWindowDecoration() -#endif - ); + return !(dirtyWidgets.isEmpty() && dirty.isEmpty() && !fullUpdatePending); } // ### Qt 4.6: Merge into a template function (after MSVC isn't supported anymore). @@ -108,7 +103,6 @@ private: QVector<QWidget *> *dirtyOnScreenWidgets; QList<QWidget *> staticWidgets; QBackingStore *store; - uint hasDirtyFromPreviousSync : 1; uint fullUpdatePending : 1; QPoint tlwOffset; @@ -130,10 +124,6 @@ private: void removeDirtyWidget(QWidget *w); -#if defined(Q_WS_QWS) && !defined(QT_NO_QWS_MANAGER) - bool hasDirtyWindowDecoration() const; - void paintWindowDecoration(); -#endif void updateLists(QWidget *widget); inline void addDirtyWidget(QWidget *widget, const QRegion &rgn) @@ -199,11 +189,7 @@ private: inline QRect topLevelRect() const { -#ifdef Q_WS_QWS - return tlw->frameGeometry(); -#else return tlw->data->crect; -#endif } inline void appendDirtyOnScreenWidget(QWidget *widget) diff --git a/src/widgets/kernel/qwidgetwindow_qpa.cpp b/src/widgets/kernel/qwidgetwindow_qpa.cpp index 40b6f486be..d124ec768a 100644 --- a/src/widgets/kernel/qwidgetwindow_qpa.cpp +++ b/src/widgets/kernel/qwidgetwindow_qpa.cpp @@ -451,10 +451,38 @@ void QWidgetWindow::handleWindowStateChangedEvent(QWindowStateChangeEvent *event { // QWindow does currently not know 'active'. Qt::WindowStates eventState = event->oldState(); - if (m_widget->windowState() & Qt::WindowActive) + Qt::WindowStates widgetState = m_widget->windowState(); + if (widgetState & Qt::WindowActive) eventState |= Qt::WindowActive; - QWindowStateChangeEvent widgetEvent(eventState); - QGuiApplication::sendSpontaneousEvent(m_widget, &widgetEvent); + + // Determine the new widget state, remember maximized/full screen + // during minimized. + switch (windowState()) { + case Qt::WindowNoState: + widgetState &= ~(Qt::WindowMinimized | Qt::WindowMaximized | Qt::WindowFullScreen); + break; + case Qt::WindowMinimized: + widgetState |= Qt::WindowMinimized; + break; + case Qt::WindowMaximized: + widgetState &= ~Qt::WindowFullScreen; + widgetState |= Qt::WindowMaximized; + break; + case Qt::WindowFullScreen: + widgetState &= ~Qt::WindowMaximized; + widgetState |= Qt::WindowFullScreen; + break; + case Qt::WindowActive: // Not handled by QWindow + break; + } + + // Sent event if the state changed (that is, it is not triggered by + // QWidget::setWindowState(), which also sends an event to the widget). + if (widgetState != m_widget->data->window_state) { + m_widget->data->window_state = widgetState; + QWindowStateChangeEvent widgetEvent(eventState); + QGuiApplication::sendSpontaneousEvent(m_widget, &widgetEvent); + } } bool QWidgetWindow::nativeEvent(const QByteArray &eventType, void *message, long *result) diff --git a/src/widgets/styles/qstyle.h b/src/widgets/styles/qstyle.h index 985e7a88aa..aebfea3620 100644 --- a/src/widgets/styles/qstyle.h +++ b/src/widgets/styles/qstyle.h @@ -188,7 +188,7 @@ public: PE_IndicatorItemViewItemDrop, PE_PanelItemViewItem, - PE_PanelItemViewRow, // ### Qt 5: remove + PE_PanelItemViewRow, // ### Qt 6: remove PE_PanelStatusBar, @@ -323,7 +323,7 @@ public: SE_CheckBoxLayoutItem, SE_ComboBoxLayoutItem, SE_DateTimeEditLayoutItem, - SE_DialogButtonBoxLayoutItem, // ### remove + SE_DialogButtonBoxLayoutItem, // ### Qt 6: remove SE_LabelLayoutItem, SE_ProgressBarLayoutItem, SE_PushButtonLayoutItem, diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 0e928b13c2..89e8f59315 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -991,9 +991,8 @@ QRenderRule::QRenderRule(const QVector<Declaration> &declarations, const QWidget hintValue = (int) decl.colorValue().rgba(); } else if (hintName.endsWith(QLatin1String("size"))) { hintValue = decl.sizeValue(); - // ### Qt5 -// } else if (hintName.endsWith(QLatin1String("icon"))) { -// hintValue = decl.iconValue(); + } else if (hintName.endsWith(QLatin1String("icon"))) { + hintValue = cssIconValueToIcon(decl.iconValue()); } else if (hintName == QLatin1String("button-layout") && decl.d->values.count() != 0 && decl.d->values.at(0).type == Value::String) { hintValue = subControlLayout(decl.d->values.at(0).variant.toString()); diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp index c911670442..801c7f7e5c 100644 --- a/src/widgets/styles/qwindowsxpstyle.cpp +++ b/src/widgets/styles/qwindowsxpstyle.cpp @@ -323,7 +323,7 @@ void QWindowsXPStylePrivate::cleanupHandleMap() HTHEME QWindowsXPStylePrivate::createTheme(int theme, HWND hwnd) { if (theme < 0 || theme >= NThemes || !hwnd) { - qWarning("%s: Invalid parameters #%d, %p", theme, hwnd); + qWarning("%s: Invalid parameters #%d, %p", Q_FUNC_INFO, theme, hwnd); return 0; } if (!m_themes[theme]) { diff --git a/src/widgets/styles/styles.pri b/src/widgets/styles/styles.pri index ef6827f74f..8f6996cfa3 100644 --- a/src/widgets/styles/styles.pri +++ b/src/widgets/styles/styles.pri @@ -37,7 +37,7 @@ contains( styles, all ) { styles = mac windows windowsxp windowsvista } -!macx-*:styles -= mac +!macx-*|!contains(QT_CONFIG, coreservices):styles -= mac x11{ QMAKE_CXXFLAGS += $$QT_CFLAGS_QGTKSTYLE diff --git a/src/widgets/util/qscroller.cpp b/src/widgets/util/qscroller.cpp index 4482134c7b..2c8b617761 100644 --- a/src/widgets/util/qscroller.cpp +++ b/src/widgets/util/qscroller.cpp @@ -58,6 +58,7 @@ #include <QGraphicsScene> #include <QGraphicsView> #include <QDesktopWidget> +#include <QVector2D> #include <QtCore/qmath.h> #include <QtGui/qevent.h> #include <qnumeric.h> @@ -1160,11 +1161,10 @@ void QScrollerPrivate::recalcScrollingSegments(bool forceRecalc) releaseVelocity = q->velocity(); - if (forceRecalc || !scrollingSegmentsValid(Qt::Horizontal)) - createScrollingSegments(releaseVelocity.x(), contentPosition.x() + overshootPosition.x(), ppm.x(), Qt::Horizontal); - - if (forceRecalc || !scrollingSegmentsValid(Qt::Vertical)) - createScrollingSegments(releaseVelocity.y(), contentPosition.y() + overshootPosition.y(), ppm.y(), Qt::Vertical); + if (forceRecalc || + !scrollingSegmentsValid(Qt::Horizontal) || + !scrollingSegmentsValid(Qt::Vertical)) + createScrollingSegments(releaseVelocity, contentPosition + overshootPosition, ppm); } /*! \internal @@ -1256,7 +1256,9 @@ void QScrollerPrivate::createScrollToSegments(qreal v, qreal deltaTime, qreal en /*! \internal */ -void QScrollerPrivate::createScrollingSegments(qreal v, qreal startPos, qreal ppm, Qt::Orientation orientation) +void QScrollerPrivate::createScrollingSegments(qreal v, qreal startPos, + qreal deltaTime, qreal deltaPos, + Qt::Orientation orientation) { const QScrollerPropertiesPrivate *sp = properties.d.data(); @@ -1287,26 +1289,20 @@ void QScrollerPrivate::createScrollingSegments(qreal v, qreal startPos, qreal pp qScrollerDebug() << "v = " << v << ", decelerationFactor = " << sp->decelerationFactor << ", curveType = " << sp->scrollingCurve.type(); - // This is only correct for QEasingCurve::OutQuad (linear velocity, - // constant deceleration), but the results look and feel ok for OutExpo - // and OutSine as well - - // v(t) = deltaTime * a * 0.5 * differentialForProgress(t / deltaTime) - // v(0) = vrelease - // v(deltaTime) = 0 - // deltaTime = (2 * vrelease) / (a * differntial(0)) - - // pos(t) = integrate(v(t)dt) - // pos(t) = vrelease * t - 0.5 * a * t * t - // pos(t) = deltaTime * a * 0.5 * progress(t / deltaTime) * deltaTime - // deltaPos = pos(deltaTime) - - qreal deltaTime = (qreal(2) * qAbs(v)) / (sp->decelerationFactor * differentialForProgress(sp->scrollingCurve, 0)); - qreal deltaPos = qSign(v) * deltaTime * deltaTime * qreal(0.5) * sp->decelerationFactor * ppm; qreal endPos = startPos + deltaPos; qScrollerDebug() << " Real Delta:" << deltaPos; + // -- check if are in overshoot and end in overshoot + if ((startPos < minPos && endPos < minPos) || + (startPos > maxPos && endPos > maxPos)) { + qreal stopPos = endPos < minPos ? minPos : maxPos; + qreal oDeltaTime = sp->overshootScrollTime; + + pushSegment(ScrollTypeOvershoot, oDeltaTime * qreal(0.7), qreal(1.0), startPos, stopPos - startPos, stopPos, sp->scrollingCurve.type(), orientation); + return; + } + // -- determine snap points qreal nextSnap = nextSnapPos(endPos, 0, orientation); qreal lowerSnapPos = nextSnapPos(startPos, -1, orientation); @@ -1320,16 +1316,6 @@ void QScrollerPrivate::createScrollingSegments(qreal v, qreal startPos, qreal pp if (nextSnap < lowerSnapPos || qIsNaN(lowerSnapPos)) lowerSnapPos = nextSnap; - // -- check if are in overshoot and end in overshoot - if ((startPos < minPos && endPos < minPos) || - (startPos > maxPos && endPos > maxPos)) { - qreal stopPos = endPos < minPos ? minPos : maxPos; - qreal oDeltaTime = sp->overshootScrollTime; - - pushSegment(ScrollTypeOvershoot, oDeltaTime * qreal(0.7), qreal(1.0), startPos, stopPos - startPos, stopPos, sp->scrollingCurve.type(), orientation); - return; - } - if (qAbs(v) < sp->minimumVelocity) { qScrollerDebug() << "### below minimum Vel" << orientation; @@ -1414,6 +1400,36 @@ void QScrollerPrivate::createScrollingSegments(qreal v, qreal startPos, qreal pp } +void QScrollerPrivate::createScrollingSegments(const QPointF &v, + const QPointF &startPos, + const QPointF &ppm) +{ + const QScrollerPropertiesPrivate *sp = properties.d.data(); + + // This is only correct for QEasingCurve::OutQuad (linear velocity, + // constant deceleration), but the results look and feel ok for OutExpo + // and OutSine as well + + // v(t) = deltaTime * a * 0.5 * differentialForProgress(t / deltaTime) + // v(0) = vrelease + // v(deltaTime) = 0 + // deltaTime = (2 * vrelease) / (a * differntial(0)) + + // pos(t) = integrate(v(t)dt) + // pos(t) = vrelease * t - 0.5 * a * t * t + // pos(t) = deltaTime * a * 0.5 * progress(t / deltaTime) * deltaTime + // deltaPos = pos(deltaTime) + + QVector2D vel(v); + qreal deltaTime = (qreal(2) * vel.length()) / (sp->decelerationFactor * differentialForProgress(sp->scrollingCurve, 0)); + QPointF deltaPos = (vel.normalized() * QVector2D(ppm)).toPointF() * deltaTime * deltaTime * qreal(0.5) * sp->decelerationFactor; + + createScrollingSegments(v.x(), startPos.x(), deltaTime, deltaPos.x(), + Qt::Horizontal); + createScrollingSegments(v.y(), startPos.y(), deltaTime, deltaPos.y(), + Qt::Vertical); +} + /*! \internal Prepares scrolling by sending a QScrollPrepareEvent to the receiver widget. Returns true if the scrolling was accepted and a target was returned. @@ -1650,8 +1666,7 @@ bool QScrollerPrivate::releaseWhileDragging(const QPointF &position, qint64 time } QPointF ppm = q->pixelPerMeter(); - createScrollingSegments(releaseVelocity.x(), contentPosition.x() + overshootPosition.x(), ppm.x(), Qt::Horizontal); - createScrollingSegments(releaseVelocity.y(), contentPosition.y() + overshootPosition.y(), ppm.y(), Qt::Vertical); + createScrollingSegments(releaseVelocity, contentPosition + overshootPosition, ppm); qScrollerDebug() << "QScroller::releaseWhileDragging() -- velocity:" << releaseVelocity << "-- minimum velocity:" << sp->minimumVelocity << "overshoot" << overshootPosition; diff --git a/src/widgets/util/qscroller_p.h b/src/widgets/util/qscroller_p.h index 6463f03573..26bd64461f 100644 --- a/src/widgets/util/qscroller_p.h +++ b/src/widgets/util/qscroller_p.h @@ -131,7 +131,10 @@ public: qreal scrollingSegmentsEndPos(Qt::Orientation orientation) const; bool scrollingSegmentsValid(Qt::Orientation orientation); void createScrollToSegments(qreal v, qreal deltaTime, qreal endPos, Qt::Orientation orientation, ScrollType type); - void createScrollingSegments(qreal v, qreal startPos, qreal ppm, Qt::Orientation orientation); + void createScrollingSegments(qreal v, qreal startPos, + qreal deltaTime, qreal deltaPos, + Qt::Orientation orientation); + void createScrollingSegments(const QPointF &v, const QPointF &startPos, const QPointF &ppm); void setContentPositionHelperDragging(const QPointF &deltaPos); void setContentPositionHelperScrolling(); diff --git a/src/widgets/widgets/qabstractbutton.cpp b/src/widgets/widgets/qabstractbutton.cpp index 5f75bd3913..4e85eae3ff 100644 --- a/src/widgets/widgets/qabstractbutton.cpp +++ b/src/widgets/widgets/qabstractbutton.cpp @@ -219,12 +219,6 @@ void QButtonGroup::setExclusive(bool exclusive) } -// TODO: Qt 5: Merge with addButton(QAbstractButton *button, int id) -void QButtonGroup::addButton(QAbstractButton *button) -{ - addButton(button, -1); -} - void QButtonGroup::addButton(QAbstractButton *button, int id) { Q_D(QButtonGroup); diff --git a/src/widgets/widgets/qbuttongroup.cpp b/src/widgets/widgets/qbuttongroup.cpp index 381e32d96b..a5e96370cf 100644 --- a/src/widgets/widgets/qbuttongroup.cpp +++ b/src/widgets/widgets/qbuttongroup.cpp @@ -175,22 +175,13 @@ */ /*! - \fn void QButtonGroup::addButton(QAbstractButton *button); + \fn void QButtonGroup::addButton(QAbstractButton *button, int id = -1); - Adds the given \a button to the end of the group's internal list - of buttons. An id will be assigned to the button by this - QButtonGroup. Automatically assigned ids are guaranteed to be - negative, starting with -2. If you are also assigning your own - ids, use positive values to avoid conflicts. - - \sa removeButton() buttons() -*/ - -/*! - \fn void QButtonGroup::addButton(QAbstractButton *button, int id); - - Adds the given \a button to the button group, with the given \a - id. It is recommended to assign only positive ids. + Adds the given \a button to the button group. If \a id is -1, + an id will be assigned to the button by this QButtonGroup. + Automatically assigned ids are guaranteed to be negative, + starting with -2. If you are assigning your own ids, use + positive values to avoid conflicts. \sa removeButton() buttons() */ diff --git a/src/widgets/widgets/qbuttongroup.h b/src/widgets/widgets/qbuttongroup.h index e24ac8bbc3..46275d9f04 100644 --- a/src/widgets/widgets/qbuttongroup.h +++ b/src/widgets/widgets/qbuttongroup.h @@ -67,8 +67,7 @@ public: void setExclusive(bool); bool exclusive() const; - void addButton(QAbstractButton *); - void addButton(QAbstractButton *, int id); + void addButton(QAbstractButton *, int id = -1); void removeButton(QAbstractButton *); QList<QAbstractButton*> buttons() const; diff --git a/src/widgets/widgets/qcombobox.h b/src/widgets/widgets/qcombobox.h index 1442cd983e..854ced596b 100644 --- a/src/widgets/widgets/qcombobox.h +++ b/src/widgets/widgets/qcombobox.h @@ -131,7 +131,7 @@ public: enum SizeAdjustPolicy { AdjustToContents, AdjustToContentsOnFirstShow, - AdjustToMinimumContentsLength, // ### Qt 5: remove + AdjustToMinimumContentsLength, // ### Qt 6: remove AdjustToMinimumContentsLengthWithIcon }; diff --git a/src/widgets/widgets/qdockwidget.h b/src/widgets/widgets/qdockwidget.h index 21872fa404..bd5a2c2aa4 100644 --- a/src/widgets/widgets/qdockwidget.h +++ b/src/widgets/widgets/qdockwidget.h @@ -82,7 +82,7 @@ public: DockWidgetVerticalTitleBar = 0x08, DockWidgetFeatureMask = 0x0f, - AllDockWidgetFeatures = DockWidgetClosable|DockWidgetMovable|DockWidgetFloatable, // ### remove in 5.0 + AllDockWidgetFeatures = DockWidgetClosable|DockWidgetMovable|DockWidgetFloatable, // ### Qt 6: remove NoDockWidgetFeatures = 0x00, Reserved = 0xff diff --git a/src/widgets/widgets/qlineedit_p.cpp b/src/widgets/widgets/qlineedit_p.cpp index 6cee96e717..d1c374a6ca 100644 --- a/src/widgets/widgets/qlineedit_p.cpp +++ b/src/widgets/widgets/qlineedit_p.cpp @@ -62,9 +62,10 @@ const int QLineEditPrivate::horizontalMargin(2); QRect QLineEditPrivate::adjustedControlRect(const QRect &rect) const { + QRect widgetRect = !rect.isEmpty() ? rect : q_func()->rect(); QRect cr = adjustedContentsRect(); int cix = cr.x() - hscroll + horizontalMargin; - return rect.translated(QPoint(cix, vscroll)); + return widgetRect.translated(QPoint(cix, vscroll)); } int QLineEditPrivate::xToPos(int x, QTextLine::CursorPosition betweenOrOn) const diff --git a/src/widgets/widgets/qmenu.h b/src/widgets/widgets/qmenu.h index e4e6390a9d..e98df595d1 100644 --- a/src/widgets/widgets/qmenu.h +++ b/src/widgets/widgets/qmenu.h @@ -46,7 +46,6 @@ #include <QtCore/qstring.h> #include <QtWidgets/qicon.h> #include <QtWidgets/qaction.h> -#include <QtWidgets/qplatformmenu_qpa.h> #ifdef Q_OS_WINCE #include <windef.h> // for HMENU @@ -61,6 +60,7 @@ QT_BEGIN_NAMESPACE class QMenuPrivate; class QStyleOptionMenuItem; +class QPlatformMenu; class Q_WIDGETS_EXPORT QMenu : public QWidget { diff --git a/src/widgets/widgets/qmenu_p.h b/src/widgets/widgets/qmenu_p.h index ee6e62653f..d637a9be8f 100644 --- a/src/widgets/widgets/qmenu_p.h +++ b/src/widgets/widgets/qmenu_p.h @@ -61,6 +61,8 @@ #include "QtCore/qbasictimer.h" #include "private/qwidget_p.h" +#include <qplatformmenu_qpa.h> + QT_BEGIN_NAMESPACE #ifndef QT_NO_MENU diff --git a/src/widgets/widgets/qmenubar.h b/src/widgets/widgets/qmenubar.h index 9818526543..c1272c45ce 100644 --- a/src/widgets/widgets/qmenubar.h +++ b/src/widgets/widgets/qmenubar.h @@ -54,6 +54,7 @@ QT_BEGIN_NAMESPACE class QMenuBarPrivate; class QStyleOptionMenuItem; class QWindowsStyle; +class QPlatformMenuBar; class Q_WIDGETS_EXPORT QMenuBar : public QWidget { diff --git a/src/widgets/widgets/qsplitter.cpp b/src/widgets/widgets/qsplitter.cpp index 285099a4cb..44c450ca47 100644 --- a/src/widgets/widgets/qsplitter.cpp +++ b/src/widgets/widgets/qsplitter.cpp @@ -232,14 +232,14 @@ void QSplitterHandle::resizeEvent(QResizeEvent *event) { Q_D(const QSplitterHandle); - // When splitters are only 1 pixel large we increase the + // When splitters are only 1 or 0 pixel large we increase the // actual grab area to five pixels // Note that QSplitter uses contentsRect for layouting // and ensures that handles are drawn on top of widgets // We simply use the contents margins for draggin and only // paint the mask area - bool useTinyMode = (d->s->handleWidth() == 1); + bool useTinyMode = (d->s->handleWidth() <= 1); setAttribute(Qt::WA_MouseNoMask, useTinyMode); if (useTinyMode) { if (orientation() == Qt::Horizontal) @@ -1528,14 +1528,14 @@ void QSplitter::setSizes(const QList<int> &list) By default, this property contains a value that depends on the user's platform and style preferences. - If you set handleWidth to 1, the actual grab area will grow to overlap a + If you set handleWidth to 1 or 0, the actual grab area will grow to overlap a few pixels of it's respective widgets. */ int QSplitter::handleWidth() const { Q_D(const QSplitter); - if (d->handleWidth > 0) { + if (d->handleWidth >= 0) { return d->handleWidth; } else { return style()->pixelMetric(QStyle::PM_SplitterWidth, 0, this); diff --git a/src/widgets/widgets/qsplitter_p.h b/src/widgets/widgets/qsplitter_p.h index c9db6ef9af..d9a0cdecb7 100644 --- a/src/widgets/widgets/qsplitter_p.h +++ b/src/widgets/widgets/qsplitter_p.h @@ -83,7 +83,7 @@ class QSplitterPrivate : public QFramePrivate Q_DECLARE_PUBLIC(QSplitter) public: QSplitterPrivate() : rubberBand(0), opaque(true), firstShow(true), - childrenCollapsible(true), compatMode(false), handleWidth(0), blockChildAdd(false) {} + childrenCollapsible(true), compatMode(false), handleWidth(-1), blockChildAdd(false) {} QPointer<QRubberBand> rubberBand; mutable QList<QSplitterLayoutStruct *> list; diff --git a/src/widgets/widgets/qstatusbar.h b/src/widgets/widgets/qstatusbar.h index b05bf627ad..4cab706c0b 100644 --- a/src/widgets/widgets/qstatusbar.h +++ b/src/widgets/widgets/qstatusbar.h @@ -87,7 +87,7 @@ protected: void paintEvent(QPaintEvent *); void resizeEvent(QResizeEvent *); - // ### Qt 5: consider making reformat() and hideOrShow() private + // ### Qt 6: consider making reformat() and hideOrShow() private void reformat(); void hideOrShow(); bool event(QEvent *); diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp index c9300d3cdd..017cbee219 100644 --- a/src/widgets/widgets/qwidgetlinecontrol.cpp +++ b/src/widgets/widgets/qwidgetlinecontrol.cpp @@ -103,11 +103,11 @@ void QWidgetLineControl::updateDisplayText(bool forceUpdate) int cursor = m_cursor - 1; QChar uc = m_text.at(cursor); str[cursor] = uc; - if (cursor > 0 && uc.unicode() >= 0xdc00 && uc.unicode() < 0xe000) { + if (cursor > 0 && uc.isLowSurrogate()) { // second half of a surrogate, check if we have the first half as well, // if yes restore both at once uc = m_text.at(cursor - 1); - if (uc.unicode() >= 0xd800 && uc.unicode() < 0xdc00) + if (uc.isHighSurrogate()) str[cursor - 1] = uc; } } @@ -220,11 +220,11 @@ void QWidgetLineControl::backspace() if (m_maskData) m_cursor = prevMaskBlank(m_cursor); QChar uc = m_text.at(m_cursor); - if (m_cursor > 0 && uc.unicode() >= 0xdc00 && uc.unicode() < 0xe000) { + if (m_cursor > 0 && uc.isLowSurrogate()) { // second half of a surrogate, check if we have the first half as well, // if yes delete both at once uc = m_text.at(m_cursor - 1); - if (uc.unicode() >= 0xd800 && uc.unicode() < 0xdc00) { + if (uc.isHighSurrogate()) { internalDelete(true); --m_cursor; } diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index d602d6daa5..91864b6608 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -79,6 +79,7 @@ #include <qtooltip.h> #include <qstyleoption.h> #include <QtWidgets/qlineedit.h> +#include <QtGui/qaccessible.h> #ifndef QT_NO_SHORTCUT #include "private/qapplication_p.h" @@ -577,8 +578,15 @@ void QWidgetTextControlPrivate::repaintOldAndNewSelection(const QTextCursor &old void QWidgetTextControlPrivate::selectionChanged(bool forceEmitSelectionChanged /*=false*/) { Q_Q(QWidgetTextControl); - if (forceEmitSelectionChanged) + if (forceEmitSelectionChanged) { emit q->selectionChanged(); +#ifndef QT_NO_ACCESSIBILITY + if (q->parent()) { + QAccessibleTextSelectionEvent ev(q->parent(), cursor.anchor(), cursor.position()); + QAccessible::updateAccessibility(&ev); + } +#endif + } if (cursor.position() == lastSelectionPosition && cursor.anchor() == lastSelectionAnchor) @@ -593,9 +601,15 @@ void QWidgetTextControlPrivate::selectionChanged(bool forceEmitSelectionChanged && (selectionStateChange || (cursor.hasSelection() && (cursor.position() != lastSelectionPosition - || cursor.anchor() != lastSelectionAnchor)))) + || cursor.anchor() != lastSelectionAnchor)))) { emit q->selectionChanged(); - +#ifndef QT_NO_ACCESSIBILITY + if (q->parent()) { + QAccessibleTextSelectionEvent ev(q->parent(), cursor.anchor(), cursor.position()); + QAccessible::updateAccessibility(&ev); + } +#endif + } emit q->microFocusChanged(); lastSelectionPosition = cursor.position(); lastSelectionAnchor = cursor.anchor(); |