summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2019-10-24 01:00:14 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2019-10-24 10:23:44 +0200
commitb327807c5ed6f151bfb22c2fe204ed289a3b6254 (patch)
tree880a0e7664e1270f4f51ccf79a3cf2ddbcd7d810 /src/widgets
parentaa4b0f5cb7e84046530fbc26581f777506fea658 (diff)
parentb61c6164c100defc519b178d73858df59cffc48d (diff)
Merge remote-tracking branch 'origin/5.13' into 5.14
Conflicts: src/corelib/io/qstandardpaths_unix.cpp src/corelib/tools/qsharedpointer_impl.h tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp Change-Id: Iae95c5778dc091058f16f6db76f04a0178a9e809
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/doc/snippets/code/doc_src_stylesheet.qdoc2
-rw-r--r--src/widgets/graphicsview/qgraphicsscene.cpp13
-rw-r--r--src/widgets/graphicsview/qgraphicsscene_p.h17
-rw-r--r--src/widgets/itemviews/qstyleditemdelegate.cpp9
-rw-r--r--src/widgets/kernel/qwidgetwindow.cpp22
5 files changed, 40 insertions, 23 deletions
diff --git a/src/widgets/doc/snippets/code/doc_src_stylesheet.qdoc b/src/widgets/doc/snippets/code/doc_src_stylesheet.qdoc
index 098eaf4717..b0d042566f 100644
--- a/src/widgets/doc/snippets/code/doc_src_stylesheet.qdoc
+++ b/src/widgets/doc/snippets/code/doc_src_stylesheet.qdoc
@@ -1107,10 +1107,10 @@ QMenu::indicator:exclusive:checked:selected {
QMenuBar {
background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1,
stop:0 lightgray, stop:1 darkgray);
+ spacing: 3px; /* spacing between menu bar items */
}
QMenuBar::item {
- spacing: 3px; /* spacing between menu bar items */
padding: 1px 4px;
background: transparent;
border-radius: 4px;
diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp
index 1208adfd17..a47d0d879d 100644
--- a/src/widgets/graphicsview/qgraphicsscene.cpp
+++ b/src/widgets/graphicsview/qgraphicsscene.cpp
@@ -386,7 +386,15 @@ void QGraphicsScenePrivate::_q_emitUpdated()
// Notify the changes to anybody interested.
QList<QRectF> oldUpdatedRects;
- oldUpdatedRects = updateAll ? (QList<QRectF>() << q->sceneRect()) : updatedRects;
+ if (updateAll) {
+ oldUpdatedRects << q->sceneRect();
+ } else {
+ // Switch to a ranged constructor in Qt 6...
+ oldUpdatedRects.reserve(int(updatedRects.size()));
+ std::copy(updatedRects.cbegin(), updatedRects.cend(),
+ std::back_inserter(oldUpdatedRects));
+ }
+
updateAll = false;
updatedRects.clear();
emit q->changed(oldUpdatedRects);
@@ -3219,8 +3227,7 @@ void QGraphicsScene::update(const QRectF &rect)
view->d_func()->updateRectF(rect);
}
} else {
- if (!d->updatedRects.contains(rect))
- d->updatedRects << rect;
+ d->updatedRects.insert(rect);
}
}
diff --git a/src/widgets/graphicsview/qgraphicsscene_p.h b/src/widgets/graphicsview/qgraphicsscene_p.h
index 7934359cee..9ecfca8ebf 100644
--- a/src/widgets/graphicsview/qgraphicsscene_p.h
+++ b/src/widgets/graphicsview/qgraphicsscene_p.h
@@ -69,6 +69,9 @@
#include <QtWidgets/qstyle.h>
#include <QtWidgets/qstyleoption.h>
+#include <set>
+#include <tuple>
+
QT_REQUIRE_CONFIG(graphicsview);
QT_BEGIN_NAMESPACE
@@ -122,7 +125,19 @@ public:
QRectF growingItemsBoundingRect;
void _q_emitUpdated();
- QList<QRectF> updatedRects;
+
+ struct UpdatedRectsCmp
+ {
+ bool operator() (const QRectF &a, const QRectF &b) const noexcept
+ {
+ return std::make_tuple(a.y(), a.x(), a.height(), a.width())
+ < std::make_tuple(b.y(), b.x(), b.height(), b.width());
+ }
+ };
+
+ // std::set was used here instead of std::unordered_set due to requiring only a comparator and
+ // showing equivalent performance in empirical measurements within the ranges of interest...
+ std::set<QRectF, UpdatedRectsCmp> updatedRects;
QPainterPath selectionArea;
int selectionChanging;
diff --git a/src/widgets/itemviews/qstyleditemdelegate.cpp b/src/widgets/itemviews/qstyleditemdelegate.cpp
index 22067851cb..702e290da3 100644
--- a/src/widgets/itemviews/qstyleditemdelegate.cpp
+++ b/src/widgets/itemviews/qstyleditemdelegate.cpp
@@ -514,15 +514,6 @@ void QStyledItemDelegate::updateEditorGeometry(QWidget *editor,
QStyle *style = widget ? widget->style() : QApplication::style();
QRect geom = style->subElementRect(QStyle::SE_ItemViewItemText, &opt, widget);
- const int delta = qSmartMinSize(editor).width() - geom.width();
- if (delta > 0) {
- //we need to widen the geometry
- if (editor->layoutDirection() == Qt::RightToLeft)
- geom.adjust(-delta, 0, 0, 0);
- else
- geom.adjust(0, 0, delta, 0);
- }
-
editor->setGeometry(geom);
}
diff --git a/src/widgets/kernel/qwidgetwindow.cpp b/src/widgets/kernel/qwidgetwindow.cpp
index b9a67edc6a..24f8c5ce43 100644
--- a/src/widgets/kernel/qwidgetwindow.cpp
+++ b/src/widgets/kernel/qwidgetwindow.cpp
@@ -893,7 +893,7 @@ void QWidgetWindow::handleDragEnterEvent(QDragEnterEvent *event, QWidget *widget
void QWidgetWindow::handleDragMoveEvent(QDragMoveEvent *event)
{
- auto *widget = findDnDTarget(m_widget, event->pos());
+ QPointer<QWidget> widget = findDnDTarget(m_widget, event->pos());
if (!widget) {
event->ignore();
if (m_dragTarget) { // Send DragLeave to previous
@@ -916,14 +916,18 @@ void QWidgetWindow::handleDragMoveEvent(QDragMoveEvent *event)
QGuiApplication::forwardEvent(m_dragTarget, &leaveEvent, event);
m_dragTarget = nullptr;
}
- // Send DragEnter to new widget.
- handleDragEnterEvent(static_cast<QDragEnterEvent*>(event), widget);
- // Handling 'DragEnter' should suffice for the application.
- translated.setDropAction(event->dropAction());
- translated.setAccepted(event->isAccepted());
- // The drag enter event is always immediately followed by a drag move event,
- // see QDragEnterEvent documentation.
- QGuiApplication::forwardEvent(m_dragTarget, &translated, event);
+ // widget might have been deleted when handling the leaveEvent
+ if (widget) {
+ // Send DragEnter to new widget.
+ handleDragEnterEvent(static_cast<QDragEnterEvent*>(event), widget);
+ // Handling 'DragEnter' should suffice for the application.
+ translated.setDropAction(event->dropAction());
+ translated.setAccepted(event->isAccepted());
+ // The drag enter event is always immediately followed by a drag move event,
+ // see QDragEnterEvent documentation.
+ if (m_dragTarget)
+ QGuiApplication::forwardEvent(m_dragTarget, &translated, event);
+ }
}
event->setAccepted(translated.isAccepted());
event->setDropAction(translated.dropAction());