From 56b3232a7d35fe2b856d1d87a7e1c59906b46681 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Arve=20S=C3=A6ther?= Date: Thu, 21 Mar 2019 11:05:44 +0100 Subject: Add some missing QT_{BEGIN,END}_NAMESPACE macros Change-Id: I16820387279ca616af6ab379874c247c83df4a2f Reviewed-by: Shawn Rutledge --- src/quick/items/qquickclipnode.cpp | 3 +++ src/quick/items/qquickclipnode_p.h | 4 ++++ 2 files changed, 7 insertions(+) (limited to 'src/quick/items') diff --git a/src/quick/items/qquickclipnode.cpp b/src/quick/items/qquickclipnode.cpp index 747e844172..d90b1f1540 100644 --- a/src/quick/items/qquickclipnode.cpp +++ b/src/quick/items/qquickclipnode.cpp @@ -43,6 +43,8 @@ #include #include +QT_BEGIN_NAMESPACE + QQuickDefaultClipNode::QQuickDefaultClipNode(const QRectF &rect) : m_rect(rect) , m_radius(0) @@ -117,3 +119,4 @@ void QQuickDefaultClipNode::updateGeometry() markDirty(DirtyGeometry); } +QT_END_NAMESPACE diff --git a/src/quick/items/qquickclipnode_p.h b/src/quick/items/qquickclipnode_p.h index ed9e1ae4d8..00914deae8 100644 --- a/src/quick/items/qquickclipnode_p.h +++ b/src/quick/items/qquickclipnode_p.h @@ -54,6 +54,8 @@ #include #include +QT_BEGIN_NAMESPACE + class Q_QUICK_PRIVATE_EXPORT QQuickDefaultClipNode : public QSGClipNode { public: @@ -78,4 +80,6 @@ private: QSGGeometry m_geometry; }; +QT_END_NAMESPACE + #endif // QQUICKCLIPNODE_P_H -- cgit v1.2.3 From a8cc4f2b51722380a30fae0009205db917feb7a9 Mon Sep 17 00:00:00 2001 From: Venugopal Shivashankar Date: Thu, 21 Mar 2019 17:43:54 +0100 Subject: Doc: Language edits - Promoted TableModel as another alternative - Added \readonly commands - Minor edits Change-Id: Iaa1a320daa8b9afb17ace4273fdc33ca35b9c59c Reviewed-by: Mitch Curtis --- src/quick/items/qquicktableview.cpp | 95 +++++++++++++++++++------------------ 1 file changed, 48 insertions(+), 47 deletions(-) (limited to 'src/quick/items') diff --git a/src/quick/items/qquicktableview.cpp b/src/quick/items/qquicktableview.cpp index ac3397d2a9..129feb26fe 100644 --- a/src/quick/items/qquicktableview.cpp +++ b/src/quick/items/qquicktableview.cpp @@ -53,11 +53,10 @@ /*! \qmltype TableView - \instantiates QQuickTableView \inqmlmodule QtQuick \ingroup qtquick-views \inherits Flickable - \brief Provides a table view of items provided by the model. + \brief Provides a table view of items to display data from a model. A TableView has a \l model that defines the data to be displayed, and a \l delegate that defines how the data should be displayed. @@ -72,8 +71,8 @@ A TableView displays data from models created from built-in QML types such as ListModel and XmlListModel, which populates the first column only - in a TableView. To create models with multiple columns, create a model in - C++ that inherits QAbstractItemModel, and expose it to QML. + in a TableView. To create models with multiple columns, either use + \l TableModel or a C++ model that inherits QAbstractItemModel. \section1 Example Usage @@ -90,7 +89,7 @@ TableView recycles delegate items by default, instead of instantiating from the \l delegate whenever new rows and columns are flicked into view. This - can give a huge performance boost, depending on the complexity of the + approach gives a huge performance boost, depending on the complexity of the delegate. When an item is flicked out, it moves to the \e{reuse pool}, which is an @@ -124,8 +123,8 @@ \section1 Row heights and column widths When a new column is flicked into view, TableView will determine its width - by calling the \l columnWidthProvider function. TableView itself will never - store row height or column width, as it's designed to support large models + by calling the \l columnWidthProvider function. TableView does not store + row height or column width, as it's designed to support large models containing any number of rows and columns. Instead, it will ask the application whenever it needs to know. @@ -139,9 +138,9 @@ \note The calculated width of a column is discarded when it is flicked out of the viewport, and is recalculated if the column is flicked back in. The calculation is always based on the items that are visible when the column - is flicked in. This means that it can end up different each time, depending - on which row you're at when the column enters. You should therefore have the - same \c implicitWidth for all items in a column, or set + is flicked in. This means that column width can be different each time, + depending on which row you're at when the column enters. You should + therefore have the same \c implicitWidth for all items in a column, or set \l columnWidthProvider. The same logic applies for the row height calculation. @@ -150,10 +149,11 @@ must call \l forceLayout. This informs TableView that it needs to use the provider functions again to recalculate and update the layout. - Since Qt 5.13, if you want to hide a specific column, you can return \c 0 from the - \l columnWidthProvider for that column. Likewise, you can return 0 from the - \l rowHeightProvider to hide a row. If you return a negative number, TableView - will fall back to calculate the size based on the delegate items. + Since Qt 5.13, if you want to hide a specific column, you can return \c 0 + from the \l columnWidthProvider for that column. Likewise, you can return 0 + from the \l rowHeightProvider to hide a row. If you return a negative + number, TableView will fall back to calculate the size based on the delegate + items. \note The size of a row or column should be a whole number to avoid sub-pixel alignment of items. @@ -167,11 +167,11 @@ \section1 Overlays and underlays - Tableview inherits \l Flickable. And when new items are instantiated from the - delegate, it will parent them to the \l{Flickable::}{contentItem} - with a \c z value equal to \c 1. You can add your own items inside the - Tableview, as child items of the Flickable. By controlling their \c z - value, you can make them be on top of or underneath the table items. + All new items that are instantiated from the delegate are parented to the + \l{Flickable::}{contentItem} with the \c z value, \c 1. You can add your + own items inside the Tableview, as child items of the Flickable. By + controlling their \c z value, you can make them be on top of or + underneath the table items. Here is an example that shows how to add some text on top of the table, that moves together with the table as you flick: @@ -181,6 +181,7 @@ /*! \qmlproperty int QtQuick::TableView::rows + \readonly This property holds the number of rows in the table. This is equal to the number of rows in the model. @@ -190,10 +191,11 @@ /*! \qmlproperty int QtQuick::TableView::columns + \readonly This property holds the number of columns in the table. This is equal to the number of columns in the model. If the model is - a list, columns will be 1. + a list, columns will be \c 1. This property is read only. */ @@ -203,7 +205,7 @@ This property holds the spacing between the rows. - The default value is 0. + The default value is \c 0. */ /*! @@ -211,20 +213,20 @@ This property holds the spacing between the columns. - The default value is 0. + The default value is \c 0. */ /*! \qmlproperty var QtQuick::TableView::rowHeightProvider This property can hold a function that returns the row height for each row - in the model. When assigned, it will be called whenever TableView needs to - know the height of a specific row. The function takes one argument, \c row, - for which the TableView needs to know the height. + in the model. It is called whenever TableView needs to know the height of + a specific row. The function takes one argument, \c row, for which the + TableView needs to know the height. - Since Qt 5.13, if you want to hide a specific row, you can return \c 0 height for - that row. If you return a negative number, TableView will fall back to - calculate the height based on the delegate items. + Since Qt 5.13, if you want to hide a specific row, you can return \c 0 + height for that row. If you return a negative number, TableView calculates + the height based on the delegate items. \sa columnWidthProvider, {Row heights and column widths} */ @@ -233,13 +235,13 @@ \qmlproperty var QtQuick::TableView::columnWidthProvider This property can hold a function that returns the column width for each - column in the model. When assigned, it is called whenever TableView needs - to know the width of a specific column. The function takes one argument, - \c column, for which the TableView needs to know the width. + column in the model. It is called whenever TableView needs to know the + width of a specific column. The function takes one argument, \c column, + for which the TableView needs to know the width. - Since Qt 5.13, if you want to hide a specific column, you can return \c 0 width for - that column. If you return a negative number, TableView will fall back to - calculate the width based on the delegate items. + Since Qt 5.13, if you want to hide a specific column, you can return \c 0 + width for that column. If you return a negative number, TableView + calculates the width based on the delegate items. \sa rowHeightProvider, {Row heights and column widths} */ @@ -249,9 +251,9 @@ This property holds the model that provides data for the table. The model provides the set of data that is used to create the items - in the view. Models can be created directly in QML using \l ListModel, - \l XmlListModel or \l ObjectModel, or provided by a custom C++ model - class. If it is a C++ model, it must be a subclass of \l QAbstractItemModel + in the view. Models can be created directly in QML using \l TableModel, + \l ListModel, \l XmlListModel, or \l ObjectModel, or provided by a custom + C++ model class. The C++ model must be a subclass of \l QAbstractItemModel or a simple list. \sa {qml-data-models}{Data Models} @@ -265,10 +267,9 @@ applies to \c row and \c column. Properties of the model are also available depending upon the type of \l {qml-data-models}{Data Model}. - A delegate should specify its size using \l [QML]{Item::implicitWidth}{implicitWidth} and - \l [QML]{Item::implicitHeight}{implicitHeight}. - The TableView lays out the items based on that information. Explicit width or - height settings are ignored and overwritten. + A delegate should specify its size using \l{Item::}{implicitWidth} and + \l {Item::}{implicitHeight}. The TableView lays out the items based on that + information. Explicit width or height settings are ignored and overwritten. \note Delegates are instantiated as needed and may be destroyed at any time. They are also reused if the \l reuseItems property is set to \c true. You @@ -313,8 +314,8 @@ always know the exact height of the table without loading all rows in the model, the \c contentHeight is usually an estimated height based on the rows it has seen so far. This estimate is recalculated - whenever new rows are flicked into view, which means that the content height - can change dynamically. + whenever new rows are flicked into view, which means that the content + height can change dynamically. If you know up front what the height of the table will be, assign a value to \c contentHeight explicitly, to avoid unnecessary calculations and @@ -329,7 +330,7 @@ Responding to changes in the model are batched so that they are handled only once per frame. This means the TableView delays showing any changes while a script is being run. The same is also true when changing - properties such as \l rowSpacing or \l {Item::anchors.leftMargin}{leftMargin}. + properties, such as \l rowSpacing or \l{Item::anchors.leftMargin}{leftMargin}. This method forces the TableView to immediately update the layout so that any recent changes take effect. @@ -366,9 +367,9 @@ item has been taken out of the pool and placed inside the content view, and the model properties such as index, row, and column have been updated. - Other properties that are not provided by the model does not change when an item - is reused. You should avoid storing any state inside a delegate, but if you do, - manually reset that state on receiving this signal. + Other properties that are not provided by the model does not change when an + item is reused. You should avoid storing any state inside a delegate, but if + you do, manually reset that state on receiving this signal. This signal is emitted when the item is reused, and not the first time the item is created. -- cgit v1.2.3 From 156066d4753243143970aeb0b740f8f429e7916b Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Mon, 25 Mar 2019 15:18:16 +0100 Subject: Restore rich Text creation speed 634b59f187c8697f03a606cbacb5f0a69650ea7c caused a significant performance regression during layout of any Text item with RichText, by calling QQuickTextDocumentWithImageResources::setPageSize() with an accurate width in ensureDoc(); but ensureDoc() is called multiple times, and doesn't need to calculate actual layout. The accurate width is needed (at least) when doing layout of HTML tables that contain percentage-based column widths. For that purpose it's enough to set the correct "page" size in updateSize(). Fixes: QTBUG-74638 Task-number: QTBUG-72457 Change-Id: I34ab085316018576eba64a67200c527bb64b9533 Reviewed-by: Simon Hausmann --- src/quick/items/qquicktext.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/quick/items') diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp index 8b6f59497f..97cc33b95f 100644 --- a/src/quick/items/qquicktext.cpp +++ b/src/quick/items/qquicktext.cpp @@ -1247,7 +1247,7 @@ void QQuickTextPrivate::ensureDoc() if (!extra.isAllocated() || !extra->doc) { Q_Q(QQuickText); extra.value().doc = new QQuickTextDocumentWithImageResources(q); - extra->doc->setPageSize(QSizeF(q->width(), -1)); + extra->doc->setPageSize(QSizeF(0, 0)); extra->doc->setDocumentMargin(0); extra->doc->setBaseUrl(q->baseUrl()); qmlobject_connect(extra->doc, QQuickTextDocumentWithImageResources, SIGNAL(imagesLoaded()), -- cgit v1.2.3 From 82247946b2733bcd5bb3740a31c7d38fb90f6ddd Mon Sep 17 00:00:00 2001 From: Eirik Aavitsland Date: Fri, 22 Mar 2019 14:30:15 +0100 Subject: Fix text wrap: do not break on last line if right elide is enabled For multiline texts with word wrapping, it is not so meaningful to add breaks in the last line if it is anyway going to be elided. Fix by using the WrapAnywhere strategy for the last line for such situations. Fixes: QTBUG-72736 Change-Id: I1263c81277b6ca89ba461529fced1094263c026f Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/quick/items/qquicktext.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/quick/items') diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp index 73b151168e..d7307daa02 100644 --- a/src/quick/items/qquicktext.cpp +++ b/src/quick/items/qquicktext.cpp @@ -754,6 +754,7 @@ QRectF QQuickTextPrivate::setupTextLayout(qreal *const baseline) bool once = true; int elideStart = 0; int elideEnd = 0; + bool noBreakLastLine = multilineElide && (wrapMode == QQuickText::Wrap || wrapMode == QQuickText::WordWrap); int eos = multilengthEos; @@ -786,11 +787,15 @@ QRectF QQuickTextPrivate::setupTextLayout(qreal *const baseline) QRectF unelidedRect; QTextLine line = layout.createLine(); for (visibleCount = 1; ; ++visibleCount) { + if (noBreakLastLine && visibleCount == maxLineCount) + layout.engine()->option.setWrapMode(QTextOption::WrapAnywhere); if (customLayout) { setupCustomLineGeometry(line, naturalHeight); } else { setLineGeometry(line, lineWidth, naturalHeight); } + if (noBreakLastLine && visibleCount == maxLineCount) + layout.engine()->option.setWrapMode(QTextOption::WrapMode(wrapMode)); unelidedRect = br.united(line.naturalTextRect()); -- cgit v1.2.3 From 1b43149decdf42e47405a9e43840b7382076cb0d Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Thu, 21 Mar 2019 14:36:57 +0100 Subject: Fix incorrect PathView.currentIndex assignment with StrictlyEnforceRange If currentIndex is quickly assigned a different index and then the previous current index again, it should not move. Fixes: QTBUG-74508 Change-Id: I8d610e3fe452c8631e082c648e77d2cb70ae57c5 Reviewed-by: Richard Moe Gustavsen --- src/quick/items/qquickpathview.cpp | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/quick/items') diff --git a/src/quick/items/qquickpathview.cpp b/src/quick/items/qquickpathview.cpp index 77ed8a659c..fd5814d2b2 100644 --- a/src/quick/items/qquickpathview.cpp +++ b/src/quick/items/qquickpathview.cpp @@ -2392,10 +2392,6 @@ void QQuickPathViewPrivate::snapToIndex(int index, MovementReason reason) return; qreal targetOffset = std::fmod(qreal(modelCount - index), qreal(modelCount)); - - if (offset == targetOffset) - return; - moveReason = reason; offsetAdj = 0.0; tl.reset(moveOffset); -- cgit v1.2.3 From 5cd819d264a932eccbd9d155a81c3c07a2918433 Mon Sep 17 00:00:00 2001 From: Venugopal Shivashankar Date: Mon, 25 Mar 2019 13:05:57 +0100 Subject: Doc; Update contentHeight and contentWidth docs Clarified that contentHeight and contentWidth define the size of the table but not the view's. The view's width and height defines the size of the viewport, while the contentWidth and contentHeight defines the size of the table based on the size of the data model. Change-Id: I17aa84d7e7efcb9369f96ff3b1206e9965015c8f Reviewed-by: Richard Moe Gustavsen --- src/quick/items/qquicktableview.cpp | 50 +++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 24 deletions(-) (limited to 'src/quick/items') diff --git a/src/quick/items/qquicktableview.cpp b/src/quick/items/qquicktableview.cpp index 129feb26fe..17bdeed1fb 100644 --- a/src/quick/items/qquicktableview.cpp +++ b/src/quick/items/qquicktableview.cpp @@ -291,37 +291,39 @@ /*! \qmlproperty real QtQuick::TableView::contentWidth - This property holds the width of the \l view, which is also - the width of the table (including margins). As a TableView cannot - always know the exact width of the table without loading all columns - in the model, the \c contentWidth is usually an estimated width based on - the columns it has seen so far. This estimate is recalculated whenever - new columns are flicked into view, which means that the content width - can change dynamically. - - If you know up front what the width of the table will be, assign a value - to \c contentWidth explicitly, to avoid unnecessary calculations and - updates to the TableView. - - \sa contentHeight + This property holds the table width required to accommodate the number of + columns in the model. This is usually not the same as the \c width of the + \l view, which means that the table's width could be larger or smaller than + the viewport width. As a TableView cannot always know the exact width of + the table without loading all columns in the model, the \c contentWidth is + usually an estimate based on the columns it has seen so far. This estimate + is recalculated whenever new columns are flicked into view, which means + that the content width can change dynamically. + + If you know what the width of the table will be, assign a value to + \c contentWidth, to avoid unnecessary calculations and updates to the + TableView. + + \sa contentHeight, columnWidthProvider */ /*! \qmlproperty real QtQuick::TableView::contentHeight - This property holds the height of the \l view, which is also - the height of the table (including margins). As a TableView cannot - always know the exact height of the table without loading all rows - in the model, the \c contentHeight is usually an estimated height - based on the rows it has seen so far. This estimate is recalculated - whenever new rows are flicked into view, which means that the content - height can change dynamically. + This property holds the table height required to accommodate the number of + rows in the data model. This is usually not the same as the \c height of the + \c view, which means that the table's height could be larger or smaller than the + viewport height. As a TableView cannot always know the exact height of the + table without loading all rows in the model, the \c contentHeight is + usually an estimate based on the rows it has seen so far. This estimate is + recalculated whenever new rows are flicked into view, which means that + the content height can change dynamically. - If you know up front what the height of the table will be, assign a - value to \c contentHeight explicitly, to avoid unnecessary calculations and - updates to the TableView. + If you know what the height of the table will be, assign a + value to \c contentHeight, to avoid unnecessary calculations and updates to + the TableView. - \sa contentWidth + \sa contentWidth, rowHeightProvider */ /*! -- cgit v1.2.3 From 57c783152f54ea18d0a5a347e9f653bf07c2f446 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Arve=20S=C3=A6ther?= Date: Wed, 13 Mar 2019 13:24:49 +0100 Subject: Refactor transform code in pinchhandler to a separate function This is needed in order for the wheel handler to have the same behavior. Change-Id: I42851789787b8da96618d82227b34c53ace15e9b Reviewed-by: Shawn Rutledge --- src/quick/items/qquickitem.cpp | 34 ++++++++++++++++++++++++++++++++++ src/quick/items/qquickitem_p.h | 5 +++++ 2 files changed, 39 insertions(+) (limited to 'src/quick/items') diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index ec6bf5a1b8..7469fee72b 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -5122,6 +5122,40 @@ void QQuickItemPrivate::transformChanged() #endif } +QPointF QQuickItemPrivate::adjustedPosForTransform(const QPointF ¢roidParentPos, + const QPointF &startPos, + const QVector2D &activeTranslation, //[0,0] means no additional translation from startPos + qreal startScale, + qreal activeScale, // 1.0 means no additional scale from startScale + qreal startRotation, + qreal activeRotation) // 0.0 means no additional rotation from startRotation +{ + Q_Q(QQuickItem); + QVector3D xformOrigin(q->transformOriginPoint()); + QMatrix4x4 startMatrix; + startMatrix.translate(float(startPos.x()), float(startPos.y())); + startMatrix.translate(xformOrigin); + startMatrix.scale(float(startScale)); + startMatrix.rotate(float(startRotation), 0, 0, -1); + startMatrix.translate(-xformOrigin); + + const QVector3D centroidParentVector(centroidParentPos); + QMatrix4x4 mat; + mat.translate(centroidParentVector); + mat.rotate(float(activeRotation), 0, 0, 1); + mat.scale(float(activeScale)); + mat.translate(-centroidParentVector); + mat.translate(QVector3D(activeTranslation)); + + mat = mat * startMatrix; + + QPointF xformOriginPoint = q->transformOriginPoint(); + QPointF pos = mat * xformOriginPoint; + pos -= xformOriginPoint; + + return pos; +} + bool QQuickItemPrivate::filterKeyEvent(QKeyEvent *e, bool post) { if (!extra.isAllocated() || !extra->keyHandler) diff --git a/src/quick/items/qquickitem_p.h b/src/quick/items/qquickitem_p.h index 771228914b..847fd90230 100644 --- a/src/quick/items/qquickitem_p.h +++ b/src/quick/items/qquickitem_p.h @@ -591,6 +591,11 @@ public: QPointF computeTransformOrigin() const; virtual void transformChanged(); + QPointF adjustedPosForTransform(const QPointF ¢roid, + const QPointF &startPos, const QVector2D &activeTranslatation, + qreal startScale, qreal activeScale, + qreal startRotation, qreal activeRotation); + void deliverKeyEvent(QKeyEvent *); bool filterKeyEvent(QKeyEvent *, bool post); #if QT_CONFIG(im) -- cgit v1.2.3 From 03c2f16d54bcab3eab5e0c244fa18dde708c64b7 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Thu, 4 Apr 2019 11:24:06 +0200 Subject: QQuickRectanglePrivate: set gradient QJSValue to undefined MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When 1771d298 changed gradient from a QQuickGradient* to a QJSValue, it forgot to also change how it was initialised, with 0 causing QJSValue to consider itself a number, and hence trigger the warning added to QGradient in 3b7db8ac90b. Change-Id: I83377c40984f596f56645aea467b74de1a152b62 Fixes: QTBUG-74911 Reviewed-by: Tor Arne Vestbø --- src/quick/items/qquickrectangle_p_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/quick/items') diff --git a/src/quick/items/qquickrectangle_p_p.h b/src/quick/items/qquickrectangle_p_p.h index c7c5293f9b..f40e5adada 100644 --- a/src/quick/items/qquickrectangle_p_p.h +++ b/src/quick/items/qquickrectangle_p_p.h @@ -64,7 +64,7 @@ class QQuickRectanglePrivate : public QQuickItemPrivate public: QQuickRectanglePrivate() : - color(Qt::white), gradient(0), pen(0), radius(0) + color(Qt::white), gradient(QJSValue::UndefinedValue), pen(0), radius(0) { } -- cgit v1.2.3 From aba6cea90e023c99ac55b0e8dcdeae0af8305ef2 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Wed, 3 Apr 2019 16:16:19 +0200 Subject: In response to touch cancel, don't just ungrab, send an ungrab event MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QQuickWindowPrivate::sendUngrabEvent() sends an UngrabMouse event, and that can be filtered by parent filters. If a touch cancel happens to a MouseArea in a ListView delegate, we need the ListView to filter the UngrabMouse event so that QQuickFlickable::childMouseEventFilter() will call QQuickFlickable::mouseUngrabEvent() and QQuickFlickablePrivate::cancelInteraction() will set pressed to false. The pressed state became true because Flickable filtered the press event; so for symmetry, it also needs to filter the touch cancel (in the form of a mouse ungrab), to avoid being stuck in a state where it can't move programmatically. Fixes: QTBUG-74679 Change-Id: I6c0ed364d2bc1f45c7e7b17846a09f6b53f91d0a Reviewed-by: Qt CI Bot Reviewed-by: Jan Arve Sæther --- src/quick/items/qquickwindow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/quick/items') diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index fa9aa88faa..c6bfcaa647 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -2017,8 +2017,8 @@ bool QQuickWindowPrivate::deliverTouchCancelEvent(QTouchEvent *event) qCDebug(DBG_TOUCH) << event; Q_Q(QQuickWindow); - if (q->mouseGrabberItem()) - q->mouseGrabberItem()->ungrabMouse(); + if (QQuickItem *grabber = q->mouseGrabberItem()) + sendUngrabEvent(grabber, true); cancelTouchMouseSynthesis(); // A TouchCancel event will typically not contain any points. -- cgit v1.2.3 From 34c98070d158386673d607eb860f682635849d4a Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 5 Apr 2019 09:42:17 +0200 Subject: Fix deprecation warnings about QVariant API Fix warnings like: sruntime/qv4serialize.cpp:378:45: warning: 'QVariant qVariantFromValue(const T&) [with T = QQmlListModelWorkerAgent::VariantRef]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations] qml/qqmlvmemetaobject.cpp:597:61: warning: 'QVariant qVariantFromValue(const T&) [with T = QList]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations] jsruntime/qv4engine.cpp:1319:66: warning: 'QVariant qVariantFromValue(const T&) [with T = QObject*]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations] jsruntime/qv4engine.cpp:1350:60: warning: 'QVariant qVariantFromValue(const T&) [with T = QList]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations] items/qquickitem.cpp:8396:78: warning: 'QVariant qVariantFromValue(const T&) [with T = QObject*]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations] items/qquickitem.cpp:8693:80: warning: 'QVariant qVariantFromValue(const T&) [with T = QObject*]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations] items/qquickgenericshadereffect.cpp:126:69: warning: 'QVariant qVariantFromValue(const T&) [with T = QObject*]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations] items/qquickgenericshadereffect.cpp:127:55: warning: 'QVariant qVariantFromValue(const T&) [with T = QSize]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations] items/qquickopenglshadereffect.cpp:713:69: warning: 'QVariant qVariantFromValue(const T&) [with T = QObject*]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations] items/qquickopenglshadereffect.cpp:714:55: warning: 'QVariant qVariantFromValue(const T&) [with T = QSize]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations] qquickcustomparticle.cpp:416:89: warning: 'QVariant qVariantFromValue(const T&) [with T = double]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations] qqmlenginedebugclient.cpp:403:47: warning: 'QVariant qVariantFromValue(const T&) [with T = QQmlEngineDebugObjectReference]' is deprecated: Use QVariant::fromValue() instead. [-Wdeprecated-declarations] Task-number: QTBUG-74043 Change-Id: I14cb7d7c1fb8dc6321e32208a7de15f6bdb19065 Reviewed-by: Ulf Hermann --- src/quick/items/qquickgenericshadereffect.cpp | 4 ++-- src/quick/items/qquickitem.cpp | 4 ++-- src/quick/items/qquickopenglshadereffect.cpp | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/quick/items') diff --git a/src/quick/items/qquickgenericshadereffect.cpp b/src/quick/items/qquickgenericshadereffect.cpp index 248c2b6ec3..3e7eda28eb 100644 --- a/src/quick/items/qquickgenericshadereffect.cpp +++ b/src/quick/items/qquickgenericshadereffect.cpp @@ -123,8 +123,8 @@ void QQuickGenericShaderEffect::setBlending(bool enable) QVariant QQuickGenericShaderEffect::mesh() const { - return m_mesh ? qVariantFromValue(static_cast(m_mesh)) - : qVariantFromValue(m_meshResolution); + return m_mesh ? QVariant::fromValue(static_cast(m_mesh)) + : QVariant::fromValue(m_meshResolution); } void QQuickGenericShaderEffect::setMesh(const QVariant &mesh) diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index 7469fee72b..e114404524 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -8393,7 +8393,7 @@ void QQuickItemLayer::activateEffect() m_effect->stackAfter(m_effectSource); } m_effect->setVisible(m_item->isVisible()); - m_effect->setProperty(m_name, qVariantFromValue(m_effectSource)); + m_effect->setProperty(m_name, QVariant::fromValue(m_effectSource)); QQuickItemPrivate::get(m_effect)->setTransparentForPositioner(true); m_effectComponent->completeCreate(); } @@ -8690,7 +8690,7 @@ void QQuickItemLayer::setName(const QByteArray &name) { return; if (m_effect) { m_effect->setProperty(m_name, QVariant()); - m_effect->setProperty(name, qVariantFromValue(m_effectSource)); + m_effect->setProperty(name, QVariant::fromValue(m_effectSource)); } m_name = name; emit nameChanged(name); diff --git a/src/quick/items/qquickopenglshadereffect.cpp b/src/quick/items/qquickopenglshadereffect.cpp index 3aa00340b2..bc1f787b81 100644 --- a/src/quick/items/qquickopenglshadereffect.cpp +++ b/src/quick/items/qquickopenglshadereffect.cpp @@ -710,8 +710,8 @@ void QQuickOpenGLShaderEffect::setBlending(bool enable) QVariant QQuickOpenGLShaderEffect::mesh() const { - return m_mesh ? qVariantFromValue(static_cast(m_mesh)) - : qVariantFromValue(m_meshResolution); + return m_mesh ? QVariant::fromValue(static_cast(m_mesh)) + : QVariant::fromValue(m_meshResolution); } void QQuickOpenGLShaderEffect::setMesh(const QVariant &mesh) -- cgit v1.2.3 From 96c4fffd8648e9c9fb95e8208a76933c8c2120bc Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 5 Apr 2019 09:58:31 +0200 Subject: Remove unused includes of qv8engine_p.h Change-Id: Ic135a863581d29a3afb9c6c7f070d2630b3913b4 Reviewed-by: Lars Knoll --- src/quick/items/qquickdrag.cpp | 1 - src/quick/items/qquickdrag_p.h | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'src/quick/items') diff --git a/src/quick/items/qquickdrag.cpp b/src/quick/items/qquickdrag.cpp index f60f3c1ccf..74a00435e7 100644 --- a/src/quick/items/qquickdrag.cpp +++ b/src/quick/items/qquickdrag.cpp @@ -45,7 +45,6 @@ #include #include #include -#include #include #include #include diff --git a/src/quick/items/qquickdrag_p.h b/src/quick/items/qquickdrag_p.h index 6bfbae74c9..81f3fb5e5c 100644 --- a/src/quick/items/qquickdrag_p.h +++ b/src/quick/items/qquickdrag_p.h @@ -53,7 +53,7 @@ #include -#include +#include #include #include -- cgit v1.2.3 From 1f4862ef5db138e9dcefe1ebc16df3e054200775 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Tue, 26 Mar 2019 17:37:48 +0100 Subject: QQuickWindow: Run render jobs when there is a render control in NoStage When running a QML application with using Canvas3D component inside a QQuickWidget, the Canvas3D is not rendered. This is due to no scheduled OpenGL commands with RenderStage == NoStage are actually executed when there is a render control instead of a window manager. Fixes: QTBUG-51993 Change-Id: I33323893cd6144187feccb1c6bcd010eff0fff6d Reviewed-by: Laszlo Agocs --- src/quick/items/qquickwindow.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/quick/items') diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index c6bfcaa647..bd01e9b3ce 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -4828,10 +4828,18 @@ void QQuickWindow::scheduleRenderJob(QRunnable *job, RenderStage stage) } else if (stage == AfterSwapStage) { d->afterSwapJobs << job; } else if (stage == NoStage) { - if (isExposed()) + if (d->renderControl && openglContext() +#if QT_CONFIG(opengl) + && openglContext()->thread() == QThread::currentThread() +#endif + ) { + job->run(); + delete job; + } else if (isExposed()) { d->windowManager->postJob(this, job); - else + } else { delete job; + } } d->renderJobMutex.unlock(); } -- cgit v1.2.3 From 65299ce292180a845eb2d76756faeeaa1456d8f0 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Thu, 4 Apr 2019 16:00:36 +0200 Subject: Remove QQmlV4Handle This is just an alias for QV4::ReturnedValue. We can as well use the latter. Change-Id: Ibd2c038a3ca726b39a8f0f05e02922adb9fccbdb Reviewed-by: Simon Hausmann --- src/quick/items/context2d/qquickcanvascontext_p.h | 3 ++- src/quick/items/context2d/qquickcanvasitem.cpp | 7 ++----- src/quick/items/context2d/qquickcanvasitem_p.h | 6 +++--- src/quick/items/context2d/qquickcontext2d.cpp | 6 +++++- src/quick/items/context2d/qquickcontext2d_p.h | 2 +- 5 files changed, 13 insertions(+), 11 deletions(-) (limited to 'src/quick/items') diff --git a/src/quick/items/context2d/qquickcanvascontext_p.h b/src/quick/items/context2d/qquickcanvascontext_p.h index 95100d2912..3872a2ac74 100644 --- a/src/quick/items/context2d/qquickcanvascontext_p.h +++ b/src/quick/items/context2d/qquickcanvascontext_p.h @@ -56,7 +56,7 @@ QT_REQUIRE_CONFIG(quick_canvas); #include -#include +#include QT_BEGIN_NAMESPACE @@ -80,6 +80,7 @@ public: virtual void prepare(const QSize& canvasSize, const QSize& tileSize, const QRect& canvasWindow, const QRect& dirtyRect, bool smooth, bool antialiasing); virtual void flush(); + virtual QV4::ExecutionEngine *v4Engine() const = 0; virtual void setV4Engine(QV4::ExecutionEngine *engine) = 0; virtual QV4::ReturnedValue v4value() const = 0; diff --git a/src/quick/items/context2d/qquickcanvasitem.cpp b/src/quick/items/context2d/qquickcanvasitem.cpp index 14443a2f2f..188e74cd89 100644 --- a/src/quick/items/context2d/qquickcanvasitem.cpp +++ b/src/quick/items/context2d/qquickcanvasitem.cpp @@ -378,13 +378,10 @@ void QQuickCanvasItem::setContextType(const QString &contextType) this property will contain the current drawing context, otherwise null. */ -QQmlV4Handle QQuickCanvasItem::context() const +QJSValue QQuickCanvasItem::context() const { Q_D(const QQuickCanvasItem); - if (d->context) - return QQmlV4Handle(d->context->v4value()); - - return QQmlV4Handle(QV4::Encode::null()); + return d->context ? QJSValue(d->context->v4Engine(), d->context->v4value()) : QJSValue(); } /*! diff --git a/src/quick/items/context2d/qquickcanvasitem_p.h b/src/quick/items/context2d/qquickcanvasitem_p.h index 7dc981a6eb..cd2977429b 100644 --- a/src/quick/items/context2d/qquickcanvasitem_p.h +++ b/src/quick/items/context2d/qquickcanvasitem_p.h @@ -56,9 +56,9 @@ QT_REQUIRE_CONFIG(quick_canvas); #include -#include #include #include +#include #include QT_BEGIN_NAMESPACE @@ -93,7 +93,7 @@ class QQuickCanvasItem : public QQuickItem Q_PROPERTY(bool available READ isAvailable NOTIFY availableChanged) Q_PROPERTY(QString contextType READ contextType WRITE setContextType NOTIFY contextTypeChanged) - Q_PROPERTY(QQmlV4Handle context READ context NOTIFY contextChanged) + Q_PROPERTY(QJSValue context READ context NOTIFY contextChanged) Q_PROPERTY(QSizeF canvasSize READ canvasSize WRITE setCanvasSize NOTIFY canvasSizeChanged) Q_PROPERTY(QSize tileSize READ tileSize WRITE setTileSize NOTIFY tileSizeChanged) Q_PROPERTY(QRectF canvasWindow READ canvasWindow WRITE setCanvasWindow NOTIFY canvasWindowChanged) @@ -122,7 +122,7 @@ public: QString contextType() const; void setContextType(const QString &contextType); - QQmlV4Handle context() const; + QJSValue context() const; QSizeF canvasSize() const; void setCanvasSize(const QSizeF &); diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp index 546f3011ec..58bc12a221 100644 --- a/src/quick/items/context2d/qquickcontext2d.cpp +++ b/src/quick/items/context2d/qquickcontext2d.cpp @@ -56,7 +56,6 @@ #include #include -#include #include #include @@ -4552,6 +4551,11 @@ void QQuickContext2D::reset() m_buffer->clearRect(QRectF(0, 0, m_canvas->width(), m_canvas->height())); } +QV4::ExecutionEngine *QQuickContext2D::v4Engine() const +{ + return m_v4engine; +} + void QQuickContext2D::setV4Engine(QV4::ExecutionEngine *engine) { if (m_v4engine != engine) { diff --git a/src/quick/items/context2d/qquickcontext2d_p.h b/src/quick/items/context2d/qquickcontext2d_p.h index 1ece6796f3..b5626dec0c 100644 --- a/src/quick/items/context2d/qquickcontext2d_p.h +++ b/src/quick/items/context2d/qquickcontext2d_p.h @@ -65,7 +65,6 @@ QT_REQUIRE_CONFIG(quick_canvas); #include #include #include -#include #include #include @@ -199,6 +198,7 @@ public: QImage toImage(const QRectF& bounds) override; QV4::ReturnedValue v4value() const override; + QV4::ExecutionEngine *v4Engine() const override; void setV4Engine(QV4::ExecutionEngine *eng) override; QQuickCanvasItem* canvas() const { return m_canvas; } -- cgit v1.2.3 From 48f9dbf06a8fc8530edeb74ff93282b7cbb570d2 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Thu, 4 Apr 2019 10:12:23 +0200 Subject: QQuickTableView: remove superfluous rebuildScheduled property We already have the variable 'scheduledRebuildOptions'. When this is set to something else than RebuildOption::None, it means that a rebuild is scheduled. Change-Id: I85cde5c45eba15023cd389ebb0ba86f9d58835ae Reviewed-by: Mitch Curtis --- src/quick/items/qquicktableview.cpp | 8 +++----- src/quick/items/qquicktableview_p_p.h | 1 - 2 files changed, 3 insertions(+), 6 deletions(-) (limited to 'src/quick/items') diff --git a/src/quick/items/qquicktableview.cpp b/src/quick/items/qquicktableview.cpp index 17bdeed1fb..12faac8127 100644 --- a/src/quick/items/qquicktableview.cpp +++ b/src/quick/items/qquicktableview.cpp @@ -1704,7 +1704,6 @@ void QQuickTableViewPrivate::scheduleRebuildTable(RebuildOptions options) { return; } - rebuildScheduled = true; scheduledRebuildOptions |= options; q_func()->polish(); } @@ -1758,7 +1757,7 @@ void QQuickTableViewPrivate::updatePolish() void QQuickTableViewPrivate::fixup(QQuickFlickablePrivate::AxisData &data, qreal minExtent, qreal maxExtent) { - if (rebuildScheduled || rebuildState != RebuildState::Done) + if (scheduledRebuildOptions || rebuildState != RebuildState::Done) return; QQuickFlickablePrivate::fixup(data, minExtent, maxExtent); @@ -1850,13 +1849,12 @@ void QQuickTableViewPrivate::syncWithPendingChanges() void QQuickTableViewPrivate::syncRebuildOptions() { - if (!rebuildScheduled) + if (!scheduledRebuildOptions) return; rebuildState = RebuildState::Begin; rebuildOptions = scheduledRebuildOptions; scheduledRebuildOptions = RebuildOption::None; - rebuildScheduled = false; if (loadedItems.isEmpty()) { // If we have no items from before, we cannot just rebuild the viewport, but need @@ -2245,7 +2243,7 @@ void QQuickTableView::viewportMoved(Qt::Orientations orientation) d->scheduleRebuildTable(options); } - if (d->rebuildScheduled) { + if (d->scheduledRebuildOptions) { // No reason to do anything, since we're about to rebuild the whole table anyway. // Besides, calling updatePolish, which will start the rebuild, can easily cause // binding loops to happen since we usually end up modifying the geometry of the diff --git a/src/quick/items/qquicktableview_p_p.h b/src/quick/items/qquicktableview_p_p.h index f2fef0d774..53bd6ec973 100644 --- a/src/quick/items/qquicktableview_p_p.h +++ b/src/quick/items/qquicktableview_p_p.h @@ -249,7 +249,6 @@ public: bool columnRowPositionsInvalid = false; bool layoutWarningIssued = false; bool polishing = false; - bool rebuildScheduled = true; QJSValue rowHeightProvider; QJSValue columnWidthProvider; -- cgit v1.2.3 From 7ded77dda5a050db7064430d1a45948bca8194ab Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Tue, 2 Apr 2019 16:07:34 +0200 Subject: Quick fix for not working input handling for eglfs On eglfs platform input events are driven by libinput and do not have window information as such. They are simply delivered based on QGuiApplication::topLevelAt window selection. In case of WebEnigne, QQuickWindow is returned as top level window. QQuickWidget uses this QQuickWindow as an offscreen window, however since 561b932 we fake 'visible' and 'visibility' values so windows api in qml can use those properties. This ends up with broken event delivery on eglfs, since window is offscreen and therefore not really visible. Make a minimalistic change to fix the issue, without braking QTBUG-49054, which requires 'visibility' to have fake values, and 'visible' will keep window as not visible for event delivery system. Fix encapsulation of setVisible(), prevent accidental window creation when setVsiible() called from qml via binding. The proper fix would require for example adding some new flag to underlying offscreen window, which could be used by event window selection mechanism or rework of qquickwidget offscreen window parameters expose to qml. Task-number: QTBUG-65761 Task-number: QTBUG-49054 Change-Id: I2a307ee5613771adf6d31f1c3cc4b4a25d7620df Reviewed-by: Ulf Hermann --- src/quick/items/qquickwindow.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src/quick/items') diff --git a/src/quick/items/qquickwindow.h b/src/quick/items/qquickwindow.h index 79e8a11aa8..53fe0a4c4b 100644 --- a/src/quick/items/qquickwindow.h +++ b/src/quick/items/qquickwindow.h @@ -241,6 +241,7 @@ private: friend class QQuickWidget; friend class QQuickRenderControl; friend class QQuickAnimatorController; + friend class QQuickWidgetPrivate; Q_DISABLE_COPY(QQuickWindow) }; -- cgit v1.2.3 From 0ddc5ba510938368a7368f2a5cfda6ea22217a96 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Tue, 9 Apr 2019 10:54:34 +0200 Subject: QQuickTableView: combine layouts and rebuilds into the same code path Rather than handle relayouts differenty than rebuilds, we can make it a part of the rebuild structure instead, since they overlap a lot. That way we can collect everything that needs to be updated into a single variable (rebuildOptions). This will simplify the upcoming work for synchronizing tableviews. Change-Id: I8bb2638612c86194a854e6fefc998eae22357a7a Reviewed-by: Mitch Curtis --- src/quick/items/qquicktableview.cpp | 49 ++++++++++++++++------------------- src/quick/items/qquicktableview_p_p.h | 11 ++++---- 2 files changed, 28 insertions(+), 32 deletions(-) (limited to 'src/quick/items') diff --git a/src/quick/items/qquicktableview.cpp b/src/quick/items/qquicktableview.cpp index 12faac8127..9bc6723cbd 100644 --- a/src/quick/items/qquicktableview.cpp +++ b/src/quick/items/qquicktableview.cpp @@ -709,9 +709,8 @@ void QQuickTableViewPrivate::syncLoadedTableRectFromLoadedTable() void QQuickTableViewPrivate::forceLayout() { - columnRowPositionsInvalid = true; clearEdgeSizeCache(); - RebuildOptions rebuildOptions = RebuildOption::None; + RebuildOptions rebuildOptions = RebuildOption::LayoutOnly; // Go through all columns from first to last, find the columns that used // to be hidden and not loaded, and check if they should become visible @@ -750,8 +749,7 @@ void QQuickTableViewPrivate::forceLayout() break; } - if (rebuildOptions) - scheduleRebuildTable(rebuildOptions); + scheduleRebuildTable(rebuildOptions); if (polishing) { qWarning() << "TableView::forceLayout(): Cannot do an immediate re-layout during an ongoing layout!"; @@ -1195,7 +1193,6 @@ void QQuickTableViewPrivate::relayoutTable() void QQuickTableViewPrivate::relayoutTableItems() { qCDebug(lcTableViewDelegateLifecycle); - columnRowPositionsInvalid = false; qreal nextColumnX = loadedTableOuterRect.x(); qreal nextRowY = loadedTableOuterRect.y(); @@ -1465,7 +1462,13 @@ bool QQuickTableViewPrivate::moveToNextRebuildState() // that the current state is not yet done. return false; } - rebuildState = RebuildState(int(rebuildState) + 1); + + if (rebuildState == RebuildState::Begin + && rebuildOptions.testFlag(RebuildOption::LayoutOnly)) + rebuildState = RebuildState::LayoutTable; + else + rebuildState = RebuildState(int(rebuildState) + 1); + qCDebug(lcTableViewDelegateLifecycle()) << int(rebuildState); return true; } @@ -1527,7 +1530,6 @@ void QQuickTableViewPrivate::beginRebuildTable() loadedRows.clear(); loadedTableOuterRect = QRect(); loadedTableInnerRect = QRect(); - columnRowPositionsInvalid = false; clearEdgeSizeCache(); if (topLeft.x() == kEdgeIndexAtEnd || topLeft.y() == kEdgeIndexAtEnd) { @@ -1541,12 +1543,14 @@ void QQuickTableViewPrivate::beginRebuildTable() void QQuickTableViewPrivate::layoutAfterLoadingInitialTable() { - if (rowHeightProvider.isUndefined() || columnWidthProvider.isUndefined()) { + if (rebuildOptions.testFlag(RebuildOption::LayoutOnly) + || rowHeightProvider.isUndefined() || columnWidthProvider.isUndefined()) { // Since we don't have both size providers, we need to calculate the // size of each row and column based on the size of the delegate items. // This couldn't be done while we were loading the initial rows and // columns, since during the process, we didn't have all the items - // available yet for the calculation. So we do it now. + // available yet for the calculation. So we do it now. The exception + // is if we specifically only requested a relayout. relayoutTable(); } @@ -1708,11 +1712,6 @@ void QQuickTableViewPrivate::scheduleRebuildTable(RebuildOptions options) { q_func()->polish(); } -void QQuickTableViewPrivate::invalidateColumnRowPositions() { - columnRowPositionsInvalid = true; - q_func()->polish(); -} - void QQuickTableViewPrivate::updatePolish() { // Whenever something changes, e.g viewport moves, spacing is set to a @@ -1745,13 +1744,6 @@ void QQuickTableViewPrivate::updatePolish() if (loadedItems.isEmpty()) return; - if (columnRowPositionsInvalid) { - relayoutTable(); - updateAverageEdgeSize(); - updateContentWidth(); - updateContentHeight(); - } - loadAndUnloadVisibleEdges(); } @@ -1856,10 +1848,15 @@ void QQuickTableViewPrivate::syncRebuildOptions() rebuildOptions = scheduledRebuildOptions; scheduledRebuildOptions = RebuildOption::None; - if (loadedItems.isEmpty()) { - // If we have no items from before, we cannot just rebuild the viewport, but need - // to rebuild everything, since we have no top-left loaded item to start from. + if (loadedItems.isEmpty()) rebuildOptions.setFlag(RebuildOption::All); + + // Some options are exclusive: + if (rebuildOptions.testFlag(RebuildOption::All)) { + rebuildOptions.setFlag(RebuildOption::ViewportOnly, false); + rebuildOptions.setFlag(RebuildOption::LayoutOnly, false); + } else if (rebuildOptions.testFlag(RebuildOption::ViewportOnly)) { + rebuildOptions.setFlag(RebuildOption::LayoutOnly, false); } } @@ -2073,7 +2070,7 @@ void QQuickTableView::setRowSpacing(qreal spacing) return; d->cellSpacing.setHeight(spacing); - d->invalidateColumnRowPositions(); + d->scheduleRebuildTable(QQuickTableViewPrivate::RebuildOption::LayoutOnly); emit rowSpacingChanged(); } @@ -2091,7 +2088,7 @@ void QQuickTableView::setColumnSpacing(qreal spacing) return; d->cellSpacing.setWidth(spacing); - d->invalidateColumnRowPositions(); + d->scheduleRebuildTable(QQuickTableViewPrivate::RebuildOption::LayoutOnly); emit columnSpacingChanged(); } diff --git a/src/quick/items/qquicktableview_p_p.h b/src/quick/items/qquicktableview_p_p.h index 53bd6ec973..acf537198b 100644 --- a/src/quick/items/qquicktableview_p_p.h +++ b/src/quick/items/qquicktableview_p_p.h @@ -188,10 +188,11 @@ public: enum class RebuildOption { None = 0, - ViewportOnly = 0x1, - CalculateNewTopLeftRow = 0x2, - CalculateNewTopLeftColumn = 0x4, - All = 0x8, + LayoutOnly = 0x1, + ViewportOnly = 0x2, + CalculateNewTopLeftRow = 0x4, + CalculateNewTopLeftColumn = 0x8, + All = 0x10, }; Q_DECLARE_FLAGS(RebuildOptions, RebuildOption) @@ -246,7 +247,6 @@ public: QQmlTableInstanceModel::ReusableFlag reusableFlag = QQmlTableInstanceModel::Reusable; bool blockItemCreatedCallback = false; - bool columnRowPositionsInvalid = false; bool layoutWarningIssued = false; bool polishing = false; @@ -356,7 +356,6 @@ public: void layoutAfterLoadingInitialTable(); void scheduleRebuildTable(QQuickTableViewPrivate::RebuildOptions options); - void invalidateColumnRowPositions(); int resolveImportVersion(); void createWrapperModel(); -- cgit v1.2.3 From 053f88c3b283db0e6b75adb4df010b948903cea4 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Wed, 27 Mar 2019 11:38:53 +0100 Subject: QQuickTableView: improve checking rebuild status while rebuilding Change-Id: I5e7b5b261d3ba28fbbf345f2fc3f086d87112a2d Reviewed-by: Mitch Curtis --- src/quick/items/qquicktableview.cpp | 57 ++++++++++++++++++++++++----------- src/quick/items/qquicktableview_p_p.h | 1 - 2 files changed, 39 insertions(+), 19 deletions(-) (limited to 'src/quick/items') diff --git a/src/quick/items/qquicktableview.cpp b/src/quick/items/qquicktableview.cpp index 9bc6723cbd..1dca5bea4a 100644 --- a/src/quick/items/qquicktableview.cpp +++ b/src/quick/items/qquicktableview.cpp @@ -1398,6 +1398,22 @@ void QQuickTableViewPrivate::processLoadRequest() void QQuickTableViewPrivate::processRebuildTable() { + Q_Q(QQuickTableView); + + if (rebuildState == RebuildState::Begin) { + if (Q_UNLIKELY(lcTableViewDelegateLifecycle().isDebugEnabled())) { + qCDebug(lcTableViewDelegateLifecycle()) << "begin rebuild:" << q; + if (rebuildOptions & RebuildOption::All) + qCDebug(lcTableViewDelegateLifecycle()) << "RebuildOption::All, options:" << rebuildOptions; + else if (rebuildOptions & RebuildOption::ViewportOnly) + qCDebug(lcTableViewDelegateLifecycle()) << "RebuildOption::ViewportOnly, options:" << rebuildOptions; + else if (rebuildOptions & RebuildOption::LayoutOnly) + qCDebug(lcTableViewDelegateLifecycle()) << "RebuildOption::LayoutOnly, options:" << rebuildOptions; + else + Q_TABLEVIEW_UNREACHABLE(rebuildOptions); + } + } + moveToNextRebuildState(); if (rebuildState == RebuildState::LoadInitalTable) { @@ -1408,12 +1424,11 @@ void QQuickTableViewPrivate::processRebuildTable() if (rebuildState == RebuildState::VerifyTable) { if (loadedItems.isEmpty()) { - qCDebug(lcTableViewDelegateLifecycle()) << "no items loaded, meaning empty model, all rows or columns hidden, or no delegate"; + qCDebug(lcTableViewDelegateLifecycle()) << "no items loaded!"; rebuildState = RebuildState::Done; + } else if (!moveToNextRebuildState()) { return; } - if (!moveToNextRebuildState()) - return; } if (rebuildState == RebuildState::LayoutTable) { @@ -1453,6 +1468,7 @@ void QQuickTableViewPrivate::processRebuildTable() } Q_TABLEVIEW_ASSERT(rebuildState == RebuildState::Done, int(rebuildState)); + qCDebug(lcTableViewDelegateLifecycle()) << "rebuild complete:" << q; } bool QQuickTableViewPrivate::moveToNextRebuildState() @@ -1532,12 +1548,30 @@ void QQuickTableViewPrivate::beginRebuildTable() loadedTableInnerRect = QRect(); clearEdgeSizeCache(); + if (!model) { + qCDebug(lcTableViewDelegateLifecycle()) << "no model found, leaving table empty"; + return; + } + + if (model->count() == 0) { + qCDebug(lcTableViewDelegateLifecycle()) << "empty model found, leaving table empty"; + return; + } + + if (tableModel && !tableModel->delegate()) { + qCDebug(lcTableViewDelegateLifecycle()) << "no delegate found, leaving table empty"; + return; + } + if (topLeft.x() == kEdgeIndexAtEnd || topLeft.y() == kEdgeIndexAtEnd) { - // No visible columns or rows, so nothing to load + qCDebug(lcTableViewDelegateLifecycle()) << "no visible rows or columns, leaving table empty"; return; } - loadInitialTopLeftItem(topLeft, topLeftPos); + // Load top-left item. After loaded, loadItemsInsideRect() will take + // care of filling out the rest of the table. + loadRequest.begin(topLeft, topLeftPos, QQmlIncubator::AsynchronousIfNested); + processLoadRequest(); loadAndUnloadVisibleEdges(); } @@ -1559,19 +1593,6 @@ void QQuickTableViewPrivate::layoutAfterLoadingInitialTable() updateContentHeight(); } -void QQuickTableViewPrivate::loadInitialTopLeftItem(const QPoint &cell, const QPointF &pos) -{ - Q_TABLEVIEW_ASSERT(loadedItems.isEmpty(), ""); - - if (tableModel && !tableModel->delegate()) - return; - - // Load top-left item. After loaded, loadItemsInsideRect() will take - // care of filling out the rest of the table. - loadRequest.begin(cell, pos, QQmlIncubator::AsynchronousIfNested); - processLoadRequest(); -} - void QQuickTableViewPrivate::unloadEdge(Qt::Edge edge) { qCDebug(lcTableViewDelegateLifecycle) << edge; diff --git a/src/quick/items/qquicktableview_p_p.h b/src/quick/items/qquicktableview_p_p.h index acf537198b..6bbfd4e2d6 100644 --- a/src/quick/items/qquicktableview_p_p.h +++ b/src/quick/items/qquicktableview_p_p.h @@ -341,7 +341,6 @@ public: void releaseLoadedItems(QQmlTableInstanceModel::ReusableFlag reusableFlag); void unloadItem(const QPoint &cell); - void loadInitialTopLeftItem(const QPoint &cell, const QPointF &pos); void loadEdge(Qt::Edge edge, QQmlIncubator::IncubationMode incubationMode); void unloadEdge(Qt::Edge edge); void loadAndUnloadVisibleEdges(); -- cgit v1.2.3