summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-09-21 08:33:50 +0200
committerLiang Qi <liang.qi@qt.io>2016-09-21 08:33:50 +0200
commit4e26a18ede1775ae06bef7c272994e84510ebd9a (patch)
tree0543dca51dc0b4f7a42c755235db4b00d2f080b4
parent271d1efc13d4534830e37fd12fa6202981da723c (diff)
parent3b093789b07c670e29d3275e26c4e7122db042ae (diff)
downloadqtquickcontrols-4e26a18ede1775ae06bef7c272994e84510ebd9a.tar.gz
Merge remote-tracking branch 'origin/5.8' into dev
Change-Id: I20f0f7a50b55907f4a6e574bdfe92bc9538879d6
-rw-r--r--dist/changes-5.6.230
-rw-r--r--examples/quickcontrols/controls/calendar/calendar.pro2
-rw-r--r--examples/quickcontrols/controls/texteditor/src/documenthandler.cpp6
-rw-r--r--src/controls/Private/ScrollViewHelper.qml10
-rw-r--r--src/controls/Private/TreeViewItemDelegateLoader.qml2
-rw-r--r--src/controls/Private/qquickrangemodel.cpp33
-rw-r--r--src/controls/Private/qquickrangemodel_p.h7
-rw-r--r--src/controls/Private/qquickrangemodel_p_p.h3
-rw-r--r--src/controls/Private/qquickstyleitem.cpp2
-rw-r--r--src/controls/Private/qquicktreemodeladaptor.cpp51
-rw-r--r--src/controls/Private/qquicktreemodeladaptor_p.h5
-rw-r--r--src/controls/Slider.qml6
-rw-r--r--src/controls/SplitView.qml6
-rw-r--r--src/controls/Styles/Base/CheckBoxStyle.qml2
-rw-r--r--src/controls/TableViewColumn.qml2
-rw-r--r--src/controls/controls.pro2
-rw-r--r--src/controls/doc/src/qtquickcontrols-examples.qdoc6
-rw-r--r--src/controls/doc/src/qtquickcontrols-tableview.qdoc2
-rw-r--r--src/controls/qquickmenu.cpp17
-rw-r--r--src/controls/qquickmenu_p.h2
-rw-r--r--src/controls/qquickpopupwindow.cpp3
-rw-r--r--src/dialogs/qquickabstractcolordialog.cpp6
-rw-r--r--src/dialogs/qquickabstractcolordialog_p.h3
-rw-r--r--src/dialogs/qquickabstractfontdialog.cpp6
-rw-r--r--src/dialogs/qquickabstractfontdialog_p.h3
-rw-r--r--src/dialogs/qquickcolordialog.cpp6
-rw-r--r--src/dialogs/qquickcolordialog_p.h3
-rw-r--r--src/dialogs/qquickfontdialog.cpp6
-rw-r--r--src/dialogs/qquickfontdialog_p.h3
-rw-r--r--src/dialogs/qquickplatformfontdialog.cpp2
-rw-r--r--tests/auto/controls/data/layout/Container.qml55
-rw-r--r--tests/auto/controls/data/layout/ContainerUser.qml53
-rw-r--r--tests/auto/controls/data/rangemodel/init.qml56
-rw-r--r--tests/auto/controls/data/tst_layout.qml11
-rw-r--r--tests/auto/controls/data/tst_rangemodel.qml8
-rw-r--r--tests/auto/controls/data/tst_scrollview.qml63
-rw-r--r--tests/auto/controls/data/tst_slider.qml40
-rw-r--r--tests/auto/extras/BLACKLIST2
-rw-r--r--tests/auto/qquicktreemodeladaptor/tst_qquicktreemodeladaptor.cpp51
-rw-r--r--tests/auto/shared/testmodel.h2
-rw-r--r--tests/auto/testplugin/testcppmodels.h52
-rw-r--r--tests/auto/testplugin/testplugin.cpp1
42 files changed, 583 insertions, 48 deletions
diff --git a/dist/changes-5.6.2 b/dist/changes-5.6.2
new file mode 100644
index 00000000..ac1d5f92
--- /dev/null
+++ b/dist/changes-5.6.2
@@ -0,0 +1,30 @@
+Qt 5.6.2 is a bug-fix release. It maintains both forward and backward
+compatibility (source and binary) with Qt 5.6.0.
+
+For more details, refer to the online documentation included in this
+distribution. The documentation is also available online:
+
+ http://doc.qt.io/qt-5/index.html
+
+The Qt version 5.6 series is binary compatible with the 5.5.x series.
+Applications compiled for 5.5 will continue to run with 5.6.
+
+Some of the changes listed in this file include issue tracking numbers
+corresponding to tasks in the Qt Bug Tracker:
+
+ https://bugreports.qt.io/
+
+Each of these identifiers can be entered in the bug tracker to obtain more
+information about a particular change.
+
+****************************************************************************
+* Controls *
+****************************************************************************
+
+ - [QTBUG-50795] ScrollView: fixed to update the position of the scroll
+ bars on content size change.
+ - [QTBUG-47523] TreeView: fixed moving of items
+ - RangeModel: fixed to emit min/max and value changes after component is
+ complete
+ - Menu: fixed native menu on macOS to to get dismissed when its parent
+ window is destroyed
diff --git a/examples/quickcontrols/controls/calendar/calendar.pro b/examples/quickcontrols/controls/calendar/calendar.pro
index 67960e27..0c79fb40 100644
--- a/examples/quickcontrols/controls/calendar/calendar.pro
+++ b/examples/quickcontrols/controls/calendar/calendar.pro
@@ -1,7 +1,7 @@
QT += qml quick sql
TARGET = calendar
-!contains(sql-drivers, sqlite): QTPLUGIN += qsqlite
+!qtConfig(sql-sqlite): QTPLUGIN += qsqlite
include(src/src.pri)
include(../shared/shared.pri)
diff --git a/examples/quickcontrols/controls/texteditor/src/documenthandler.cpp b/examples/quickcontrols/controls/texteditor/src/documenthandler.cpp
index bdecf5ba..69da88f0 100644
--- a/examples/quickcontrols/controls/texteditor/src/documenthandler.cpp
+++ b/examples/quickcontrols/controls/texteditor/src/documenthandler.cpp
@@ -179,6 +179,9 @@ void DocumentHandler::reset()
QTextCursor DocumentHandler::textCursor() const
{
+ if (!m_doc)
+ return QTextCursor();
+
QTextCursor cursor = QTextCursor(m_doc);
if (m_selectionStart != m_selectionEnd) {
cursor.setPosition(m_selectionStart);
@@ -209,6 +212,9 @@ void DocumentHandler::setSelectionEnd(int position)
void DocumentHandler::setAlignment(Qt::Alignment a)
{
+ if (!m_doc)
+ return;
+
QTextBlockFormat fmt;
fmt.setAlignment((Qt::Alignment) a);
QTextCursor cursor = QTextCursor(m_doc);
diff --git a/src/controls/Private/ScrollViewHelper.qml b/src/controls/Private/ScrollViewHelper.qml
index 066bc6cd..810de91d 100644
--- a/src/controls/Private/ScrollViewHelper.qml
+++ b/src/controls/Private/ScrollViewHelper.qml
@@ -134,6 +134,11 @@ Item {
anchors.right: cornerFill.left
anchors.leftMargin: leftMargin
anchors.bottomMargin: bottomMargin
+ onScrollAmountChanged: {
+ if (flickableItem && (flickableItem.atXBeginning || flickableItem.atXEnd)) {
+ value = flickableItem.contentX - flickableItem.originX
+ }
+ }
onValueChanged: {
if (!blockUpdates) {
flickableItem.contentX = value + flickableItem.originX
@@ -183,6 +188,11 @@ Item {
anchors.top: parent.top
anchors.topMargin: __scrollBarTopMargin + topMargin
anchors.rightMargin: rightMargin
+ onScrollAmountChanged: {
+ if (flickableItem && (flickableItem.atYBeginning || flickableItem.atYEnd)) {
+ value = flickableItem.contentY - flickableItem.originY
+ }
+ }
onValueChanged: {
if (flickableItem && !blockUpdates && enabled) {
flickableItem.contentY = value + flickableItem.originY
diff --git a/src/controls/Private/TreeViewItemDelegateLoader.qml b/src/controls/Private/TreeViewItemDelegateLoader.qml
index 4f8b26f6..e19215ed 100644
--- a/src/controls/Private/TreeViewItemDelegateLoader.qml
+++ b/src/controls/Private/TreeViewItemDelegateLoader.qml
@@ -81,7 +81,7 @@ TableViewItemDelegateLoader {
readonly property color textColor: __rowItem ? __rowItem.itemTextColor : "black"
readonly property string role: __column ? __column.role : ""
readonly property var value: model && model.hasOwnProperty(role) ? model[role] : ""
- readonly property var index: __treeModel.mapRowToModelIndex(row)
+ readonly property var index: model ? model["_q_TreeView_ModelIndex"] : __treeModel.index(-1,-1,null)
readonly property int depth: model && column === 0 ? model["_q_TreeView_ItemDepth"] : 0
readonly property bool hasChildren: model ? model["_q_TreeView_HasChildren"] : false
readonly property bool hasSibling: model ? model["_q_TreeView_HasSibling"] : false
diff --git a/src/controls/Private/qquickrangemodel.cpp b/src/controls/Private/qquickrangemodel.cpp
index d881e3c8..ca393c83 100644
--- a/src/controls/Private/qquickrangemodel.cpp
+++ b/src/controls/Private/qquickrangemodel.cpp
@@ -72,6 +72,9 @@ void QQuickRangeModel1Private::init()
posatmin = 0;
posatmax = 0;
inverted = false;
+ isComplete = false;
+ positionChanged = false;
+ valueChanged = false;
}
/*!
@@ -158,10 +161,16 @@ void QQuickRangeModel1Private::emitValueAndPositionIfChanged(const qreal oldValu
// unchanged. This will be the case when operating with values outside range:
const qreal newValue = q->value();
const qreal newPosition = q->position();
- if (!qFuzzyCompare(newValue, oldValue))
- emit q->valueChanged(newValue);
- if (!qFuzzyCompare(newPosition, oldPosition))
- emit q->positionChanged(newPosition);
+
+ if (isComplete) {
+ if (!qFuzzyCompare(newValue, oldValue))
+ emit q->valueChanged(newValue);
+ if (!qFuzzyCompare(newPosition, oldPosition))
+ emit q->positionChanged(newPosition);
+ } else {
+ positionChanged |= qFuzzyCompare(oldPosition, newPosition);
+ valueChanged |= !qFuzzyCompare(oldValue, newValue);
+ }
}
/*!
@@ -349,6 +358,22 @@ qreal QQuickRangeModel1::positionForValue(qreal value) const
return d->publicPosition(unconstrainedPosition);
}
+void QQuickRangeModel1::classBegin()
+{
+}
+
+void QQuickRangeModel1::componentComplete()
+{
+ Q_D(QQuickRangeModel1);
+ d->isComplete = true;
+ emit minimumChanged(minimum());
+ emit maximumChanged(maximum());
+ if (d->valueChanged)
+ emit valueChanged(value());
+ if (d->positionChanged)
+ emit positionChanged(position());
+}
+
/*!
\property QQuickRangeModel1::position
\brief the current position of the model
diff --git a/src/controls/Private/qquickrangemodel_p.h b/src/controls/Private/qquickrangemodel_p.h
index 0c93bed3..e5796725 100644
--- a/src/controls/Private/qquickrangemodel_p.h
+++ b/src/controls/Private/qquickrangemodel_p.h
@@ -47,7 +47,7 @@ QT_BEGIN_NAMESPACE
class QQuickRangeModel1Private;
-class QQuickRangeModel1 : public QObject
+class QQuickRangeModel1 : public QObject, public QQmlParserStatus
{
Q_OBJECT
Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged USER true)
@@ -59,6 +59,8 @@ class QQuickRangeModel1 : public QObject
Q_PROPERTY(qreal positionAtMaximum READ positionAtMaximum WRITE setPositionAtMaximum NOTIFY positionAtMaximumChanged)
Q_PROPERTY(bool inverted READ inverted WRITE setInverted NOTIFY invertedChanged)
+ Q_INTERFACES(QQmlParserStatus)
+
public:
QQuickRangeModel1(QObject *parent = 0);
virtual ~QQuickRangeModel1();
@@ -90,6 +92,9 @@ public:
Q_INVOKABLE qreal valueForPosition(qreal position) const;
Q_INVOKABLE qreal positionForValue(qreal value) const;
+ void classBegin();
+ void componentComplete();
+
public Q_SLOTS:
void toMinimum();
void toMaximum();
diff --git a/src/controls/Private/qquickrangemodel_p_p.h b/src/controls/Private/qquickrangemodel_p_p.h
index 5c56814e..ab0627d3 100644
--- a/src/controls/Private/qquickrangemodel_p_p.h
+++ b/src/controls/Private/qquickrangemodel_p_p.h
@@ -70,6 +70,9 @@ public:
uint inverted : 1;
QQuickRangeModel1 *q_ptr;
+ bool isComplete;
+ bool positionChanged;
+ bool valueChanged;
inline qreal effectivePosAtMin() const {
return inverted ? posatmax : posatmin;
diff --git a/src/controls/Private/qquickstyleitem.cpp b/src/controls/Private/qquickstyleitem.cpp
index 3fe68230..1d79d634 100644
--- a/src/controls/Private/qquickstyleitem.cpp
+++ b/src/controls/Private/qquickstyleitem.cpp
@@ -70,7 +70,7 @@ static inline HIRect qt_hirectForQRect(const QRect &convertRect, const QRect &re
returned if it can't be obtained. It is the caller's responsibility to
CGContextRelease the context when finished using it.
- \warning This function is only available on Mac OS X.
+ \warning This function is only available on \macos.
\warning This function is duplicated in qmacstyle_mac.mm
*/
CGContextRef qt_mac_cg_context(const QPaintDevice *pdev)
diff --git a/src/controls/Private/qquicktreemodeladaptor.cpp b/src/controls/Private/qquicktreemodeladaptor.cpp
index 9c0dd71c..26db62a3 100644
--- a/src/controls/Private/qquicktreemodeladaptor.cpp
+++ b/src/controls/Private/qquicktreemodeladaptor.cpp
@@ -156,6 +156,7 @@ QHash<int, QByteArray> QQuickTreeModelAdaptor1::roleNames() const
modelRoleNames.insert(ExpandedRole, "_q_TreeView_ItemExpanded");
modelRoleNames.insert(HasChildrenRole, "_q_TreeView_HasChildren");
modelRoleNames.insert(HasSiblingRole, "_q_TreeView_HasSibling");
+ modelRoleNames.insert(ModelIndexRole, "_q_TreeView_ModelIndex");
return modelRoleNames;
}
@@ -180,6 +181,8 @@ QVariant QQuickTreeModelAdaptor1::data(const QModelIndex &index, int role) const
return !(modelIndex.flags() & Qt::ItemNeverHasChildren) && m_model->hasChildren(modelIndex);
case HasSiblingRole:
return modelIndex.row() != m_model->rowCount(modelIndex.parent()) - 1;
+ case ModelIndexRole:
+ return modelIndex;
default:
return m_model->data(modelIndex, role);
}
@@ -195,6 +198,7 @@ bool QQuickTreeModelAdaptor1::setData(const QModelIndex &index, const QVariant &
case ExpandedRole:
case HasChildrenRole:
case HasSiblingRole:
+ case ModelIndexRole:
return false;
default: {
const QModelIndex &pmi = mapToModel(index);
@@ -719,8 +723,11 @@ void QQuickTreeModelAdaptor1::modelRowsAboutToBeMoved(const QModelIndex & source
destIndex = itemIndex(m_model->index(destinationRow, 0, destinationParent));
}
- beginMoveRows(QModelIndex(), startIndex, endIndex, QModelIndex(), destIndex);
int totalMovedCount = endIndex - startIndex + 1;
+
+ const bool visibleRowsMoved = startIndex != destIndex &&
+ beginMoveRows(QModelIndex(), startIndex, endIndex, QModelIndex(), destIndex);
+
const QList<TreeItem> &buffer = m_items.mid(startIndex, totalMovedCount);
int bufferCopyOffset;
if (destIndex > endIndex) {
@@ -729,6 +736,7 @@ void QQuickTreeModelAdaptor1::modelRowsAboutToBeMoved(const QModelIndex & source
}
bufferCopyOffset = destIndex - totalMovedCount;
} else {
+ // NOTE: we will not enter this loop if startIndex == destIndex
for (int i = startIndex - 1; i >= destIndex; i--) {
m_items.swap(i, i + totalMovedCount); // Fast move from 1st to 2nd position
}
@@ -739,14 +747,49 @@ void QQuickTreeModelAdaptor1::modelRowsAboutToBeMoved(const QModelIndex & source
item.depth += depthDifference;
m_items.replace(bufferCopyOffset + i, item);
}
- endMoveRows();
+
+ if (visibleRowsMoved)
+ endMoveRows();
+
+ if (depthDifference != 0) {
+ const QModelIndex &topLeft = index(bufferCopyOffset, 0, QModelIndex());
+ const QModelIndex &bottomRight = index(bufferCopyOffset + totalMovedCount - 1, 0, QModelIndex());
+ const QVector<int> changedRole(1, DepthRole);
+ emit dataChanged(topLeft, bottomRight, changedRole);
+ }
}
}
void QQuickTreeModelAdaptor1::modelRowsMoved(const QModelIndex & sourceParent, int sourceStart, int sourceEnd, const QModelIndex & destinationParent, int destinationRow)
{
- if (!childrenVisible(sourceParent) && childrenVisible(destinationParent))
- modelRowsInserted(destinationParent, destinationRow, destinationRow + sourceEnd - sourceStart);
+ if (childrenVisible(destinationParent)) {
+ if (!childrenVisible(sourceParent))
+ modelRowsInserted(destinationParent, destinationRow, destinationRow + sourceEnd - sourceStart);
+ else {
+ int destIndex = -1;
+ if (destinationRow == m_model->rowCount(destinationParent)) {
+ const QModelIndex &emi = m_model->index(destinationRow - 1, 0, destinationParent);
+ destIndex = lastChildIndex(emi) + 1;
+ } else {
+ destIndex = itemIndex(m_model->index(destinationRow, 0, destinationParent));
+ }
+
+ const QModelIndex &emi = m_model->index(destinationRow + sourceEnd - sourceStart, 0, destinationParent);
+ int endIndex = -1;
+ if (isExpanded(emi)) {
+ int rowCount = m_model->rowCount(emi);
+ if (rowCount > 0)
+ endIndex = lastChildIndex(m_model->index(rowCount - 1, 0, emi));
+ }
+ if (endIndex == -1)
+ endIndex = itemIndex(emi);
+
+ const QModelIndex &topLeft = index(destIndex, 0, QModelIndex());
+ const QModelIndex &bottomRight = index(endIndex, 0, QModelIndex());
+ const QVector<int> changedRole(1, ModelIndexRole);
+ emit dataChanged(topLeft, bottomRight, changedRole);
+ }
+ }
ASSERT_CONSISTENCY();
}
diff --git a/src/controls/Private/qquicktreemodeladaptor_p.h b/src/controls/Private/qquicktreemodeladaptor_p.h
index ddad96cb..e7192314 100644
--- a/src/controls/Private/qquicktreemodeladaptor_p.h
+++ b/src/controls/Private/qquicktreemodeladaptor_p.h
@@ -77,10 +77,11 @@ public:
void resetRootIndex();
enum {
- DepthRole = Qt::UserRole - 4,
+ DepthRole = Qt::UserRole - 5,
ExpandedRole,
HasChildrenRole,
- HasSiblingRole
+ HasSiblingRole,
+ ModelIndexRole
};
QHash<int, QByteArray> roleNames() const;
diff --git a/src/controls/Slider.qml b/src/controls/Slider.qml
index f38db0e4..4023929a 100644
--- a/src/controls/Slider.qml
+++ b/src/controls/Slider.qml
@@ -176,9 +176,11 @@ Control {
/*! \internal
The extra arguments positionAtMinimum and positionAtMaximum are there to force
- re-evaluation of the handle position when the constraints change (QTBUG-41255).
+ re-evaluation of the handle position when the constraints change (QTBUG-41255),
+ and the same for range.minimumValue (QTBUG-51765).
*/
- property real __handlePos: range.valueForPosition(__horizontal ? fakeHandle.x : fakeHandle.y, range.positionAtMinimum, range.positionAtMaximum)
+ property real __handlePos: range.valueForPosition(__horizontal ? fakeHandle.x : fakeHandle.y,
+ range.positionAtMinimum, range.positionAtMaximum, range.minimumValue)
activeFocusOnTab: true
diff --git a/src/controls/SplitView.qml b/src/controls/SplitView.qml
index 6ad785ba..b95704d3 100644
--- a/src/controls/SplitView.qml
+++ b/src/controls/SplitView.qml
@@ -61,9 +61,13 @@ import QtQuick.Window 2.1
item will get all leftover space when other items have been laid out.
By default, the last visible child of the SplitView will have this set, but
it can be changed by explicitly setting fillWidth to \c true on another item.
+
As the fillWidth item will automatically be resized to fit the extra space, explicit assignments
- to width and height will be ignored (but \l{Layout::minimumWidth}{Layout.minimumWidth} and
+ to its width and height properties will be ignored (but \l{Layout::minimumWidth}{Layout.minimumWidth} and
\l{Layout::maximumWidth}{Layout.maximumWidth} will still be respected).
+ The initial sizes of other items should be set via their width and height properties.
+ Any binding assignment to an item's width or height will be broken as soon as the user
+ drags that item's splitter handle.
A handle can belong to the item either on the left or top side, or on the right or bottom side:
\list
diff --git a/src/controls/Styles/Base/CheckBoxStyle.qml b/src/controls/Styles/Base/CheckBoxStyle.qml
index 0baf244b..30057ca1 100644
--- a/src/controls/Styles/Base/CheckBoxStyle.qml
+++ b/src/controls/Styles/Base/CheckBoxStyle.qml
@@ -114,7 +114,7 @@ Style {
/*! This defines the indicator button. */
property Component indicator: Item {
implicitWidth: Math.round(TextSingleton.implicitHeight)
- height: width
+ implicitHeight: implicitWidth
Rectangle {
anchors.fill: parent
anchors.bottomMargin: -1
diff --git a/src/controls/TableViewColumn.qml b/src/controls/TableViewColumn.qml
index d1fd0c00..64e68515 100644
--- a/src/controls/TableViewColumn.qml
+++ b/src/controls/TableViewColumn.qml
@@ -77,7 +77,7 @@ QtObject {
/*! The model \c role of the column. */
property string role
- /*! The current width of the column
+ /*! The current width of the column.
The default value depends on platform. If only one
column is defined, the width expands to the viewport.
*/
diff --git a/src/controls/controls.pro b/src/controls/controls.pro
index 8efc2271..63d055d6 100644
--- a/src/controls/controls.pro
+++ b/src/controls/controls.pro
@@ -88,6 +88,8 @@ osx: LIBS_PRIVATE += -framework Carbon
$$PRIVATE_QML_FILES \
$$STYLES_QML_FILES \
$$SHADER_FILES
+ OTHER_FILES += $$QML_FILES
}
+
CONFIG += no_cxx_module
load(qml_plugin)
diff --git a/src/controls/doc/src/qtquickcontrols-examples.qdoc b/src/controls/doc/src/qtquickcontrols-examples.qdoc
index 70c8eabb..08f61e10 100644
--- a/src/controls/doc/src/qtquickcontrols-examples.qdoc
+++ b/src/controls/doc/src/qtquickcontrols-examples.qdoc
@@ -46,7 +46,7 @@
<tr><td style="border:0px">
\endraw
\image qtquickcontrols-example-gallery-osx.png
- \caption OS X
+ \caption \macos
\raw HTML
</td><td style="border:0px">
\endraw
@@ -157,7 +157,7 @@
import org.qtproject.example 1.0
\endcode
- For more information about registering C++ classses as QML types, see
+ For more information about registering C++ classes as QML types, see
\l {Defining QML Types from C++}.
\include examples-run.qdocinc
@@ -198,7 +198,7 @@
import org.qtproject.example 1.0
\endcode
- For more information about registering C++ classses as QML types, see
+ For more information about registering C++ classes as QML types, see
\l {Defining QML Types from C++}.
\include examples-run.qdocinc
diff --git a/src/controls/doc/src/qtquickcontrols-tableview.qdoc b/src/controls/doc/src/qtquickcontrols-tableview.qdoc
index cf86174a..ba16b115 100644
--- a/src/controls/doc/src/qtquickcontrols-tableview.qdoc
+++ b/src/controls/doc/src/qtquickcontrols-tableview.qdoc
@@ -243,7 +243,7 @@
\endcode
\b Example: To iterate over selected indexes, you can pass a callback function.
- \a rowIndex is passed as as an argument to the callback function.
+ \a rowIndex is passed as an argument to the callback function.
\code
tableview.selection.forEach( function(rowIndex) {console.log(rowIndex)} )
\endcode
diff --git a/src/controls/qquickmenu.cpp b/src/controls/qquickmenu.cpp
index ddb25790..67682ad3 100644
--- a/src/controls/qquickmenu.cpp
+++ b/src/controls/qquickmenu.cpp
@@ -442,6 +442,10 @@ void QQuickMenu1::__popup(const QRectF &targetRect, int atItemIndex, MenuType me
// parentWindow may not be a QQuickWindow (happens when using QQuickWidget)
if (m_platformMenu) {
+ if (m_windowConnection)
+ QObject::disconnect(m_windowConnection);
+ m_windowConnection = connect(parentWindow, &QWindow::visibleChanged, this,
+ &QQuickMenu1::platformMenuWindowVisibleChanged, Qt::UniqueConnection);
QRectF globalTargetRect = targetRect.translated(m_xOffset, m_yOffset);
if (visualItem()) {
if (qGuiApp->isRightToLeft()) {
@@ -571,6 +575,19 @@ void QQuickMenu1::windowVisibleChanged(bool v)
}
}
+void QQuickMenu1::platformMenuWindowVisibleChanged(bool visible)
+{
+ if (!visible) {
+ if (m_windowConnection) {
+ QObject::disconnect(m_windowConnection);
+ m_windowConnection = QMetaObject::Connection();
+ }
+ if (m_platformMenu) {
+ m_platformMenu->dismiss();
+ }
+ }
+}
+
void QQuickMenu1::clearPopupWindow()
{
m_popupWindow = 0;
diff --git a/src/controls/qquickmenu_p.h b/src/controls/qquickmenu_p.h
index a8a14c5a..800981dd 100644
--- a/src/controls/qquickmenu_p.h
+++ b/src/controls/qquickmenu_p.h
@@ -168,6 +168,7 @@ protected Q_SLOTS:
void updateText();
void windowVisibleChanged(bool);
+ void platformMenuWindowVisibleChanged(bool);
private:
QQuickWindow *findParentWindow();
@@ -208,6 +209,7 @@ private:
QFont m_font;
int m_triggerCount;
bool m_proxy;
+ QMetaObject::Connection m_windowConnection;
};
QT_END_NAMESPACE
diff --git a/src/controls/qquickpopupwindow.cpp b/src/controls/qquickpopupwindow.cpp
index 6d87ac47..9a6519ed 100644
--- a/src/controls/qquickpopupwindow.cpp
+++ b/src/controls/qquickpopupwindow.cpp
@@ -227,7 +227,8 @@ void QQuickPopupWindow1::hideEvent(QHideEvent *e)
{
if (QWindow *tp = !m_needsActivatedEvent ? transientParent() : 0) {
m_needsActivatedEvent = true;
- QWindowSystemInterface::handleWindowActivated(tp);
+ if (tp->isVisible())
+ QWindowSystemInterface::handleWindowActivated(tp);
}
QQuickWindow::hideEvent(e);
diff --git a/src/dialogs/qquickabstractcolordialog.cpp b/src/dialogs/qquickabstractcolordialog.cpp
index ee9e4023..a558b12c 100644
--- a/src/dialogs/qquickabstractcolordialog.cpp
+++ b/src/dialogs/qquickabstractcolordialog.cpp
@@ -124,4 +124,10 @@ void QQuickAbstractColorDialog::setShowAlphaChannel(bool arg)
emit showAlphaChannelChanged();
}
+void QQuickAbstractColorDialog::accept()
+{
+ setColor(m_currentColor);
+ QQuickAbstractDialog::accept();
+}
+
QT_END_NAMESPACE
diff --git a/src/dialogs/qquickabstractcolordialog_p.h b/src/dialogs/qquickabstractcolordialog_p.h
index 99be766c..16b39c26 100644
--- a/src/dialogs/qquickabstractcolordialog_p.h
+++ b/src/dialogs/qquickabstractcolordialog_p.h
@@ -96,6 +96,9 @@ Q_SIGNALS:
void currentColorChanged();
void selectionAccepted();
+protected Q_SLOTS:
+ virtual void accept();
+
protected:
QPlatformColorDialogHelper *m_dlgHelper;
QSharedPointer<QColorDialogOptions> m_options;
diff --git a/src/dialogs/qquickabstractfontdialog.cpp b/src/dialogs/qquickabstractfontdialog.cpp
index 9b0f0ec6..f94a36a0 100644
--- a/src/dialogs/qquickabstractfontdialog.cpp
+++ b/src/dialogs/qquickabstractfontdialog.cpp
@@ -154,4 +154,10 @@ void QQuickAbstractFontDialog::setProportionalFonts(bool arg)
emit proportionalFontsChanged();
}
+void QQuickAbstractFontDialog::accept()
+{
+ setFont(m_currentFont);
+ QQuickAbstractDialog::accept();
+}
+
QT_END_NAMESPACE
diff --git a/src/dialogs/qquickabstractfontdialog_p.h b/src/dialogs/qquickabstractfontdialog_p.h
index 3162be2a..f60c4ddb 100644
--- a/src/dialogs/qquickabstractfontdialog_p.h
+++ b/src/dialogs/qquickabstractfontdialog_p.h
@@ -101,6 +101,9 @@ Q_SIGNALS:
void currentFontChanged();
void selectionAccepted();
+protected Q_SLOTS:
+ virtual void accept();
+
protected:
QPlatformFontDialogHelper *m_dlgHelper;
QSharedPointer<QFontDialogOptions> m_options;
diff --git a/src/dialogs/qquickcolordialog.cpp b/src/dialogs/qquickcolordialog.cpp
index 875c6740..686bd850 100644
--- a/src/dialogs/qquickcolordialog.cpp
+++ b/src/dialogs/qquickcolordialog.cpp
@@ -118,10 +118,4 @@ QQuickColorDialog::~QQuickColorDialog()
\l Window or an \l Item.
*/
-void QQuickColorDialog::accept()
-{
- setColor(m_currentColor);
- QQuickAbstractColorDialog::accept();
-}
-
QT_END_NAMESPACE
diff --git a/src/dialogs/qquickcolordialog_p.h b/src/dialogs/qquickcolordialog_p.h
index d3c3463b..619b7b10 100644
--- a/src/dialogs/qquickcolordialog_p.h
+++ b/src/dialogs/qquickcolordialog_p.h
@@ -65,9 +65,6 @@ public:
explicit QQuickColorDialog(QObject *parent = 0);
~QQuickColorDialog();
-protected Q_SLOTS:
- virtual void accept();
-
protected:
virtual QPlatformColorDialogHelper *helper() { return 0; }
diff --git a/src/dialogs/qquickfontdialog.cpp b/src/dialogs/qquickfontdialog.cpp
index 0e27d29a..00acf238 100644
--- a/src/dialogs/qquickfontdialog.cpp
+++ b/src/dialogs/qquickfontdialog.cpp
@@ -119,10 +119,4 @@ QQuickFontDialog::~QQuickFontDialog()
\l Window or an \l Item.
*/
-void QQuickFontDialog::accept()
-{
- setFont(m_currentFont);
- QQuickAbstractFontDialog::accept();
-}
-
QT_END_NAMESPACE
diff --git a/src/dialogs/qquickfontdialog_p.h b/src/dialogs/qquickfontdialog_p.h
index 71301a76..bd04f536 100644
--- a/src/dialogs/qquickfontdialog_p.h
+++ b/src/dialogs/qquickfontdialog_p.h
@@ -65,9 +65,6 @@ public:
explicit QQuickFontDialog(QObject *parent = 0);
~QQuickFontDialog();
-protected Q_SLOTS:
- virtual void accept();
-
protected:
virtual QPlatformFontDialogHelper *helper() { return 0; }
diff --git a/src/dialogs/qquickplatformfontdialog.cpp b/src/dialogs/qquickplatformfontdialog.cpp
index 247e869e..2c501a1c 100644
--- a/src/dialogs/qquickplatformfontdialog.cpp
+++ b/src/dialogs/qquickplatformfontdialog.cpp
@@ -170,7 +170,7 @@ QPlatformFontDialogHelper *QQuickPlatformFontDialog::helper()
return m_dlgHelper;
connect(m_dlgHelper, SIGNAL(accept()), this, SLOT(accept()));
connect(m_dlgHelper, SIGNAL(reject()), this, SLOT(reject()));
- connect(m_dlgHelper, SIGNAL(currentFontChanged(QFont)), this, SLOT(setFont(QFont)));
+ connect(m_dlgHelper, SIGNAL(currentFontChanged(QFont)), this, SLOT(setCurrentFont(QFont)));
connect(m_dlgHelper, SIGNAL(fontSelected(QFont)), this, SLOT(setFont(QFont)));
}
diff --git a/tests/auto/controls/data/layout/Container.qml b/tests/auto/controls/data/layout/Container.qml
new file mode 100644
index 00000000..db3d68c4
--- /dev/null
+++ b/tests/auto/controls/data/layout/Container.qml
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.5
+import QtQuick.Layouts 1.2
+
+Item {
+ objectName: "qtbug51927-window"
+ visible: true
+
+ default property alias _contents: customContent.data
+
+ ColumnLayout {
+ id: customContent
+ objectName: "qtbug51927-columnLayout"
+ anchors.fill: parent
+ }
+}
diff --git a/tests/auto/controls/data/layout/ContainerUser.qml b/tests/auto/controls/data/layout/ContainerUser.qml
new file mode 100644
index 00000000..ff7ce622
--- /dev/null
+++ b/tests/auto/controls/data/layout/ContainerUser.qml
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.6
+import QtQuick.Window 2.2
+
+Container {
+ visible: true
+
+ Text {
+ objectName: "qtbug51927-text"
+ text: qsTr("Hello World")
+ anchors.centerIn: parent
+ renderType: Text.QtRendering
+ }
+}
diff --git a/tests/auto/controls/data/rangemodel/init.qml b/tests/auto/controls/data/rangemodel/init.qml
new file mode 100644
index 00000000..9d050143
--- /dev/null
+++ b/tests/auto/controls/data/rangemodel/init.qml
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.2
+import QtQuick.Controls 1.2
+import QtQuick.Controls.Private 1.0
+import QtTest 1.0
+
+RangeModel {
+ id: rangemodel
+ positionAtMinimum: 0
+ positionAtMaximum: 100
+ stepSize: 1
+
+ property QtObject spy: SignalSpy {
+ target: rangemodel
+ signalName: "valueChanged"
+ }
+}
diff --git a/tests/auto/controls/data/tst_layout.qml b/tests/auto/controls/data/tst_layout.qml
index f2a69047..e5ac7728 100644
--- a/tests/auto/controls/data/tst_layout.qml
+++ b/tests/auto/controls/data/tst_layout.qml
@@ -63,5 +63,16 @@ TestCase {
var object = Qt.createQmlObject('import QtQuick 2.2; import QtQuick.Layouts 1.0; QtObject { Layout.fillWidth: true }', testCase, '');
object.destroy()
}
+
+ function test_defaultPropertyAliasCrash() {
+ var containerUserComponent = Qt.createComponent("layout/ContainerUser.qml");
+ compare(containerUserComponent.status, Component.Ready);
+
+ var containerUser = containerUserComponent.createObject(testCase);
+ verify(containerUser);
+
+ // Shouldn't crash.
+ containerUser.destroy();
+ }
}
diff --git a/tests/auto/controls/data/tst_rangemodel.qml b/tests/auto/controls/data/tst_rangemodel.qml
index f489e4b5..fd0a8dbe 100644
--- a/tests/auto/controls/data/tst_rangemodel.qml
+++ b/tests/auto/controls/data/tst_rangemodel.qml
@@ -78,6 +78,14 @@ TestCase {
spy.clear()
}
+ function test_delayedinit() {
+ var component = Qt.createComponent("rangemodel/init.qml");
+ compare(component.status, Component.Ready)
+ var r = component.createObject(testCase, {minimumValue: 40, maximumValue: 90, value: 80});
+ compare(r.value, 80)
+ compare(r.spy.count, 1)
+ }
+
function test_setminimumvalue() {
spy.signalName = "minimumChanged"
compare(spy.count, 0)
diff --git a/tests/auto/controls/data/tst_scrollview.qml b/tests/auto/controls/data/tst_scrollview.qml
index a9148db4..842fd6dc 100644
--- a/tests/auto/controls/data/tst_scrollview.qml
+++ b/tests/auto/controls/data/tst_scrollview.qml
@@ -51,6 +51,7 @@
import QtQuick 2.2
import QtTest 1.0
import QtQuick.Controls 1.2
+import QtQuick.Controls.Styles 1.1
import QtQuickControlsTests 1.0
Item {
@@ -100,6 +101,68 @@ TestCase {
scrollView.destroy()
}
+ Component {
+ id: dragFetchAppendComponent
+
+ ScrollView {
+ width: 400; height: 400
+ frameVisible: false
+ style: ScrollViewStyle {
+ transientScrollBars: false
+ handle: Rectangle {
+ implicitWidth: 16; implicitHeight: 16
+ color: "red"
+ }
+ scrollBarBackground: Item {width: 16 ; height: 16}
+ incrementControl: Rectangle {
+ width: 16; height: 16
+ color: "blue"
+ }
+ decrementControl: Rectangle {
+ width: 16; height: 16
+ color: "blue"
+ }
+ }
+ ListView {
+ id: view
+
+ verticalLayoutDirection: ListView.BottomToTop
+ model: TestFetchAppendModel { }
+ delegate: Text {
+ width: view.width
+ height: 60
+ verticalAlignment: Text.AlignVCenter
+ horizontalAlignment: Text.AlignHCenter
+ text: "Item %1".arg(model.index)
+ }
+ }
+ }
+ }
+
+ function test_dragFetchAppend() { // QTBUG-50795
+ var scrollView = dragFetchAppendComponent.createObject(container)
+ verify(scrollView !== null, "view created is null")
+ waitForRendering(scrollView)
+ tryCompare(scrollView.flickableItem, "contentHeight", 60 * 20)
+
+ // After scrolling to the end, view should ask the model to fetch more
+ // data, content height should increase and scrollbar handle should move
+ // to the center.
+ mouseDrag(scrollView, scrollView.width - 2, scrollView.height - 8 - 16, 0, -scrollView.height + 8 + 16)
+ waitForRendering(scrollView)
+
+ // Move it again to fetch more data from the model.
+ mouseDrag(scrollView, scrollView.width - 2, scrollView.height / 2, 0, -scrollView.height / 2 + 8 + 16)
+ waitForRendering(scrollView)
+
+ mouseRelease(scrollView, scrollView.width - 2, 8 + 16)
+ waitForRendering(scrollView)
+
+ verify(Math.round(scrollView.flickableItem.contentHeight) > 60 * 20)
+ verify(Math.round(scrollView.flickableItem.contentY) < -(60 * 20))
+
+ scrollView.destroy()
+ }
function test_scrollbars() {
var component = scrollViewComponent
diff --git a/tests/auto/controls/data/tst_slider.qml b/tests/auto/controls/data/tst_slider.qml
index 48612215..1d7e92d2 100644
--- a/tests/auto/controls/data/tst_slider.qml
+++ b/tests/auto/controls/data/tst_slider.qml
@@ -48,11 +48,12 @@
**
****************************************************************************/
-import QtQuick 2.2
+import QtQuick 2.6
import QtTest 1.0
import QtQuickControlsTests 1.0
-import QtQuick.Controls 1.2
+import QtQuick.Controls 1.4
import QtQuick.Controls.Private 1.0
+import QtQuick.Controls.Styles 1.4
Item {
id: container
@@ -74,6 +75,12 @@ Item {
id: util
}
+ Component {
+ id: sliderComponent
+
+ Slider {}
+ }
+
function test_vertical() {
var slider = Qt.createQmlObject('import QtQuick.Controls 1.2; Slider {}', testCase, '');
verify(slider.height < slider.width)
@@ -371,5 +378,34 @@ Item {
control.destroy()
component.destroy()
}
+
+ Component {
+ id: namedHandleStyle
+
+ SliderStyle {
+ handle: Rectangle {
+ objectName: "sliderHandle"
+ implicitWidth: 20
+ implicitHeight: 20
+ color: "salmon"
+ }
+ }
+ }
+
+ function test_minimumValueLargerThanValue() {
+ var control = sliderComponent.createObject(container, { "style": namedHandleStyle, "minimumValue": 0, "maximumValue": 2, value: "minimumValue" });
+ verify(control);
+
+ var handle = findChild(control, "sliderHandle");
+ verify(handle);
+
+ // The handle should stay within the bounds of the slider when
+ // minimumValue is set to a value larger than "value".
+ control.minimumValue = 1;
+ compare(control.value, control.minimumValue);
+ compare(handle.mapToItem(null, 0, 0).x, 0)
+
+ control.destroy();
+ }
}
}
diff --git a/tests/auto/extras/BLACKLIST b/tests/auto/extras/BLACKLIST
index a22550c4..3a502904 100644
--- a/tests/auto/extras/BLACKLIST
+++ b/tests/auto/extras/BLACKLIST
@@ -1,5 +1,3 @@
-[Tests_CircularTickmarkLabel::test_tickmarksAndLabels]
-*
[Tests_Tumbler::test_focusPastLastColumn]
*
[Tests_Tumbler::test_itemsCorrectlyPositioned]
diff --git a/tests/auto/qquicktreemodeladaptor/tst_qquicktreemodeladaptor.cpp b/tests/auto/qquicktreemodeladaptor/tst_qquicktreemodeladaptor.cpp
index 03927fc2..96659a2c 100644
--- a/tests/auto/qquicktreemodeladaptor/tst_qquicktreemodeladaptor.cpp
+++ b/tests/auto/qquicktreemodeladaptor/tst_qquicktreemodeladaptor.cpp
@@ -73,6 +73,7 @@ private slots:
void moveRows_data();
void moveRows();
+ void reparentOnSameRow();
void selectionForRowRange();
@@ -1152,6 +1153,56 @@ void tst_QQuickTreeModelAdaptor::moveRows()
compareModels(tma, model);
}
+void tst_QQuickTreeModelAdaptor::reparentOnSameRow()
+{
+ TestModel model(2, 1);
+ model.alternateChildlessRows = false;
+ QQuickTreeModelAdaptor1 tma;
+ tma.setModel(&model);
+
+ const QModelIndex &destParent = model.index(0, 0);
+ const QModelIndex &sourceParent = QModelIndex();
+ QVERIFY(destParent.isValid());
+ tma.expand(destParent);
+ QVERIFY(tma.isExpanded(destParent));
+
+ QSignalSpy dataChangedSpy(&tma, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)));
+ QSignalSpy rowsMovedSpy(&tma, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int)));
+ QVERIFY(rowsMovedSpy.isValid());
+ QVERIFY(dataChangedSpy.isValid());
+
+ QVERIFY(model.moveRows(sourceParent, 1, 1, destParent, 2));
+
+ QModelIndex movedIndex = tma.index(3, 0, QModelIndex());
+ QVERIFY(movedIndex.isValid());
+ QCOMPARE(movedIndex.data(QQuickTreeModelAdaptor1::DepthRole).toInt(), 1);
+ QCOMPARE(tma.data(movedIndex, QQuickTreeModelAdaptor1::ModelIndexRole).toModelIndex(), model.index(2, 0, destParent));
+
+ // at least DepthRole and ModeIndexRole changes should have happened for the affected row
+ bool depthChanged = false;
+ bool modelIndexChanged = false;
+ QList<QList<QVariant> > &changes = dataChangedSpy;
+ foreach (QList<QVariant> change, changes) {
+ if (change.at(0) == movedIndex) {
+ if (change.at(2).value<QVector<int> >().contains(QQuickTreeModelAdaptor1::DepthRole))
+ depthChanged = true;
+ if (change.at(2).value<QVector<int> >().contains(QQuickTreeModelAdaptor1::ModelIndexRole))
+ modelIndexChanged = true;
+ }
+ }
+
+ QCOMPARE(depthChanged, true);
+ QCOMPARE(modelIndexChanged, true);
+
+ QCOMPARE(rowsMovedSpy.count(), 0);
+
+ model.moveRow(destParent, 2, QModelIndex(), 1);
+
+ QCOMPARE(rowsMovedSpy.count(), 0);
+ QVERIFY(tma.testConsistency());
+ compareModels(tma, model);
+}
+
void tst_QQuickTreeModelAdaptor::selectionForRowRange()
{
const int ModelRowCount = 9;
diff --git a/tests/auto/shared/testmodel.h b/tests/auto/shared/testmodel.h
index d8ddd80a..6eaab74a 100644
--- a/tests/auto/shared/testmodel.h
+++ b/tests/auto/shared/testmodel.h
@@ -230,7 +230,7 @@ public:
bool moveRows(const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild)
{
Q_ASSERT_X(sourceRow >= 0 && sourceRow < rowCount(sourceParent)
- && count > 0 && sourceRow + count < rowCount(sourceParent)
+ && count > 0 && sourceRow + count - 1 < rowCount(sourceParent)
&& destinationChild >= 0 && destinationChild <= rowCount(destinationParent),
Q_FUNC_INFO, "Rows out of range.");
Q_ASSERT_X(!(sourceParent == destinationParent && destinationChild >= sourceRow && destinationChild < sourceRow + count),
diff --git a/tests/auto/testplugin/testcppmodels.h b/tests/auto/testplugin/testcppmodels.h
index cb1cfb4f..03b598c4 100644
--- a/tests/auto/testplugin/testcppmodels.h
+++ b/tests/auto/testplugin/testcppmodels.h
@@ -88,6 +88,58 @@ private:
QList<TestObject> m_testobject;
};
+class TestFetchAppendModel : public QAbstractListModel
+{
+ Q_OBJECT
+public:
+ explicit TestFetchAppendModel(QObject *parent = 0)
+ : QAbstractListModel(parent) { }
+
+ virtual int rowCount(const QModelIndex &parent) const
+ {
+ if (parent.isValid()) {
+ return 0;
+ }
+
+ return m_data.size();
+ }
+ virtual QVariant data(const QModelIndex &index, int role) const
+ {
+ if (!index.isValid() || role != Qt::DisplayRole) {
+ return QVariant();
+ }
+
+ return QVariant::fromValue(index.row());
+ }
+
+ virtual bool canFetchMore(const QModelIndex &parent) const
+ {
+ Q_UNUSED(parent)
+
+ return true;
+ }
+ virtual void fetchMore(const QModelIndex & parent)
+ {
+ Q_UNUSED(parent)
+
+ addMoreData();
+ }
+
+private:
+ void addMoreData()
+ {
+ static const int insertCount = 20;
+
+ beginInsertRows(QModelIndex(), m_data.size(), m_data.size() + insertCount - 1);
+ for (int i = 0; i < insertCount; i++) {
+ m_data.append(int());
+ }
+ endInsertRows();
+ }
+
+ QList<int> m_data;
+};
+
#endif // TESTCPPMODELS_H
diff --git a/tests/auto/testplugin/testplugin.cpp b/tests/auto/testplugin/testplugin.cpp
index 45573d92..039a59e0 100644
--- a/tests/auto/testplugin/testplugin.cpp
+++ b/tests/auto/testplugin/testplugin.cpp
@@ -40,6 +40,7 @@ void TestPlugin::registerTypes(const char *uri)
qmlRegisterType<TestObject>(uri, 1, 0, "TestObject");
qmlRegisterType<TestItemModel>(uri, 1, 0, "TestItemModel");
qmlRegisterType<TestModel>(uri, 1, 0, "TreeModel");
+ qmlRegisterType<TestFetchAppendModel>(uri, 1, 0, "TestFetchAppendModel");
}
void TestPlugin::initializeEngine(QQmlEngine *engine, const char * /*uri*/)