diff options
author | Liang Qi <liang.qi@qt.io> | 2020-04-22 18:04:39 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2020-04-22 18:04:39 +0200 |
commit | a42144610b1e268e82c0aa972e957fd24ac4cc6a (patch) | |
tree | b63d3344952f34d76e0991e3ac0ecbe629c77702 | |
parent | 796f6e1e8e99ea1046ffe2a744cfd1dca1248258 (diff) | |
parent | 560bc348d86aba6cef5fdf88bc9d7304dd914bc8 (diff) |
Merge remote-tracking branch 'origin/5.14' into 5.15.0
Conflicts:
src/imports/labsmodels/qqmltablemodel.cpp
tests/auto/qml/qqmltablemodel/tst_qqmltablemodel.cpp
This follows edc8512580fa16892dc13034e93300cc6a2bba59.
Change-Id: I42d1a977d33043045558118948db9151d03950c7
-rw-r--r-- | dist/changes-5.14.2 | 56 | ||||
-rw-r--r-- | src/imports/labsmodels/qqmltablemodel.cpp | 21 | ||||
-rw-r--r-- | src/quick/items/qquicktextinput.cpp | 3 | ||||
-rw-r--r-- | tests/auto/qml/qqmltablemodel/data/intAndDouble.qml | 86 | ||||
-rw-r--r-- | tests/auto/qml/qqmltablemodel/tst_qqmltablemodel.cpp | 73 |
5 files changed, 232 insertions, 7 deletions
diff --git a/dist/changes-5.14.2 b/dist/changes-5.14.2 new file mode 100644 index 0000000000..63b4b2fe46 --- /dev/null +++ b/dist/changes-5.14.2 @@ -0,0 +1,56 @@ +Qt 5.14.2 is a bug-fix release. It maintains both forward and backward +compatibility (source and binary) with Qt 5.14.0 through 5.14.1. + +For more details, refer to the online documentation included in this +distribution. The documentation is also available online: + +https://doc.qt.io/qt-5/index.html + +The Qt version 5.14 series is binary compatible with the 5.13.x series. +Applications compiled for 5.13 will continue to run with 5.14. + +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. + +**************************************************************************** +* QtQml * +**************************************************************************** + + - [QTBUG-82000] Fixed leaking metatypes in QQmlTableInstanceModel. + - [QTBUG-82017] QQmlProperty and Connections now work for properties + that start with '_'. + - [QTBUG-81945] Fixed an invalid type bug when using an array of strings + as a ListView model. + - [QTBUG-80916] Conversion between container types and QJSValue arrays is + now bidirectionally supported. + - [QTBUG-81699] Fixed the "qmlRegisterType requires absolute URLs." error. + - [QTBUG-79553] Fixed a crash by avoiding storage of user-created objects + in QQmlValueType. + - [QTBUG-81581] We now check for exceptions before using the result of a + JS function call. + +**************************************************************************** +* QtQuick * +**************************************************************************** + - [QTBUG-73683] Fix a layout bug that caused an infinite loop when the width + of a RowLayout containing Text with WrapAtWordBoundaryOrAnywhere changed. + - [QTBUG-78284] Fixed VoiceOver in QtWebEngine and other cases in which + the focused item must be discovered recursively for accessibility. + - [QTBUG-76362] Fix some bugs with snapping in a ListView with a header. + - [QTBUG-81098] Fixed division by zero in Flickable with binding to visibleArea. + - [QTBUG-82002] QQuickLoader emits statusChanged only when it really changed. + +**************************************************************************** +* Platform Specific Changes * +**************************************************************************** + - [QTBUG-81021] Plugins built with debug info with *d.dll filenames are + again found at runtime on Windows. + - [QTBUG-80843] Fixed a cmake problem with qt5_import_qml_plugins() + - [QTBUG-38296] qmlimportscanner and androiddeployqt now detect when the + Particles module is needed, so it's no longer an explicit dependency + on Android. diff --git a/src/imports/labsmodels/qqmltablemodel.cpp b/src/imports/labsmodels/qqmltablemodel.cpp index 6ba2cecf19..5a2d68780c 100644 --- a/src/imports/labsmodels/qqmltablemodel.cpp +++ b/src/imports/labsmodels/qqmltablemodel.cpp @@ -1043,11 +1043,24 @@ bool QQmlTableModel::validateNewRow(const char *functionName, const QVariant &ro } const QVariant rolePropertyValue = rowAsMap.value(roleData.name); + if (rolePropertyValue.userType() != roleData.type) { - qmlWarning(this).quote() << functionName << ": expected the property named " - << roleData.name << " to be of type " << roleData.typeName - << ", but got " << QString::fromLatin1(rolePropertyValue.typeName()) << " instead"; - return false; + if (!rolePropertyValue.canConvert(int(roleData.type))) { + qmlWarning(this).quote() << functionName << ": expected the property named " + << roleData.name << " to be of type " << roleData.typeName + << ", but got " << QString::fromLatin1(rolePropertyValue.typeName()) + << " instead"; + return false; + } + + QVariant effectiveValue = rolePropertyValue; + if (!effectiveValue.convert(int(roleData.type))) { + qmlWarning(this).nospace() << functionName << ": failed converting value " + << rolePropertyValue << " set at column " << columnIndex << " with role " + << QString::fromLatin1(rolePropertyValue.typeName()) << " to " + << roleData.typeName; + return false; + } } } } diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp index 8f306daed2..06a9f134ac 100644 --- a/src/quick/items/qquicktextinput.cpp +++ b/src/quick/items/qquicktextinput.cpp @@ -2895,8 +2895,7 @@ void QQuickTextInputPrivate::updateDisplayText(bool forceUpdate) // characters) QChar* uc = str.data(); for (int i = 0; i < str.length(); ++i) { - if ((uc[i].unicode() < 0x20 && uc[i] != QChar::Tabulation) - || uc[i] == QChar::LineSeparator + if (uc[i] == QChar::LineSeparator || uc[i] == QChar::ParagraphSeparator || uc[i] == QChar::ObjectReplacementCharacter) uc[i] = QChar(0x0020); diff --git a/tests/auto/qml/qqmltablemodel/data/intAndDouble.qml b/tests/auto/qml/qqmltablemodel/data/intAndDouble.qml new file mode 100644 index 0000000000..261bc8a115 --- /dev/null +++ b/tests/auto/qml/qqmltablemodel/data/intAndDouble.qml @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.12 +import Qt.labs.qmlmodels 1.0 + +Item { + id: root + width: 200 + height: 200 + + property alias testModel: testModel + property alias tableView: tableView + + function appendBanana() { + testModel.appendRow({ + fruit: "Banana", + price: 3.5 + }) + } + + function appendStrawberry() { + testModel.appendRow({ + fruit: "Strawberry", + price: "5" + }) + } + + function appendInvalid() { + testModel.appendRow({ + fruit: "Pear", + price: "Invalid" + }) + } + + TableModel { + id: testModel + objectName: "testModel" + + TableModelColumn { display: "fruit" } + TableModelColumn { display: "price" } + rows: [ + { + fruit: "Apple", + price: 1 + }, + { + fruit: "Orange", + price: 2 + } + ] + } + TableView { + id: tableView + anchors.fill: parent + model: testModel + delegate: Text { + text: model.display + } + } +} diff --git a/tests/auto/qml/qqmltablemodel/tst_qqmltablemodel.cpp b/tests/auto/qml/qqmltablemodel/tst_qqmltablemodel.cpp index 5457597df3..3923824fa2 100644 --- a/tests/auto/qml/qqmltablemodel/tst_qqmltablemodel.cpp +++ b/tests/auto/qml/qqmltablemodel/tst_qqmltablemodel.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2019 The Qt Company Ltd. +** Copyright (C) 2020 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the test suite of the Qt Toolkit. @@ -59,6 +59,7 @@ private slots: void dataAndEditing(); void omitTableModelColumnIndex(); void complexRow(); + void appendRowWithDouble(); }; void tst_QQmlTableModel::appendRemoveRow() @@ -975,6 +976,76 @@ void tst_QQmlTableModel::complexRow() QCOMPARE(model->data(model->index(1, 1, QModelIndex()), roleNames.key("display")).toInt(), 33); } +void tst_QQmlTableModel::appendRowWithDouble() +{ + QQuickView view(testFileUrl("intAndDouble.qml")); + QCOMPARE(view.status(), QQuickView::Ready); + view.show(); + QVERIFY(QTest::qWaitForWindowActive(&view)); + + auto *model = view.rootObject()->property("testModel").value<QAbstractTableModel*>(); + QVERIFY(model); + QCOMPARE(model->rowCount(), 2); + QCOMPARE(model->columnCount(), 2); + + QSignalSpy columnCountSpy(model, SIGNAL(columnCountChanged())); + QVERIFY(columnCountSpy.isValid()); + + QSignalSpy rowCountSpy(model, SIGNAL(rowCountChanged())); + QVERIFY(rowCountSpy.isValid()); + + QQuickTableView *tableView = view.rootObject()->property("tableView").value<QQuickTableView*>(); + QVERIFY(tableView); + QCOMPARE(tableView->rows(), 2); + QCOMPARE(tableView->columns(), 2); + + QVERIFY(QMetaObject::invokeMethod(view.rootObject(), "appendBanana")); + QCOMPARE(model->rowCount(), 3); + QCOMPARE(model->columnCount(), 2); + const QHash<int, QByteArray> roleNames = model->roleNames(); + const int roleKey = roleNames.key("display"); + QCOMPARE(model->data(model->index(0, 1, QModelIndex()), roleKey).toString(), + QLatin1String("1")); + QCOMPARE(model->data(model->index(2, 0, QModelIndex()), roleKey).toString(), + QLatin1String("Banana")); + QCOMPARE(model->data(model->index(2, 1, QModelIndex()), roleKey).toDouble(), 3.5); + QCOMPARE(model->data(model->index(2, 1, QModelIndex()), roleKey).toString(), + QLatin1String("3.5")); + QCOMPARE(columnCountSpy.count(), 0); + QCOMPARE(rowCountSpy.count(), 1); + QTRY_COMPARE(tableView->rows(), 3); + QCOMPARE(tableView->columns(), 2); + + rowCountSpy.clear(); + + QVERIFY(QMetaObject::invokeMethod(view.rootObject(), "appendStrawberry")); + QCOMPARE(model->rowCount(), 4); + QCOMPARE(model->columnCount(), 2); + QCOMPARE(model->data(model->index(3, 0, QModelIndex()), roleKey).toString(), + QLatin1String("Strawberry")); + QCOMPARE(model->data(model->index(3, 1, QModelIndex()), roleKey).toDouble(), 5); + QCOMPARE(model->data(model->index(3, 1, QModelIndex()), roleKey).toString(), + QLatin1String("5")); + QCOMPARE(columnCountSpy.count(), 0); + QCOMPARE(rowCountSpy.count(), 1); + QTRY_COMPARE(tableView->rows(), 4); + QCOMPARE(tableView->columns(), 2); + + rowCountSpy.clear(); + QTest::ignoreMessage(QtWarningMsg, + QRegularExpression(".*appendRow\\(\\): failed converting value " + "QVariant\\(QString, \"Invalid\"\\) set at column 1 with " + "role \"QString\" to \"int\"")); + QVERIFY(QMetaObject::invokeMethod(view.rootObject(), "appendInvalid")); + // Nothing should change + QCOMPARE(model->rowCount(), 4); + QCOMPARE(model->columnCount(), 2); + QCOMPARE(columnCountSpy.count(), 0); + QCOMPARE(rowCountSpy.count(), 0); + QCOMPARE(tableView->rows(), 4); + QCOMPARE(tableView->columns(), 2); +} + QTEST_MAIN(tst_QQmlTableModel) #include "tst_qqmltablemodel.moc" |