Merge remote-tracking branch 'origin/5.14' into 5.15

Change-Id: Ic4ffd206bdd3ed68fd3d21a93818923e8d3a1e7a
This commit is contained in:
Qt Forward Merge Bot 2019-11-20 01:00:50 +01:00
commit 1315133233
8 changed files with 96 additions and 20 deletions

View File

@ -13,7 +13,7 @@ QMKSRC = $(SOURCE_PATH)\qmake
!if "$(QMAKESPEC)" == "win32-icc"
CXX = icl
LINKER = xilink
CFLAGS_EXTRA = /Zc:forScope /Qstd=c++11 /O3
CFLAGS_EXTRA = /Zc:forScope /Qstd=c++11
!elseif "$(QMAKESPEC)" == "win32-clang-msvc"
CXX = clang-cl
LINKER = lld-link

View File

@ -846,6 +846,7 @@ QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos,
/*!
Constructs a wheel event object.
\since 5.12
The \a pos provides the location of the mouse cursor
within the window. The position in global coordinates is specified
by \a globalPos.

View File

@ -182,6 +182,9 @@ QSqlQueryPrivate::~QSqlQueryPrivate()
You can retrieve the values of all the fields in a single variable
(a map) using boundValues().
\note Not all SQL operations support binding values. Refer to your database
system's documentation to check their availability.
\section1 Approaches to Binding Values
Below we present the same example using each of the four

View File

@ -79,8 +79,11 @@ int main(int argc, char *argv[])
//! [0]
QFileSystemModel *model = new QFileSystemModel;
QModelIndex parentIndex = model->index(QDir::currentPath());
int numRows = model->rowCount(parentIndex);
connect(model, &QFileSystemModel::directoryLoaded, [model](const QString &directory) {
QModelIndex parentIndex = model->index(directory);
int numRows = model->rowCount(parentIndex);
});
model->setRootPath(QDir::currentPath);
//! [0]
//! [1]

View File

@ -465,14 +465,19 @@
Although this does not show a normal way of using a model, it demonstrates
the conventions used by models when dealing with model indexes.
QFileSystemModel loading is asynchronous to minimize system resource use.
We have to take that into account when dealing with this model.
We construct a file system model in the following way:
\snippet simplemodel-use/main.cpp 0
In this case, we set up a default QFileSystemModel, obtain a parent index
using a specific implementation of \l{QFileSystemModel::}{index()}
provided by that model, and we count the number of rows in the model using
the \l{QFileSystemModel::}{rowCount()} function.
In this case, we start by setting up a default QFileSystemModel. We connect
it to a lambda, in which we will obtain a parent index using a specific
implementation of \l{QFileSystemModel::}{index()} provided by that model.
In the lambda, we count the number of rows in the model using the
\l{QFileSystemModel::}{rowCount()} function. Finally, we set the root path
of the QFileSystemModel so it starts loading data and triggers the lambda.
For simplicity, we are only interested in the items in the first column
of the model. We examine each row in turn, obtaining a model index for

View File

@ -4312,20 +4312,20 @@ void QDomElement::setAttribute(const QString& name, const QString& value)
\fn void QDomElement::setAttribute(const QString& name, int value)
\overload
The number is formatted according to the current locale.
The formatting always uses QLocale::C.
*/
/*!
\fn void QDomElement::setAttribute(const QString& name, uint value)
\overload
The number is formatted according to the current locale.
The formatting always uses QLocale::C.
*/
/*!
\overload
The number is formatted according to the current locale.
The formatting always uses QLocale::C.
*/
void QDomElement::setAttribute(const QString& name, qlonglong value)
{
@ -4339,7 +4339,7 @@ void QDomElement::setAttribute(const QString& name, qlonglong value)
/*!
\overload
The number is formatted according to the current locale.
The formatting always uses QLocale::C.
*/
void QDomElement::setAttribute(const QString& name, qulonglong value)
{
@ -4353,7 +4353,7 @@ void QDomElement::setAttribute(const QString& name, qulonglong value)
/*!
\overload
The number is formatted according to the current locale.
The formatting always uses QLocale::C.
*/
void QDomElement::setAttribute(const QString& name, float value)
{
@ -4367,19 +4367,14 @@ void QDomElement::setAttribute(const QString& name, float value)
/*!
\overload
The number is formatted according to the current locale.
The formatting always uses QLocale::C.
*/
void QDomElement::setAttribute(const QString& name, double value)
{
if (!impl)
return;
QString x;
char buf[256];
int count = qsnprintf(buf, sizeof(buf), "%.16g", value);
if (count > 0)
x = QString::fromLatin1(buf, count);
else
x.setNum(value); // Fallback
x.setNum(value);
IMPL->setAttribute(name, x);
}

View File

@ -67,7 +67,7 @@ void tst_QScopedGuard::exceptions()
bool caught = false;
QT_TRY
{
auto cleanup = qScopeGuard([&caught] { s_globalState++; });
auto cleanup = qScopeGuard([] { s_globalState++; });
QT_THROW(std::bad_alloc()); //if Qt compiled without exceptions this is noop
s_globalState = 100;
}

View File

@ -57,6 +57,7 @@ private slots:
void toString_02();
void hasAttributes_data();
void hasAttributes();
void setGetAttributes();
void save_data();
void save();
void saveWithSerialization() const;
@ -392,6 +393,74 @@ void tst_QDom::hasAttributes()
QTEST( visitedNodes, "visitedNodes" );
}
void tst_QDom::setGetAttributes()
{
QDomDocument doc;
QDomElement rootNode = doc.createElement("Root");
doc.appendChild(rootNode);
const QLocale oldLocale = QLocale();
QLocale::setDefault(QLocale::German); // decimal separator != '.'
const QString qstringVal("QString");
const qlonglong qlonglongVal = std::numeric_limits<qlonglong>::min();
const qulonglong qulonglongVal = std::numeric_limits<qulonglong>::max();
const int intVal = std::numeric_limits<int>::min();
const uint uintVal = std::numeric_limits<uint>::max();
const float floatVal = 0.1234f;
const double doubleVal = 0.1234;
rootNode.setAttribute("qstringVal", qstringVal);
rootNode.setAttribute("qlonglongVal", qlonglongVal);
rootNode.setAttribute("qulonglongVal", qulonglongVal);
rootNode.setAttribute("intVal", intVal);
rootNode.setAttribute("uintVal", uintVal);
rootNode.setAttribute("floatVal", floatVal);
rootNode.setAttribute("doubleVal", doubleVal);
QDomElement nsNode = doc.createElement("NS");
rootNode.appendChild(nsNode);
nsNode.setAttributeNS("namespace", "qstringVal", qstringVal);
nsNode.setAttributeNS("namespace", "qlonglongVal", qlonglongVal);
nsNode.setAttributeNS("namespace", "qulonglongVal", qulonglongVal);
nsNode.setAttributeNS("namespace", "intVal", intVal);
nsNode.setAttributeNS("namespace", "uintVal", uintVal);
nsNode.setAttributeNS("namespace", "floatVal", floatVal); // not available atm
nsNode.setAttributeNS("namespace", "doubleVal", doubleVal);
bool bOk;
QCOMPARE(rootNode.attribute("qstringVal"), qstringVal);
QCOMPARE(rootNode.attribute("qlonglongVal").toLongLong(&bOk), qlonglongVal);
QVERIFY(bOk);
QCOMPARE(rootNode.attribute("qulonglongVal").toULongLong(&bOk), qulonglongVal);
QVERIFY(bOk);
QCOMPARE(rootNode.attribute("intVal").toInt(&bOk), intVal);
QVERIFY(bOk);
QCOMPARE(rootNode.attribute("uintVal").toUInt(&bOk), uintVal);
QVERIFY(bOk);
QCOMPARE(rootNode.attribute("floatVal").toFloat(&bOk), floatVal);
QVERIFY(bOk);
QCOMPARE(rootNode.attribute("doubleVal").toDouble(&bOk), doubleVal);
QVERIFY(bOk);
QCOMPARE(nsNode.attributeNS("namespace", "qstringVal"), qstringVal);
QCOMPARE(nsNode.attributeNS("namespace", "qlonglongVal").toLongLong(&bOk), qlonglongVal);
QVERIFY(bOk);
QCOMPARE(nsNode.attributeNS("namespace", "qulonglongVal").toULongLong(&bOk), qulonglongVal);
QVERIFY(bOk);
QCOMPARE(nsNode.attributeNS("namespace", "intVal").toInt(&bOk), intVal);
QVERIFY(bOk);
QCOMPARE(nsNode.attributeNS("namespace", "uintVal").toUInt(&bOk), uintVal);
QVERIFY(bOk);
QCOMPARE(nsNode.attributeNS("namespace", "floatVal").toFloat(&bOk), floatVal);
QVERIFY(bOk);
QCOMPARE(nsNode.attributeNS("namespace", "doubleVal").toDouble(&bOk), doubleVal);
QVERIFY(bOk);
QLocale::setDefault(oldLocale);
}
int tst_QDom::hasAttributesHelper( const QDomNode& node )
{
int visitedNodes = 1;