summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2020-01-28 01:00:39 +0100
committerLiang Qi <liang.qi@qt.io>2020-01-28 14:14:20 +0000
commit558fc903acc610769279da2737ad679aa9fd728d (patch)
treeebe36deb140e47ca32fea9b0753cde06f465a0fa /src/corelib
parent089d54f06ff327f5212cb08fdbcb540066357dd5 (diff)
parentbe8c257da9a264994243c120231965ff0008ef09 (diff)
Merge remote-tracking branch 'origin/5.15' into dev
Conflicts: src/corelib/io/qsettings.cpp src/corelib/kernel/qvariant.cpp src/corelib/serialization/qjsoncbor.cpp src/corelib/serialization/qjsonvalue.cpp src/corelib/tools/tools.pri src/gui/image/qimage.cpp src/gui/kernel/qguivariant.cpp src/widgets/kernel/qshortcut.cpp tests/auto/tools/moc/allmocs_baseline_in.json tests/auto/tools/moc/tst_moc.cpp src/opengl/qglframebufferobject.cpp Done-With: Edward Welbourne <edward.welbourne@qt.io> Done-With: Leander Beernaert <leander.beernaert@qt.io> Change-Id: Ie7f5fa646c607fe70c314bf7195f7578ded1d271
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/Qt5CoreConfigExtras.cmake.in24
-rw-r--r--src/corelib/Qt5CoreMacros.cmake66
-rw-r--r--src/corelib/animation/qpropertyanimation.cpp6
-rw-r--r--src/corelib/doc/snippets/code/doc_src_properties.cpp1
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_kernel_qcoreapplication.cpp10
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_statemachine_qstatemachine.cpp2
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_thread_qfuturewatcher.cpp2
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qtimeline.cpp4
-rw-r--r--src/corelib/doc/snippets/qsignalmapper/buttonwidget.cpp14
-rw-r--r--src/corelib/doc/snippets/qsignalmapper/buttonwidget.h4
-rw-r--r--src/corelib/doc/snippets/resource-system/mainwindow.cpp36
-rw-r--r--src/corelib/doc/snippets/statemachine/main.cpp13
-rw-r--r--src/corelib/doc/snippets/statemachine/main2.cpp15
-rw-r--r--src/corelib/doc/snippets/statemachine/main3.cpp2
-rw-r--r--src/corelib/doc/snippets/statemachine/main5.cpp14
-rw-r--r--src/corelib/doc/snippets/timers/analogclock.cpp2
-rw-r--r--src/corelib/doc/snippets/timers/timers.cpp6
-rw-r--r--src/corelib/doc/src/animation.qdoc4
-rw-r--r--src/corelib/doc/src/objectmodel/properties.qdoc6
-rw-r--r--src/corelib/doc/src/statemachine.qdoc4
-rw-r--r--src/corelib/global/qglobal.cpp4
-rw-r--r--src/corelib/global/qnamespace.h3
-rw-r--r--src/corelib/global/qnamespace.qdoc12
-rw-r--r--src/corelib/io/qbuffer.cpp2
-rw-r--r--src/corelib/io/qiodevice.cpp2
-rw-r--r--src/corelib/io/qsettings.cpp37
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel.cpp40
-rw-r--r--src/corelib/kernel/qabstracteventdispatcher.cpp2
-rw-r--r--src/corelib/kernel/qmetaobject.cpp31
-rw-r--r--src/corelib/kernel/qmetaobject.h1
-rw-r--r--src/corelib/kernel/qmetaobject_p.h3
-rw-r--r--src/corelib/kernel/qmetatype.cpp3
-rw-r--r--src/corelib/kernel/qmetatype.h7
-rw-r--r--src/corelib/kernel/qmimedata.cpp72
-rw-r--r--src/corelib/kernel/qvariant.cpp494
-rw-r--r--src/corelib/kernel/qvariant_p.h4
-rw-r--r--src/corelib/serialization/qjsoncbor.cpp40
-rw-r--r--src/corelib/serialization/qjsondocument.cpp10
-rw-r--r--src/corelib/serialization/qjsonvalue.cpp28
-rw-r--r--src/corelib/serialization/qtextstream.cpp2
-rw-r--r--src/corelib/text/qlocale.cpp6
-rw-r--r--src/corelib/text/qlocale_unix.cpp12
-rw-r--r--src/corelib/text/qstringlist.cpp10
-rw-r--r--src/corelib/thread/qmutex.cpp2
-rw-r--r--src/corelib/thread/qthread.cpp6
-rw-r--r--src/corelib/thread/qthread_win.cpp2
-rw-r--r--src/corelib/time/qdatetime.cpp6
-rw-r--r--src/corelib/time/qdatetimeparser.cpp24
-rw-r--r--src/corelib/time/qdatetimeparser_p.h4
-rw-r--r--src/corelib/tools/qduplicatetracker_p.h94
-rw-r--r--src/corelib/tools/qmap.cpp7
-rw-r--r--src/corelib/tools/tools.pri1
52 files changed, 719 insertions, 487 deletions
diff --git a/src/corelib/Qt5CoreConfigExtras.cmake.in b/src/corelib/Qt5CoreConfigExtras.cmake.in
index 9b672327ef..4c1c3a612b 100644
--- a/src/corelib/Qt5CoreConfigExtras.cmake.in
+++ b/src/corelib/Qt5CoreConfigExtras.cmake.in
@@ -1,3 +1,6 @@
+if(NOT DEFINED QT_DEFAULT_MAJOR_VERSION)
+ set(QT_DEFAULT_MAJOR_VERSION 5)
+endif()
if (NOT TARGET Qt5::qmake)
add_executable(Qt5::qmake IMPORTED)
@@ -177,3 +180,24 @@ if (ANDROID_PLATFORM)
endif()
_qt5_Core_check_file_exists(${_Qt5CTestMacros})
+
+# Create versionless tool targets.
+foreach(__qt_tool qmake moc rcc)
+ if(NOT \"${QT_NO_CREATE_VERSIONLESS_TARGETS}\" AND NOT TARGET Qt::${__qt_tool}
+ AND TARGET Qt5::${__qt_tool})
+ add_executable(Qt::${__qt_tool} IMPORTED)
+ get_target_property(__qt_imported_location Qt5::${__qt_tool} IMPORTED_LOCATION)
+ set_target_properties(Qt::${__qt_tool}
+ PROPERTIES IMPORTED_LOCATION \"${__qt_imported_location}\")
+ endif()
+endforeach()
+
+!!IF !isEmpty(CMAKE_WINDOWS_BUILD)
+# Add a versionless target for WinMain.
+if(NOT \"${QT_NO_CREATE_VERSIONLESS_TARGETS}\" AND NOT TARGET Qt::WinMain)
+ add_library(Qt::WinMain INTERFACE IMPORTED)
+ set_target_properties(Qt::WinMain PROPERTIES
+ INTERFACE_LINK_LIBRARIES \"Qt5::WinMain\"
+ )
+endif()
+!!ENDIF
diff --git a/src/corelib/Qt5CoreMacros.cmake b/src/corelib/Qt5CoreMacros.cmake
index e298cf7de7..6c21470164 100644
--- a/src/corelib/Qt5CoreMacros.cmake
+++ b/src/corelib/Qt5CoreMacros.cmake
@@ -157,6 +157,16 @@ function(qt5_generate_moc infile outfile )
qt5_create_moc_command(${abs_infile} ${_outfile} "${moc_flags}" "" "${moc_target}" "")
endfunction()
+if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
+ function(qt_generate_moc)
+ if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
+ qt5_generate_moc(${ARGV})
+ elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
+ qt6_generate_moc(${ARGV})
+ endif()
+ endfunction()
+endif()
+
# qt5_wrap_cpp(outfiles inputfile ... )
@@ -184,6 +194,17 @@ function(qt5_wrap_cpp outfiles )
set(${outfiles} ${${outfiles}} PARENT_SCOPE)
endfunction()
+# This will override the CMake upstream command, because that one is for Qt 3.
+if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
+ function(qt_wrap_cpp outfiles)
+ if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
+ qt5_wrap_cpp("${outfiles}" ${ARGN})
+ elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
+ qt6_wrap_cpp("${outfiles}" ${ARGN})
+ endif()
+ set("${outfiles}" "${${outfiles}}" PARENT_SCOPE)
+ endfunction()
+endif()
# _qt5_parse_qrc_file(infile _out_depends _rc_depends)
@@ -255,6 +276,16 @@ function(qt5_add_binary_resources target )
add_custom_target(${target} ALL DEPENDS ${rcc_destination})
endfunction()
+if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
+ function(qt_add_binary_resources)
+ if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
+ qt5_add_binary_resources(${ARGV})
+ elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
+ qt6_add_binary_resources(${ARGV})
+ endif()
+ endfunction()
+endif()
+
# qt5_add_resources(outfiles inputfile ... )
@@ -293,6 +324,18 @@ function(qt5_add_resources outfiles )
set(${outfiles} ${${outfiles}} PARENT_SCOPE)
endfunction()
+if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
+ function(qt_add_resources outfiles)
+ if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
+ qt5_add_resources("${outfiles}" ${ARGN})
+ elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
+ qt6_add_resources("${outfiles}" ${ARGN})
+ endif()
+ set("${outfiles}" "${${outfiles}}" PARENT_SCOPE)
+ endfunction()
+endif()
+
+
# qt5_add_big_resources(outfiles inputfile ... )
function(qt5_add_big_resources outfiles )
@@ -341,6 +384,18 @@ function(qt5_add_big_resources outfiles )
set(${outfiles} ${${outfiles}} PARENT_SCOPE)
endfunction()
+if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
+ function(qt_add_big_resources outfiles)
+ if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
+ qt5_add_big_resources(${outfiles} ${ARGN})
+ elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
+ qt6_add_big_resources(${outfiles} ${ARGN})
+ endif()
+ set("${outfiles}" "${${outfiles}}" PARENT_SCOPE)
+ endfunction()
+endif()
+
+
set(_Qt5_COMPONENT_PATH "${CMAKE_CURRENT_LIST_DIR}/..")
macro(qt5_use_modules _target _link_type)
@@ -413,10 +468,19 @@ function(qt5_import_plugins TARGET_NAME)
elseif(_doing STREQUAL "EXCLUDE_BY_TYPE")
string(REGEX REPLACE "[-/]" "_" _plugin_type "${_arg}")
set_property(TARGET ${TARGET_NAME} PROPERTY "QT_PLUGINS_${_plugin_type}" -)
- set(_doing "")
else()
message(FATAL_ERROR "Unexpected extra argument: \"${_arg}\"")
endif()
endif()
endforeach()
endfunction()
+
+if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
+ function(qt_import_plugins)
+ if(QT_DEFAULT_MAJOR_VERSION EQUAL 5)
+ qt5_import_plugins(${ARGV})
+ elseif(QT_DEFAULT_MAJOR_VERSION EQUAL 6)
+ qt6_import_plugins(${ARGV})
+ endif()
+ endfunction()
+endif()
diff --git a/src/corelib/animation/qpropertyanimation.cpp b/src/corelib/animation/qpropertyanimation.cpp
index c71a77e073..d014b5c441 100644
--- a/src/corelib/animation/qpropertyanimation.cpp
+++ b/src/corelib/animation/qpropertyanimation.cpp
@@ -92,7 +92,7 @@ QT_BEGIN_NAMESPACE
void QPropertyAnimationPrivate::updateMetaProperty()
{
if (!target || propertyName.isEmpty()) {
- propertyType = QVariant::Invalid;
+ propertyType = QMetaType::UnknownType;
propertyIndex = -1;
return;
}
@@ -102,11 +102,11 @@ void QPropertyAnimationPrivate::updateMetaProperty()
propertyType = targetValue->property(propertyName).userType();
propertyIndex = targetValue->metaObject()->indexOfProperty(propertyName);
- if (propertyType != QVariant::Invalid)
+ if (propertyType != QMetaType::UnknownType)
convertValues(propertyType);
if (propertyIndex == -1) {
//there is no Q_PROPERTY on the object
- propertyType = QVariant::Invalid;
+ propertyType = QMetaType::UnknownType;
if (!targetValue->dynamicPropertyNames().contains(propertyName))
qWarning("QPropertyAnimation: you're trying to animate a non-existing property %s of your QObject", propertyName.constData());
} else if (!targetValue->metaObject()->property(propertyIndex).isWritable()) {
diff --git a/src/corelib/doc/snippets/code/doc_src_properties.cpp b/src/corelib/doc/snippets/code/doc_src_properties.cpp
index b72c9d13e1..a67945bbcf 100644
--- a/src/corelib/doc/snippets/code/doc_src_properties.cpp
+++ b/src/corelib/doc/snippets/code/doc_src_properties.cpp
@@ -61,6 +61,7 @@ Q_PROPERTY(type name
[USER bool]
[CONSTANT]
[FINAL])
+ [REQUIRED]
//! [0]
diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qcoreapplication.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qcoreapplication.cpp
index aae2456bf1..36b47e6f6e 100644
--- a/src/corelib/doc/snippets/code/src_corelib_kernel_qcoreapplication.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qcoreapplication.cpp
@@ -56,7 +56,7 @@ QApplication::sendEvent(mainWindow, &event);
//! [1]
QPushButton *quitButton = new QPushButton("Quit");
-connect(quitButton, SIGNAL(clicked()), &app, SLOT(quit()), Qt::QueuedConnection);
+connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection);
//! [1]
@@ -79,12 +79,12 @@ Q_COREAPP_STARTUP_FUNCTION(preRoutineMyDebugTool)
//! [4]
-static int *global_ptr = 0;
+static int *global_ptr = nullptr;
static void cleanup_ptr()
{
delete [] global_ptr;
- global_ptr = 0;
+ global_ptr = nullptr;
}
void init_ptr()
@@ -125,9 +125,9 @@ private:
//! [6]
static inline QString tr(const char *sourceText,
- const char *comment = 0);
+ const char *comment = nullptr);
static inline QString trUtf8(const char *sourceText,
- const char *comment = 0);
+ const char *comment = nullptr);
//! [6]
diff --git a/src/corelib/doc/snippets/code/src_corelib_statemachine_qstatemachine.cpp b/src/corelib/doc/snippets/code/src_corelib_statemachine_qstatemachine.cpp
index a606da1a0c..c756116de4 100644
--- a/src/corelib/doc/snippets/code/src_corelib_statemachine_qstatemachine.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_statemachine_qstatemachine.cpp
@@ -56,7 +56,7 @@ QState *s1 = new QState();
s1->assignProperty(&button, "text", "Click me");
QFinalState *s2 = new QFinalState();
-s1->addTransition(&button, SIGNAL(clicked()), s2);
+s1->addTransition(&button, &QPushButton::clicked, s2);
machine.addState(s1);
machine.addState(s2);
diff --git a/src/corelib/doc/snippets/code/src_corelib_thread_qfuturewatcher.cpp b/src/corelib/doc/snippets/code/src_corelib_thread_qfuturewatcher.cpp
index 043974b25b..336c1e9c79 100644
--- a/src/corelib/doc/snippets/code/src_corelib_thread_qfuturewatcher.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_thread_qfuturewatcher.cpp
@@ -52,7 +52,7 @@
// Instantiate the objects and connect to the finished signal.
MyClass myObject;
QFutureWatcher<int> watcher;
-connect(&watcher, SIGNAL(finished()), &myObject, SLOT(handleFinished()));
+connect(&watcher, QFutureWatcher<int>::finished, &myObject, &MyClass::handleFinished);
// Start the computation.
QFuture<int> future = QtConcurrent::run(...);
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qtimeline.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qtimeline.cpp
index 004a810fce..80859d5ba5 100644
--- a/src/corelib/doc/snippets/code/src_corelib_tools_qtimeline.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qtimeline.cpp
@@ -56,10 +56,10 @@ progressBar->setRange(0, 100);
// Construct a 1-second timeline with a frame range of 0 - 100
QTimeLine *timeLine = new QTimeLine(1000, this);
timeLine->setFrameRange(0, 100);
-connect(timeLine, SIGNAL(frameChanged(int)), progressBar, SLOT(setValue(int)));
+connect(timeLine, &QTimeLine::frameChanged, progressBar, &QProgressBar::setValue);
// Clicking the push button will start the progress bar animation
pushButton = new QPushButton(tr("Start animation"), this);
-connect(pushButton, SIGNAL(clicked()), timeLine, SLOT(start()));
+connect(pushButton, &QPushButton::clicked, timeLine, &QTimeLine::start);
...
//! [0]
diff --git a/src/corelib/doc/snippets/qsignalmapper/buttonwidget.cpp b/src/corelib/doc/snippets/qsignalmapper/buttonwidget.cpp
index e91c41b305..84a156bb6d 100644
--- a/src/corelib/doc/snippets/qsignalmapper/buttonwidget.cpp
+++ b/src/corelib/doc/snippets/qsignalmapper/buttonwidget.cpp
@@ -48,11 +48,10 @@
**
****************************************************************************/
-#include <QtGui>
-#include <QtWidgets>
-
#include "buttonwidget.h"
+#include <QtWidgets>
+
//! [0]
ButtonWidget::ButtonWidget(const QStringList &texts, QWidget *parent)
: QWidget(parent)
@@ -62,15 +61,16 @@ ButtonWidget::ButtonWidget(const QStringList &texts, QWidget *parent)
QGridLayout *gridLayout = new QGridLayout;
for (int i = 0; i < texts.size(); ++i) {
QPushButton *button = new QPushButton(texts[i]);
- connect(button, SIGNAL(clicked()), signalMapper, SLOT(map()));
+ connect(button, &QPushButton::clicked,
+ signalMapper, &QSignalMapper::map);
//! [0] //! [1]
signalMapper->setMapping(button, texts[i]);
gridLayout->addWidget(button, i / 3, i % 3);
}
- connect(signalMapper, SIGNAL(mapped(QString)),
+ connect(signalMapper, QOverload<const QString &>::of(&QSignalMapper::mapped),
//! [1] //! [2]
- this, SIGNAL(clicked(QString)));
+ this, &ButtonWidget::clicked);
setLayout(gridLayout);
}
@@ -84,7 +84,7 @@ ButtonWidget::ButtonWidget(const QStringList &texts, QWidget *parent)
for (int i = 0; i < texts.size(); ++i) {
QString text = texts[i];
QPushButton *button = new QPushButton(text);
- connect(button, &QPushButton::clicked, [=] { clicked(text); });
+ connect(button, &QPushButton::clicked, [this, text] { clicked(text); });
gridLayout->addWidget(button, i / 3, i % 3);
}
setLayout(gridLayout);
diff --git a/src/corelib/doc/snippets/qsignalmapper/buttonwidget.h b/src/corelib/doc/snippets/qsignalmapper/buttonwidget.h
index f55683c2d5..b9d59f8dd8 100644
--- a/src/corelib/doc/snippets/qsignalmapper/buttonwidget.h
+++ b/src/corelib/doc/snippets/qsignalmapper/buttonwidget.h
@@ -51,7 +51,7 @@
#ifndef BUTTONWIDGET_H
#define BUTTONWIDGET_H
-#include <qwidget.h>
+#include <QWidget>
class QSignalMapper;
class QString;
@@ -63,7 +63,7 @@ class ButtonWidget : public QWidget
Q_OBJECT
public:
- ButtonWidget(const QStringList &texts, QWidget *parent = 0);
+ ButtonWidget(const QStringList &texts, QWidget *parent = nullptr);
signals:
void clicked(const QString &text);
diff --git a/src/corelib/doc/snippets/resource-system/mainwindow.cpp b/src/corelib/doc/snippets/resource-system/mainwindow.cpp
index 86e93aaa62..6dc525304c 100644
--- a/src/corelib/doc/snippets/resource-system/mainwindow.cpp
+++ b/src/corelib/doc/snippets/resource-system/mainwindow.cpp
@@ -68,10 +68,10 @@ MainWindow::MainWindow()
readSettings();
- connect(textEdit->document(), SIGNAL(contentsChanged()),
- this, SLOT(documentWasModified()));
+ connect(textEdit->document(), &QTextEdit::contentsChanged,
+ this, &QAction::documentWasModified);
- setCurrentFile("");
+ setCurrentFile(QString());
setUnifiedTitleAndToolBarOnMac(true);
}
//! [2]
@@ -95,7 +95,7 @@ void MainWindow::newFile()
{
if (maybeSave()) {
textEdit->clear();
- setCurrentFile("");
+ setCurrentFile(QString());
}
}
//! [6]
@@ -162,31 +162,31 @@ void MainWindow::createActions()
newAct = new QAction(QIcon(":/images/new.png"), tr("&New"), this);
newAct->setShortcuts(QKeySequence::New);
newAct->setStatusTip(tr("Create a new file"));
- connect(newAct, SIGNAL(triggered()), this, SLOT(newFile()));
+ connect(newAct, &QAction::triggered, this, &MainWindow::newFile);
//! [19]
openAct = new QAction(QIcon(":/images/open.png"), tr("&Open..."), this);
openAct->setShortcuts(QKeySequence::Open);
openAct->setStatusTip(tr("Open an existing file"));
- connect(openAct, SIGNAL(triggered()), this, SLOT(open()));
+ connect(openAct, &QAction::triggered, this, &MainWindow::open);
//! [18] //! [19]
saveAct = new QAction(QIcon(":/images/save.png"), tr("&Save"), this);
saveAct->setShortcuts(QKeySequence::Save);
saveAct->setStatusTip(tr("Save the document to disk"));
- connect(saveAct, SIGNAL(triggered()), this, SLOT(save()));
+ connect(saveAct, &QAction::triggered, this, &MainWindow::save);
saveAsAct = new QAction(tr("Save &As..."), this);
saveAsAct->setShortcuts(QKeySequence::SaveAs);
saveAsAct->setStatusTip(tr("Save the document under a new name"));
- connect(saveAsAct, SIGNAL(triggered()), this, SLOT(saveAs()));
+ connect(saveAsAct, &QAction::triggered, this, &MainWindow::saveAs);
//! [20]
exitAct = new QAction(tr("E&xit"), this);
exitAct->setShortcuts(QKeySequence::Quit);
//! [20]
exitAct->setStatusTip(tr("Exit the application"));
- connect(exitAct, SIGNAL(triggered()), this, SLOT(close()));
+ connect(exitAct, &QAction::triggered, this, &MainWindow::close);
//! [21]
cutAct = new QAction(QIcon(":/images/cut.png"), tr("Cu&t"), this);
@@ -194,38 +194,38 @@ void MainWindow::createActions()
cutAct->setShortcuts(QKeySequence::Cut);
cutAct->setStatusTip(tr("Cut the current selection's contents to the "
"clipboard"));
- connect(cutAct, SIGNAL(triggered()), textEdit, SLOT(cut()));
+ connect(cutAct, &QAction::triggered, textEdit, &QTextEdit::cut);
copyAct = new QAction(QIcon(":/images/copy.png"), tr("&Copy"), this);
copyAct->setShortcuts(QKeySequence::Copy);
copyAct->setStatusTip(tr("Copy the current selection's contents to the "
"clipboard"));
- connect(copyAct, SIGNAL(triggered()), textEdit, SLOT(copy()));
+ connect(copyAct, &QAction::triggered, textEdit, &QTextEdit::copy);
pasteAct = new QAction(QIcon(":/images/paste.png"), tr("&Paste"), this);
pasteAct->setShortcuts(QKeySequence::Paste);
pasteAct->setStatusTip(tr("Paste the clipboard's contents into the current "
"selection"));
- connect(pasteAct, SIGNAL(triggered()), textEdit, SLOT(paste()));
+ connect(pasteAct, &QAction::triggered, textEdit, &QTextEdit::paste);
aboutAct = new QAction(tr("&About"), this);
aboutAct->setStatusTip(tr("Show the application's About box"));
- connect(aboutAct, SIGNAL(triggered()), this, SLOT(about()));
+ connect(aboutAct, &QAction::triggered, this, &MainWindow::about);
//! [22]
aboutQtAct = new QAction(tr("About &Qt"), this);
aboutQtAct->setStatusTip(tr("Show the Qt library's About box"));
- connect(aboutQtAct, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
+ connect(aboutQtAct, &QAction::triggered, qApp, &QApplication::aboutQt);
//! [22]
//! [23]
cutAct->setEnabled(false);
//! [23] //! [24]
copyAct->setEnabled(false);
- connect(textEdit, SIGNAL(copyAvailable(bool)),
- cutAct, SLOT(setEnabled(bool)));
- connect(textEdit, SIGNAL(copyAvailable(bool)),
- copyAct, SLOT(setEnabled(bool)));
+ connect(textEdit, &QTextEdit::copyAvailable,
+ cutAct, &QAction::setEnabled);
+ connect(textEdit, &QTextEdit::copyAvailable,
+ copyAct, &QAction::setEnabled);
}
//! [24]
diff --git a/src/corelib/doc/snippets/statemachine/main.cpp b/src/corelib/doc/snippets/statemachine/main.cpp
index 8cd8b69e12..c399f4f199 100644
--- a/src/corelib/doc/snippets/statemachine/main.cpp
+++ b/src/corelib/doc/snippets/statemachine/main.cpp
@@ -48,13 +48,14 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
int main(int argv, char **args)
{
QApplication app(argv, args);
QLabel *label = new QLabel;
+ QPushButton *button = new QPushButton;
//![0]
QStateMachine machine;
@@ -70,14 +71,14 @@ int main(int argv, char **args)
//![4]
//![5]
- QObject::connect(s3, SIGNAL(entered()), button, SLOT(showMaximized()));
- QObject::connect(s3, SIGNAL(exited()), button, SLOT(showMinimized()));
+ QObject::connect(s3, &QState::entered, button, &QPushButton:showMaximized);
+ QObject::connect(s3, &QState::exited, button, &QPushButton::showMinimized);
//![5]
//![1]
- s1->addTransition(button, SIGNAL(clicked()), s2);
- s2->addTransition(button, SIGNAL(clicked()), s3);
- s3->addTransition(button, SIGNAL(clicked()), s1);
+ s1->addTransition(button, &QPushButton::clicked, s2);
+ s2->addTransition(button, &QPushButton::clicked, s3);
+ s3->addTransition(button, &QPushButton::clicked, s1);
//![1]
//![2]
diff --git a/src/corelib/doc/snippets/statemachine/main2.cpp b/src/corelib/doc/snippets/statemachine/main2.cpp
index 96eb912b14..dedd2d29bf 100644
--- a/src/corelib/doc/snippets/statemachine/main2.cpp
+++ b/src/corelib/doc/snippets/statemachine/main2.cpp
@@ -48,11 +48,11 @@
**
****************************************************************************/
-#include <QtGui>
+#include <QtWidgets>
int main(int argv, char **args)
{
- QApplication app(argv, args);
+ QApplication app(argv, args);
QStateMachine machine;
@@ -66,16 +66,17 @@ int main(int argv, char **args)
//![0]
//![2]
- s12->addTransition(quitButton, SIGNAL(clicked()), s12);
+ s12->addTransition(quitButton, &QPushButton::clicked, s12);
//![2]
//![1]
QFinalState *s2 = new QFinalState();
- s1->addTransition(quitButton, SIGNAL(clicked()), s2);
+ s1->addTransition(quitButton, &QPushButton::clicked, s2);
machine.addState(s2);
machine.setInitialState(s1);
- QObject::connect(&machine, SIGNAL(finished()), QApplication::instance(), SLOT(quit()));
+ QObject::connect(&machine, &QStateMachine::finished,
+ QCoreApplication::instance(), &QCoreApplication::quit);
//![1]
QButton *interruptButton = new QPushButton("Interrupt Button");
@@ -90,11 +91,11 @@ int main(int argv, char **args)
mbox->addButton(QMessageBox::Ok);
mbox->setText("Interrupted!");
mbox->setIcon(QMessageBox::Information);
- QObject::connect(s3, SIGNAL(entered()), mbox, SLOT(exec()));
+ QObject::connect(s3, &QState::entered, mbox, &QMessageBox::exec);
s3->addTransition(s1h);
machine.addState(s3);
- s1->addTransition(interruptButton, SIGNAL(clicked()), s3);
+ s1->addTransition(interruptButton, &QPushButton::clicked, s3);
//![3]
return app.exec();
diff --git a/src/corelib/doc/snippets/statemachine/main3.cpp b/src/corelib/doc/snippets/statemachine/main3.cpp
index bc9a0e29c4..b665565aef 100644
--- a/src/corelib/doc/snippets/statemachine/main3.cpp
+++ b/src/corelib/doc/snippets/statemachine/main3.cpp
@@ -62,7 +62,7 @@ int main(int argv, char **args)
//![0]
//![1]
- s1->addTransition(s1, SIGNAL(finished()), s2);
+ s1->addTransition(s1, &QState::finished, s2);
//![1]
return app.exec();
diff --git a/src/corelib/doc/snippets/statemachine/main5.cpp b/src/corelib/doc/snippets/statemachine/main5.cpp
index 38bb2cb475..d701f51e2b 100644
--- a/src/corelib/doc/snippets/statemachine/main5.cpp
+++ b/src/corelib/doc/snippets/statemachine/main5.cpp
@@ -98,7 +98,7 @@ int main(int argv, char **args)
s1->assignProperty(button, "geometry", QRectF(0, 0, 50, 50));
s2->assignProperty(button, "geometry", QRectF(0, 0, 100, 100));
- s1->addTransition(button, SIGNAL(clicked()), s2);
+ s1->addTransition(button, &QPushButton::clicked, s2);
//![3]
}
@@ -111,7 +111,7 @@ int main(int argv, char **args)
s1->assignProperty(button, "geometry", QRectF(0, 0, 50, 50));
s2->assignProperty(button, "geometry", QRectF(0, 0, 100, 100));
- QSignalTransition *transition = s1->addTransition(button, SIGNAL(clicked()), s2);
+ QSignalTransition *transition = s1->addTransition(button, &QPushButton::clicked, s2);
transition->addAnimation(new QPropertyAnimation(button, "geometry"));
//![4]
@@ -130,9 +130,9 @@ int main(int argv, char **args)
QState *s2 = new QState();
s2->assignProperty(button, "geometry", QRectF(0, 0, 50, 50));
- connect(s2, SIGNAL(entered()), messageBox, SLOT(exec()));
+ connect(s2, &QState::entered, messageBox, SLOT(exec()));
- s1->addTransition(button, SIGNAL(clicked()), s2);
+ s1->addTransition(button, &QPushButton::clicked, s2);
//![5]
}
@@ -151,10 +151,10 @@ int main(int argv, char **args)
s2->assignProperty(button, "geometry", QRectF(0, 0, 50, 50));
QState *s3 = new QState();
- connect(s3, SIGNAL(entered()), messageBox, SLOT(exec()));
+ connect(s3, &QState::entered, messageBox, SLOT(exec()));
- s1->addTransition(button, SIGNAL(clicked()), s2);
- s2->addTransition(s2, SIGNAL(propertiesAssigned()), s3);
+ s1->addTransition(button, &QPushButton::clicked, s2);
+ s2->addTransition(s2, &QState::propertiesAssigned, s3);
//![6]
}
diff --git a/src/corelib/doc/snippets/timers/analogclock.cpp b/src/corelib/doc/snippets/timers/analogclock.cpp
index 4e1957a450..3edfce3235 100644
--- a/src/corelib/doc/snippets/timers/analogclock.cpp
+++ b/src/corelib/doc/snippets/timers/analogclock.cpp
@@ -61,7 +61,7 @@ AnalogClock::AnalogClock(QWidget *parent)
//! [3] //! [4]
QTimer *timer = new QTimer(this);
//! [4] //! [5]
- connect(timer, SIGNAL(timeout()), this, SLOT(update()));
+ connect(timer, &QTimer::timeout, this, QOverload<>::of(&AnalogClock::update));
//! [5] //! [6]
timer->start(1000);
//! [6]
diff --git a/src/corelib/doc/snippets/timers/timers.cpp b/src/corelib/doc/snippets/timers/timers.cpp
index 5f95899af2..eb0c82c625 100644
--- a/src/corelib/doc/snippets/timers/timers.cpp
+++ b/src/corelib/doc/snippets/timers/timers.cpp
@@ -61,13 +61,13 @@ Foo::Foo()
//! [0]
QTimer *timer = new QTimer(this);
//! [0] //! [1]
- connect(timer, SIGNAL(timeout()), this, SLOT(updateCaption()));
+ connect(timer, &QTimer::timeout, this, &Foo::updateCaption);
//! [1] //! [2]
timer->start(1000);
//! [2]
//! [3]
- QTimer::singleShot(200, this, SLOT(updateCaption()));
+ QTimer::singleShot(200, this, &Foo::updateCaption);
//! [3]
{
@@ -75,7 +75,7 @@ Foo::Foo()
//! [4]
QTimer *timer = new QTimer(this);
//! [4] //! [5]
- connect(timer, SIGNAL(timeout()), this, SLOT(processOneThing()));
+ connect(timer, &QTimer::timeout, this, &Foo::processOneThing);
//! [5] //! [6]
timer->start();
//! [6]
diff --git a/src/corelib/doc/src/animation.qdoc b/src/corelib/doc/src/animation.qdoc
index 0c1b2aed17..9cbe50d4a9 100644
--- a/src/corelib/doc/src/animation.qdoc
+++ b/src/corelib/doc/src/animation.qdoc
@@ -356,11 +356,11 @@
state2->assignProperty(button, "geometry", QRect(250, 250, 100, 30));
QSignalTransition *transition1 = state1->addTransition(button,
- SIGNAL(clicked()), state2);
+ &QPushButton::clicked, state2);
transition1->addAnimation(new QPropertyAnimation(button, "geometry"));
QSignalTransition *transition2 = state2->addTransition(button,
- SIGNAL(clicked()), state1);
+ &QPushButton::clicked, state1);
transition2->addAnimation(new QPropertyAnimation(button, "geometry"));
machine->start();
diff --git a/src/corelib/doc/src/objectmodel/properties.qdoc b/src/corelib/doc/src/objectmodel/properties.qdoc
index 9ef08cce07..680e5598f0 100644
--- a/src/corelib/doc/src/objectmodel/properties.qdoc
+++ b/src/corelib/doc/src/objectmodel/properties.qdoc
@@ -144,6 +144,12 @@
optimizations in some cases, but is not enforced by moc. Care must be taken
never to override a \c FINAL property.
+ \li The presence of the \c REQUIRED attribute indicates that the property
+ should be set by a user of the class. This is not enforced by moc, and is
+ mostly useful for classes exposed to QML. In QML, classes with REQUIRED
+ properties cannot be instantiated unless all REQUIRED properties have
+ been set.
+
\endlist
The \c READ, \c WRITE, and \c RESET functions can be inherited.
diff --git a/src/corelib/doc/src/statemachine.qdoc b/src/corelib/doc/src/statemachine.qdoc
index 43c8497ef2..881a0785c6 100644
--- a/src/corelib/doc/src/statemachine.qdoc
+++ b/src/corelib/doc/src/statemachine.qdoc
@@ -323,12 +323,12 @@
QState *s1 = new QState(&machine);
QPushButton button;
- QSignalTransition *trans = new QSignalTransition(&button, SIGNAL(clicked()));
+ QSignalTransition *trans = new QSignalTransition(&button, &QPushButton::clicked);
s1->addTransition(trans);
QMessageBox msgBox;
msgBox.setText("The button was clicked; carry on.");
- QObject::connect(trans, SIGNAL(triggered()), &msgBox, SLOT(exec()));
+ QObject::connect(trans, QSignalTransition::triggered, &msgBox, &QMessageBox::exec);
machine.setInitialState(s1);
\endcode
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index ea91dee471..c9e155555c 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -702,7 +702,7 @@ Q_STATIC_ASSERT((std::is_same<qsizetype, qptrdiff>::value));
64-bit integer literals in a platform-independent way. The
Q_CHECK_PTR() macro prints a warning containing the source code's
file name and line number, saying that the program ran out of
- memory, if the pointer is 0. The qPrintable() and qUtf8Printable()
+ memory, if the pointer is \nullptr. The qPrintable() and qUtf8Printable()
macros represent an easy way of printing text.
The QT_POINTER_SIZE macro expands to the size of a pointer in bytes.
@@ -3279,7 +3279,7 @@ QByteArray QSysInfo::bootUniqueId()
\macro void Q_CHECK_PTR(void *pointer)
\relates <QtGlobal>
- If \a pointer is 0, prints a message containing the source
+ If \a pointer is \nullptr, prints a message containing the source
code's file name and line number, saying that the program ran out
of memory and aborts program execution. It throws \c std::bad_alloc instead
if exceptions are enabled.
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index b9e981b4a6..f278850ccf 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -1749,6 +1749,9 @@ namespace Qt {
PassThrough
};
+ // QTBUG-48701
+ enum ReturnByValue_t { ReturnByValue }; // ### Qt 7: Remove me
+
#ifndef Q_QDOC
// NOTE: Generally, do not add Q_ENUM_NS if a corresponding Q_FLAG_NS exists.
Q_ENUM_NS(ScrollBarPolicy)
diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc
index 6149281904..29b58783d5 100644
--- a/src/corelib/global/qnamespace.qdoc
+++ b/src/corelib/global/qnamespace.qdoc
@@ -3319,3 +3319,15 @@
\value RoundPreferFloor Round up for .75 and above.
\value PassThrough Don't round.
*/
+
+/*!
+ \enum Qt::ReturnByValue_t
+ \since 5.15
+
+ This is a dummy type, designed to help users transition from certain deprecated APIs to their replacement APIs.
+
+ \sa QCursor::bitmap()
+ \sa QCursor::mask()
+ \sa QLabel::picture()
+ \sa QLabel::pixmap()
+*/
diff --git a/src/corelib/io/qbuffer.cpp b/src/corelib/io/qbuffer.cpp
index 8e980733de..595fcd2724 100644
--- a/src/corelib/io/qbuffer.cpp
+++ b/src/corelib/io/qbuffer.cpp
@@ -227,7 +227,7 @@ QBuffer::~QBuffer()
\snippet buffer/buffer.cpp 4
- If \a byteArray is 0, the buffer creates its own internal
+ If \a byteArray is \nullptr, the buffer creates its own internal
QByteArray to work on. This byte array is initially empty.
\sa buffer(), setData(), open()
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp
index b89cab5e3c..f7a86c25cd 100644
--- a/src/corelib/io/qiodevice.cpp
+++ b/src/corelib/io/qiodevice.cpp
@@ -1829,7 +1829,7 @@ QByteArray QIODevicePrivate::peek(qint64 maxSize)
/*! \fn bool QIODevice::getChar(char *c)
Reads one character from the device and stores it in \a c. If \a c
- is 0, the character is discarded. Returns \c true on success;
+ is \nullptr, the character is discarded. Returns \c true on success;
otherwise returns \c false.
\sa read(), putChar(), ungetChar()
diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp
index 779b6f72de..6c66d1097d 100644
--- a/src/corelib/io/qsettings.cpp
+++ b/src/corelib/io/qsettings.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -396,12 +396,12 @@ QString QSettingsPrivate::variantToString(const QVariant &v)
{
QString result;
- switch (v.type()) {
- case QVariant::Invalid:
+ switch (v.userType()) {
+ case QMetaType::UnknownType:
result = QLatin1String("@Invalid()");
break;
- case QVariant::ByteArray: {
+ case QMetaType::QByteArray: {
QByteArray a = v.toByteArray();
result = QLatin1String("@ByteArray(")
+ QLatin1String(a.constData(), a.size())
@@ -409,17 +409,16 @@ QString QSettingsPrivate::variantToString(const QVariant &v)
break;
}
- case QVariant::String:
- case QVariant::LongLong:
- case QVariant::ULongLong:
- case QVariant::Int:
- case QVariant::UInt:
- case QVariant::Bool:
- case QVariant::Double:
#if QT_CONFIG(shortcut)
- case QVariant::KeySequence:
+ case QMetaType::QKeySequence:
#endif
- {
+ case QMetaType::QString:
+ case QMetaType::LongLong:
+ case QMetaType::ULongLong:
+ case QMetaType::Int:
+ case QMetaType::UInt:
+ case QMetaType::Bool:
+ case QMetaType::Double: {
result = v.toString();
if (result.contains(QChar::Null))
result = QLatin1String("@String(") + result + QLatin1Char(')');
@@ -428,17 +427,17 @@ QString QSettingsPrivate::variantToString(const QVariant &v)
break;
}
#ifndef QT_NO_GEOM_VARIANT
- case QVariant::Rect: {
+ case QMetaType::QRect: {
QRect r = qvariant_cast<QRect>(v);
result = QString::asprintf("@Rect(%d %d %d %d)", r.x(), r.y(), r.width(), r.height());
break;
}
- case QVariant::Size: {
+ case QMetaType::QSize: {
QSize s = qvariant_cast<QSize>(v);
result = QString::asprintf("@Size(%d %d)", s.width(), s.height());
break;
}
- case QVariant::Point: {
+ case QMetaType::QPoint: {
QPoint p = qvariant_cast<QPoint>(v);
result = QString::asprintf("@Point(%d %d)", p.x(), p.y());
break;
@@ -449,7 +448,7 @@ QString QSettingsPrivate::variantToString(const QVariant &v)
#ifndef QT_NO_DATASTREAM
QDataStream::Version version;
const char *typeSpec;
- if (v.type() == QVariant::DateTime) {
+ if (v.userType() == QMetaType::QDateTime) {
version = QDataStream::Qt_5_6;
typeSpec = "@DateTime(";
} else {
@@ -1891,8 +1890,8 @@ bool QConfFileSettingsPrivate::writeIniFile(QIODevice &device, const ParsedSetti
QVariant(QString("foo")).toList() returns an empty
list, not a list containing "foo".
*/
- if (value.type() == QVariant::StringList
- || (value.type() == QVariant::List && value.toList().size() != 1)) {
+ if (value.userType() == QMetaType::QStringList
+ || (value.userType() == QMetaType::QVariantList && value.toList().size() != 1)) {
iniEscapedStringList(variantListToStringList(value.toList()), block, iniCodec);
} else {
iniEscapedString(variantToString(value), block, iniCodec);
diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp
index 3bcd81bcdf..f0eb8e5c8b 100644
--- a/src/corelib/itemmodels/qabstractitemmodel.cpp
+++ b/src/corelib/itemmodels/qabstractitemmodel.cpp
@@ -552,32 +552,32 @@ const QHash<int,QByteArray> &QAbstractItemModelPrivate::defaultRoleNames()
bool QAbstractItemModelPrivate::isVariantLessThan(const QVariant &left, const QVariant &right,
Qt::CaseSensitivity cs, bool isLocaleAware)
{
- if (left.userType() == QVariant::Invalid)
+ if (left.userType() == QMetaType::UnknownType)
return false;
- if (right.userType() == QVariant::Invalid)
+ if (right.userType() == QMetaType::UnknownType)
return true;
switch (left.userType()) {
- case QVariant::Int:
+ case QMetaType::Int:
return left.toInt() < right.toInt();
- case QVariant::UInt:
+ case QMetaType::UInt:
return left.toUInt() < right.toUInt();
- case QVariant::LongLong:
+ case QMetaType::LongLong:
return left.toLongLong() < right.toLongLong();
- case QVariant::ULongLong:
+ case QMetaType::ULongLong:
return left.toULongLong() < right.toULongLong();
case QMetaType::Float:
return left.toFloat() < right.toFloat();
- case QVariant::Double:
+ case QMetaType::Double:
return left.toDouble() < right.toDouble();
- case QVariant::Char:
+ case QMetaType::QChar:
return left.toChar() < right.toChar();
- case QVariant::Date:
+ case QMetaType::QDate:
return left.toDate() < right.toDate();
- case QVariant::Time:
+ case QMetaType::QTime:
return left.toTime() < right.toTime();
- case QVariant::DateTime:
+ case QMetaType::QDateTime:
return left.toDateTime() < right.toDateTime();
- case QVariant::String:
+ case QMetaType::QString:
default:
if (isLocaleAware)
return left.toString().localeAwareCompare(right.toString()) < 0;
@@ -591,19 +591,19 @@ static uint typeOfVariant(const QVariant &value)
{
//return 0 for integer, 1 for floating point and 2 for other
switch (value.userType()) {
- case QVariant::Bool:
- case QVariant::Int:
- case QVariant::UInt:
- case QVariant::LongLong:
- case QVariant::ULongLong:
- case QVariant::Char:
+ case QMetaType::Bool:
+ case QMetaType::Int:
+ case QMetaType::UInt:
+ case QMetaType::LongLong:
+ case QMetaType::ULongLong:
+ case QMetaType::QChar:
case QMetaType::Short:
case QMetaType::UShort:
case QMetaType::UChar:
case QMetaType::ULong:
case QMetaType::Long:
return 0;
- case QVariant::Double:
+ case QMetaType::Double:
case QMetaType::Float:
return 1;
default:
@@ -2374,7 +2374,7 @@ QModelIndexList QAbstractItemModel::match(const QModelIndex &start, int role,
} else { // QString or regular expression based matching
if (matchType == Qt::MatchRegularExpression) {
if (rx.pattern().isEmpty()) {
- if (value.type() == QVariant::RegularExpression) {
+ if (value.userType() == QMetaType::QRegularExpression) {
rx = value.toRegularExpression();
} else {
rx.setPattern(value.toString());
diff --git a/src/corelib/kernel/qabstracteventdispatcher.cpp b/src/corelib/kernel/qabstracteventdispatcher.cpp
index 7215b3f2bd..685a0c595a 100644
--- a/src/corelib/kernel/qabstracteventdispatcher.cpp
+++ b/src/corelib/kernel/qabstracteventdispatcher.cpp
@@ -160,7 +160,7 @@ QAbstractEventDispatcher::~QAbstractEventDispatcher()
/*!
Returns a pointer to the event dispatcher object for the specified
- \a thread. If \a thread is zero, the current thread is used. If no
+ \a thread. If \a thread is \nullptr, the current thread is used. If no
event dispatcher exists for the specified thread, this function
returns \nullptr.
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp
index 3883613d49..f4d0a88529 100644
--- a/src/corelib/kernel/qmetaobject.cpp
+++ b/src/corelib/kernel/qmetaobject.cpp
@@ -603,7 +603,7 @@ static bool methodMatch(const QMetaObject *m, int handle,
* \internal
* helper function for indexOf{Method,Slot,Signal}, returns the relative index of the method within
* the baseObject
-* \a MethodType might be MethodSignal or MethodSlot, or 0 to match everything.
+* \a MethodType might be MethodSignal or MethodSlot, or \nullptr to match everything.
*/
template<int MethodType>
static inline int indexOfMethodRelative(const QMetaObject **baseObject,
@@ -737,7 +737,7 @@ int QMetaObject::indexOfSignal(const char *signal) const
\internal
Same as QMetaObject::indexOfSignal, but the result is the local offset to the base object.
- \a baseObject will be adjusted to the enclosing QMetaObject, or 0 if the signal is not found
+ \a baseObject will be adjusted to the enclosing QMetaObject, or \nullptr if the signal is not found
*/
int QMetaObjectPrivate::indexOfSignalRelative(const QMetaObject **baseObject,
const QByteArray &name, int argc,
@@ -2988,7 +2988,7 @@ int QMetaProperty::userType() const
if (type == QMetaType::UnknownType) {
type = registerPropertyType();
if (type == QMetaType::UnknownType)
- return QVariant::Int; // Match behavior of QMetaType::type()
+ return QMetaType::Int; // Match behavior of QMetaType::type()
}
return type;
}
@@ -3106,7 +3106,7 @@ QVariant QMetaProperty::read(const QObject *object) const
if (!object || !mobj)
return QVariant();
- uint t = QVariant::Int;
+ uint t = QMetaType::Int;
if (isEnumType()) {
/*
try to create a QVariant that can be converted to this enum
@@ -3183,9 +3183,9 @@ bool QMetaProperty::write(QObject *object, const QVariant &value) const
return false;
QVariant v = value;
- uint t = QVariant::Invalid;
+ uint t = QMetaType::UnknownType;
if (isEnumType()) {
- if (v.type() == QVariant::String) {
+ if (v.userType() == QMetaType::QString) {
bool ok;
if (isFlagType())
v = QVariant(menum.keysToValue(value.toByteArray(), &ok));
@@ -3193,13 +3193,13 @@ bool QMetaProperty::write(QObject *object, const QVariant &value) const
v = QVariant(menum.keyToValue(value.toByteArray(), &ok));
if (!ok)
return false;
- } else if (v.type() != QVariant::Int && v.type() != QVariant::UInt) {
+ } else if (v.userType() != QMetaType::Int && v.userType() != QMetaType::UInt) {
int enumMetaTypeId = QMetaType::type(qualifiedName(menum));
if ((enumMetaTypeId == QMetaType::UnknownType) || (v.userType() != enumMetaTypeId) || !v.constData())
return false;
v = QVariant(*reinterpret_cast<const int *>(v.constData()));
}
- v.convert(QVariant::Int);
+ v.convert(QMetaType::Int);
} else {
int handle = priv(mobj->d.data)->propertyData + 3*idx;
const char *typeName = nullptr;
@@ -3579,6 +3579,21 @@ bool QMetaProperty::isFinal() const
}
/*!
+ \since 5.15
+ Returns \c true if the property is required; otherwise returns \c false.
+
+ A property is final if the \c{Q_PROPERTY()}'s \c REQUIRED attribute
+ is set.
+*/
+bool QMetaProperty::isRequired() const
+{
+ if (!mobj)
+ return false;
+ int flags = mobj->d.data[handle + 2];
+ return flags & Required;
+}
+
+/*!
\obsolete
Returns \c true if the property is editable for the given \a object;
diff --git a/src/corelib/kernel/qmetaobject.h b/src/corelib/kernel/qmetaobject.h
index 31fecd0b07..d0c4b489a6 100644
--- a/src/corelib/kernel/qmetaobject.h
+++ b/src/corelib/kernel/qmetaobject.h
@@ -263,6 +263,7 @@ public:
bool isUser(const QObject *obj = nullptr) const;
bool isConstant() const;
bool isFinal() const;
+ bool isRequired() const;
bool isFlagType() const;
bool isEnumType() const;
diff --git a/src/corelib/kernel/qmetaobject_p.h b/src/corelib/kernel/qmetaobject_p.h
index 56e3d6cb44..277109dac4 100644
--- a/src/corelib/kernel/qmetaobject_p.h
+++ b/src/corelib/kernel/qmetaobject_p.h
@@ -85,7 +85,8 @@ enum PropertyFlags {
User = 0x00100000,
ResolveUser = 0x00200000,
Notify = 0x00400000,
- Revisioned = 0x00800000
+ Revisioned = 0x00800000,
+ Required = 0x01000000,
};
enum MethodFlags {
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index 79d6d0aa93..e498772e32 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -254,6 +254,7 @@ struct DefinedTypesFilter {
\value QPolygon QPolygon
\value QPolygonF QPolygonF
\value QColor QColor
+ \value QColorSpace QColorSpace
\value QSizeF QSizeF
\value QRectF QRectF
\value QLine QLine
@@ -458,7 +459,7 @@ struct DefinedTypesFilter {
\deprecated
Constructs a value of the given type which is a copy of \a copy.
- The default value for \a copy is 0.
+ The default value for \a copy is \nullptr.
Deprecated, use the static function QMetaType::create(int type,
const void *copy) instead.
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index 7628f5f6b3..927bfb7667 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -182,6 +182,7 @@ inline Q_DECL_CONSTEXPR int qMetaTypeId();
F(QVector4D, 84, QVector4D) \
F(QQuaternion, 85, QQuaternion) \
F(QPolygonF, 86, QPolygonF) \
+ F(QColorSpace, 87, QColorSpace) \
#define QT_FOR_EACH_STATIC_WIDGETS_CLASS(F)\
@@ -440,7 +441,7 @@ public:
FirstCoreType = Bool,
LastCoreType = QCborMap,
FirstGuiType = QFont,
- LastGuiType = QPolygonF,
+ LastGuiType = QColorSpace,
FirstWidgetsType = QSizePolicy,
LastWidgetsType = QSizePolicy,
HighestInternalId = LastWidgetsType,
@@ -475,12 +476,12 @@ public:
QIcon = 69, QImage = 70, QPolygon = 71, QRegion = 72, QBitmap = 73,
QCursor = 74, QKeySequence = 75, QPen = 76, QTextLength = 77, QTextFormat = 78,
QMatrix = 79, QTransform = 80, QMatrix4x4 = 81, QVector2D = 82,
- QVector3D = 83, QVector4D = 84, QQuaternion = 85, QPolygonF = 86,
+ QVector3D = 83, QVector4D = 84, QQuaternion = 85, QPolygonF = 86, QColorSpace = 87,
// Widget types
QSizePolicy = 121,
LastCoreType = QCborMap,
- LastGuiType = QPolygonF,
+ LastGuiType = QColorSpace,
User = 1024
};
#endif
diff --git a/src/corelib/kernel/qmimedata.cpp b/src/corelib/kernel/qmimedata.cpp
index 00e5183eb1..fca258c9e3 100644
--- a/src/corelib/kernel/qmimedata.cpp
+++ b/src/corelib/kernel/qmimedata.cpp
@@ -70,7 +70,7 @@ public:
void setData(const QString &format, const QVariant &data);
QVariant getData(const QString &format) const;
- QVariant retrieveTypedData(const QString &format, QVariant::Type type) const;
+ QVariant retrieveTypedData(const QString &format, QMetaType::Type type) const;
QVector<QMimeDataStruct> dataList;
};
@@ -108,23 +108,23 @@ QVariant QMimeDataPrivate::getData(const QString &format) const
return data;
}
-QVariant QMimeDataPrivate::retrieveTypedData(const QString &format, QVariant::Type type) const
+QVariant QMimeDataPrivate::retrieveTypedData(const QString &format, QMetaType::Type type) const
{
Q_Q(const QMimeData);
- QVariant data = q->retrieveData(format, type);
+ QVariant data = q->retrieveData(format, QVariant::Type(type));
// Text data requested: fallback to URL data if available
if (format == QLatin1String("text/plain") && !data.isValid()) {
- data = retrieveTypedData(textUriListLiteral(), QVariant::List);
- if (data.type() == QVariant::Url) {
+ data = retrieveTypedData(textUriListLiteral(), QMetaType::QVariantList);
+ if (data.userType() == QMetaType::QUrl) {
data = QVariant(data.toUrl().toDisplayString());
- } else if (data.type() == QVariant::List) {
+ } else if (data.userType() == QMetaType::QVariantList) {
QString text;
int numUrls = 0;
const QList<QVariant> list = data.toList();
for (int i = 0; i < list.size(); ++i) {
- if (list.at(i).type() == QVariant::Url) {
+ if (list.at(i).userType() == QMetaType::QUrl) {
text += list.at(i).toUrl().toDisplayString() + QLatin1Char('\n');
++numUrls;
}
@@ -135,26 +135,26 @@ QVariant QMimeDataPrivate::retrieveTypedData(const QString &format, QVariant::Ty
}
}
- if (data.type() == type || !data.isValid())
+ if (data.userType() == type || !data.isValid())
return data;
// provide more conversion possiblities than just what QVariant provides
// URLs can be lists as well...
- if ((type == QVariant::Url && data.type() == QVariant::List)
- || (type == QVariant::List && data.type() == QVariant::Url))
+ if ((type == QMetaType::QUrl && data.userType() == QMetaType::QVariantList)
+ || (type == QMetaType::QVariantList && data.userType() == QMetaType::QUrl))
return data;
// images and pixmaps are interchangeable
- if ((type == QVariant::Pixmap && data.type() == QVariant::Image)
- || (type == QVariant::Image && data.type() == QVariant::Pixmap))
+ if ((type == QMetaType::QPixmap && data.userType() == QMetaType::QImage)
+ || (type == QMetaType::QImage && data.userType() == QMetaType::QPixmap))
return data;
- if (data.type() == QVariant::ByteArray) {
+ if (data.userType() == QMetaType::QByteArray) {
// see if we can convert to the requested type
switch(type) {
#if QT_CONFIG(textcodec)
- case QVariant::String: {
+ case QMetaType::QString: {
const QByteArray ba = data.toByteArray();
QTextCodec *codec = QTextCodec::codecForName("utf-8");
if (format == QLatin1String("text/html"))
@@ -162,17 +162,17 @@ QVariant QMimeDataPrivate::retrieveTypedData(const QString &format, QVariant::Ty
return codec->toUnicode(ba);
}
#endif // textcodec
- case QVariant::Color: {
+ case QMetaType::QColor: {
QVariant newData = data;
- newData.convert(QVariant::Color);
+ newData.convert(QMetaType::QColor);
return newData;
}
- case QVariant::List: {
+ case QMetaType::QVariantList: {
if (format != QLatin1String("text/uri-list"))
break;
Q_FALLTHROUGH();
}
- case QVariant::Url: {
+ case QMetaType::QUrl: {
QByteArray ba = data.toByteArray();
// Qt 3.x will send text/uri-list with a trailing
// null-terminator (that is *not* sent for any other
@@ -193,23 +193,23 @@ QVariant QMimeDataPrivate::retrieveTypedData(const QString &format, QVariant::Ty
break;
}
- } else if (type == QVariant::ByteArray) {
+ } else if (type == QMetaType::QByteArray) {
// try to convert to bytearray
- switch(data.type()) {
- case QVariant::ByteArray:
- case QVariant::Color:
+ switch (data.userType()) {
+ case QMetaType::QByteArray:
+ case QMetaType::QColor:
return data.toByteArray();
- case QVariant::String:
+ case QMetaType::QString:
return data.toString().toUtf8();
- case QVariant::Url:
+ case QMetaType::QUrl:
return data.toUrl().toEncoded();
- case QVariant::List: {
+ case QMetaType::QVariantList: {
// has to be list of URLs
QByteArray result;
QList<QVariant> list = data.toList();
for (int i = 0; i < list.size(); ++i) {
- if (list.at(i).type() == QVariant::Url) {
+ if (list.at(i).userType() == QMetaType::QUrl) {
result += list.at(i).toUrl().toEncoded();
result += "\r\n";
}
@@ -340,14 +340,14 @@ QMimeData::~QMimeData()
QList<QUrl> QMimeData::urls() const
{
Q_D(const QMimeData);
- QVariant data = d->retrieveTypedData(textUriListLiteral(), QVariant::List);
+ QVariant data = d->retrieveTypedData(textUriListLiteral(), QMetaType::QVariantList);
QList<QUrl> urls;
- if (data.type() == QVariant::Url)
+ if (data.userType() == QMetaType::QUrl)
urls.append(data.toUrl());
- else if (data.type() == QVariant::List) {
+ else if (data.userType() == QMetaType::QVariantList) {
QList<QVariant> list = data.toList();
for (int i = 0; i < list.size(); ++i) {
- if (list.at(i).type() == QVariant::Url)
+ if (list.at(i).userType() == QMetaType::QUrl)
urls.append(list.at(i).toUrl());
}
}
@@ -400,11 +400,11 @@ bool QMimeData::hasUrls() const
QString QMimeData::text() const
{
Q_D(const QMimeData);
- QVariant utf8Text = d->retrieveTypedData(textPlainUtf8Literal(), QVariant::String);
+ QVariant utf8Text = d->retrieveTypedData(textPlainUtf8Literal(), QMetaType::QString);
if (!utf8Text.isNull())
return utf8Text.toString();
- QVariant data = d->retrieveTypedData(textPlainLiteral(), QVariant::String);
+ QVariant data = d->retrieveTypedData(textPlainLiteral(), QMetaType::QString);
return data.toString();
}
@@ -440,7 +440,7 @@ bool QMimeData::hasText() const
QString QMimeData::html() const
{
Q_D(const QMimeData);
- QVariant data = d->retrieveTypedData(textHtmlLiteral(), QVariant::String);
+ QVariant data = d->retrieveTypedData(textHtmlLiteral(), QMetaType::QString);
return data.toString();
}
@@ -482,7 +482,7 @@ bool QMimeData::hasHtml() const
QVariant QMimeData::imageData() const
{
Q_D(const QMimeData);
- return d->retrieveTypedData(applicationXQtImageLiteral(), QVariant::Image);
+ return d->retrieveTypedData(applicationXQtImageLiteral(), QMetaType::QImage);
}
/*!
@@ -529,7 +529,7 @@ bool QMimeData::hasImage() const
QVariant QMimeData::colorData() const
{
Q_D(const QMimeData);
- return d->retrieveTypedData(applicationXColorLiteral(), QVariant::Color);
+ return d->retrieveTypedData(applicationXColorLiteral(), QMetaType::QColor);
}
/*!
@@ -564,7 +564,7 @@ bool QMimeData::hasColor() const
QByteArray QMimeData::data(const QString &mimeType) const
{
Q_D(const QMimeData);
- QVariant data = d->retrieveTypedData(mimeType, QVariant::ByteArray);
+ QVariant data = d->retrieveTypedData(mimeType, QMetaType::QByteArray);
return data.toByteArray();
}
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index 888da17a98..815eefc617 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Copyright (C) 2018 Intel Corporation.
** Copyright (C) 2015 Olivier Goffart <ogoffart@woboq.com>
** Contact: https://www.qt.io/licensing/
@@ -168,7 +168,7 @@ static qlonglong qMetaTypeNumber(const QVariant::Private *d)
return qlonglong(d->data.l);
case QMetaType::Float:
return qRound64(d->data.f);
- case QVariant::Double:
+ case QMetaType::Double:
return qRound64(d->data.d);
#ifndef QT_BOOTSTRAPPED
case QMetaType::QJsonValue:
@@ -184,9 +184,9 @@ static qlonglong qMetaTypeNumber(const QVariant::Private *d)
static qulonglong qMetaTypeUNumber(const QVariant::Private *d)
{
switch (d->type) {
- case QVariant::UInt:
+ case QMetaType::UInt:
return d->data.u;
- case QVariant::ULongLong:
+ case QMetaType::ULongLong:
return d->data.ull;
case QMetaType::UChar:
return d->data.uc;
@@ -204,13 +204,13 @@ static qlonglong qConvertToNumber(const QVariant::Private *d, bool *ok)
*ok = true;
switch (uint(d->type)) {
- case QVariant::String:
+ case QMetaType::QString:
return v_cast<QString>(d)->toLongLong(ok);
- case QVariant::Char:
+ case QMetaType::QChar:
return v_cast<QChar>(d)->unicode();
- case QVariant::ByteArray:
+ case QMetaType::QByteArray:
return v_cast<QByteArray>(d)->toLongLong(ok);
- case QVariant::Bool:
+ case QMetaType::Bool:
return qlonglong(d->data.b);
#ifndef QT_BOOTSTRAPPED
case QMetaType::QCborValue:
@@ -222,8 +222,8 @@ static qlonglong qConvertToNumber(const QVariant::Private *d, bool *ok)
break;
Q_FALLTHROUGH();
#endif
- case QVariant::Double:
- case QVariant::Int:
+ case QMetaType::Double:
+ case QMetaType::Int:
case QMetaType::Char:
case QMetaType::SChar:
case QMetaType::Short:
@@ -231,8 +231,8 @@ static qlonglong qConvertToNumber(const QVariant::Private *d, bool *ok)
case QMetaType::Float:
case QMetaType::LongLong:
return qMetaTypeNumber(d);
- case QVariant::ULongLong:
- case QVariant::UInt:
+ case QMetaType::ULongLong:
+ case QMetaType::UInt:
case QMetaType::UChar:
case QMetaType::UShort:
case QMetaType::ULong:
@@ -262,12 +262,12 @@ static qreal qConvertToRealNumber(const QVariant::Private *d, bool *ok)
{
*ok = true;
switch (uint(d->type)) {
- case QVariant::Double:
+ case QMetaType::Double:
return qreal(d->data.d);
case QMetaType::Float:
return qreal(d->data.f);
- case QVariant::ULongLong:
- case QVariant::UInt:
+ case QMetaType::ULongLong:
+ case QMetaType::UInt:
case QMetaType::UChar:
case QMetaType::UShort:
case QMetaType::ULong:
@@ -289,13 +289,13 @@ static qulonglong qConvertToUnsignedNumber(const QVariant::Private *d, bool *ok)
*ok = true;
switch (uint(d->type)) {
- case QVariant::String:
+ case QMetaType::QString:
return v_cast<QString>(d)->toULongLong(ok);
- case QVariant::Char:
+ case QMetaType::QChar:
return v_cast<QChar>(d)->unicode();
- case QVariant::ByteArray:
+ case QMetaType::QByteArray:
return v_cast<QByteArray>(d)->toULongLong(ok);
- case QVariant::Bool:
+ case QMetaType::Bool:
return qulonglong(d->data.b);
#ifndef QT_BOOTSTRAPPED
case QMetaType::QCborValue:
@@ -309,8 +309,8 @@ static qulonglong qConvertToUnsignedNumber(const QVariant::Private *d, bool *ok)
break;
Q_FALLTHROUGH();
#endif
- case QVariant::Double:
- case QVariant::Int:
+ case QMetaType::Double:
+ case QMetaType::Int:
case QMetaType::Char:
case QMetaType::SChar:
case QMetaType::Short:
@@ -318,8 +318,8 @@ static qulonglong qConvertToUnsignedNumber(const QVariant::Private *d, bool *ok)
case QMetaType::Float:
case QMetaType::LongLong:
return qulonglong(qMetaTypeNumber(d));
- case QVariant::ULongLong:
- case QVariant::UInt:
+ case QMetaType::ULongLong:
+ case QMetaType::UInt:
case QMetaType::UChar:
case QMetaType::UShort:
case QMetaType::ULong:
@@ -406,9 +406,9 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
switch (uint(t)) {
#ifndef QT_BOOTSTRAPPED
- case QVariant::Url:
+ case QMetaType::QUrl:
switch (d->type) {
- case QVariant::String:
+ case QMetaType::QString:
*static_cast<QUrl *>(result) = QUrl(*v_cast<QString>(d));
break;
case QMetaType::QCborValue:
@@ -423,18 +423,18 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
break;
#endif // QT_BOOTSTRAPPED
#if QT_CONFIG(itemmodel)
- case QVariant::ModelIndex:
+ case QMetaType::QModelIndex:
switch (d->type) {
- case QVariant::PersistentModelIndex:
+ case QMetaType::QPersistentModelIndex:
*static_cast<QModelIndex *>(result) = QModelIndex(*v_cast<QPersistentModelIndex>(d));
break;
default:
return false;
}
break;
- case QVariant::PersistentModelIndex:
+ case QMetaType::QPersistentModelIndex:
switch (d->type) {
- case QVariant::ModelIndex:
+ case QMetaType::QModelIndex:
*static_cast<QPersistentModelIndex *>(result) = QPersistentModelIndex(*v_cast<QModelIndex>(d));
break;
default:
@@ -442,10 +442,10 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
}
break;
#endif // QT_CONFIG(itemmodel)
- case QVariant::String: {
+ case QMetaType::QString: {
QString *str = static_cast<QString *>(result);
switch (d->type) {
- case QVariant::Char:
+ case QMetaType::QChar:
*str = *v_cast<QChar>(d);
break;
case QMetaType::Char:
@@ -455,12 +455,12 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
break;
case QMetaType::Short:
case QMetaType::Long:
- case QVariant::Int:
- case QVariant::LongLong:
+ case QMetaType::Int:
+ case QMetaType::LongLong:
*str = QString::number(qMetaTypeNumber(d));
break;
- case QVariant::UInt:
- case QVariant::ULongLong:
+ case QMetaType::UInt:
+ case QMetaType::ULongLong:
case QMetaType::UShort:
case QMetaType::ULong:
*str = QString::number(qMetaTypeUNumber(d));
@@ -468,32 +468,32 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
case QMetaType::Float:
*str = QString::number(d->data.f, 'g', QLocale::FloatingPointShortest);
break;
- case QVariant::Double:
+ case QMetaType::Double:
*str = QString::number(d->data.d, 'g', QLocale::FloatingPointShortest);
break;
#if QT_CONFIG(datestring)
- case QVariant::Date:
+ case QMetaType::QDate:
*str = v_cast<QDate>(d)->toString(Qt::ISODate);
break;
- case QVariant::Time:
+ case QMetaType::QTime:
*str = v_cast<QTime>(d)->toString(Qt::ISODateWithMs);
break;
- case QVariant::DateTime:
+ case QMetaType::QDateTime:
*str = v_cast<QDateTime>(d)->toString(Qt::ISODateWithMs);
break;
#endif
- case QVariant::Bool:
+ case QMetaType::Bool:
*str = d->data.b ? QStringLiteral("true") : QStringLiteral("false");
break;
- case QVariant::ByteArray:
+ case QMetaType::QByteArray:
*str = QString::fromUtf8(v_cast<QByteArray>(d)->constData());
break;
- case QVariant::StringList:
+ case QMetaType::QStringList:
if (v_cast<QStringList>(d)->count() == 1)
*str = v_cast<QStringList>(d)->at(0);
break;
#ifndef QT_BOOTSTRAPPED
- case QVariant::Url:
+ case QMetaType::QUrl:
*str = v_cast<QUrl>(d)->toString();
break;
case QMetaType::QJsonValue:
@@ -508,7 +508,7 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
*str = v_cast<QCborValue>(d)->toVariant().toString();
break;
#endif
- case QVariant::Uuid:
+ case QMetaType::QUuid:
*str = v_cast<QUuid>(d)->toString();
break;
case QMetaType::Nullptr:
@@ -528,11 +528,11 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
}
break;
}
- case QVariant::Char: {
+ case QMetaType::QChar: {
QChar *c = static_cast<QChar *>(result);
switch (d->type) {
- case QVariant::Int:
- case QVariant::LongLong:
+ case QMetaType::Int:
+ case QMetaType::LongLong:
case QMetaType::Char:
case QMetaType::SChar:
case QMetaType::Short:
@@ -540,8 +540,8 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
case QMetaType::Float:
*c = QChar(ushort(qMetaTypeNumber(d)));
break;
- case QVariant::UInt:
- case QVariant::ULongLong:
+ case QMetaType::UInt:
+ case QMetaType::ULongLong:
case QMetaType::UChar:
case QMetaType::UShort:
case QMetaType::ULong:
@@ -553,10 +553,10 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
break;
}
#ifndef QT_NO_GEOM_VARIANT
- case QVariant::Size: {
+ case QMetaType::QSize: {
QSize *s = static_cast<QSize *>(result);
switch (d->type) {
- case QVariant::SizeF:
+ case QMetaType::QSizeF:
*s = v_cast<QSizeF>(d)->toSize();
break;
default:
@@ -565,10 +565,10 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
break;
}
- case QVariant::SizeF: {
+ case QMetaType::QSizeF: {
QSizeF *s = static_cast<QSizeF *>(result);
switch (d->type) {
- case QVariant::Size:
+ case QMetaType::QSize:
*s = QSizeF(*(v_cast<QSize>(d)));
break;
default:
@@ -577,10 +577,10 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
break;
}
- case QVariant::Line: {
+ case QMetaType::QLine: {
QLine *s = static_cast<QLine *>(result);
switch (d->type) {
- case QVariant::LineF:
+ case QMetaType::QLineF:
*s = v_cast<QLineF>(d)->toLine();
break;
default:
@@ -589,10 +589,10 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
break;
}
- case QVariant::LineF: {
+ case QMetaType::QLineF: {
QLineF *s = static_cast<QLineF *>(result);
switch (d->type) {
- case QVariant::Line:
+ case QMetaType::QLine:
*s = QLineF(*(v_cast<QLine>(d)));
break;
default:
@@ -601,27 +601,27 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
break;
}
#endif
- case QVariant::StringList:
- if (d->type == QVariant::List) {
+ case QMetaType::QStringList:
+ if (d->type == QMetaType::QVariantList) {
QStringList *slst = static_cast<QStringList *>(result);
const QVariantList *list = v_cast<QVariantList >(d);
const int size = list->size();
slst->reserve(size);
for (int i = 0; i < size; ++i)
slst->append(list->at(i).toString());
- } else if (d->type == QVariant::String) {
+ } else if (d->type == QMetaType::QString) {
QStringList *slst = static_cast<QStringList *>(result);
*slst = QStringList(*v_cast<QString>(d));
} else {
return false;
}
break;
- case QVariant::Date: {
+ case QMetaType::QDate: {
QDate *dt = static_cast<QDate *>(result);
- if (d->type == QVariant::DateTime)
+ if (d->type == QMetaType::QDateTime)
*dt = v_cast<QDateTime>(d)->date();
#if QT_CONFIG(datestring)
- else if (d->type == QVariant::String)
+ else if (d->type == QMetaType::QString)
*dt = QDate::fromString(*v_cast<QString>(d), Qt::ISODate);
#endif
else
@@ -629,14 +629,14 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
return dt->isValid();
}
- case QVariant::Time: {
+ case QMetaType::QTime: {
QTime *t = static_cast<QTime *>(result);
switch (d->type) {
- case QVariant::DateTime:
+ case QMetaType::QDateTime:
*t = v_cast<QDateTime>(d)->time();
break;
#if QT_CONFIG(datestring)
- case QVariant::String:
+ case QMetaType::QString:
*t = QTime::fromString(*v_cast<QString>(d), Qt::ISODate);
break;
#endif
@@ -645,11 +645,11 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
}
return t->isValid();
}
- case QVariant::DateTime: {
+ case QMetaType::QDateTime: {
QDateTime *dt = static_cast<QDateTime *>(result);
switch (d->type) {
#if QT_CONFIG(datestring)
- case QVariant::String:
+ case QMetaType::QString:
*dt = QDateTime::fromString(*v_cast<QString>(d), Qt::ISODate);
break;
# ifndef QT_BOOTSTRAPPED
@@ -661,7 +661,7 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
break;
# endif
#endif
- case QVariant::Date:
+ case QMetaType::QDate:
*dt = QDateTime(*v_cast<QDate>(d));
break;
default:
@@ -669,13 +669,13 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
}
return dt->isValid();
}
- case QVariant::ByteArray: {
+ case QMetaType::QByteArray: {
QByteArray *ba = static_cast<QByteArray *>(result);
switch (d->type) {
- case QVariant::String:
+ case QMetaType::QString:
*ba = v_cast<QString>(d)->toUtf8();
break;
- case QVariant::Double:
+ case QMetaType::Double:
*ba = QByteArray::number(d->data.d, 'g', QLocale::FloatingPointShortest);
break;
case QMetaType::Float:
@@ -686,22 +686,22 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
case QMetaType::UChar:
*ba = QByteArray(1, d->data.c);
break;
- case QVariant::Int:
- case QVariant::LongLong:
+ case QMetaType::Int:
+ case QMetaType::LongLong:
case QMetaType::Short:
case QMetaType::Long:
*ba = QByteArray::number(qMetaTypeNumber(d));
break;
- case QVariant::UInt:
- case QVariant::ULongLong:
+ case QMetaType::UInt:
+ case QMetaType::ULongLong:
case QMetaType::UShort:
case QMetaType::ULong:
*ba = QByteArray::number(qMetaTypeUNumber(d));
break;
- case QVariant::Bool:
+ case QMetaType::Bool:
*ba = QByteArray(d->data.b ? "true" : "false");
break;
- case QVariant::Uuid:
+ case QMetaType::QUuid:
*ba = v_cast<QUuid>(d)->toByteArray();
break;
case QMetaType::Nullptr:
@@ -741,16 +741,16 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
case QMetaType::ULong:
*static_cast<ulong *>(result) = ulong(qConvertToUnsignedNumber(d, ok));
return *ok;
- case QVariant::Int:
+ case QMetaType::Int:
*static_cast<int *>(result) = int(qConvertToNumber(d, ok));
return *ok;
- case QVariant::UInt:
+ case QMetaType::UInt:
*static_cast<uint *>(result) = uint(qConvertToUnsignedNumber(d, ok));
return *ok;
- case QVariant::LongLong:
+ case QMetaType::LongLong:
*static_cast<qlonglong *>(result) = qConvertToNumber(d, ok);
return *ok;
- case QVariant::ULongLong: {
+ case QMetaType::ULongLong: {
*static_cast<qulonglong *>(result) = qConvertToUnsignedNumber(d, ok);
return *ok;
}
@@ -763,21 +763,21 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
*static_cast<uchar *>(result) = qConvertToUnsignedNumber(d, ok);
return *ok;
}
- case QVariant::Bool: {
+ case QMetaType::Bool: {
bool *b = static_cast<bool *>(result);
switch(d->type) {
- case QVariant::ByteArray:
+ case QMetaType::QByteArray:
*b = qt_convertToBool<QByteArray, const char*>(d);
break;
- case QVariant::String:
+ case QMetaType::QString:
*b = qt_convertToBool<QString, QLatin1String>(d);
break;
- case QVariant::Char:
+ case QMetaType::QChar:
*b = !v_cast<QChar>(d)->isNull();
break;
- case QVariant::Double:
- case QVariant::Int:
- case QVariant::LongLong:
+ case QMetaType::Double:
+ case QMetaType::Int:
+ case QMetaType::LongLong:
case QMetaType::Char:
case QMetaType::SChar:
case QMetaType::Short:
@@ -785,8 +785,8 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
case QMetaType::Float:
*b = qMetaTypeNumber(d) != Q_INT64_C(0);
break;
- case QVariant::UInt:
- case QVariant::ULongLong:
+ case QMetaType::UInt:
+ case QMetaType::ULongLong:
case QMetaType::UChar:
case QMetaType::UShort:
case QMetaType::ULong:
@@ -810,31 +810,31 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
}
break;
}
- case QVariant::Double: {
+ case QMetaType::Double: {
double *f = static_cast<double *>(result);
switch (d->type) {
- case QVariant::String:
+ case QMetaType::QString:
*f = v_cast<QString>(d)->toDouble(ok);
break;
- case QVariant::ByteArray:
+ case QMetaType::QByteArray:
*f = v_cast<QByteArray>(d)->toDouble(ok);
break;
- case QVariant::Bool:
+ case QMetaType::Bool:
*f = double(d->data.b);
break;
case QMetaType::Float:
*f = double(d->data.f);
break;
- case QVariant::LongLong:
- case QVariant::Int:
+ case QMetaType::LongLong:
+ case QMetaType::Int:
case QMetaType::Char:
case QMetaType::SChar:
case QMetaType::Short:
case QMetaType::Long:
*f = double(qMetaTypeNumber(d));
break;
- case QVariant::UInt:
- case QVariant::ULongLong:
+ case QMetaType::UInt:
+ case QMetaType::ULongLong:
case QMetaType::UChar:
case QMetaType::UShort:
case QMetaType::ULong:
@@ -861,28 +861,28 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
case QMetaType::Float: {
float *f = static_cast<float *>(result);
switch (d->type) {
- case QVariant::String:
+ case QMetaType::QString:
*f = v_cast<QString>(d)->toFloat(ok);
break;
- case QVariant::ByteArray:
+ case QMetaType::QByteArray:
*f = v_cast<QByteArray>(d)->toFloat(ok);
break;
- case QVariant::Bool:
+ case QMetaType::Bool:
*f = float(d->data.b);
break;
- case QVariant::Double:
+ case QMetaType::Double:
*f = float(d->data.d);
break;
- case QVariant::LongLong:
- case QVariant::Int:
+ case QMetaType::LongLong:
+ case QMetaType::Int:
case QMetaType::Char:
case QMetaType::SChar:
case QMetaType::Short:
case QMetaType::Long:
*f = float(qMetaTypeNumber(d));
break;
- case QVariant::UInt:
- case QVariant::ULongLong:
+ case QMetaType::UInt:
+ case QMetaType::ULongLong:
case QMetaType::UChar:
case QMetaType::UShort:
case QMetaType::ULong:
@@ -906,8 +906,8 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
}
break;
}
- case QVariant::List:
- if (d->type == QVariant::StringList) {
+ case QMetaType::QVariantList:
+ if (d->type == QMetaType::QStringList) {
QVariantList *lst = static_cast<QVariantList *>(result);
const QStringList *slist = v_cast<QStringList>(d);
const int size = slist->size();
@@ -935,11 +935,11 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
return false;
}
break;
- case QVariant::Map:
+ case QMetaType::QVariantMap:
if (qstrcmp(QMetaType::typeName(d->type), "QMap<QString, QVariant>") == 0) {
*static_cast<QVariantMap *>(result) =
*static_cast<QMap<QString, QVariant> *>(d->data.shared->ptr);
- } else if (d->type == QVariant::Hash) {
+ } else if (d->type == QMetaType::QVariantHash) {
QVariantMap *map = static_cast<QVariantMap *>(result);
const QVariantHash *hash = v_cast<QVariantHash>(d);
const auto end = hash->end();
@@ -963,11 +963,11 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
return false;
}
break;
- case QVariant::Hash:
+ case QMetaType::QVariantHash:
if (qstrcmp(QMetaType::typeName(d->type), "QHash<QString, QVariant>") == 0) {
*static_cast<QVariantHash *>(result) =
*static_cast<QHash<QString, QVariant> *>(d->data.shared->ptr);
- } else if (d->type == QVariant::Map) {
+ } else if (d->type == QMetaType::QVariantMap) {
QVariantHash *hash = static_cast<QVariantHash *>(result);
const QVariantMap *map = v_cast<QVariantMap>(d);
const auto end = map->end();
@@ -992,26 +992,26 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
}
break;
#ifndef QT_NO_GEOM_VARIANT
- case QVariant::Rect:
- if (d->type == QVariant::RectF)
+ case QMetaType::QRect:
+ if (d->type == QMetaType::QRectF)
*static_cast<QRect *>(result) = (v_cast<QRectF>(d))->toRect();
else
return false;
break;
- case QVariant::RectF:
- if (d->type == QVariant::Rect)
+ case QMetaType::QRectF:
+ if (d->type == QMetaType::QRect)
*static_cast<QRectF *>(result) = *v_cast<QRect>(d);
else
return false;
break;
- case QVariant::PointF:
- if (d->type == QVariant::Point)
+ case QMetaType::QPointF:
+ if (d->type == QMetaType::QPoint)
*static_cast<QPointF *>(result) = *v_cast<QPoint>(d);
else
return false;
break;
- case QVariant::Point:
- if (d->type == QVariant::PointF)
+ case QMetaType::QPoint:
+ if (d->type == QMetaType::QPointF)
*static_cast<QPoint *>(result) = (v_cast<QPointF>(d))->toPoint();
else
return false;
@@ -1022,12 +1022,12 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
return *ok;
}
#endif
- case QVariant::Uuid:
+ case QMetaType::QUuid:
switch (d->type) {
- case QVariant::String:
+ case QMetaType::QString:
*static_cast<QUuid *>(result) = QUuid(*v_cast<QString>(d));
break;
- case QVariant::ByteArray:
+ case QMetaType::QByteArray:
*static_cast<QUuid *>(result) = QUuid(*v_cast<QByteArray>(d));
break;
#ifndef QT_BOOTSTRAPPED
@@ -1067,7 +1067,7 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
case QMetaType::Nullptr:
*static_cast<QJsonValue *>(result) = QJsonValue(QJsonValue::Null);
break;
- case QVariant::Bool:
+ case QMetaType::Bool:
*static_cast<QJsonValue *>(result) = QJsonValue(d->data.b);
break;
case QMetaType::Int:
@@ -1086,19 +1086,19 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
*static_cast<QJsonValue *>(result) = QJsonValue(qConvertToRealNumber(d, ok));
Q_ASSERT(ok);
break;
- case QVariant::String:
+ case QMetaType::QString:
*static_cast<QJsonValue *>(result) = QJsonValue(*v_cast<QString>(d));
break;
- case QVariant::StringList:
+ case QMetaType::QStringList:
*static_cast<QJsonValue *>(result) = QJsonValue(QJsonArray::fromStringList(*v_cast<QStringList>(d)));
break;
- case QVariant::List:
+ case QMetaType::QVariantList:
*static_cast<QJsonValue *>(result) = QJsonValue(QJsonArray::fromVariantList(*v_cast<QVariantList>(d)));
break;
- case QVariant::Map:
+ case QMetaType::QVariantMap:
*static_cast<QJsonValue *>(result) = QJsonValue(QJsonObject::fromVariantMap(*v_cast<QVariantMap>(d)));
break;
- case QVariant::Hash:
+ case QMetaType::QVariantHash:
*static_cast<QJsonValue *>(result) = QJsonValue(QJsonObject::fromVariantHash(*v_cast<QVariantHash>(d)));
break;
case QMetaType::QJsonObject:
@@ -1128,10 +1128,10 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
break;
case QMetaType::QJsonArray:
switch (d->type) {
- case QVariant::StringList:
+ case QMetaType::QStringList:
*static_cast<QJsonArray *>(result) = QJsonArray::fromStringList(*v_cast<QStringList>(d));
break;
- case QVariant::List:
+ case QMetaType::QVariantList:
*static_cast<QJsonArray *>(result) = QJsonArray::fromVariantList(*v_cast<QVariantList>(d));
break;
case QMetaType::QJsonValue:
@@ -1158,10 +1158,10 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
break;
case QMetaType::QJsonObject:
switch (d->type) {
- case QVariant::Map:
+ case QMetaType::QVariantMap:
*static_cast<QJsonObject *>(result) = QJsonObject::fromVariantMap(*v_cast<QVariantMap>(d));
break;
- case QVariant::Hash:
+ case QMetaType::QVariantHash:
*static_cast<QJsonObject *>(result) = QJsonObject::fromVariantHash(*v_cast<QVariantHash>(d));
break;
case QMetaType::QJsonValue:
@@ -1197,7 +1197,7 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
case QMetaType::Nullptr:
*static_cast<QCborValue *>(result) = QCborValue(QCborValue::Null);
break;
- case QVariant::Bool:
+ case QMetaType::Bool:
*static_cast<QCborValue *>(result) = QCborValue(d->data.b);
break;
case QMetaType::Int:
@@ -1219,39 +1219,39 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
*static_cast<QCborValue *>(result) = QCborValue(qConvertToRealNumber(d, ok));
Q_ASSERT(ok);
break;
- case QVariant::String:
+ case QMetaType::QString:
*static_cast<QCborValue *>(result) = *v_cast<QString>(d);
break;
- case QVariant::StringList:
+ case QMetaType::QStringList:
*static_cast<QCborValue *>(result) = QCborArray::fromStringList(*v_cast<QStringList>(d));
break;
- case QVariant::ByteArray:
+ case QMetaType::QByteArray:
*static_cast<QCborValue *>(result) = *v_cast<QByteArray>(d);
break;
- case QVariant::Date:
+ case QMetaType::QDate:
*static_cast<QCborValue *>(result) = QCborValue(QDateTime(*v_cast<QDate>(d)));
break;
- case QVariant::DateTime:
+ case QMetaType::QDateTime:
*static_cast<QCborValue *>(result) = QCborValue(*v_cast<QDateTime>(d));
break;
- case QVariant::Url:
+ case QMetaType::QUrl:
*static_cast<QCborValue *>(result) = QCborValue(*v_cast<QUrl>(d));
break;
#if QT_CONFIG(regularexpression)
- case QVariant::RegularExpression:
+ case QMetaType::QRegularExpression:
*static_cast<QCborValue *>(result) = QCborValue(*v_cast<QRegularExpression>(d));
break;
#endif
- case QVariant::Uuid:
+ case QMetaType::QUuid:
*static_cast<QCborValue *>(result) = QCborValue(*v_cast<QUuid>(d));
break;
- case QVariant::List:
+ case QMetaType::QVariantList:
*static_cast<QCborValue *>(result) = QCborArray::fromVariantList(*v_cast<QVariantList>(d));
break;
- case QVariant::Map:
+ case QMetaType::QVariantMap:
*static_cast<QCborValue *>(result) = QCborMap::fromVariantMap(*v_cast<QVariantMap>(d));
break;
- case QVariant::Hash:
+ case QMetaType::QVariantHash:
*static_cast<QCborValue *>(result) = QCborMap::fromVariantHash(*v_cast<QVariantHash>(d));
break;
case QMetaType::QJsonValue:
@@ -1287,10 +1287,10 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
break;
case QMetaType::QCborArray:
switch (d->type) {
- case QVariant::StringList:
+ case QMetaType::QStringList:
*static_cast<QCborArray *>(result) = QCborArray::fromStringList(*v_cast<QStringList>(d));
break;
- case QVariant::List:
+ case QMetaType::QVariantList:
*static_cast<QCborArray *>(result) = QCborArray::fromVariantList(*v_cast<QVariantList>(d));
break;
case QMetaType::QCborValue:
@@ -1317,10 +1317,10 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
break;
case QMetaType::QCborMap:
switch (d->type) {
- case QVariant::Map:
+ case QMetaType::QVariantMap:
*static_cast<QCborMap *>(result) = QCborMap::fromVariantMap(*v_cast<QVariantMap>(d));
break;
- case QVariant::Hash:
+ case QMetaType::QVariantHash:
*static_cast<QCborMap *>(result) = QCborMap::fromVariantHash(*v_cast<QVariantHash>(d));
break;
case QMetaType::QCborValue:
@@ -1349,10 +1349,10 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
default:
#ifndef QT_NO_QOBJECT
- if (d->type == QVariant::String || d->type == QVariant::ByteArray) {
+ if (d->type == QMetaType::QString || d->type == QMetaType::QByteArray) {
QMetaEnum en = metaEnumFromType(t);
if (en.isValid()) {
- QByteArray keys = (d->type == QVariant::String) ? v_cast<QString>(d)->toUtf8() : *v_cast<QByteArray>(d);
+ QByteArray keys = (d->type == QMetaType::QString) ? v_cast<QString>(d)->toUtf8() : *v_cast<QByteArray>(d);
int value = en.keysToValue(keys.constData(), ok);
if (*ok) {
switch (QMetaType::sizeOf(t)) {
@@ -1457,7 +1457,7 @@ static void customConstruct(QVariant::Private *d, const void *copy)
const uint size = type.sizeOf();
if (!size) {
qWarning("Trying to construct an instance of an invalid type, type id: %i", d->type);
- d->type = QVariant::Invalid;
+ d->type = QMetaType::UnknownType;
return;
}
@@ -2438,45 +2438,45 @@ QVariant::Type QVariant::nameToType(const char *name)
enum { MapFromThreeCount = 36 };
static const ushort mapIdFromQt3ToCurrent[MapFromThreeCount] =
{
- QVariant::Invalid,
- QVariant::Map,
- QVariant::List,
- QVariant::String,
- QVariant::StringList,
- QVariant::Font,
- QVariant::Pixmap,
- QVariant::Brush,
- QVariant::Rect,
- QVariant::Size,
- QVariant::Color,
- QVariant::Palette,
+ QMetaType::UnknownType,
+ QMetaType::QVariantMap,
+ QMetaType::QVariantList,
+ QMetaType::QString,
+ QMetaType::QStringList,
+ QMetaType::QFont,
+ QMetaType::QPixmap,
+ QMetaType::QBrush,
+ QMetaType::QRect,
+ QMetaType::QSize,
+ QMetaType::QColor,
+ QMetaType::QPalette,
0, // ColorGroup
- QVariant::Icon,
- QVariant::Point,
- QVariant::Image,
- QVariant::Int,
- QVariant::UInt,
- QVariant::Bool,
- QVariant::Double,
+ QMetaType::QIcon,
+ QMetaType::QPoint,
+ QMetaType::QImage,
+ QMetaType::Int,
+ QMetaType::UInt,
+ QMetaType::Bool,
+ QMetaType::Double,
0, // Buggy ByteArray, QByteArray never had id == 20
- QVariant::Polygon,
- QVariant::Region,
- QVariant::Bitmap,
- QVariant::Cursor,
- QVariant::SizePolicy,
- QVariant::Date,
- QVariant::Time,
- QVariant::DateTime,
- QVariant::ByteArray,
- QVariant::BitArray,
+ QMetaType::QPolygon,
+ QMetaType::QRegion,
+ QMetaType::QBitmap,
+ QMetaType::QCursor,
+ QMetaType::QSizePolicy,
+ QMetaType::QDate,
+ QMetaType::QTime,
+ QMetaType::QDateTime,
+ QMetaType::QByteArray,
+ QMetaType::QBitArray,
#if QT_CONFIG(shortcut)
- QVariant::KeySequence,
+ QMetaType::QKeySequence,
#endif
- QVariant::Pen,
- QVariant::LongLong,
- QVariant::ULongLong,
+ QMetaType::QPen,
+ QMetaType::LongLong,
+ QMetaType::ULongLong,
#if QT_CONFIG(easingcurve)
- QVariant::EasingCurve
+ QMetaType::QEasingCurve
#endif
};
@@ -2553,7 +2553,7 @@ void QVariant::load(QDataStream &s)
*/
void QVariant::save(QDataStream &s) const
{
- quint32 typeId = type();
+ quint32 typeId = d.type >= QMetaType::User ? QMetaType::User : userType();
bool fakeUserType = false;
if (s.version() < QDataStream::Qt_4_0) {
int i;
@@ -3300,80 +3300,80 @@ QVariantList QVariant::toList() const
}
-static const quint32 qCanConvertMatrix[QVariant::LastCoreType + 1] =
+static const quint32 qCanConvertMatrix[QMetaType::LastCoreType + 1] =
{
/*Invalid*/ 0,
-/*Bool*/ 1 << QVariant::Double | 1 << QVariant::Int | 1 << QVariant::UInt
- | 1 << QVariant::LongLong | 1 << QVariant::ULongLong | 1 << QVariant::ByteArray
- | 1 << QVariant::String | 1 << QVariant::Char,
+/*Bool*/ 1 << QMetaType::Double | 1 << QMetaType::Int | 1 << QMetaType::UInt
+ | 1 << QMetaType::LongLong | 1 << QMetaType::ULongLong | 1 << QMetaType::QByteArray
+ | 1 << QMetaType::QString | 1 << QMetaType::QChar,
-/*Int*/ 1 << QVariant::UInt | 1 << QVariant::String | 1 << QVariant::Double
- | 1 << QVariant::Bool | 1 << QVariant::LongLong | 1 << QVariant::ULongLong
- | 1 << QVariant::Char | 1 << QVariant::ByteArray | 1 << QVariant::Int,
+/*Int*/ 1 << QMetaType::UInt | 1 << QMetaType::QString | 1 << QMetaType::Double
+ | 1 << QMetaType::Bool | 1 << QMetaType::LongLong | 1 << QMetaType::ULongLong
+ | 1 << QMetaType::QChar | 1 << QMetaType::QByteArray | 1 << QMetaType::Int,
-/*UInt*/ 1 << QVariant::Int | 1 << QVariant::String | 1 << QVariant::Double
- | 1 << QVariant::Bool | 1 << QVariant::LongLong | 1 << QVariant::ULongLong
- | 1 << QVariant::Char | 1 << QVariant::ByteArray,
+/*UInt*/ 1 << QMetaType::Int | 1 << QMetaType::QString | 1 << QMetaType::Double
+ | 1 << QMetaType::Bool | 1 << QMetaType::LongLong | 1 << QMetaType::ULongLong
+ | 1 << QMetaType::QChar | 1 << QMetaType::QByteArray,
-/*LLong*/ 1 << QVariant::Int | 1 << QVariant::String | 1 << QVariant::Double
- | 1 << QVariant::Bool | 1 << QVariant::UInt | 1 << QVariant::ULongLong
- | 1 << QVariant::Char | 1 << QVariant::ByteArray,
+/*LLong*/ 1 << QMetaType::Int | 1 << QMetaType::QString | 1 << QMetaType::Double
+ | 1 << QMetaType::Bool | 1 << QMetaType::UInt | 1 << QMetaType::ULongLong
+ | 1 << QMetaType::QChar | 1 << QMetaType::QByteArray,
-/*ULlong*/ 1 << QVariant::Int | 1 << QVariant::String | 1 << QVariant::Double
- | 1 << QVariant::Bool | 1 << QVariant::UInt | 1 << QVariant::LongLong
- | 1 << QVariant::Char | 1 << QVariant::ByteArray,
+/*ULlong*/ 1 << QMetaType::Int | 1 << QMetaType::QString | 1 << QMetaType::Double
+ | 1 << QMetaType::Bool | 1 << QMetaType::UInt | 1 << QMetaType::LongLong
+ | 1 << QMetaType::QChar | 1 << QMetaType::QByteArray,
-/*double*/ 1 << QVariant::Int | 1 << QVariant::String | 1 << QVariant::ULongLong
- | 1 << QVariant::Bool | 1 << QVariant::UInt | 1 << QVariant::LongLong
- | 1 << QVariant::ByteArray,
+/*double*/ 1 << QMetaType::Int | 1 << QMetaType::QString | 1 << QMetaType::ULongLong
+ | 1 << QMetaType::Bool | 1 << QMetaType::UInt | 1 << QMetaType::LongLong
+ | 1 << QMetaType::QByteArray,
-/*QChar*/ 1 << QVariant::Int | 1 << QVariant::UInt | 1 << QVariant::LongLong
- | 1 << QVariant::ULongLong,
+/*QChar*/ 1 << QMetaType::Int | 1 << QMetaType::UInt | 1 << QMetaType::LongLong
+ | 1 << QMetaType::ULongLong,
/*QMap*/ 0,
-/*QList*/ 1 << QVariant::StringList,
+/*QList*/ 1 << QMetaType::QStringList,
-/*QString*/ 1 << QVariant::StringList | 1 << QVariant::ByteArray | 1 << QVariant::Int
- | 1 << QVariant::UInt | 1 << QVariant::Bool | 1 << QVariant::Double
- | 1 << QVariant::Date | 1 << QVariant::Time | 1 << QVariant::DateTime
- | 1 << QVariant::LongLong | 1 << QVariant::ULongLong | 1 << QVariant::Char
- | 1 << QVariant::Url | 1 << QVariant::Uuid,
+/*QString*/ 1 << QMetaType::QStringList | 1 << QMetaType::QByteArray | 1 << QMetaType::Int
+ | 1 << QMetaType::UInt | 1 << QMetaType::Bool | 1 << QMetaType::Double
+ | 1 << QMetaType::QDate | 1 << QMetaType::QTime | 1 << QMetaType::QDateTime
+ | 1 << QMetaType::LongLong | 1 << QMetaType::ULongLong | 1 << QMetaType::QChar
+ | 1 << QMetaType::QUrl | 1 << QMetaType::QUuid,
-/*QStringList*/ 1 << QVariant::List | 1 << QVariant::String,
+/*QStringList*/ 1 << QMetaType::QVariantList | 1 << QMetaType::QString,
-/*QByteArray*/ 1 << QVariant::String | 1 << QVariant::Int | 1 << QVariant::UInt | 1 << QVariant::Bool
- | 1 << QVariant::Double | 1 << QVariant::LongLong | 1 << QVariant::ULongLong
- | 1 << QVariant::Uuid,
+/*QByteArray*/ 1 << QMetaType::QString | 1 << QMetaType::Int | 1 << QMetaType::UInt | 1 << QMetaType::Bool
+ | 1 << QMetaType::Double | 1 << QMetaType::LongLong | 1 << QMetaType::ULongLong
+ | 1 << QMetaType::QUuid,
/*QBitArray*/ 0,
-/*QDate*/ 1 << QVariant::String | 1 << QVariant::DateTime,
+/*QDate*/ 1 << QMetaType::QString | 1 << QMetaType::QDateTime,
-/*QTime*/ 1 << QVariant::String | 1 << QVariant::DateTime,
+/*QTime*/ 1 << QMetaType::QString | 1 << QMetaType::QDateTime,
-/*QDateTime*/ 1 << QVariant::String | 1 << QVariant::Date,
+/*QDateTime*/ 1 << QMetaType::QString | 1 << QMetaType::QDate,
-/*QUrl*/ 1 << QVariant::String,
+/*QUrl*/ 1 << QMetaType::QString,
/*QLocale*/ 0,
-/*QRect*/ 1 << QVariant::RectF,
+/*QRect*/ 1 << QMetaType::QRectF,
-/*QRectF*/ 1 << QVariant::Rect,
+/*QRectF*/ 1 << QMetaType::QRect,
-/*QSize*/ 1 << QVariant::SizeF,
+/*QSize*/ 1 << QMetaType::QSizeF,
-/*QSizeF*/ 1 << QVariant::Size,
+/*QSizeF*/ 1 << QMetaType::QSize,
-/*QLine*/ 1 << QVariant::LineF,
+/*QLine*/ 1 << QMetaType::QLineF,
-/*QLineF*/ 1 << QVariant::Line,
+/*QLineF*/ 1 << QMetaType::QLine,
-/*QPoint*/ 1 << QVariant::PointF,
+/*QPoint*/ 1 << QMetaType::QPointF,
-/*QPointF*/ 1 << QVariant::Point,
+/*QPointF*/ 1 << QMetaType::QPoint,
/*QRegExp*/ 0,
@@ -3381,7 +3381,7 @@ static const quint32 qCanConvertMatrix[QVariant::LastCoreType + 1] =
/*QEasingCurve*/ 0,
-/*QUuid*/ 1 << QVariant::String | 1 << QVariant::ByteArray,
+/*QUuid*/ 1 << QMetaType::QString | 1 << QMetaType::QByteArray,
};
static const size_t qCanConvertMatrixMaximumTargetType = 8 * sizeof(*qCanConvertMatrix);
@@ -3862,7 +3862,7 @@ static bool qIsNumericType(uint tp)
static bool qIsFloatingPoint(uint tp)
{
- return tp == QVariant::Double || tp == QMetaType::Float;
+ return tp == QMetaType::Double || tp == QMetaType::Float;
}
static int normalizeLowerRanks(uint tp)
@@ -3874,13 +3874,13 @@ static int normalizeLowerRanks(uint tp)
Q_UINT64_C(1) << QMetaType::UChar |
Q_UINT64_C(1) << QMetaType::Short |
Q_UINT64_C(1) << QMetaType::UShort;
- return numericTypeBits & (Q_UINT64_C(1) << tp) ? QVariant::Int : tp;
+ return numericTypeBits & (Q_UINT64_C(1) << tp) ? uint(QMetaType::Int) : tp;
}
static int normalizeLong(uint tp)
{
- const uint IntType = sizeof(long) == sizeof(int) ? QVariant::Int : QVariant::LongLong;
- const uint UIntType = sizeof(ulong) == sizeof(uint) ? QVariant::UInt : QVariant::ULongLong;
+ const uint IntType = sizeof(long) == sizeof(int) ? QMetaType::Int : QMetaType::LongLong;
+ const uint UIntType = sizeof(ulong) == sizeof(uint) ? QMetaType::UInt : QMetaType::ULongLong;
return tp == QMetaType::Long ? IntType :
tp == QMetaType::ULong ? UIntType : tp;
}
@@ -3922,13 +3922,13 @@ static int numericTypePromotion(uint t1, uint t2)
// if any of the two is ULongLong, then it wins (highest rank, unsigned)
// otherwise, if one of the two is LongLong, then the other is either LongLong too or lower-ranked
// otherwise, if one of the two is UInt, then the other is either UInt too or Int
- if (t1 == QVariant::ULongLong || t2 == QVariant::ULongLong)
- return QVariant::ULongLong;
- if (t1 == QVariant::LongLong || t2 == QVariant::LongLong)
- return QVariant::LongLong;
- if (t1 == QVariant::UInt || t2 == QVariant::UInt)
- return QVariant::UInt;
- return QVariant::Int;
+ if (t1 == QMetaType::ULongLong || t2 == QMetaType::ULongLong)
+ return QMetaType::ULongLong;
+ if (t1 == QMetaType::LongLong || t2 == QMetaType::LongLong)
+ return QMetaType::LongLong;
+ if (t1 == QMetaType::UInt || t2 == QMetaType::UInt)
+ return QMetaType::UInt;
+ return QMetaType::Int;
}
static int integralCompare(uint promotedType, const QVariant::Private *d1, const QVariant::Private *d2)
@@ -3941,13 +3941,13 @@ static int integralCompare(uint promotedType, const QVariant::Private *d1, const
qlonglong l2 = qConvertToNumber(d2, &ok);
Q_ASSERT(ok);
- if (promotedType == QVariant::Int)
+ if (promotedType == QMetaType::Int)
return int(l1) < int(l2) ? -1 : int(l1) == int(l2) ? 0 : 1;
- if (promotedType == QVariant::UInt)
+ if (promotedType == QMetaType::UInt)
return uint(l1) < uint(l2) ? -1 : uint(l1) == uint(l2) ? 0 : 1;
- if (promotedType == QVariant::LongLong)
+ if (promotedType == QMetaType::LongLong)
return l1 < l2 ? -1 : l1 == l2 ? 0 : 1;
- if (promotedType == QVariant::ULongLong)
+ if (promotedType == QMetaType::ULongLong)
return qulonglong(l1) < qulonglong(l2) ? -1 : qulonglong(l1) == qulonglong(l2) ? 0 : 1;
Q_UNREACHABLE();
diff --git a/src/corelib/kernel/qvariant_p.h b/src/corelib/kernel/qvariant_p.h
index b8b63b5e6f..94781a9957 100644
--- a/src/corelib/kernel/qvariant_p.h
+++ b/src/corelib/kernel/qvariant_p.h
@@ -362,7 +362,7 @@ class QVariantConstructor
FilteredConstructor(const QVariantConstructor &tc)
{
// ignore types that lives outside of the current library
- tc.m_x->type = QVariant::Invalid;
+ tc.m_x->type = QMetaType::UnknownType;
}
};
public:
@@ -430,7 +430,7 @@ public:
{}
~QVariantDestructor()
{
- m_d->type = QVariant::Invalid;
+ m_d->type = QMetaType::UnknownType;
m_d->is_null = true;
m_d->is_shared = false;
}
diff --git a/src/corelib/serialization/qjsoncbor.cpp b/src/corelib/serialization/qjsoncbor.cpp
index fbea84fe73..000008db50 100644
--- a/src/corelib/serialization/qjsoncbor.cpp
+++ b/src/corelib/serialization/qjsoncbor.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 Intel Corporation.
+** Copyright (C) 2020 Intel Corporation.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -637,9 +637,9 @@ static void appendVariant(QCborContainerPrivate *d, const QVariant &variant)
// Handle strings and byte arrays directly, to avoid creating a temporary
// dummy container to hold their data.
int type = variant.userType();
- if (type == QVariant::String) {
+ if (type == QMetaType::QString) {
d->append(variant.toString());
- } else if (type == QVariant::ByteArray) {
+ } else if (type == QMetaType::QByteArray) {
QByteArray ba = variant.toByteArray();
d->appendByteData(ba.constData(), ba.size(), QCborValue::ByteArray);
} else {
@@ -698,48 +698,48 @@ static void appendVariant(QCborContainerPrivate *d, const QVariant &variant)
QCborValue QCborValue::fromVariant(const QVariant &variant)
{
switch (variant.userType()) {
- case QVariant::Invalid:
+ case QMetaType::UnknownType:
return {};
case QMetaType::Nullptr:
return nullptr;
- case QVariant::Bool:
+ case QMetaType::Bool:
return variant.toBool();
case QMetaType::Short:
case QMetaType::UShort:
- case QVariant::Int:
- case QVariant::LongLong:
- case QVariant::UInt:
+ case QMetaType::Int:
+ case QMetaType::LongLong:
+ case QMetaType::UInt:
return variant.toLongLong();
- case QVariant::ULongLong:
+ case QMetaType::ULongLong:
if (variant.toULongLong() <= static_cast<uint64_t>(std::numeric_limits<qint64>::max()))
return variant.toLongLong();
Q_FALLTHROUGH();
case QMetaType::Float:
- case QVariant::Double:
+ case QMetaType::Double:
return variant.toDouble();
- case QVariant::String:
+ case QMetaType::QString:
return variant.toString();
- case QVariant::StringList:
+ case QMetaType::QStringList:
return QCborArray::fromStringList(variant.toStringList());
- case QVariant::ByteArray:
+ case QMetaType::QByteArray:
return variant.toByteArray();
- case QVariant::DateTime:
+ case QMetaType::QDateTime:
return QCborValue(variant.toDateTime());
#ifndef QT_BOOTSTRAPPED
- case QVariant::Url:
+ case QMetaType::QUrl:
return QCborValue(variant.toUrl());
#endif
- case QVariant::Uuid:
+ case QMetaType::QUuid:
return QCborValue(variant.toUuid());
- case QVariant::List:
+ case QMetaType::QVariantList:
return QCborArray::fromVariantList(variant.toList());
- case QVariant::Map:
+ case QMetaType::QVariantMap:
return QCborMap::fromVariantMap(variant.toMap());
- case QVariant::Hash:
+ case QMetaType::QVariantHash:
return QCborMap::fromVariantHash(variant.toHash());
#ifndef QT_BOOTSTRAPPED
#if QT_CONFIG(regularexpression)
- case QVariant::RegularExpression:
+ case QMetaType::QRegularExpression:
return QCborValue(variant.toRegularExpression());
#endif
case QMetaType::QJsonValue:
diff --git a/src/corelib/serialization/qjsondocument.cpp b/src/corelib/serialization/qjsondocument.cpp
index fe0500bdef..0be0fc020d 100644
--- a/src/corelib/serialization/qjsondocument.cpp
+++ b/src/corelib/serialization/qjsondocument.cpp
@@ -405,17 +405,17 @@ QJsonDocument QJsonDocument::fromVariant(const QVariant &variant)
{
QJsonDocument doc;
- switch (variant.type()) {
- case QVariant::Map:
+ switch (variant.userType()) {
+ case QMetaType::QVariantMap:
doc.setObject(QJsonObject::fromVariantMap(variant.toMap()));
break;
- case QVariant::Hash:
+ case QMetaType::QVariantHash:
doc.setObject(QJsonObject::fromVariantHash(variant.toHash()));
break;
- case QVariant::List:
+ case QMetaType::QVariantList:
doc.setArray(QJsonArray::fromVariantList(variant.toList()));
break;
- case QVariant::StringList:
+ case QMetaType::QStringList:
doc.d = qt_make_unique<QJsonDocumentPrivate>();
doc.d->value = QCborArray::fromStringList(variant.toStringList());
break;
diff --git a/src/corelib/serialization/qjsonvalue.cpp b/src/corelib/serialization/qjsonvalue.cpp
index 4a7fab21d7..e9ba176d7f 100644
--- a/src/corelib/serialization/qjsonvalue.cpp
+++ b/src/corelib/serialization/qjsonvalue.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -449,35 +449,35 @@ QJsonValue QJsonValue::fromVariant(const QVariant &variant)
switch (variant.userType()) {
case QMetaType::Nullptr:
return QJsonValue(Null);
- case QVariant::Bool:
+ case QMetaType::Bool:
return QJsonValue(variant.toBool());
case QMetaType::Short:
case QMetaType::UShort:
- case QVariant::Int:
- case QVariant::UInt:
- case QVariant::LongLong:
+ case QMetaType::Int:
+ case QMetaType::UInt:
+ case QMetaType::LongLong:
return QJsonValue(variant.toLongLong());
- case QVariant::ULongLong:
+ case QMetaType::ULongLong:
if (variant.toULongLong() <= static_cast<uint64_t>(std::numeric_limits<qint64>::max()))
return QJsonValue(variant.toLongLong());
Q_FALLTHROUGH();
case QMetaType::Float:
- case QVariant::Double:
+ case QMetaType::Double:
return QJsonValue(variant.toDouble());
- case QVariant::String:
+ case QMetaType::QString:
return QJsonValue(variant.toString());
- case QVariant::StringList:
+ case QMetaType::QStringList:
return QJsonValue(QJsonArray::fromStringList(variant.toStringList()));
- case QVariant::List:
+ case QMetaType::QVariantList:
return QJsonValue(QJsonArray::fromVariantList(variant.toList()));
- case QVariant::Map:
+ case QMetaType::QVariantMap:
return QJsonValue(QJsonObject::fromVariantMap(variant.toMap()));
- case QVariant::Hash:
+ case QMetaType::QVariantHash:
return QJsonValue(QJsonObject::fromVariantHash(variant.toHash()));
#ifndef QT_BOOTSTRAPPED
- case QVariant::Url:
+ case QMetaType::QUrl:
return QJsonValue(variant.toUrl().toString(QUrl::FullyEncoded));
- case QVariant::Uuid:
+ case QMetaType::QUuid:
return variant.toUuid().toString(QUuid::WithoutBraces);
case QMetaType::QJsonValue:
return variant.toJsonValue();
diff --git a/src/corelib/serialization/qtextstream.cpp b/src/corelib/serialization/qtextstream.cpp
index 4d92b1e0da..b8137e0abd 100644
--- a/src/corelib/serialization/qtextstream.cpp
+++ b/src/corelib/serialization/qtextstream.cpp
@@ -1681,7 +1681,7 @@ QString QTextStream::readLine(qint64 maxlen)
\since 5.5
Reads one line of text from the stream into \a line.
- If \a line is 0, the read line is not stored.
+ If \a line is \nullptr, the read line is not stored.
The maximum allowed line length is set to \a maxlen. If
the stream contains lines longer than this, then the lines will be
diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp
index 93a8abb1ce..fb45b82967 100644
--- a/src/corelib/text/qlocale.cpp
+++ b/src/corelib/text/qlocale.cpp
@@ -2430,7 +2430,7 @@ QTime QLocale::toTime(const QString &string, const QString &format, QCalendar ca
{
QTime time;
#if QT_CONFIG(datetimeparser)
- QDateTimeParser dt(QVariant::Time, QDateTimeParser::FromString, cal);
+ QDateTimeParser dt(QMetaType::QTime, QDateTimeParser::FromString, cal);
dt.setDefaultLocale(*this);
if (dt.parseFormat(format))
dt.fromString(string, nullptr, &time);
@@ -2469,7 +2469,7 @@ QDate QLocale::toDate(const QString &string, const QString &format, QCalendar ca
{
QDate date;
#if QT_CONFIG(datetimeparser)
- QDateTimeParser dt(QVariant::Date, QDateTimeParser::FromString, cal);
+ QDateTimeParser dt(QMetaType::QDate, QDateTimeParser::FromString, cal);
dt.setDefaultLocale(*this);
if (dt.parseFormat(format))
dt.fromString(string, &date, nullptr);
@@ -2510,7 +2510,7 @@ QDateTime QLocale::toDateTime(const QString &string, const QString &format, QCal
QTime time;
QDate date;
- QDateTimeParser dt(QVariant::DateTime, QDateTimeParser::FromString, cal);
+ QDateTimeParser dt(QMetaType::QDateTime, QDateTimeParser::FromString, cal);
dt.setDefaultLocale(*this);
if (dt.parseFormat(format) && dt.fromString(string, &date, &time))
return QDateTime(date, time);
diff --git a/src/corelib/text/qlocale_unix.cpp b/src/corelib/text/qlocale_unix.cpp
index 5e1e47eae7..207331b8ac 100644
--- a/src/corelib/text/qlocale_unix.cpp
+++ b/src/corelib/text/qlocale_unix.cpp
@@ -234,16 +234,16 @@ QVariant QSystemLocale::query(QueryType type, QVariant in) const
case CurrencySymbol:
return lc_monetary.currencySymbol(QLocale::CurrencySymbolFormat(in.toUInt()));
case CurrencyToString: {
- switch (in.type()) {
- case QVariant::Int:
+ switch (in.userType()) {
+ case QMetaType::Int:
return lc_monetary.toCurrencyString(in.toInt());
- case QVariant::UInt:
+ case QMetaType::UInt:
return lc_monetary.toCurrencyString(in.toUInt());
- case QVariant::Double:
+ case QMetaType::Double:
return lc_monetary.toCurrencyString(in.toDouble());
- case QVariant::LongLong:
+ case QMetaType::LongLong:
return lc_monetary.toCurrencyString(in.toLongLong());
- case QVariant::ULongLong:
+ case QMetaType::ULongLong:
return lc_monetary.toCurrencyString(in.toULongLong());
default:
break;
diff --git a/src/corelib/text/qstringlist.cpp b/src/corelib/text/qstringlist.cpp
index 4bbe424ed2..4b9dcee169 100644
--- a/src/corelib/text/qstringlist.cpp
+++ b/src/corelib/text/qstringlist.cpp
@@ -43,9 +43,9 @@
#if QT_CONFIG(regularexpression)
# include <qregularexpression.h>
#endif
+#include <private/qduplicatetracker_p.h>
#include <algorithm>
-
QT_BEGIN_NAMESPACE
/*! \typedef QStringListIterator
@@ -885,15 +885,13 @@ int QtPrivate::QStringList_removeDuplicates(QStringList *that)
{
int n = that->size();
int j = 0;
- QSet<QString> seen;
+
+ QDuplicateTracker<QString> seen;
seen.reserve(n);
- int setSize = 0;
for (int i = 0; i < n; ++i) {
const QString &s = that->at(i);
- seen.insert(s);
- if (setSize == seen.size()) // unchanged size => was already seen
+ if (seen.hasSeen(s))
continue;
- ++setSize;
if (j != i)
that->swapItemsAt(i, j);
++j;
diff --git a/src/corelib/thread/qmutex.cpp b/src/corelib/thread/qmutex.cpp
index f3883278e3..0508932d68 100644
--- a/src/corelib/thread/qmutex.cpp
+++ b/src/corelib/thread/qmutex.cpp
@@ -487,7 +487,7 @@ QRecursiveMutex::~QRecursiveMutex()
\fn QMutexLocker::QMutexLocker(QMutex *mutex)
Constructs a QMutexLocker and locks \a mutex. The mutex will be
- unlocked when the QMutexLocker is destroyed. If \a mutex is zero,
+ unlocked when the QMutexLocker is destroyed. If \a mutex is \nullptr,
QMutexLocker does nothing.
\sa QMutex::lock()
diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp
index 1437768f1c..155bff1758 100644
--- a/src/corelib/thread/qthread.cpp
+++ b/src/corelib/thread/qthread.cpp
@@ -614,7 +614,7 @@ void QThread::run()
priority.
The \a priority argument can be any value in the \c
- QThread::Priority enum except for \c InheritPriorty.
+ QThread::Priority enum except for \c InheritPriority.
The effect of the \a priority parameter is dependent on the
operating system's scheduling policy. In particular, the \a priority
@@ -626,6 +626,10 @@ void QThread::run()
*/
void QThread::setPriority(Priority priority)
{
+ if (priority == QThread::InheritPriority) {
+ qWarning("QThread::setPriority: Argument cannot be InheritPriority");
+ return;
+ }
Q_D(QThread);
QMutexLocker locker(&d->mutex);
if (!d->running) {
diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp
index 44cb5653bf..00d67b3a00 100644
--- a/src/corelib/thread/qthread_win.cpp
+++ b/src/corelib/thread/qthread_win.cpp
@@ -715,9 +715,7 @@ void QThreadPrivate::setPriority(QThread::Priority threadPriority)
prio = THREAD_PRIORITY_TIME_CRITICAL;
break;
- case QThread::InheritPriority:
default:
- qWarning("QThread::setPriority: Argument cannot be InheritPriority");
return;
}
diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp
index 67d37f19d8..80751e60a0 100644
--- a/src/corelib/time/qdatetime.cpp
+++ b/src/corelib/time/qdatetime.cpp
@@ -1791,7 +1791,7 @@ QDate QDate::fromString(const QString &string, const QString &format, QCalendar
{
QDate date;
#if QT_CONFIG(datetimeparser)
- QDateTimeParser dt(QVariant::Date, QDateTimeParser::FromString, cal);
+ QDateTimeParser dt(QMetaType::QDate, QDateTimeParser::FromString, cal);
// dt.setDefaultLocale(QLocale::c()); ### Qt 6
if (dt.parseFormat(format))
dt.fromString(string, &date, nullptr);
@@ -2537,7 +2537,7 @@ QTime QTime::fromString(const QString &string, const QString &format)
{
QTime time;
#if QT_CONFIG(datetimeparser)
- QDateTimeParser dt(QVariant::Time, QDateTimeParser::FromString, QCalendar());
+ QDateTimeParser dt(QMetaType::QTime, QDateTimeParser::FromString, QCalendar());
// dt.setDefaultLocale(QLocale::c()); ### Qt 6
if (dt.parseFormat(format))
dt.fromString(string, nullptr, &time);
@@ -5482,7 +5482,7 @@ QDateTime QDateTime::fromString(const QString &string, const QString &format, QC
QTime time;
QDate date;
- QDateTimeParser dt(QVariant::DateTime, QDateTimeParser::FromString, cal);
+ QDateTimeParser dt(QMetaType::QDateTime, QDateTimeParser::FromString, cal);
// dt.setDefaultLocale(QLocale::c()); ### Qt 6
if (dt.parseFormat(format) && dt.fromString(string, &date, &time))
return QDateTime(date, time);
diff --git a/src/corelib/time/qdatetimeparser.cpp b/src/corelib/time/qdatetimeparser.cpp
index 31d8e6cc20..70460ae632 100644
--- a/src/corelib/time/qdatetimeparser.cpp
+++ b/src/corelib/time/qdatetimeparser.cpp
@@ -425,7 +425,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat)
switch (sect) {
case 'H':
case 'h':
- if (parserType != QVariant::Date) {
+ if (parserType != QMetaType::QDate) {
const Section hour = (sect == 'h') ? Hour12Section : Hour24Section;
const SectionNode sn = { hour, i - add, countRepeat(newFormat, i, 2), 0 };
newSectionNodes.append(sn);
@@ -436,7 +436,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat)
}
break;
case 'm':
- if (parserType != QVariant::Date) {
+ if (parserType != QMetaType::QDate) {
const SectionNode sn = { MinuteSection, i - add, countRepeat(newFormat, i, 2), 0 };
newSectionNodes.append(sn);
appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote);
@@ -446,7 +446,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat)
}
break;
case 's':
- if (parserType != QVariant::Date) {
+ if (parserType != QMetaType::QDate) {
const SectionNode sn = { SecondSection, i - add, countRepeat(newFormat, i, 2), 0 };
newSectionNodes.append(sn);
appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote);
@@ -457,7 +457,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat)
break;
case 'z':
- if (parserType != QVariant::Date) {
+ if (parserType != QMetaType::QDate) {
const SectionNode sn = { MSecSection, i - add, countRepeat(newFormat, i, 3) < 3 ? 1 : 3, 0 };
newSectionNodes.append(sn);
appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote);
@@ -468,7 +468,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat)
break;
case 'A':
case 'a':
- if (parserType != QVariant::Date) {
+ if (parserType != QMetaType::QDate) {
const bool cap = (sect == 'A');
const SectionNode sn = { AmPmSection, i - add, (cap ? 1 : 0), 0 };
newSectionNodes.append(sn);
@@ -482,7 +482,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat)
}
break;
case 'y':
- if (parserType != QVariant::Time) {
+ if (parserType != QMetaType::QTime) {
const int repeat = countRepeat(newFormat, i, 4);
if (repeat >= 2) {
const SectionNode sn = { repeat == 4 ? YearSection : YearSection2Digits,
@@ -496,7 +496,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat)
}
break;
case 'M':
- if (parserType != QVariant::Time) {
+ if (parserType != QMetaType::QTime) {
const SectionNode sn = { MonthSection, i - add, countRepeat(newFormat, i, 4), 0 };
newSectionNodes.append(sn);
newSeparators.append(unquote(newFormat.midRef(index, i - index)));
@@ -506,7 +506,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat)
}
break;
case 'd':
- if (parserType != QVariant::Time) {
+ if (parserType != QMetaType::QTime) {
const int repeat = countRepeat(newFormat, i, 4);
const Section sectionType = (repeat == 4 ? DayOfWeekSectionLong
: (repeat == 3 ? DayOfWeekSectionShort : DaySection));
@@ -519,7 +519,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat)
}
break;
case 't':
- if (parserType != QVariant::Time) {
+ if (parserType != QMetaType::QTime) {
const SectionNode sn = { TimeZoneSection, i - add, countRepeat(newFormat, i, 4), 0 };
newSectionNodes.append(sn);
appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote);
@@ -1252,7 +1252,7 @@ QDateTimeParser::scanString(const QDateTime &defaultValue,
return StateNode();
}
- if (parserType != QVariant::Time) {
+ if (parserType != QMetaType::QTime) {
if (year % 100 != year2digits && (isSet & YearSection2Digits)) {
if (!(isSet & YearSection)) {
year = (year / 100) * 100;
@@ -1322,7 +1322,7 @@ QDateTimeParser::scanString(const QDateTime &defaultValue,
}
}
- if (parserType != QVariant::Date) {
+ if (parserType != QMetaType::QDate) {
if (isSet & Hour12Section) {
const bool hasHour = isSet & Hour24Section;
if (ampm == -1) {
@@ -1360,7 +1360,7 @@ QDateTimeParser::scanString(const QDateTime &defaultValue,
// If hour wasn't specified, check the default we're using exists on the
// given date (which might be a spring-forward, skipping an hour).
- if (parserType == QVariant::DateTime && !(isSet & HourSectionMask) && !when.isValid()) {
+ if (parserType == QMetaType::QDateTime && !(isSet & HourSectionMask) && !when.isValid()) {
qint64 msecs = when.toMSecsSinceEpoch();
// Fortunately, that gets a useful answer, even though when is invalid ...
const QDateTime replace =
diff --git a/src/corelib/time/qdatetimeparser_p.h b/src/corelib/time/qdatetimeparser_p.h
index ff8da956f0..bc390db223 100644
--- a/src/corelib/time/qdatetimeparser_p.h
+++ b/src/corelib/time/qdatetimeparser_p.h
@@ -82,7 +82,7 @@ public:
FromString,
DateTimeEdit
};
- QDateTimeParser(QVariant::Type t, Context ctx, const QCalendar &cal = QCalendar())
+ QDateTimeParser(QMetaType::Type t, Context ctx, const QCalendar &cal = QCalendar())
: currentSectionIndex(-1), cachedDay(-1), parserType(t),
fixday(false), spec(Qt::LocalTime), context(ctx), calendar(cal)
{
@@ -295,7 +295,7 @@ protected: // for the benefit of QDateTimeEditPrivate
QStringList separators;
QString displayFormat;
QLocale defaultLocale;
- QVariant::Type parserType;
+ QMetaType::Type parserType;
bool fixday;
Qt::TimeSpec spec; // spec if used by QDateTimeEdit
Context context;
diff --git a/src/corelib/tools/qduplicatetracker_p.h b/src/corelib/tools/qduplicatetracker_p.h
new file mode 100644
index 0000000000..99068c01a3
--- /dev/null
+++ b/src/corelib/tools/qduplicatetracker_p.h
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2020 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz <marc.mutz@kdab.com>
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** 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 Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** 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-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QDUPLICATETRACKER_P_H
+#define QDUPLICATETRACKER_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <qglobal.h>
+
+#if QT_HAS_INCLUDE(<memory_resource>) && __cplusplus > 201402L
+# include <unordered_set>
+# include <memory_resource>
+#else
+# include <qset.h>
+#endif
+
+QT_BEGIN_NAMESPACE
+
+template <typename T, size_t Prealloc = 32>
+class QDuplicateTracker {
+#ifdef __cpp_lib_memory_resource
+ char buffer[Prealloc * sizeof(T)];
+ std::pmr::monotonic_buffer_resource res{buffer, sizeof buffer};
+ std::pmr::unordered_set<T> set{&res};
+#else
+ QSet<T> set;
+ int setSize = 0;
+#endif
+ Q_DISABLE_COPY_MOVE(QDuplicateTracker);
+public:
+ QDuplicateTracker() = default;
+ void reserve(int n) { set.reserve(n); }
+ Q_REQUIRED_RESULT bool hasSeen(const T &s)
+ {
+ bool inserted;
+#ifdef __cpp_lib_memory_resource
+ inserted = set.insert(s).second;
+#else
+ set.insert(s);
+ const int n = set.size();
+ inserted = qExchange(setSize, n) != n;
+#endif
+ return !inserted;
+ }
+};
+
+QT_END_NAMESPACE
+
+#endif /* QDUPLICATETRACKER_P_H */
diff --git a/src/corelib/tools/qmap.cpp b/src/corelib/tools/qmap.cpp
index d747a8cda4..e2b7705b55 100644
--- a/src/corelib/tools/qmap.cpp
+++ b/src/corelib/tools/qmap.cpp
@@ -2128,4 +2128,11 @@ void QMapDataBase::freeData(QMapDataBase *d)
once in the returned list.
*/
+/*! \fn template <class Key, class T> QMultiMap<Key, T> &QMultiMap<Key, T>::unite(const QMultiMap<Key, T> &other)
+
+ Inserts all the items in the \a other map into this map. If a
+ key is common to both maps, the resulting map will contain the
+ key multiple times.
+*/
+
QT_END_NAMESPACE
diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri
index 230456bef9..ff300bcf7b 100644
--- a/src/corelib/tools/tools.pri
+++ b/src/corelib/tools/tools.pri
@@ -12,6 +12,7 @@ HEADERS += \
tools/qcontainerfwd.h \
tools/qcontainertools_impl.h \
tools/qcryptographichash.h \
+ tools/qduplicatetracker_p.h \
tools/qflatmap_p.h \
tools/qfreelist_p.h \
tools/qhash.h \