From d4748c7c936cdf603e0b72bfdb4e39f822ab2e9d Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Fri, 28 Feb 2020 11:04:36 +0100 Subject: TableModel: Allow a double to be added to a field seen as int previously Since the type for a TableModelColumn can be seen as an int when it is in the first row, it is still possible that it is representing a double value in other rows. Therefore it should be allowed to add/change a row that would display a double for that column. Change-Id: I994a8ead595f836a20a4e82fbf94953b1aa4b7da Reviewed-by: Mitch Curtis --- src/qmlmodels/qqmltablemodel.cpp | 21 +++++- .../auto/qml/qqmltablemodel/data/intAndDouble.qml | 86 ++++++++++++++++++++++ .../auto/qml/qqmltablemodel/tst_qqmltablemodel.cpp | 71 ++++++++++++++++++ 3 files changed, 174 insertions(+), 4 deletions(-) create mode 100644 tests/auto/qml/qqmltablemodel/data/intAndDouble.qml diff --git a/src/qmlmodels/qqmltablemodel.cpp b/src/qmlmodels/qqmltablemodel.cpp index f190ad86b1..fab20f7410 100644 --- a/src/qmlmodels/qqmltablemodel.cpp +++ b/src/qmlmodels/qqmltablemodel.cpp @@ -1028,11 +1028,24 @@ bool QQmlTableModel::validateNewRow(const char *functionName, const QVariant &ro } const QVariant rolePropertyValue = rowAsMap.value(roleData.name); + if (rolePropertyValue.type() != 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/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 d913bcdf9a..321896a8f3 100644 --- a/tests/auto/qml/qqmltablemodel/tst_qqmltablemodel.cpp +++ b/tests/auto/qml/qqmltablemodel/tst_qqmltablemodel.cpp @@ -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)); + + QQmlTableModel *model = view.rootObject()->property("testModel").value(); + 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(); + 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 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" -- cgit v1.2.3 From df034c07be4828778d43a4037f89f31ac26f411d Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Mon, 2 Mar 2020 10:29:23 +0100 Subject: Don't replace all characters below 0x20 with spaces as they may be valid Some fonts will still render something for characters below 0x20 so these should not be replaced with a space and should just be left as is. It will not be rendered as a box if the dontPrint flag is set so we can trust the renderer to do the right thing here. Change-Id: Ie091c14713d8c2948c82b1991c295d80bc35dfde Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/quick/items/qquicktextinput.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp index 11a6600b74..ee51711d34 100644 --- a/src/quick/items/qquicktextinput.cpp +++ b/src/quick/items/qquicktextinput.cpp @@ -2901,8 +2901,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); -- cgit v1.2.3 From 23a000f9a14889753a63cd73de2c61e49bb7e0d8 Mon Sep 17 00:00:00 2001 From: Antti Kokko Date: Tue, 3 Mar 2020 15:10:32 +0200 Subject: Add changes file for Qt 5.14.2 Change-Id: I54aae60a5ad987b7a9fd74c012f337952b855ec5 Reviewed-by: Ulf Hermann --- dist/changes-5.14.2 | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 dist/changes-5.14.2 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. -- cgit v1.2.3