Merge remote-tracking branch 'origin/dev' into wip/cmake

Conflicts:
        src/corelib/Qt5CoreConfigExtras.cmake.in
        src/corelib/Qt5CoreMacros.cmake
        src/dbus/Qt5DBusConfigExtras.cmake.in
        src/widgets/Qt5WidgetsConfigExtras.cmake.in

Change-Id: Ib782f3b177c38b2cce83beebe15be9c0baa578f7
This commit is contained in:
Alexandru Croitor 2020-01-29 16:57:12 +01:00
commit a1dbdcbd6e
432 changed files with 12952 additions and 2009 deletions

View File

@ -134,7 +134,7 @@ static QVariant convertCborValue(const QCborValue &value)
enum TrimFloatingPoint { Double, Float, Float16 }; enum TrimFloatingPoint { Double, Float, Float16 };
static QCborValue convertFromVariant(const QVariant &v, TrimFloatingPoint fpTrimming) static QCborValue convertFromVariant(const QVariant &v, TrimFloatingPoint fpTrimming)
{ {
if (v.userType() == QVariant::List) { if (v.userType() == QMetaType::QVariantList) {
const QVariantList list = v.toList(); const QVariantList list = v.toList();
QCborArray array; QCborArray array;
for (const QVariant &v : list) for (const QVariant &v : list)
@ -152,7 +152,7 @@ static QCborValue convertFromVariant(const QVariant &v, TrimFloatingPoint fpTrim
return map; return map;
} }
if (v.userType() == QVariant::Double && fpTrimming != Double) { if (v.userType() == QMetaType::Double && fpTrimming != Double) {
float f = float(v.toDouble()); float f = float(v.toDouble());
if (fpTrimming == Float16) if (fpTrimming == Float16)
return float(qfloat16(f)); return float(qfloat16(f));

View File

@ -96,8 +96,8 @@ static QString dumpVariant(const QVariant &v, const QString &indent = QLatin1Str
QString indented = indent + QLatin1String(" "); QString indented = indent + QLatin1String(" ");
int type = v.userType(); int type = v.userType();
if (type == qMetaTypeId<VariantOrderedMap>() || type == QVariant::Map) { if (type == qMetaTypeId<VariantOrderedMap>() || type == QMetaType::QVariantMap) {
const auto map = (type == QVariant::Map) ? const auto map = (type == QMetaType::QVariantMap) ?
VariantOrderedMap(v.toMap()) : qvariant_cast<VariantOrderedMap>(v); VariantOrderedMap(v.toMap()) : qvariant_cast<VariantOrderedMap>(v);
result = QLatin1String("Map {"); result = QLatin1String("Map {");
@ -109,7 +109,7 @@ static QString dumpVariant(const QVariant &v, const QString &indent = QLatin1Str
} }
result.chop(1); // remove comma result.chop(1); // remove comma
result += indent + QLatin1String("},"); result += indent + QLatin1String("},");
} else if (type == QVariant::List) { } else if (type == QMetaType::QVariantList) {
const QVariantList list = v.toList(); const QVariantList list = v.toList();
result = QLatin1String("List ["); result = QLatin1String("List [");

View File

@ -56,21 +56,21 @@
static void dumpVariant(QTextStream &out, const QVariant &v) static void dumpVariant(QTextStream &out, const QVariant &v)
{ {
switch (v.userType()) { switch (v.userType()) {
case QVariant::List: { case QMetaType::QVariantList: {
const QVariantList list = v.toList(); const QVariantList list = v.toList();
for (const QVariant &item : list) for (const QVariant &item : list)
dumpVariant(out, item); dumpVariant(out, item);
break; break;
} }
case QVariant::String: { case QMetaType::QString: {
const QStringList list = v.toStringList(); const QStringList list = v.toStringList();
for (const QString &s : list) for (const QString &s : list)
out << s << Qt::endl; out << s << Qt::endl;
break; break;
} }
case QVariant::Map: { case QMetaType::QVariantMap: {
const QVariantMap map = v.toMap(); const QVariantMap map = v.toMap();
for (auto it = map.begin(); it != map.end(); ++it) { for (auto it = map.begin(); it != map.end(); ++it) {
out << it.key() << " => "; out << it.key() << " => ";

View File

@ -284,18 +284,18 @@ static QVariant variantFromXml(QXmlStreamReader &xml, Converter::Options options
ba.resize(n); ba.resize(n);
result = ba; result = ba;
} else { } else {
int id = QVariant::Invalid; int id = QMetaType::UnknownType;
if (type == QLatin1String("datetime")) if (type == QLatin1String("datetime"))
id = QVariant::DateTime; id = QMetaType::QDateTime;
else if (type == QLatin1String("url")) else if (type == QLatin1String("url"))
id = QVariant::Url; id = QMetaType::QUrl;
else if (type == QLatin1String("uuid")) else if (type == QLatin1String("uuid"))
id = QVariant::Uuid; id = QMetaType::QUuid;
else if (type == QLatin1String("regex")) else if (type == QLatin1String("regex"))
id = QVariant::RegularExpression; id = QMetaType::QRegularExpression;
else else
id = QMetaType::type(type.toLatin1()); id = QMetaType::type(type.toLatin1());
if (id == QVariant::Invalid) { if (id == QMetaType::UnknownType) {
fprintf(stderr, "%lld:%lld: Invalid XML: unknown type '%s'.\n", fprintf(stderr, "%lld:%lld: Invalid XML: unknown type '%s'.\n",
xml.lineNumber(), xml.columnNumber(), qPrintable(type.toString())); xml.lineNumber(), xml.columnNumber(), qPrintable(type.toString()));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
@ -327,14 +327,14 @@ static QVariant variantFromXml(QXmlStreamReader &xml, Converter::Options options
static void variantToXml(QXmlStreamWriter &xml, const QVariant &v) static void variantToXml(QXmlStreamWriter &xml, const QVariant &v)
{ {
int type = v.userType(); int type = v.userType();
if (type == QVariant::List) { if (type == QMetaType::QVariantList) {
QVariantList list = v.toList(); QVariantList list = v.toList();
xml.writeStartElement("list"); xml.writeStartElement("list");
for (const QVariant &v : list) for (const QVariant &v : list)
variantToXml(xml, v); variantToXml(xml, v);
xml.writeEndElement(); xml.writeEndElement();
} else if (type == QVariant::Map || type == qMetaTypeId<VariantOrderedMap>()) { } else if (type == QMetaType::QVariantMap || type == qMetaTypeId<VariantOrderedMap>()) {
const VariantOrderedMap map = (type == QVariant::Map) ? const VariantOrderedMap map = (type == QMetaType::QVariantMap) ?
VariantOrderedMap(v.toMap()) : VariantOrderedMap(v.toMap()) :
qvariant_cast<VariantOrderedMap>(v); qvariant_cast<VariantOrderedMap>(v);
@ -433,7 +433,7 @@ static void variantToXml(QXmlStreamWriter &xml, const QVariant &v)
// does this convert to string? // does this convert to string?
const char *typeName = v.typeName(); const char *typeName = v.typeName();
QVariant copy = v; QVariant copy = v;
if (copy.convert(QVariant::String)) { if (copy.convert(QMetaType::QString)) {
xml.writeAttribute(typeString, QString::fromLatin1(typeName)); xml.writeAttribute(typeString, QString::fromLatin1(typeName));
xml.writeCharacters(copy.toString()); xml.writeCharacters(copy.toString());
} else { } else {

View File

@ -6,5 +6,3 @@ CONFIG += no_docs_target
SUBDIRS += analogclock SUBDIRS += analogclock
SUBDIRS += rasterwindow SUBDIRS += rasterwindow
qtHaveModule(gui):qtConfig(opengl): \
SUBDIRS += openglwindow

View File

@ -209,7 +209,7 @@ void TrackerClient::httpRequestDone(QNetworkReply *reply)
// store it // store it
peers.clear(); peers.clear();
QVariant peerEntry = dict.value("peers"); QVariant peerEntry = dict.value("peers");
if (peerEntry.type() == QVariant::List) { if (peerEntry.userType() == QMetaType::QVariantList) {
QList<QVariant> peerTmp = peerEntry.toList(); QList<QVariant> peerTmp = peerEntry.toList();
for (int i = 0; i < peerTmp.size(); ++i) { for (int i = 0; i < peerTmp.size(); ++i) {
TorrentPeer tmp; TorrentPeer tmp;

View File

@ -2,6 +2,7 @@ TEMPLATE = subdirs
SUBDIRS = hellowindow \ SUBDIRS = hellowindow \
paintedwindow \ paintedwindow \
openglwindow \
qopenglwindow qopenglwindow
qtHaveModule(widgets) { qtHaveModule(widgets) {

View File

@ -1,3 +1,4 @@
QT += opengl
INCLUDEPATH += $$PWD INCLUDEPATH += $$PWD
SOURCES += $$PWD/openglwindow.cpp SOURCES += $$PWD/openglwindow.cpp
HEADERS += $$PWD/openglwindow.h HEADERS += $$PWD/openglwindow.h

View File

@ -3,5 +3,5 @@ include(openglwindow.pri)
SOURCES += \ SOURCES += \
main.cpp main.cpp
target.path = $$[QT_INSTALL_EXAMPLES]/gui/openglwindow target.path = $$[QT_INSTALL_EXAMPLES]/opengl/openglwindow
INSTALLS += target INSTALLS += target

View File

@ -1,3 +1,5 @@
QT += opengl
HEADERS += paintedwindow.h HEADERS += paintedwindow.h
SOURCES += paintedwindow.cpp main.cpp SOURCES += paintedwindow.cpp main.cpp

View File

@ -425,7 +425,7 @@
The \c findWindow() function simply searches through the list of The \c findWindow() function simply searches through the list of
existing windows, returning a pointer to the window that matches existing windows, returning a pointer to the window that matches
the given item ID, or 0 if the window doesn't exists. the given item ID, or \nullptr if the window doesn't exists.
Finally, let's take a quick look at our custom \c ImageItem class: Finally, let's take a quick look at our custom \c ImageItem class:

View File

@ -67,7 +67,7 @@ Window::Window(QWidget *parent)
connect(m_ui.easingCurvePicker, &QListWidget::currentRowChanged, connect(m_ui.easingCurvePicker, &QListWidget::currentRowChanged,
this, &Window::curveChanged); this, &Window::curveChanged);
connect(m_ui.buttonGroup, QOverload<int>::of(&QButtonGroup::buttonClicked), connect(m_ui.buttonGroup, QOverload<QAbstractButton *>::of(&QButtonGroup::buttonClicked),
this, &Window::pathChanged); this, &Window::pathChanged);
connect(m_ui.periodSpinBox, QOverload<double>::of(&QDoubleSpinBox::valueChanged), connect(m_ui.periodSpinBox, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
this, &Window::periodChanged); this, &Window::periodChanged);
@ -180,9 +180,10 @@ void Window::curveChanged(int row)
m_ui.overshootSpinBox->setEnabled(curveType >= QEasingCurve::InBack && curveType <= QEasingCurve::OutInBack); m_ui.overshootSpinBox->setEnabled(curveType >= QEasingCurve::InBack && curveType <= QEasingCurve::OutInBack);
} }
void Window::pathChanged(int index) void Window::pathChanged(QAbstractButton *button)
{ {
m_anim->setPathType((Animation::PathType)index); const int index = m_ui.buttonGroup->id(button);
m_anim->setPathType(Animation::PathType(index));
} }
void Window::periodChanged(double value) void Window::periodChanged(double value)

View File

@ -69,7 +69,7 @@ public:
Window(QWidget *parent = nullptr); Window(QWidget *parent = nullptr);
private slots: private slots:
void curveChanged(int row); void curveChanged(int row);
void pathChanged(int index); void pathChanged(QAbstractButton *button);
void periodChanged(double); void periodChanged(double);
void amplitudeChanged(double); void amplitudeChanged(double);
void overshootChanged(double); void overshootChanged(double);

View File

@ -26,7 +26,7 @@
****************************************************************************/ ****************************************************************************/
/*! /*!
\example widgets/gallery \example gallery
\title Widgets Gallery Example \title Widgets Gallery Example
\ingroup examples-widgets \ingroup examples-widgets
\brief The Widgets Gallery example shows widgets relevant for designing UIs. \brief The Widgets Gallery example shows widgets relevant for designing UIs.

View File

@ -220,11 +220,11 @@ void View::setupMatrix()
{ {
qreal scale = qPow(qreal(2), (zoomSlider->value() - 250) / qreal(50)); qreal scale = qPow(qreal(2), (zoomSlider->value() - 250) / qreal(50));
QMatrix matrix; QTransform matrix;
matrix.scale(scale, scale); matrix.scale(scale, scale);
matrix.rotate(rotateSlider->value()); matrix.rotate(rotateSlider->value());
graphicsView->setMatrix(matrix); graphicsView->setTransform(matrix);
setResetButtonEnabled(); setResetButtonEnabled();
} }

View File

@ -113,13 +113,14 @@ void MainWindow::backgroundButtonGroupClicked(QAbstractButton *button)
//! [1] //! [1]
//! [2] //! [2]
void MainWindow::buttonGroupClicked(int id) void MainWindow::buttonGroupClicked(QAbstractButton *button)
{ {
const QList<QAbstractButton *> buttons = buttonGroup->buttons(); const QList<QAbstractButton *> buttons = buttonGroup->buttons();
for (QAbstractButton *button : buttons) { for (QAbstractButton *myButton : buttons) {
if (buttonGroup->button(id) != button) if (myButton != button)
button->setChecked(false); button->setChecked(false);
} }
const int id = buttonGroup->id(button);
if (id == InsertTextButton) { if (id == InsertTextButton) {
scene->setMode(DiagramScene::InsertText); scene->setMode(DiagramScene::InsertText);
} else { } else {
@ -154,7 +155,7 @@ void MainWindow::deleteItem()
//! [3] //! [3]
//! [4] //! [4]
void MainWindow::pointerGroupClicked(int) void MainWindow::pointerGroupClicked()
{ {
scene->setMode(DiagramScene::Mode(pointerTypeGroup->checkedId())); scene->setMode(DiagramScene::Mode(pointerTypeGroup->checkedId()));
} }
@ -231,8 +232,8 @@ void MainWindow::fontSizeChanged(const QString &)
void MainWindow::sceneScaleChanged(const QString &scale) void MainWindow::sceneScaleChanged(const QString &scale)
{ {
double newScale = scale.left(scale.indexOf(tr("%"))).toDouble() / 100.0; double newScale = scale.left(scale.indexOf(tr("%"))).toDouble() / 100.0;
QMatrix oldMatrix = view->matrix(); QTransform oldMatrix = view->transform();
view->resetMatrix(); view->resetTransform();
view->translate(oldMatrix.dx(), oldMatrix.dy()); view->translate(oldMatrix.dx(), oldMatrix.dy());
view->scale(newScale, newScale); view->scale(newScale, newScale);
} }
@ -334,7 +335,7 @@ void MainWindow::createToolBox()
{ {
buttonGroup = new QButtonGroup(this); buttonGroup = new QButtonGroup(this);
buttonGroup->setExclusive(false); buttonGroup->setExclusive(false);
connect(buttonGroup, QOverload<int>::of(&QButtonGroup::buttonClicked), connect(buttonGroup, QOverload<QAbstractButton *>::of(&QButtonGroup::buttonClicked),
this, &MainWindow::buttonGroupClicked); this, &MainWindow::buttonGroupClicked);
QGridLayout *layout = new QGridLayout; QGridLayout *layout = new QGridLayout;
layout->addWidget(createCellWidget(tr("Conditional"), DiagramItem::Conditional), 0, 0); layout->addWidget(createCellWidget(tr("Conditional"), DiagramItem::Conditional), 0, 0);
@ -528,7 +529,7 @@ void MainWindow::createToolbars()
pointerTypeGroup = new QButtonGroup(this); pointerTypeGroup = new QButtonGroup(this);
pointerTypeGroup->addButton(pointerButton, int(DiagramScene::MoveItem)); pointerTypeGroup->addButton(pointerButton, int(DiagramScene::MoveItem));
pointerTypeGroup->addButton(linePointerButton, int(DiagramScene::InsertLine)); pointerTypeGroup->addButton(linePointerButton, int(DiagramScene::InsertLine));
connect(pointerTypeGroup, QOverload<int>::of(&QButtonGroup::buttonClicked), connect(pointerTypeGroup, QOverload<QAbstractButton *>::of(&QButtonGroup::buttonClicked),
this, &MainWindow::pointerGroupClicked); this, &MainWindow::pointerGroupClicked);
sceneScaleCombo = new QComboBox; sceneScaleCombo = new QComboBox;

View File

@ -82,9 +82,9 @@ public:
private slots: private slots:
void backgroundButtonGroupClicked(QAbstractButton *button); void backgroundButtonGroupClicked(QAbstractButton *button);
void buttonGroupClicked(int id); void buttonGroupClicked(QAbstractButton *button);
void deleteItem(); void deleteItem();
void pointerGroupClicked(int id); void pointerGroupClicked();
void bringToFront(); void bringToFront();
void sendToBack(); void sendToBack();
void itemInserted(DiagramItem *item); void itemInserted(DiagramItem *item);

View File

@ -61,7 +61,7 @@ Window::Window()
QItemEditorCreatorBase *colorListCreator = QItemEditorCreatorBase *colorListCreator =
new QStandardItemEditorCreator<ColorListEditor>(); new QStandardItemEditorCreator<ColorListEditor>();
factory->registerEditor(QVariant::Color, colorListCreator); factory->registerEditor(QMetaType::QColor, colorListCreator);
QItemEditorFactory::setDefaultFactory(factory); QItemEditorFactory::setDefaultFactory(factory);

View File

@ -98,7 +98,7 @@ bool MySortFilterProxyModel::lessThan(const QModelIndex &left,
//! [4] //! [4]
//! [6] //! [6]
if (leftData.type() == QVariant::DateTime) { if (leftData.userType() == QMetaType::QDateTime) {
return leftData.toDateTime() < rightData.toDateTime(); return leftData.toDateTime() < rightData.toDateTime();
} else { } else {
static const QRegularExpression emailPattern("[\\w\\.]*@[\\w\\.]*"); static const QRegularExpression emailPattern("[\\w\\.]*@[\\w\\.]*");

View File

@ -223,7 +223,7 @@ void XFormView::setRotation(qreal r)
m_rotation = r; m_rotation = r;
QPointF center(pts->points().at(0)); QPointF center(pts->points().at(0));
QMatrix m; QTransform m;
m.translate(center.x(), center.y()); m.translate(center.x(), center.y());
m.rotate(m_rotation - old_rot); m.rotate(m_rotation - old_rot);
m.translate(-center.x(), -center.y()); m.translate(-center.x(), -center.y());
@ -236,7 +236,7 @@ void XFormView::timerEvent(QTimerEvent *e)
{ {
if (e->timerId() == timer.timerId()) { if (e->timerId() == timer.timerId()) {
QPointF center(pts->points().at(0)); QPointF center(pts->points().at(0));
QMatrix m; QTransform m;
m.translate(center.x(), center.y()); m.translate(center.x(), center.y());
m.rotate(0.2); m.rotate(0.2);
m.translate(-center.x(), -center.y()); m.translate(-center.x(), -center.y());

View File

@ -374,7 +374,7 @@ void PathDeformRenderer::setText(const QString &text)
} }
for (int i=0; i<m_paths.size(); ++i) for (int i=0; i<m_paths.size(); ++i)
m_paths[i] = m_paths[i] * QMatrix(1, 0, 0, 1, -m_pathBounds.x(), -m_pathBounds.y()); m_paths[i] = m_paths[i] * QTransform(1, 0, 0, 1, -m_pathBounds.x(), -m_pathBounds.y());
update(); update();
} }

View File

@ -511,10 +511,10 @@ void PathStrokeRenderer::initializePoints()
m_points.clear(); m_points.clear();
m_vectors.clear(); m_vectors.clear();
QMatrix m; QTransform m;
qreal rot = 360.0 / count; qreal rot = 360.0 / count;
QPointF center(width() / 2, height() / 2); QPointF center(width() / 2, height() / 2);
QMatrix vm; QTransform vm;
vm.shear(2, -1); vm.shear(2, -1);
vm.scale(3, 3); vm.scale(3, 3);

View File

@ -62,8 +62,8 @@
#include <QRegularExpression> #include <QRegularExpression>
#include <QOffscreenSurface> #include <QOffscreenSurface>
#include <QOpenGLContext> #include <QOpenGLContext>
#include <QOpenGLPaintDevice>
#if QT_CONFIG(opengl) #if QT_CONFIG(opengl)
#include <QtOpenGL/QOpenGLPaintDevice>
#include <QtOpenGL/QOpenGLWindow> #include <QtOpenGL/QOpenGLWindow>
#endif #endif

View File

@ -208,7 +208,7 @@ void SettingsTree::updateChildItems(QTreeWidgetItem *parent)
} }
QVariant value = settings->value(key); QVariant value = settings->value(key);
if (value.type() == QVariant::Invalid) { if (value.userType() == QMetaType::UnknownType) {
child->setText(1, "Invalid"); child->setText(1, "Invalid");
} else { } else {
child->setText(1, value.typeName()); child->setText(1, value.typeName());

View File

@ -81,7 +81,7 @@ void VariantDelegate::paint(QPainter *painter,
{ {
if (index.column() == 2) { if (index.column() == 2) {
QVariant value = index.model()->data(index, Qt::UserRole); QVariant value = index.model()->data(index, Qt::UserRole);
if (!isSupportedType(value.type())) { if (!isSupportedType(value.userType())) {
QStyleOptionViewItem myOption = option; QStyleOptionViewItem myOption = option;
myOption.state &= ~QStyle::State_Enabled; myOption.state &= ~QStyle::State_Enabled;
QStyledItemDelegate::paint(painter, myOption, index); QStyledItemDelegate::paint(painter, myOption, index);
@ -100,7 +100,7 @@ QWidget *VariantDelegate::createEditor(QWidget *parent,
return nullptr; return nullptr;
QVariant originalValue = index.model()->data(index, Qt::UserRole); QVariant originalValue = index.model()->data(index, Qt::UserRole);
if (!isSupportedType(originalValue.type())) if (!isSupportedType(originalValue.userType()))
return nullptr; return nullptr;
QLineEdit *lineEdit = new QLineEdit(parent); QLineEdit *lineEdit = new QLineEdit(parent);
@ -108,46 +108,46 @@ QWidget *VariantDelegate::createEditor(QWidget *parent,
QRegularExpression regExp; QRegularExpression regExp;
switch (originalValue.type()) { switch (originalValue.userType()) {
case QVariant::Bool: case QMetaType::Bool:
regExp = boolExp; regExp = boolExp;
break; break;
case QVariant::ByteArray: case QMetaType::QByteArray:
regExp = byteArrayExp; regExp = byteArrayExp;
break; break;
case QVariant::Char: case QMetaType::QChar:
regExp = charExp; regExp = charExp;
break; break;
case QVariant::Color: case QMetaType::QColor:
regExp = colorExp; regExp = colorExp;
break; break;
case QVariant::Date: case QMetaType::QDate:
regExp = dateExp; regExp = dateExp;
break; break;
case QVariant::DateTime: case QMetaType::QDateTime:
regExp = dateTimeExp; regExp = dateTimeExp;
break; break;
case QVariant::Double: case QMetaType::Double:
regExp = doubleExp; regExp = doubleExp;
break; break;
case QVariant::Int: case QMetaType::Int:
case QVariant::LongLong: case QMetaType::LongLong:
regExp = signedIntegerExp; regExp = signedIntegerExp;
break; break;
case QVariant::Point: case QMetaType::QPoint:
regExp = pointExp; regExp = pointExp;
break; break;
case QVariant::Rect: case QMetaType::QRect:
regExp = rectExp; regExp = rectExp;
break; break;
case QVariant::Size: case QMetaType::QSize:
regExp = sizeExp; regExp = sizeExp;
break; break;
case QVariant::Time: case QMetaType::QTime:
regExp = timeExp; regExp = timeExp;
break; break;
case QVariant::UInt: case QMetaType::UInt:
case QVariant::ULongLong: case QMetaType::ULongLong:
regExp = unsignedIntegerExp; regExp = unsignedIntegerExp;
break; break;
default: default:
@ -189,18 +189,18 @@ void VariantDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
QVariant value; QVariant value;
QRegularExpressionMatch match; QRegularExpressionMatch match;
switch (originalValue.type()) { switch (originalValue.userType()) {
case QVariant::Char: case QMetaType::QChar:
value = text.at(0); value = text.at(0);
break; break;
case QVariant::Color: case QMetaType::QColor:
match = colorExp.match(text); match = colorExp.match(text);
value = QColor(qMin(match.captured(1).toInt(), 255), value = QColor(qMin(match.captured(1).toInt(), 255),
qMin(match.captured(2).toInt(), 255), qMin(match.captured(2).toInt(), 255),
qMin(match.captured(3).toInt(), 255), qMin(match.captured(3).toInt(), 255),
qMin(match.captured(4).toInt(), 255)); qMin(match.captured(4).toInt(), 255));
break; break;
case QVariant::Date: case QMetaType::QDate:
{ {
QDate date = QDate::fromString(text, Qt::ISODate); QDate date = QDate::fromString(text, Qt::ISODate);
if (!date.isValid()) if (!date.isValid())
@ -208,7 +208,7 @@ void VariantDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
value = date; value = date;
} }
break; break;
case QVariant::DateTime: case QMetaType::QDateTime:
{ {
QDateTime dateTime = QDateTime::fromString(text, Qt::ISODate); QDateTime dateTime = QDateTime::fromString(text, Qt::ISODate);
if (!dateTime.isValid()) if (!dateTime.isValid())
@ -216,23 +216,23 @@ void VariantDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
value = dateTime; value = dateTime;
} }
break; break;
case QVariant::Point: case QMetaType::QPoint:
match = pointExp.match(text); match = pointExp.match(text);
value = QPoint(match.captured(1).toInt(), match.captured(2).toInt()); value = QPoint(match.captured(1).toInt(), match.captured(2).toInt());
break; break;
case QVariant::Rect: case QMetaType::QRect:
match = rectExp.match(text); match = rectExp.match(text);
value = QRect(match.captured(1).toInt(), match.captured(2).toInt(), value = QRect(match.captured(1).toInt(), match.captured(2).toInt(),
match.captured(3).toInt(), match.captured(4).toInt()); match.captured(3).toInt(), match.captured(4).toInt());
break; break;
case QVariant::Size: case QMetaType::QSize:
match = sizeExp.match(text); match = sizeExp.match(text);
value = QSize(match.captured(1).toInt(), match.captured(2).toInt()); value = QSize(match.captured(1).toInt(), match.captured(2).toInt());
break; break;
case QVariant::StringList: case QMetaType::QStringList:
value = text.split(','); value = text.split(',');
break; break;
case QVariant::Time: case QMetaType::QTime:
{ {
QTime time = QTime::fromString(text, Qt::ISODate); QTime time = QTime::fromString(text, Qt::ISODate);
if (!time.isValid()) if (!time.isValid())
@ -242,33 +242,33 @@ void VariantDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
break; break;
default: default:
value = text; value = text;
value.convert(originalValue.type()); value.convert(originalValue.userType());
} }
model->setData(index, displayText(value), Qt::DisplayRole); model->setData(index, displayText(value), Qt::DisplayRole);
model->setData(index, value, Qt::UserRole); model->setData(index, value, Qt::UserRole);
} }
bool VariantDelegate::isSupportedType(QVariant::Type type) bool VariantDelegate::isSupportedType(int type)
{ {
switch (type) { switch (type) {
case QVariant::Bool: case QMetaType::Bool:
case QVariant::ByteArray: case QMetaType::QByteArray:
case QVariant::Char: case QMetaType::QChar:
case QVariant::Color: case QMetaType::QColor:
case QVariant::Date: case QMetaType::QDate:
case QVariant::DateTime: case QMetaType::QDateTime:
case QVariant::Double: case QMetaType::Double:
case QVariant::Int: case QMetaType::Int:
case QVariant::LongLong: case QMetaType::LongLong:
case QVariant::Point: case QMetaType::QPoint:
case QVariant::Rect: case QMetaType::QRect:
case QVariant::Size: case QMetaType::QSize:
case QVariant::String: case QMetaType::QString:
case QVariant::StringList: case QMetaType::QStringList:
case QVariant::Time: case QMetaType::QTime:
case QVariant::UInt: case QMetaType::UInt:
case QVariant::ULongLong: case QMetaType::ULongLong:
return true; return true;
default: default:
return false; return false;
@ -277,50 +277,50 @@ bool VariantDelegate::isSupportedType(QVariant::Type type)
QString VariantDelegate::displayText(const QVariant &value) QString VariantDelegate::displayText(const QVariant &value)
{ {
switch (value.type()) { switch (value.userType()) {
case QVariant::Bool: case QMetaType::Bool:
case QVariant::ByteArray: case QMetaType::QByteArray:
case QVariant::Char: case QMetaType::QChar:
case QVariant::Double: case QMetaType::Double:
case QVariant::Int: case QMetaType::Int:
case QVariant::LongLong: case QMetaType::LongLong:
case QVariant::String: case QMetaType::QString:
case QVariant::UInt: case QMetaType::UInt:
case QVariant::ULongLong: case QMetaType::ULongLong:
return value.toString(); return value.toString();
case QVariant::Color: case QMetaType::QColor:
{ {
QColor color = qvariant_cast<QColor>(value); QColor color = qvariant_cast<QColor>(value);
return QString("(%1,%2,%3,%4)") return QString("(%1,%2,%3,%4)")
.arg(color.red()).arg(color.green()) .arg(color.red()).arg(color.green())
.arg(color.blue()).arg(color.alpha()); .arg(color.blue()).arg(color.alpha());
} }
case QVariant::Date: case QMetaType::QDate:
return value.toDate().toString(Qt::ISODate); return value.toDate().toString(Qt::ISODate);
case QVariant::DateTime: case QMetaType::QDateTime:
return value.toDateTime().toString(Qt::ISODate); return value.toDateTime().toString(Qt::ISODate);
case QVariant::Invalid: case QMetaType::UnknownType:
return "<Invalid>"; return "<Invalid>";
case QVariant::Point: case QMetaType::QPoint:
{ {
QPoint point = value.toPoint(); QPoint point = value.toPoint();
return QString("(%1,%2)").arg(point.x()).arg(point.y()); return QString("(%1,%2)").arg(point.x()).arg(point.y());
} }
case QVariant::Rect: case QMetaType::QRect:
{ {
QRect rect = value.toRect(); QRect rect = value.toRect();
return QString("(%1,%2,%3,%4)") return QString("(%1,%2,%3,%4)")
.arg(rect.x()).arg(rect.y()) .arg(rect.x()).arg(rect.y())
.arg(rect.width()).arg(rect.height()); .arg(rect.width()).arg(rect.height());
} }
case QVariant::Size: case QMetaType::QSize:
{ {
QSize size = value.toSize(); QSize size = value.toSize();
return QString("(%1,%2)").arg(size.width()).arg(size.height()); return QString("(%1,%2)").arg(size.width()).arg(size.height());
} }
case QVariant::StringList: case QMetaType::QStringList:
return value.toStringList().join(','); return value.toStringList().join(',');
case QVariant::Time: case QMetaType::QTime:
return value.toTime().toString(Qt::ISODate); return value.toTime().toString(Qt::ISODate);
default: default:
break; break;

View File

@ -69,7 +69,7 @@ public:
void setModelData(QWidget *editor, QAbstractItemModel *model, void setModelData(QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index) const override; const QModelIndex &index) const override;
static bool isSupportedType(QVariant::Type type); static bool isSupportedType(int type);
static QString displayText(const QVariant &value); static QString displayText(const QVariant &value);
private: private:

View File

@ -60,7 +60,7 @@
#include <QWidget> #include <QWidget>
// Making use of the class from the opengl example in gui. // Making use of the class from the openglwindow example
class Window : public OpenGLWindow class Window : public OpenGLWindow
{ {
Q_OBJECT Q_OBJECT

View File

@ -6,4 +6,4 @@ QT += widgets
target.path = $$[QT_INSTALL_EXAMPLES]/widgets/windowcontainer target.path = $$[QT_INSTALL_EXAMPLES]/widgets/windowcontainer
INSTALLS += target INSTALLS += target
include(../../gui/openglwindow/openglwindow.pri) include(../../opengl/openglwindow/openglwindow.pri)

View File

@ -176,7 +176,7 @@ contains(CONFIG, plugin) {
list_plugin_extends = list_plugin_extends =
for (p, PLUGIN_EXTENDS) { for (p, PLUGIN_EXTENDS) {
m = $$cmakeModuleName($$p) m = $$cmakeModuleName($$p)
list_plugin_extends += Qt5::$$m list_plugin_extends += Qt::$$m
} }
CMAKE_PLUGIN_EXTENDS = $$join(list_plugin_extends, ";") CMAKE_PLUGIN_EXTENDS = $$join(list_plugin_extends, ";")
} }
@ -212,21 +212,17 @@ contains(CONFIG, plugin) {
CMAKE_PLUGIN_TYPE_ESCAPED = $$replace(PLUGIN_TYPE, [-/], _) CMAKE_PLUGIN_TYPE_ESCAPED = $$replace(PLUGIN_TYPE, [-/], _)
win32 { win32 {
CMAKE_PRL_FILE_LOCATION_RELEASE = $$PLUGIN_TYPE/$${CMAKE_QT_STEM}.prl
CMAKE_PRL_FILE_LOCATION_DEBUG = $$PLUGIN_TYPE/$${CMAKE_QT_STEM}d.prl
isEmpty(CMAKE_STATIC_TYPE) { isEmpty(CMAKE_STATIC_TYPE) {
CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/$${CMAKE_QT_STEM}.dll CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/$${CMAKE_QT_STEM}.dll
CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/$${CMAKE_QT_STEM}d.dll CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/$${CMAKE_QT_STEM}d.dll
CMAKE_PRL_FILE_LOCATION_RELEASE = $$PLUGIN_TYPE/$${CMAKE_QT_STEM}.prl
CMAKE_PRL_FILE_LOCATION_DEBUG = $$PLUGIN_TYPE/$${CMAKE_QT_STEM}d.prl
} else:mingw { } else:mingw {
CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}.a CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}.a
CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}d.a CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}d.a
CMAKE_PRL_FILE_LOCATION_RELEASE = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}.prl
CMAKE_PRL_FILE_LOCATION_DEBUG = $$PLUGIN_TYPE/lib$${CMAKE_QT_STEM}d.prl
} else { # MSVC static } else { # MSVC static
CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/$${CMAKE_QT_STEM}.lib CMAKE_PLUGIN_LOCATION_RELEASE = $$PLUGIN_TYPE/$${CMAKE_QT_STEM}.lib
CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/$${CMAKE_QT_STEM}d.lib CMAKE_PLUGIN_LOCATION_DEBUG = $$PLUGIN_TYPE/$${CMAKE_QT_STEM}d.lib
CMAKE_PRL_FILE_LOCATION_RELEASE = $$PLUGIN_TYPE/$${CMAKE_QT_STEM}.prl
CMAKE_PRL_FILE_LOCATION_DEBUG = $$PLUGIN_TYPE/$${CMAKE_QT_STEM}d.prl
} }
} else { } else {
mac { mac {
@ -291,6 +287,10 @@ CMAKE_INTERFACE_MODULE_DEPS = $$join(aux_mod_deps, ";")
CMAKE_INTERFACE_QT5_MODULE_DEPS = $$join(aux_lib_deps, ";") CMAKE_INTERFACE_QT5_MODULE_DEPS = $$join(aux_lib_deps, ";")
CMAKE_MODULE_PLUGIN_TYPES = $$join(QT.$${MODULE}.plugin_types, ";") CMAKE_MODULE_PLUGIN_TYPES = $$join(QT.$${MODULE}.plugin_types, ";")
# Interface libraries have to have all properties starting with "INTERFACE_".
CMAKE_FEATURE_PROPERTY_PREFIX = ""
equals(TEMPLATE, aux): CMAKE_FEATURE_PROPERTY_PREFIX = "INTERFACE_"
mac { mac {
!isEmpty(CMAKE_STATIC_TYPE) { !isEmpty(CMAKE_STATIC_TYPE) {
CMAKE_LIB_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}_debug.a CMAKE_LIB_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}_debug.a
@ -316,36 +316,25 @@ mac {
CMAKE_LIB_FILE_LOCATION_DEBUG = $${CMAKE_QT_STEM}d.dll CMAKE_LIB_FILE_LOCATION_DEBUG = $${CMAKE_QT_STEM}d.dll
CMAKE_LIB_FILE_LOCATION_RELEASE = $${CMAKE_QT_STEM}.dll CMAKE_LIB_FILE_LOCATION_RELEASE = $${CMAKE_QT_STEM}.dll
!isEmpty(CMAKE_STATIC_TYPE) {
CMAKE_STATIC_WINDOWS_BUILD = "true"
CMAKE_PRL_FILE_LOCATION_DEBUG = $${CMAKE_QT_STEM}d.prl
CMAKE_PRL_FILE_LOCATION_RELEASE = $${CMAKE_QT_STEM}.prl
}
mingw { mingw {
CMAKE_WINMAIN_FILE_LOCATION_DEBUG = libqtmain$${QT_LIBINFIX}d.a CMAKE_WINMAIN_FILE_LOCATION_DEBUG = libqtmain$${QT_LIBINFIX}d.a
CMAKE_WINMAIN_FILE_LOCATION_RELEASE = libqtmain$${QT_LIBINFIX}.a CMAKE_WINMAIN_FILE_LOCATION_RELEASE = libqtmain$${QT_LIBINFIX}.a
!isEmpty(CMAKE_STATIC_TYPE) { CMAKE_IMPLIB_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}d.a
CMAKE_STATIC_WINDOWS_BUILD = "true" CMAKE_IMPLIB_FILE_LOCATION_RELEASE = lib$${CMAKE_QT_STEM}.a
CMAKE_IMPLIB_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}d.a
CMAKE_IMPLIB_FILE_LOCATION_RELEASE = lib$${CMAKE_QT_STEM}.a
CMAKE_PRL_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}d.prl
CMAKE_PRL_FILE_LOCATION_RELEASE = lib$${CMAKE_QT_STEM}.prl
} else {
CMAKE_IMPLIB_FILE_LOCATION_DEBUG = lib$${CMAKE_QT_STEM}d.a
CMAKE_IMPLIB_FILE_LOCATION_RELEASE = lib$${CMAKE_QT_STEM}.a
}
} else { } else {
CMAKE_WINMAIN_FILE_LOCATION_DEBUG = qtmain$${QT_LIBINFIX}d.lib CMAKE_WINMAIN_FILE_LOCATION_DEBUG = qtmain$${QT_LIBINFIX}d.lib
CMAKE_WINMAIN_FILE_LOCATION_RELEASE = qtmain$${QT_LIBINFIX}.lib CMAKE_WINMAIN_FILE_LOCATION_RELEASE = qtmain$${QT_LIBINFIX}.lib
!isEmpty(CMAKE_STATIC_TYPE) { CMAKE_IMPLIB_FILE_LOCATION_DEBUG = $${CMAKE_QT_STEM}d.lib
CMAKE_STATIC_WINDOWS_BUILD = "true" CMAKE_IMPLIB_FILE_LOCATION_RELEASE = $${CMAKE_QT_STEM}.lib
CMAKE_IMPLIB_FILE_LOCATION_DEBUG = $${CMAKE_QT_STEM}d.lib
CMAKE_IMPLIB_FILE_LOCATION_RELEASE = $${CMAKE_QT_STEM}.lib
CMAKE_PRL_FILE_LOCATION_DEBUG = $${CMAKE_QT_STEM}d.prl
CMAKE_PRL_FILE_LOCATION_RELEASE = $${CMAKE_QT_STEM}.prl
} else {
CMAKE_IMPLIB_FILE_LOCATION_DEBUG = $${CMAKE_QT_STEM}d.lib
CMAKE_IMPLIB_FILE_LOCATION_RELEASE = $${CMAKE_QT_STEM}.lib
}
} }
} else { } else {
!isEmpty(CMAKE_STATIC_TYPE) { !isEmpty(CMAKE_STATIC_TYPE) {

View File

@ -406,6 +406,15 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
add_library(Qt5::$${CMAKE_MODULE_NAME} SHARED IMPORTED) add_library(Qt5::$${CMAKE_MODULE_NAME} SHARED IMPORTED)
!!ENDIF !!ENDIF
!!ENDIF !!ENDIF
# Add a versionless target, for compatibility with Qt6.
if(NOT \"${QT_NO_CREATE_VERSIONLESS_TARGETS}\" AND NOT TARGET Qt::$${CMAKE_MODULE_NAME})
add_library(Qt::$${CMAKE_MODULE_NAME} INTERFACE IMPORTED)
set_target_properties(Qt::$${CMAKE_MODULE_NAME} PROPERTIES
INTERFACE_LINK_LIBRARIES \"Qt5::$${CMAKE_MODULE_NAME}\"
)
endif()
!!IF !equals(TEMPLATE, aux) !!IF !equals(TEMPLATE, aux)
!!IF !isEmpty(CMAKE_BUILD_IS_FRAMEWORK) !!IF !isEmpty(CMAKE_BUILD_IS_FRAMEWORK)
set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY FRAMEWORK 1) set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY FRAMEWORK 1)
@ -420,6 +429,20 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY INTERFACE_QT_ENABLED_FEATURES $$join(QT.$${MODULE}.enabled_features, ";")) set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY INTERFACE_QT_ENABLED_FEATURES $$join(QT.$${MODULE}.enabled_features, ";"))
set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY INTERFACE_QT_DISABLED_FEATURES $$join(QT.$${MODULE}.disabled_features, ";")) set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY INTERFACE_QT_DISABLED_FEATURES $$join(QT.$${MODULE}.disabled_features, ";"))
# Qt 6 forward compatible properties.
set_property(TARGET Qt5::$${CMAKE_MODULE_NAME}
PROPERTY $${CMAKE_FEATURE_PROPERTY_PREFIX}QT_ENABLED_PUBLIC_FEATURES
$$join(QT.$${MODULE}.enabled_features, ";"))
set_property(TARGET Qt5::$${CMAKE_MODULE_NAME}
PROPERTY $${CMAKE_FEATURE_PROPERTY_PREFIX}QT_DISABLED_PUBLIC_FEATURES
$$join(QT.$${MODULE}.disabled_features, ";"))
set_property(TARGET Qt5::$${CMAKE_MODULE_NAME}
PROPERTY $${CMAKE_FEATURE_PROPERTY_PREFIX}QT_ENABLED_PRIVATE_FEATURES
$$join(QT.$${MODULE}_private.enabled_features, ";"))
set_property(TARGET Qt5::$${CMAKE_MODULE_NAME}
PROPERTY $${CMAKE_FEATURE_PROPERTY_PREFIX}QT_DISABLED_PRIVATE_FEATURES
$$join(QT.$${MODULE}_private.disabled_features, ";"))
set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY INTERFACE_QT_PLUGIN_TYPES \"$${CMAKE_MODULE_PLUGIN_TYPES}\") set_property(TARGET Qt5::$${CMAKE_MODULE_NAME} PROPERTY INTERFACE_QT_PLUGIN_TYPES \"$${CMAKE_MODULE_PLUGIN_TYPES}\")
set(_Qt5$${CMAKE_MODULE_NAME}_PRIVATE_DIRS_EXIST TRUE) set(_Qt5$${CMAKE_MODULE_NAME}_PRIVATE_DIRS_EXIST TRUE)
@ -443,6 +466,14 @@ if (NOT TARGET Qt5::$${CMAKE_MODULE_NAME})
set_property(TARGET Qt5::$${CMAKE_MODULE_NAME}Private PROPERTY set_property(TARGET Qt5::$${CMAKE_MODULE_NAME}Private PROPERTY
INTERFACE_LINK_LIBRARIES Qt5::$${CMAKE_MODULE_NAME} ${_Qt5$${CMAKE_MODULE_NAME}_PRIVATEDEPS} INTERFACE_LINK_LIBRARIES Qt5::$${CMAKE_MODULE_NAME} ${_Qt5$${CMAKE_MODULE_NAME}_PRIVATEDEPS}
) )
# Add a versionless target, for compatibility with Qt6.
if(NOT \"${QT_NO_CREATE_VERSIONLESS_TARGETS}\" AND NOT TARGET Qt::$${CMAKE_MODULE_NAME}Private)
add_library(Qt::$${CMAKE_MODULE_NAME}Private INTERFACE IMPORTED)
set_target_properties(Qt::$${CMAKE_MODULE_NAME}Private PROPERTIES
INTERFACE_LINK_LIBRARIES \"Qt5::$${CMAKE_MODULE_NAME}Private\"
)
endif()
endif() endif()
!!IF !equals(TEMPLATE, aux) !!IF !equals(TEMPLATE, aux)

View File

@ -75,19 +75,30 @@ endif()
set(_user_specified_genex set(_user_specified_genex
\"$<IN_LIST:Qt5::$$CMAKE_PLUGIN_NAME,${_manual_plugins_genex};${_plugin_type_genex}>\" \"$<IN_LIST:Qt5::$$CMAKE_PLUGIN_NAME,${_manual_plugins_genex};${_plugin_type_genex}>\"
) )
set(_user_specified_genex_versionless
\"$<IN_LIST:Qt::$$CMAKE_PLUGIN_NAME,${_manual_plugins_genex};${_plugin_type_genex}>\"
)
string(CONCAT _plugin_genex string(CONCAT _plugin_genex
\"$<$<OR:\" \"$<$<OR:\"
# Add this plugin if it\'s in the list of manual plugins or plugins for the type # Add this plugin if it\'s in the list of manually specified plugins or in the list of
# explicitly included plugin types.
\"${_user_specified_genex},\" \"${_user_specified_genex},\"
# Add this plugin if the list of plugins for the type is empty, the PLUGIN_EXTENDS \"${_user_specified_genex_versionless},\"
# is either empty or equal to the module name, and the user hasn\'t blacklisted it # Add this plugin if all of the following are true:
# 1) the list of explicitly included plugin types is empty
# 2) the QT_PLUGIN_EXTENDS property for the plugin is empty or equal to the current
# module name
# 3) the user hasn\'t explicitly excluded the plugin.
\"$<AND:\" \"$<AND:\"
\"$<STREQUAL:${_plugin_type_genex},>,\" \"$<STREQUAL:${_plugin_type_genex},>,\"
\"$<OR:\" \"$<OR:\"
\"$<STREQUAL:$<TARGET_PROPERTY:Qt5::$${CMAKE_PLUGIN_NAME},QT_PLUGIN_EXTENDS>,Qt5::$${CMAKE_MODULE_NAME}>,\" # FIXME: The value of CMAKE_MODULE_NAME seems to be wrong (e.g for Svg plugin
# it should be Qt::Svg instead of Qt::Gui).
\"$<STREQUAL:$<TARGET_PROPERTY:Qt5::$${CMAKE_PLUGIN_NAME},QT_PLUGIN_EXTENDS>,Qt::$${CMAKE_MODULE_NAME}>,\"
\"$<STREQUAL:$<TARGET_PROPERTY:Qt5::$${CMAKE_PLUGIN_NAME},QT_PLUGIN_EXTENDS>,>\" \"$<STREQUAL:$<TARGET_PROPERTY:Qt5::$${CMAKE_PLUGIN_NAME},QT_PLUGIN_EXTENDS>,>\"
\">,\" \">,\"
\"$<NOT:$<IN_LIST:Qt5::$${CMAKE_PLUGIN_NAME},${_no_plugins_genex}>>\" \"$<NOT:$<IN_LIST:Qt5::$${CMAKE_PLUGIN_NAME},${_no_plugins_genex}>>,\"
\"$<NOT:$<IN_LIST:Qt::$${CMAKE_PLUGIN_NAME},${_no_plugins_genex}>>\"
\">\" \">\"
\">:Qt5::$$CMAKE_PLUGIN_NAME>\" \">:Qt5::$$CMAKE_PLUGIN_NAME>\"
) )
@ -100,3 +111,4 @@ set_property(TARGET Qt5::$${CMAKE_PLUGIN_NAME} APPEND PROPERTY INTERFACE_LINK_LI
!!ENDIF !!ENDIF
set_property(TARGET Qt5::$${CMAKE_PLUGIN_NAME} PROPERTY QT_PLUGIN_TYPE \"$$CMAKE_PLUGIN_TYPE\") set_property(TARGET Qt5::$${CMAKE_PLUGIN_NAME} PROPERTY QT_PLUGIN_TYPE \"$$CMAKE_PLUGIN_TYPE\")
set_property(TARGET Qt5::$${CMAKE_PLUGIN_NAME} PROPERTY QT_PLUGIN_EXTENDS \"$$CMAKE_PLUGIN_EXTENDS\") set_property(TARGET Qt5::$${CMAKE_PLUGIN_NAME} PROPERTY QT_PLUGIN_EXTENDS \"$$CMAKE_PLUGIN_EXTENDS\")
set_property(TARGET Qt5::$${CMAKE_PLUGIN_NAME} PROPERTY QT_PLUGIN_CLASS_NAME \"$$CMAKE_PLUGIN_NAME\")

View File

@ -64,11 +64,13 @@ debug {
QMAKE_CXXFLAGS += $$QMAKE_CXXFLAGS_DEBUG QMAKE_CXXFLAGS += $$QMAKE_CXXFLAGS_DEBUG
QMAKE_LFLAGS += $$QMAKE_LFLAGS_DEBUG QMAKE_LFLAGS += $$QMAKE_LFLAGS_DEBUG
QMAKE_LIBFLAGS += $$QMAKE_LIBFLAGS_DEBUG QMAKE_LIBFLAGS += $$QMAKE_LIBFLAGS_DEBUG
DEFINES += $$DEFINES_DEBUG
} else { } else {
QMAKE_CFLAGS += $$QMAKE_CFLAGS_RELEASE QMAKE_CFLAGS += $$QMAKE_CFLAGS_RELEASE
QMAKE_CXXFLAGS += $$QMAKE_CXXFLAGS_RELEASE QMAKE_CXXFLAGS += $$QMAKE_CXXFLAGS_RELEASE
QMAKE_LFLAGS += $$QMAKE_LFLAGS_RELEASE QMAKE_LFLAGS += $$QMAKE_LFLAGS_RELEASE
QMAKE_LIBFLAGS += $$QMAKE_LIBFLAGS_RELEASE QMAKE_LIBFLAGS += $$QMAKE_LIBFLAGS_RELEASE
DEFINES += $$DEFINES_RELEASE
} }
stack_protector_strong { stack_protector_strong {

View File

@ -26,10 +26,4 @@ CONFIG = \
unset(today) unset(today)
} }
CONFIG(debug, debug|release) {
DEFINES += $$DEFINES_DEBUG
} else {
DEFINES += $$DEFINES_RELEASE
}
load(toolchain) load(toolchain)

View File

@ -23,7 +23,6 @@ qtConfig(c11): CONFIG += c11
qtConfig(stack-protector-strong): CONFIG += stack_protector_strong qtConfig(stack-protector-strong): CONFIG += stack_protector_strong
contains(TEMPLATE, .*lib) { contains(TEMPLATE, .*lib) {
# module and plugins # module and plugins
if(!host_build|!cross_compile):qtConfig(reduce_exports): CONFIG += hide_symbols
unix:qtConfig(reduce_relocations): CONFIG += bsymbolic_functions unix:qtConfig(reduce_relocations): CONFIG += bsymbolic_functions
qtConfig(separate_debug_info): CONFIG += separate_debug_info qtConfig(separate_debug_info): CONFIG += separate_debug_info
@ -58,6 +57,9 @@ contains(TEMPLATE, .*lib) {
QMAKE_PRL_INSTALL_REPLACE += qtlibdir_replace QMAKE_PRL_INSTALL_REPLACE += qtlibdir_replace
} }
} }
contains(TEMPLATE, .*lib)|darwin {
if(!host_build|!cross_compile):qtConfig(reduce_exports): CONFIG += hide_symbols
}
# The remainder of this file must not apply to host tools/libraries, # The remainder of this file must not apply to host tools/libraries,
# as the host compiler's version and capabilities are not checked. # as the host compiler's version and capabilities are not checked.

View File

@ -36,6 +36,7 @@ EMCC_COMMON_LFLAGS += \
-s USE_WEBGL2=1 \ -s USE_WEBGL2=1 \
-s NO_EXIT_RUNTIME=0 \ -s NO_EXIT_RUNTIME=0 \
-s ERROR_ON_UNDEFINED_SYMBOLS=1 \ -s ERROR_ON_UNDEFINED_SYMBOLS=1 \
-s EXTRA_EXPORTED_RUNTIME_METHODS=[\"UTF16ToString\",\"stringToUTF16\"] \
--bind --bind
# The -s arguments can also be used with release builds, # The -s arguments can also be used with release builds,

View File

@ -1168,7 +1168,7 @@
\section1 DEFINES_DEBUG \section1 DEFINES_DEBUG
Specifies preprocessor defines for the debug configuration. The values of Specifies preprocessor defines for the debug configuration. The values of
this variable get added to \l{DEFINES} before the project is loaded. This this variable get added to \l{DEFINES} after the project is loaded. This
variable is typically set in \l{#QMAKESPEC}{qmake.conf} and rarely needs variable is typically set in \l{#QMAKESPEC}{qmake.conf} and rarely needs
to be modified. to be modified.
@ -1178,10 +1178,13 @@
\section1 DEFINES_RELEASE \section1 DEFINES_RELEASE
Specifies preprocessor defines for the release configuration. The values of Specifies preprocessor defines for the release configuration. The values of
this variable get added to \l{DEFINES} before the project is loaded. This this variable get added to \l{DEFINES} after the project is loaded. This
variable is typically set in \l{#QMAKESPEC}{qmake.conf} and rarely needs variable is typically set in \l{#QMAKESPEC}{qmake.conf} and rarely needs
to be modified. to be modified.
\note For MSVC mkspecs, this variable contains the value \c NDEBUG by
default.
This variable was introduced in Qt 5.13.2. This variable was introduced in Qt 5.13.2.
\target DEF_FILE \target DEF_FILE

View File

@ -1851,7 +1851,6 @@ QString MakefileGenerator::resolveDependency(const QDir &outDir, const QString &
} }
void MakefileGenerator::callExtraCompilerDependCommand(const ProString &extraCompiler, void MakefileGenerator::callExtraCompilerDependCommand(const ProString &extraCompiler,
const QString &dep_cd_cmd,
const QString &tmp_dep_cmd, const QString &tmp_dep_cmd,
const QString &inpf, const QString &inpf,
const QString &tmp_out, const QString &tmp_out,
@ -1864,7 +1863,10 @@ void MakefileGenerator::callExtraCompilerDependCommand(const ProString &extraCom
QString dep_cmd = replaceExtraCompilerVariables(tmp_dep_cmd, inpf, tmp_out, LocalShell); QString dep_cmd = replaceExtraCompilerVariables(tmp_dep_cmd, inpf, tmp_out, LocalShell);
if (checkCommandAvailability && !canExecute(dep_cmd)) if (checkCommandAvailability && !canExecute(dep_cmd))
return; return;
dep_cmd = dep_cd_cmd + fixEnvVariables(dep_cmd); dep_cmd = QLatin1String("cd ")
+ IoUtils::shellQuote(Option::fixPathToLocalOS(Option::output_dir, false))
+ QLatin1String(" && ")
+ fixEnvVariables(dep_cmd);
if (FILE *proc = QT_POPEN(dep_cmd.toLatin1().constData(), QT_POPEN_READ)) { if (FILE *proc = QT_POPEN(dep_cmd.toLatin1().constData(), QT_POPEN_READ)) {
QByteArray depData; QByteArray depData;
while (int read_in = feof(proc) ? 0 : (int)fread(buff, 1, 255, proc)) while (int read_in = feof(proc) ? 0 : (int)fread(buff, 1, 255, proc))
@ -1916,12 +1918,6 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
FileFixifyFromOutdir); FileFixifyFromOutdir);
const QString tmp_cmd = project->values(ProKey(*it + ".commands")).join(' '); const QString tmp_cmd = project->values(ProKey(*it + ".commands")).join(' ');
const QString tmp_dep_cmd = project->values(ProKey(*it + ".depend_command")).join(' '); const QString tmp_dep_cmd = project->values(ProKey(*it + ".depend_command")).join(' ');
QString dep_cd_cmd;
if (!tmp_dep_cmd.isEmpty()) {
dep_cd_cmd = QLatin1String("cd ")
+ IoUtils::shellQuote(Option::fixPathToLocalOS(Option::output_dir, false))
+ QLatin1String(" && ");
}
const bool dep_lines = (config.indexOf("dep_lines") != -1); const bool dep_lines = (config.indexOf("dep_lines") != -1);
const ProStringList &vars = project->values(ProKey(*it + ".variables")); const ProStringList &vars = project->values(ProKey(*it + ".variables"));
if(tmp_out.isEmpty() || tmp_cmd.isEmpty()) if(tmp_out.isEmpty() || tmp_cmd.isEmpty())
@ -2035,7 +2031,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
deps += findDependencies(inpf); deps += findDependencies(inpf);
inputs += Option::fixPathToTargetOS(inpf, false); inputs += Option::fixPathToTargetOS(inpf, false);
if(!tmp_dep_cmd.isEmpty() && doDepends()) { if(!tmp_dep_cmd.isEmpty() && doDepends()) {
callExtraCompilerDependCommand(*it, dep_cd_cmd, tmp_dep_cmd, inpf, callExtraCompilerDependCommand(*it, tmp_dep_cmd, inpf,
tmp_out, dep_lines, &deps, existingDepsOnly); tmp_out, dep_lines, &deps, existingDepsOnly);
} }
} }
@ -2084,7 +2080,7 @@ MakefileGenerator::writeExtraCompilerTargets(QTextStream &t)
for (ProStringList::ConstIterator it3 = vars.constBegin(); it3 != vars.constEnd(); ++it3) for (ProStringList::ConstIterator it3 = vars.constBegin(); it3 != vars.constEnd(); ++it3)
cmd.replace("$(" + (*it3) + ")", "$(QMAKE_COMP_" + (*it3)+")"); cmd.replace("$(" + (*it3) + ")", "$(QMAKE_COMP_" + (*it3)+")");
if(!tmp_dep_cmd.isEmpty() && doDepends()) { if(!tmp_dep_cmd.isEmpty() && doDepends()) {
callExtraCompilerDependCommand(*it, dep_cd_cmd, tmp_dep_cmd, inpf, callExtraCompilerDependCommand(*it, tmp_dep_cmd, inpf,
tmp_out, dep_lines, &deps, existingDepsOnly); tmp_out, dep_lines, &deps, existingDepsOnly);
//use the depend system to find includes of these included files //use the depend system to find includes of these included files
QStringList inc_deps; QStringList inc_deps;

View File

@ -84,7 +84,7 @@ protected:
void writeExtraVariables(QTextStream &t); void writeExtraVariables(QTextStream &t);
void writeExtraTargets(QTextStream &t); void writeExtraTargets(QTextStream &t);
QString resolveDependency(const QDir &outDir, const QString &file); QString resolveDependency(const QDir &outDir, const QString &file);
void callExtraCompilerDependCommand(const ProString &extraCompiler, const QString &dep_cd_cmd, void callExtraCompilerDependCommand(const ProString &extraCompiler,
const QString &tmp_dep_cmd, const QString &inpf, const QString &tmp_dep_cmd, const QString &inpf,
const QString &tmp_out, bool dep_lines, QStringList *deps, const QString &tmp_out, bool dep_lines, QStringList *deps,
bool existingDepsOnly, bool existingDepsOnly,

View File

@ -2351,10 +2351,7 @@ bool VCFilter::addExtraCompiler(const VCFilterFile &info)
if (!tmp_dep.isEmpty()) if (!tmp_dep.isEmpty())
deps = tmp_dep; deps = tmp_dep;
if (!tmp_dep_cmd.isEmpty()) { if (!tmp_dep_cmd.isEmpty()) {
const QString dep_cd_cmd = QLatin1String("cd ") Project->callExtraCompilerDependCommand(extraCompilerName, tmp_dep_cmd,
+ IoUtils::shellQuote(Option::fixPathToLocalOS(Option::output_dir, false))
+ QLatin1String(" && ");
Project->callExtraCompilerDependCommand(extraCompilerName, dep_cd_cmd, tmp_dep_cmd,
inFile, out, inFile, out,
true, // dep_lines true, // dep_lines
&deps, &deps,

View File

@ -1481,36 +1481,20 @@ void VcprojGenerator::initResourceFiles()
// Bad hack, please look away ------------------------------------- // Bad hack, please look away -------------------------------------
QString rcc_dep_cmd = project->values("rcc.depend_command").join(' '); QString rcc_dep_cmd = project->values("rcc.depend_command").join(' ');
if(!rcc_dep_cmd.isEmpty()) { if(!rcc_dep_cmd.isEmpty()) {
ProStringList qrc_files = project->values("RESOURCES"); const QStringList qrc_files = project->values("RESOURCES").toQStringList();
QStringList deps; QStringList deps;
if(!qrc_files.isEmpty()) { for (const QString &qrc_file : qrc_files) {
for (int i = 0; i < qrc_files.count(); ++i) { callExtraCompilerDependCommand("rcc",
char buff[256]; rcc_dep_cmd,
QString dep_cmd = replaceExtraCompilerVariables( qrc_file,
rcc_dep_cmd, qrc_files.at(i).toQString(), QString(), LocalShell); QString(),
true, // dep_lines
dep_cmd = Option::fixPathToLocalOS(dep_cmd, true, false); &deps,
if(canExecute(dep_cmd)) { false, // existingDepsOnly
dep_cmd.prepend(QLatin1String("cd ") true // checkCommandavailability
+ IoUtils::shellQuote(Option::fixPathToLocalOS(Option::output_dir, false)) );
+ QLatin1String(" && "));
if (FILE *proc = QT_POPEN(dep_cmd.toLatin1().constData(), QT_POPEN_READ)) {
QString indeps;
while(!feof(proc)) {
int read_in = (int)fread(buff, 1, 255, proc);
if(!read_in)
break;
indeps += QByteArray(buff, read_in);
}
QT_PCLOSE(proc);
if(!indeps.isEmpty())
deps += fileFixify(indeps.replace('\n', ' ').simplified().split(' '),
FileFixifyFromOutdir);
}
}
}
vcProject.ResourceFiles.addFiles(deps);
} }
vcProject.ResourceFiles.addFiles(deps);
} }
// You may look again -------------------------------------------- // You may look again --------------------------------------------

View File

@ -92,7 +92,7 @@ QT_BEGIN_NAMESPACE
void QPropertyAnimationPrivate::updateMetaProperty() void QPropertyAnimationPrivate::updateMetaProperty()
{ {
if (!target || propertyName.isEmpty()) { if (!target || propertyName.isEmpty()) {
propertyType = QVariant::Invalid; propertyType = QMetaType::UnknownType;
propertyIndex = -1; propertyIndex = -1;
return; return;
} }
@ -102,11 +102,11 @@ void QPropertyAnimationPrivate::updateMetaProperty()
propertyType = targetValue->property(propertyName).userType(); propertyType = targetValue->property(propertyName).userType();
propertyIndex = targetValue->metaObject()->indexOfProperty(propertyName); propertyIndex = targetValue->metaObject()->indexOfProperty(propertyName);
if (propertyType != QVariant::Invalid) if (propertyType != QMetaType::UnknownType)
convertValues(propertyType); convertValues(propertyType);
if (propertyIndex == -1) { if (propertyIndex == -1) {
//there is no Q_PROPERTY on the object //there is no Q_PROPERTY on the object
propertyType = QVariant::Invalid; propertyType = QMetaType::UnknownType;
if (!targetValue->dynamicPropertyNames().contains(propertyName)) if (!targetValue->dynamicPropertyNames().contains(propertyName))
qWarning("QPropertyAnimation: you're trying to animate a non-existing property %s of your QObject", propertyName.constData()); qWarning("QPropertyAnimation: you're trying to animate a non-existing property %s of your QObject", propertyName.constData());
} else if (!targetValue->metaObject()->property(propertyIndex).isWritable()) { } else if (!targetValue->metaObject()->property(propertyIndex).isWritable()) {

View File

@ -61,6 +61,7 @@ Q_PROPERTY(type name
[USER bool] [USER bool]
[CONSTANT] [CONSTANT]
[FINAL]) [FINAL])
[REQUIRED]
//! [0] //! [0]

View File

@ -56,7 +56,7 @@ QApplication::sendEvent(mainWindow, &event);
//! [1] //! [1]
QPushButton *quitButton = new QPushButton("Quit"); QPushButton *quitButton = new QPushButton("Quit");
connect(quitButton, SIGNAL(clicked()), &app, SLOT(quit()), Qt::QueuedConnection); connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection);
//! [1] //! [1]
@ -79,12 +79,12 @@ Q_COREAPP_STARTUP_FUNCTION(preRoutineMyDebugTool)
//! [4] //! [4]
static int *global_ptr = 0; static int *global_ptr = nullptr;
static void cleanup_ptr() static void cleanup_ptr()
{ {
delete [] global_ptr; delete [] global_ptr;
global_ptr = 0; global_ptr = nullptr;
} }
void init_ptr() void init_ptr()
@ -125,9 +125,9 @@ private:
//! [6] //! [6]
static inline QString tr(const char *sourceText, static inline QString tr(const char *sourceText,
const char *comment = 0); const char *comment = nullptr);
static inline QString trUtf8(const char *sourceText, static inline QString trUtf8(const char *sourceText,
const char *comment = 0); const char *comment = nullptr);
//! [6] //! [6]

View File

@ -56,7 +56,7 @@ QState *s1 = new QState();
s1->assignProperty(&button, "text", "Click me"); s1->assignProperty(&button, "text", "Click me");
QFinalState *s2 = new QFinalState(); QFinalState *s2 = new QFinalState();
s1->addTransition(&button, SIGNAL(clicked()), s2); s1->addTransition(&button, &QPushButton::clicked, s2);
machine.addState(s1); machine.addState(s1);
machine.addState(s2); machine.addState(s2);

View File

@ -52,7 +52,7 @@
// Instantiate the objects and connect to the finished signal. // Instantiate the objects and connect to the finished signal.
MyClass myObject; MyClass myObject;
QFutureWatcher<int> watcher; QFutureWatcher<int> watcher;
connect(&watcher, SIGNAL(finished()), &myObject, SLOT(handleFinished())); connect(&watcher, QFutureWatcher<int>::finished, &myObject, &MyClass::handleFinished);
// Start the computation. // Start the computation.
QFuture<int> future = QtConcurrent::run(...); QFuture<int> future = QtConcurrent::run(...);

View File

@ -56,10 +56,10 @@ progressBar->setRange(0, 100);
// Construct a 1-second timeline with a frame range of 0 - 100 // Construct a 1-second timeline with a frame range of 0 - 100
QTimeLine *timeLine = new QTimeLine(1000, this); QTimeLine *timeLine = new QTimeLine(1000, this);
timeLine->setFrameRange(0, 100); 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 // Clicking the push button will start the progress bar animation
pushButton = new QPushButton(tr("Start animation"), this); pushButton = new QPushButton(tr("Start animation"), this);
connect(pushButton, SIGNAL(clicked()), timeLine, SLOT(start())); connect(pushButton, &QPushButton::clicked, timeLine, &QTimeLine::start);
... ...
//! [0] //! [0]

View File

@ -48,11 +48,10 @@
** **
****************************************************************************/ ****************************************************************************/
#include <QtGui>
#include <QtWidgets>
#include "buttonwidget.h" #include "buttonwidget.h"
#include <QtWidgets>
//! [0] //! [0]
ButtonWidget::ButtonWidget(const QStringList &texts, QWidget *parent) ButtonWidget::ButtonWidget(const QStringList &texts, QWidget *parent)
: QWidget(parent) : QWidget(parent)
@ -62,15 +61,16 @@ ButtonWidget::ButtonWidget(const QStringList &texts, QWidget *parent)
QGridLayout *gridLayout = new QGridLayout; QGridLayout *gridLayout = new QGridLayout;
for (int i = 0; i < texts.size(); ++i) { for (int i = 0; i < texts.size(); ++i) {
QPushButton *button = new QPushButton(texts[i]); QPushButton *button = new QPushButton(texts[i]);
connect(button, SIGNAL(clicked()), signalMapper, SLOT(map())); connect(button, &QPushButton::clicked,
signalMapper, &QSignalMapper::map);
//! [0] //! [1] //! [0] //! [1]
signalMapper->setMapping(button, texts[i]); signalMapper->setMapping(button, texts[i]);
gridLayout->addWidget(button, i / 3, i % 3); gridLayout->addWidget(button, i / 3, i % 3);
} }
connect(signalMapper, SIGNAL(mapped(QString)), connect(signalMapper, QOverload<const QString &>::of(&QSignalMapper::mapped),
//! [1] //! [2] //! [1] //! [2]
this, SIGNAL(clicked(QString))); this, &ButtonWidget::clicked);
setLayout(gridLayout); setLayout(gridLayout);
} }
@ -84,7 +84,7 @@ ButtonWidget::ButtonWidget(const QStringList &texts, QWidget *parent)
for (int i = 0; i < texts.size(); ++i) { for (int i = 0; i < texts.size(); ++i) {
QString text = texts[i]; QString text = texts[i];
QPushButton *button = new QPushButton(text); 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); gridLayout->addWidget(button, i / 3, i % 3);
} }
setLayout(gridLayout); setLayout(gridLayout);

View File

@ -51,7 +51,7 @@
#ifndef BUTTONWIDGET_H #ifndef BUTTONWIDGET_H
#define BUTTONWIDGET_H #define BUTTONWIDGET_H
#include <qwidget.h> #include <QWidget>
class QSignalMapper; class QSignalMapper;
class QString; class QString;
@ -63,7 +63,7 @@ class ButtonWidget : public QWidget
Q_OBJECT Q_OBJECT
public: public:
ButtonWidget(const QStringList &texts, QWidget *parent = 0); ButtonWidget(const QStringList &texts, QWidget *parent = nullptr);
signals: signals:
void clicked(const QString &text); void clicked(const QString &text);

View File

@ -68,10 +68,10 @@ MainWindow::MainWindow()
readSettings(); readSettings();
connect(textEdit->document(), SIGNAL(contentsChanged()), connect(textEdit->document(), &QTextEdit::contentsChanged,
this, SLOT(documentWasModified())); this, &QAction::documentWasModified);
setCurrentFile(""); setCurrentFile(QString());
setUnifiedTitleAndToolBarOnMac(true); setUnifiedTitleAndToolBarOnMac(true);
} }
//! [2] //! [2]
@ -95,7 +95,7 @@ void MainWindow::newFile()
{ {
if (maybeSave()) { if (maybeSave()) {
textEdit->clear(); textEdit->clear();
setCurrentFile(""); setCurrentFile(QString());
} }
} }
//! [6] //! [6]
@ -162,31 +162,31 @@ void MainWindow::createActions()
newAct = new QAction(QIcon(":/images/new.png"), tr("&New"), this); newAct = new QAction(QIcon(":/images/new.png"), tr("&New"), this);
newAct->setShortcuts(QKeySequence::New); newAct->setShortcuts(QKeySequence::New);
newAct->setStatusTip(tr("Create a new file")); newAct->setStatusTip(tr("Create a new file"));
connect(newAct, SIGNAL(triggered()), this, SLOT(newFile())); connect(newAct, &QAction::triggered, this, &MainWindow::newFile);
//! [19] //! [19]
openAct = new QAction(QIcon(":/images/open.png"), tr("&Open..."), this); openAct = new QAction(QIcon(":/images/open.png"), tr("&Open..."), this);
openAct->setShortcuts(QKeySequence::Open); openAct->setShortcuts(QKeySequence::Open);
openAct->setStatusTip(tr("Open an existing file")); openAct->setStatusTip(tr("Open an existing file"));
connect(openAct, SIGNAL(triggered()), this, SLOT(open())); connect(openAct, &QAction::triggered, this, &MainWindow::open);
//! [18] //! [19] //! [18] //! [19]
saveAct = new QAction(QIcon(":/images/save.png"), tr("&Save"), this); saveAct = new QAction(QIcon(":/images/save.png"), tr("&Save"), this);
saveAct->setShortcuts(QKeySequence::Save); saveAct->setShortcuts(QKeySequence::Save);
saveAct->setStatusTip(tr("Save the document to disk")); 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 = new QAction(tr("Save &As..."), this);
saveAsAct->setShortcuts(QKeySequence::SaveAs); saveAsAct->setShortcuts(QKeySequence::SaveAs);
saveAsAct->setStatusTip(tr("Save the document under a new name")); 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] //! [20]
exitAct = new QAction(tr("E&xit"), this); exitAct = new QAction(tr("E&xit"), this);
exitAct->setShortcuts(QKeySequence::Quit); exitAct->setShortcuts(QKeySequence::Quit);
//! [20] //! [20]
exitAct->setStatusTip(tr("Exit the application")); exitAct->setStatusTip(tr("Exit the application"));
connect(exitAct, SIGNAL(triggered()), this, SLOT(close())); connect(exitAct, &QAction::triggered, this, &MainWindow::close);
//! [21] //! [21]
cutAct = new QAction(QIcon(":/images/cut.png"), tr("Cu&t"), this); cutAct = new QAction(QIcon(":/images/cut.png"), tr("Cu&t"), this);
@ -194,38 +194,38 @@ void MainWindow::createActions()
cutAct->setShortcuts(QKeySequence::Cut); cutAct->setShortcuts(QKeySequence::Cut);
cutAct->setStatusTip(tr("Cut the current selection's contents to the " cutAct->setStatusTip(tr("Cut the current selection's contents to the "
"clipboard")); "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 = new QAction(QIcon(":/images/copy.png"), tr("&Copy"), this);
copyAct->setShortcuts(QKeySequence::Copy); copyAct->setShortcuts(QKeySequence::Copy);
copyAct->setStatusTip(tr("Copy the current selection's contents to the " copyAct->setStatusTip(tr("Copy the current selection's contents to the "
"clipboard")); "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 = new QAction(QIcon(":/images/paste.png"), tr("&Paste"), this);
pasteAct->setShortcuts(QKeySequence::Paste); pasteAct->setShortcuts(QKeySequence::Paste);
pasteAct->setStatusTip(tr("Paste the clipboard's contents into the current " pasteAct->setStatusTip(tr("Paste the clipboard's contents into the current "
"selection")); "selection"));
connect(pasteAct, SIGNAL(triggered()), textEdit, SLOT(paste())); connect(pasteAct, &QAction::triggered, textEdit, &QTextEdit::paste);
aboutAct = new QAction(tr("&About"), this); aboutAct = new QAction(tr("&About"), this);
aboutAct->setStatusTip(tr("Show the application's About box")); aboutAct->setStatusTip(tr("Show the application's About box"));
connect(aboutAct, SIGNAL(triggered()), this, SLOT(about())); connect(aboutAct, &QAction::triggered, this, &MainWindow::about);
//! [22] //! [22]
aboutQtAct = new QAction(tr("About &Qt"), this); aboutQtAct = new QAction(tr("About &Qt"), this);
aboutQtAct->setStatusTip(tr("Show the Qt library's About box")); 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] //! [22]
//! [23] //! [23]
cutAct->setEnabled(false); cutAct->setEnabled(false);
//! [23] //! [24] //! [23] //! [24]
copyAct->setEnabled(false); copyAct->setEnabled(false);
connect(textEdit, SIGNAL(copyAvailable(bool)), connect(textEdit, &QTextEdit::copyAvailable,
cutAct, SLOT(setEnabled(bool))); cutAct, &QAction::setEnabled);
connect(textEdit, SIGNAL(copyAvailable(bool)), connect(textEdit, &QTextEdit::copyAvailable,
copyAct, SLOT(setEnabled(bool))); copyAct, &QAction::setEnabled);
} }
//! [24] //! [24]

View File

@ -48,13 +48,14 @@
** **
****************************************************************************/ ****************************************************************************/
#include <QtGui> #include <QtWidgets>
int main(int argv, char **args) int main(int argv, char **args)
{ {
QApplication app(argv, args); QApplication app(argv, args);
QLabel *label = new QLabel; QLabel *label = new QLabel;
QPushButton *button = new QPushButton;
//![0] //![0]
QStateMachine machine; QStateMachine machine;
@ -70,14 +71,14 @@ int main(int argv, char **args)
//![4] //![4]
//![5] //![5]
QObject::connect(s3, SIGNAL(entered()), button, SLOT(showMaximized())); QObject::connect(s3, &QState::entered, button, &QPushButton:showMaximized);
QObject::connect(s3, SIGNAL(exited()), button, SLOT(showMinimized())); QObject::connect(s3, &QState::exited, button, &QPushButton::showMinimized);
//![5] //![5]
//![1] //![1]
s1->addTransition(button, SIGNAL(clicked()), s2); s1->addTransition(button, &QPushButton::clicked, s2);
s2->addTransition(button, SIGNAL(clicked()), s3); s2->addTransition(button, &QPushButton::clicked, s3);
s3->addTransition(button, SIGNAL(clicked()), s1); s3->addTransition(button, &QPushButton::clicked, s1);
//![1] //![1]
//![2] //![2]

View File

@ -48,11 +48,11 @@
** **
****************************************************************************/ ****************************************************************************/
#include <QtGui> #include <QtWidgets>
int main(int argv, char **args) int main(int argv, char **args)
{ {
QApplication app(argv, args); QApplication app(argv, args);
QStateMachine machine; QStateMachine machine;
@ -66,16 +66,17 @@ int main(int argv, char **args)
//![0] //![0]
//![2] //![2]
s12->addTransition(quitButton, SIGNAL(clicked()), s12); s12->addTransition(quitButton, &QPushButton::clicked, s12);
//![2] //![2]
//![1] //![1]
QFinalState *s2 = new QFinalState(); QFinalState *s2 = new QFinalState();
s1->addTransition(quitButton, SIGNAL(clicked()), s2); s1->addTransition(quitButton, &QPushButton::clicked, s2);
machine.addState(s2); machine.addState(s2);
machine.setInitialState(s1); machine.setInitialState(s1);
QObject::connect(&machine, SIGNAL(finished()), QApplication::instance(), SLOT(quit())); QObject::connect(&machine, &QStateMachine::finished,
QCoreApplication::instance(), &QCoreApplication::quit);
//![1] //![1]
QButton *interruptButton = new QPushButton("Interrupt Button"); QButton *interruptButton = new QPushButton("Interrupt Button");
@ -90,11 +91,11 @@ int main(int argv, char **args)
mbox->addButton(QMessageBox::Ok); mbox->addButton(QMessageBox::Ok);
mbox->setText("Interrupted!"); mbox->setText("Interrupted!");
mbox->setIcon(QMessageBox::Information); mbox->setIcon(QMessageBox::Information);
QObject::connect(s3, SIGNAL(entered()), mbox, SLOT(exec())); QObject::connect(s3, &QState::entered, mbox, &QMessageBox::exec);
s3->addTransition(s1h); s3->addTransition(s1h);
machine.addState(s3); machine.addState(s3);
s1->addTransition(interruptButton, SIGNAL(clicked()), s3); s1->addTransition(interruptButton, &QPushButton::clicked, s3);
//![3] //![3]
return app.exec(); return app.exec();

View File

@ -62,7 +62,7 @@ int main(int argv, char **args)
//![0] //![0]
//![1] //![1]
s1->addTransition(s1, SIGNAL(finished()), s2); s1->addTransition(s1, &QState::finished, s2);
//![1] //![1]
return app.exec(); return app.exec();

View File

@ -98,7 +98,7 @@ int main(int argv, char **args)
s1->assignProperty(button, "geometry", QRectF(0, 0, 50, 50)); s1->assignProperty(button, "geometry", QRectF(0, 0, 50, 50));
s2->assignProperty(button, "geometry", QRectF(0, 0, 100, 100)); s2->assignProperty(button, "geometry", QRectF(0, 0, 100, 100));
s1->addTransition(button, SIGNAL(clicked()), s2); s1->addTransition(button, &QPushButton::clicked, s2);
//![3] //![3]
} }
@ -111,7 +111,7 @@ int main(int argv, char **args)
s1->assignProperty(button, "geometry", QRectF(0, 0, 50, 50)); s1->assignProperty(button, "geometry", QRectF(0, 0, 50, 50));
s2->assignProperty(button, "geometry", QRectF(0, 0, 100, 100)); 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")); transition->addAnimation(new QPropertyAnimation(button, "geometry"));
//![4] //![4]
@ -130,9 +130,9 @@ int main(int argv, char **args)
QState *s2 = new QState(); QState *s2 = new QState();
s2->assignProperty(button, "geometry", QRectF(0, 0, 50, 50)); 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] //![5]
} }
@ -151,10 +151,10 @@ int main(int argv, char **args)
s2->assignProperty(button, "geometry", QRectF(0, 0, 50, 50)); s2->assignProperty(button, "geometry", QRectF(0, 0, 50, 50));
QState *s3 = new QState(); QState *s3 = new QState();
connect(s3, SIGNAL(entered()), messageBox, SLOT(exec())); connect(s3, &QState::entered, messageBox, SLOT(exec()));
s1->addTransition(button, SIGNAL(clicked()), s2); s1->addTransition(button, &QPushButton::clicked, s2);
s2->addTransition(s2, SIGNAL(propertiesAssigned()), s3); s2->addTransition(s2, &QState::propertiesAssigned, s3);
//![6] //![6]
} }

View File

@ -61,7 +61,7 @@ AnalogClock::AnalogClock(QWidget *parent)
//! [3] //! [4] //! [3] //! [4]
QTimer *timer = new QTimer(this); QTimer *timer = new QTimer(this);
//! [4] //! [5] //! [4] //! [5]
connect(timer, SIGNAL(timeout()), this, SLOT(update())); connect(timer, &QTimer::timeout, this, QOverload<>::of(&AnalogClock::update));
//! [5] //! [6] //! [5] //! [6]
timer->start(1000); timer->start(1000);
//! [6] //! [6]

View File

@ -61,13 +61,13 @@ Foo::Foo()
//! [0] //! [0]
QTimer *timer = new QTimer(this); QTimer *timer = new QTimer(this);
//! [0] //! [1] //! [0] //! [1]
connect(timer, SIGNAL(timeout()), this, SLOT(updateCaption())); connect(timer, &QTimer::timeout, this, &Foo::updateCaption);
//! [1] //! [2] //! [1] //! [2]
timer->start(1000); timer->start(1000);
//! [2] //! [2]
//! [3] //! [3]
QTimer::singleShot(200, this, SLOT(updateCaption())); QTimer::singleShot(200, this, &Foo::updateCaption);
//! [3] //! [3]
{ {
@ -75,7 +75,7 @@ Foo::Foo()
//! [4] //! [4]
QTimer *timer = new QTimer(this); QTimer *timer = new QTimer(this);
//! [4] //! [5] //! [4] //! [5]
connect(timer, SIGNAL(timeout()), this, SLOT(processOneThing())); connect(timer, &QTimer::timeout, this, &Foo::processOneThing);
//! [5] //! [6] //! [5] //! [6]
timer->start(); timer->start();
//! [6] //! [6]

View File

@ -356,11 +356,11 @@
state2->assignProperty(button, "geometry", QRect(250, 250, 100, 30)); state2->assignProperty(button, "geometry", QRect(250, 250, 100, 30));
QSignalTransition *transition1 = state1->addTransition(button, QSignalTransition *transition1 = state1->addTransition(button,
SIGNAL(clicked()), state2); &QPushButton::clicked, state2);
transition1->addAnimation(new QPropertyAnimation(button, "geometry")); transition1->addAnimation(new QPropertyAnimation(button, "geometry"));
QSignalTransition *transition2 = state2->addTransition(button, QSignalTransition *transition2 = state2->addTransition(button,
SIGNAL(clicked()), state1); &QPushButton::clicked, state1);
transition2->addAnimation(new QPropertyAnimation(button, "geometry")); transition2->addAnimation(new QPropertyAnimation(button, "geometry"));
machine->start(); machine->start();

View File

@ -144,6 +144,12 @@
optimizations in some cases, but is not enforced by moc. Care must be taken optimizations in some cases, but is not enforced by moc. Care must be taken
never to override a \c FINAL property. 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 \endlist
The \c READ, \c WRITE, and \c RESET functions can be inherited. The \c READ, \c WRITE, and \c RESET functions can be inherited.

View File

@ -323,12 +323,12 @@
QState *s1 = new QState(&machine); QState *s1 = new QState(&machine);
QPushButton button; QPushButton button;
QSignalTransition *trans = new QSignalTransition(&button, SIGNAL(clicked())); QSignalTransition *trans = new QSignalTransition(&button, &QPushButton::clicked);
s1->addTransition(trans); s1->addTransition(trans);
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setText("The button was clicked; carry on."); 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); machine.setInitialState(s1);
\endcode \endcode

View File

@ -702,7 +702,7 @@ Q_STATIC_ASSERT((std::is_same<qsizetype, qptrdiff>::value));
64-bit integer literals in a platform-independent way. The 64-bit integer literals in a platform-independent way. The
Q_CHECK_PTR() macro prints a warning containing the source code's Q_CHECK_PTR() macro prints a warning containing the source code's
file name and line number, saying that the program ran out of 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. macros represent an easy way of printing text.
The QT_POINTER_SIZE macro expands to the size of a pointer in bytes. 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) \macro void Q_CHECK_PTR(void *pointer)
\relates <QtGlobal> \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 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 of memory and aborts program execution. It throws \c std::bad_alloc instead
if exceptions are enabled. if exceptions are enabled.

View File

@ -534,8 +534,25 @@ static QString getRelocatablePrefix()
#if defined(QT_STATIC) #if defined(QT_STATIC)
prefixPath = prefixFromAppDirHelper(); prefixPath = prefixFromAppDirHelper();
#elif defined(Q_OS_DARWIN) && QT_CONFIG(framework) #elif defined(Q_OS_DARWIN) && QT_CONFIG(framework)
CFBundleRef qtCoreBundle = CFBundleGetBundleWithIdentifier( auto qtCoreBundle = CFBundleGetBundleWithIdentifier(CFSTR("org.qt-project.QtCore"));
CFSTR("org.qt-project.QtCore")); if (!qtCoreBundle) {
// When running Qt apps over Samba shares, CoreFoundation will fail to find
// the Resources directory inside the bundle, This directory is a symlink,
// and CF relies on readdir() and dtent.dt_type to detect symlinks, which
// does not work reliably for Samba shares. We work around it by manually
// looking for the QtCore bundle.
auto allBundles = CFBundleGetAllBundles();
auto bundleCount = CFArrayGetCount(allBundles);
for (int i = 0; i < bundleCount; ++i) {
auto bundle = CFBundleRef(CFArrayGetValueAtIndex(allBundles, i));
auto url = QCFType<CFURLRef>(CFBundleCopyBundleURL(bundle));
auto path = QCFType<CFStringRef>(CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle));
if (CFStringHasSuffix(path, CFSTR("/QtCore.framework"))) {
qtCoreBundle = bundle;
break;
}
}
}
Q_ASSERT(qtCoreBundle); Q_ASSERT(qtCoreBundle);
QCFType<CFURLRef> qtCorePath = CFBundleCopyBundleURL(qtCoreBundle); QCFType<CFURLRef> qtCorePath = CFBundleCopyBundleURL(qtCoreBundle);

View File

@ -1749,6 +1749,9 @@ namespace Qt {
PassThrough PassThrough
}; };
// QTBUG-48701
enum ReturnByValue_t { ReturnByValue }; // ### Qt 7: Remove me
#ifndef Q_QDOC #ifndef Q_QDOC
// NOTE: Generally, do not add Q_ENUM_NS if a corresponding Q_FLAG_NS exists. // NOTE: Generally, do not add Q_ENUM_NS if a corresponding Q_FLAG_NS exists.
Q_ENUM_NS(ScrollBarPolicy) Q_ENUM_NS(ScrollBarPolicy)

View File

@ -1023,7 +1023,7 @@
\value WA_MacNoClickThrough This value is obsolete and has no effect. \value WA_MacNoClickThrough This value is obsolete and has no effect.
\value WA_MacOpaqueSizeGrip Indicates that the native Carbon size grip \value WA_MacOpaqueSizeGrip Indicates that the native size grip
should be opaque instead of transparent (the default). This attribute should be opaque instead of transparent (the default). This attribute
is only applicable to \macos and is set by the widget's author. is only applicable to \macos and is set by the widget's author.
@ -3319,3 +3319,15 @@
\value RoundPreferFloor Round up for .75 and above. \value RoundPreferFloor Round up for .75 and above.
\value PassThrough Don't round. \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()
*/

View File

@ -227,7 +227,7 @@ QBuffer::~QBuffer()
\snippet buffer/buffer.cpp 4 \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. QByteArray to work on. This byte array is initially empty.
\sa buffer(), setData(), open() \sa buffer(), setData(), open()

View File

@ -1829,7 +1829,7 @@ QByteArray QIODevicePrivate::peek(qint64 maxSize)
/*! \fn bool QIODevice::getChar(char *c) /*! \fn bool QIODevice::getChar(char *c)
Reads one character from the device and stores it in \a c. If \a 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. otherwise returns \c false.
\sa read(), putChar(), ungetChar() \sa read(), putChar(), ungetChar()

View File

@ -810,16 +810,6 @@ void QProcessPrivate::Channel::clear()
\a newState argument is the state QProcess changed to. \a newState argument is the state QProcess changed to.
*/ */
#if QT_DEPRECATED_SINCE(5, 13)
/*!
\fn void QProcess::finished(int exitCode)
\obsolete
\overload
Use finished(int exitCode, QProcess::ExitStatus status) instead.
*/
#endif
/*! /*!
\fn void QProcess::finished(int exitCode, QProcess::ExitStatus exitStatus) \fn void QProcess::finished(int exitCode, QProcess::ExitStatus exitStatus)
@ -1175,12 +1165,6 @@ bool QProcessPrivate::_q_processDied()
//emit q->standardOutputClosed(); //emit q->standardOutputClosed();
//emit q->standardErrorClosed(); //emit q->standardErrorClosed();
#if QT_DEPRECATED_SINCE(5, 13)
QT_WARNING_PUSH
QT_WARNING_DISABLE_DEPRECATED
emit q->finished(exitCode);
QT_WARNING_POP
#endif
emit q->finished(exitCode, exitStatus); emit q->finished(exitCode, exitStatus);
} }
#if defined QPROCESS_DEBUG #if defined QPROCESS_DEBUG

View File

@ -273,11 +273,7 @@ public Q_SLOTS:
Q_SIGNALS: Q_SIGNALS:
void started(QPrivateSignal); void started(QPrivateSignal);
#if QT_DEPRECATED_SINCE(5, 13) void finished(int exitCode, QProcess::ExitStatus exitStatus = NormalExit);
QT_DEPRECATED_X("Use QProcess::finished(int, QProcess::ExitStatus) instead")
void finished(int exitCode); // ### Qt 6: merge the two signals with a default value
#endif
void finished(int exitCode, QProcess::ExitStatus exitStatus);
#if QT_DEPRECATED_SINCE(5, 6) #if QT_DEPRECATED_SINCE(5, 6)
QT_DEPRECATED_X("Use QProcess::errorOccurred(QProcess::ProcessError) instead") QT_DEPRECATED_X("Use QProcess::errorOccurred(QProcess::ProcessError) instead")
void error(QProcess::ProcessError error); void error(QProcess::ProcessError error);

View File

@ -1,6 +1,6 @@
/**************************************************************************** /****************************************************************************
** **
** Copyright (C) 2016 The Qt Company Ltd. ** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/ ** Contact: https://www.qt.io/licensing/
** **
** This file is part of the QtCore module of the Qt Toolkit. ** This file is part of the QtCore module of the Qt Toolkit.
@ -396,12 +396,12 @@ QString QSettingsPrivate::variantToString(const QVariant &v)
{ {
QString result; QString result;
switch (v.type()) { switch (v.userType()) {
case QVariant::Invalid: case QMetaType::UnknownType:
result = QLatin1String("@Invalid()"); result = QLatin1String("@Invalid()");
break; break;
case QVariant::ByteArray: { case QMetaType::QByteArray: {
QByteArray a = v.toByteArray(); QByteArray a = v.toByteArray();
result = QLatin1String("@ByteArray(") result = QLatin1String("@ByteArray(")
+ QLatin1String(a.constData(), a.size()) + QLatin1String(a.constData(), a.size())
@ -409,17 +409,16 @@ QString QSettingsPrivate::variantToString(const QVariant &v)
break; 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) #if QT_CONFIG(shortcut)
case QVariant::KeySequence: case QMetaType::QKeySequence:
#endif #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(); result = v.toString();
if (result.contains(QChar::Null)) if (result.contains(QChar::Null))
result = QLatin1String("@String(") + result + QLatin1Char(')'); result = QLatin1String("@String(") + result + QLatin1Char(')');
@ -428,17 +427,17 @@ QString QSettingsPrivate::variantToString(const QVariant &v)
break; break;
} }
#ifndef QT_NO_GEOM_VARIANT #ifndef QT_NO_GEOM_VARIANT
case QVariant::Rect: { case QMetaType::QRect: {
QRect r = qvariant_cast<QRect>(v); QRect r = qvariant_cast<QRect>(v);
result = QString::asprintf("@Rect(%d %d %d %d)", r.x(), r.y(), r.width(), r.height()); result = QString::asprintf("@Rect(%d %d %d %d)", r.x(), r.y(), r.width(), r.height());
break; break;
} }
case QVariant::Size: { case QMetaType::QSize: {
QSize s = qvariant_cast<QSize>(v); QSize s = qvariant_cast<QSize>(v);
result = QString::asprintf("@Size(%d %d)", s.width(), s.height()); result = QString::asprintf("@Size(%d %d)", s.width(), s.height());
break; break;
} }
case QVariant::Point: { case QMetaType::QPoint: {
QPoint p = qvariant_cast<QPoint>(v); QPoint p = qvariant_cast<QPoint>(v);
result = QString::asprintf("@Point(%d %d)", p.x(), p.y()); result = QString::asprintf("@Point(%d %d)", p.x(), p.y());
break; break;
@ -449,7 +448,7 @@ QString QSettingsPrivate::variantToString(const QVariant &v)
#ifndef QT_NO_DATASTREAM #ifndef QT_NO_DATASTREAM
QDataStream::Version version; QDataStream::Version version;
const char *typeSpec; const char *typeSpec;
if (v.type() == QVariant::DateTime) { if (v.userType() == QMetaType::QDateTime) {
version = QDataStream::Qt_5_6; version = QDataStream::Qt_5_6;
typeSpec = "@DateTime("; typeSpec = "@DateTime(";
} else { } else {
@ -1891,8 +1890,8 @@ bool QConfFileSettingsPrivate::writeIniFile(QIODevice &device, const ParsedSetti
QVariant(QString("foo")).toList() returns an empty QVariant(QString("foo")).toList() returns an empty
list, not a list containing "foo". list, not a list containing "foo".
*/ */
if (value.type() == QVariant::StringList if (value.userType() == QMetaType::QStringList
|| (value.type() == QVariant::List && value.toList().size() != 1)) { || (value.userType() == QMetaType::QVariantList && value.toList().size() != 1)) {
iniEscapedStringList(variantListToStringList(value.toList()), block, iniCodec); iniEscapedStringList(variantListToStringList(value.toList()), block, iniCodec);
} else { } else {
iniEscapedString(variantToString(value), block, iniCodec); iniEscapedString(variantToString(value), block, iniCodec);

View File

@ -552,32 +552,32 @@ const QHash<int,QByteArray> &QAbstractItemModelPrivate::defaultRoleNames()
bool QAbstractItemModelPrivate::isVariantLessThan(const QVariant &left, const QVariant &right, bool QAbstractItemModelPrivate::isVariantLessThan(const QVariant &left, const QVariant &right,
Qt::CaseSensitivity cs, bool isLocaleAware) Qt::CaseSensitivity cs, bool isLocaleAware)
{ {
if (left.userType() == QVariant::Invalid) if (left.userType() == QMetaType::UnknownType)
return false; return false;
if (right.userType() == QVariant::Invalid) if (right.userType() == QMetaType::UnknownType)
return true; return true;
switch (left.userType()) { switch (left.userType()) {
case QVariant::Int: case QMetaType::Int:
return left.toInt() < right.toInt(); return left.toInt() < right.toInt();
case QVariant::UInt: case QMetaType::UInt:
return left.toUInt() < right.toUInt(); return left.toUInt() < right.toUInt();
case QVariant::LongLong: case QMetaType::LongLong:
return left.toLongLong() < right.toLongLong(); return left.toLongLong() < right.toLongLong();
case QVariant::ULongLong: case QMetaType::ULongLong:
return left.toULongLong() < right.toULongLong(); return left.toULongLong() < right.toULongLong();
case QMetaType::Float: case QMetaType::Float:
return left.toFloat() < right.toFloat(); return left.toFloat() < right.toFloat();
case QVariant::Double: case QMetaType::Double:
return left.toDouble() < right.toDouble(); return left.toDouble() < right.toDouble();
case QVariant::Char: case QMetaType::QChar:
return left.toChar() < right.toChar(); return left.toChar() < right.toChar();
case QVariant::Date: case QMetaType::QDate:
return left.toDate() < right.toDate(); return left.toDate() < right.toDate();
case QVariant::Time: case QMetaType::QTime:
return left.toTime() < right.toTime(); return left.toTime() < right.toTime();
case QVariant::DateTime: case QMetaType::QDateTime:
return left.toDateTime() < right.toDateTime(); return left.toDateTime() < right.toDateTime();
case QVariant::String: case QMetaType::QString:
default: default:
if (isLocaleAware) if (isLocaleAware)
return left.toString().localeAwareCompare(right.toString()) < 0; 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 //return 0 for integer, 1 for floating point and 2 for other
switch (value.userType()) { switch (value.userType()) {
case QVariant::Bool: case QMetaType::Bool:
case QVariant::Int: case QMetaType::Int:
case QVariant::UInt: case QMetaType::UInt:
case QVariant::LongLong: case QMetaType::LongLong:
case QVariant::ULongLong: case QMetaType::ULongLong:
case QVariant::Char: case QMetaType::QChar:
case QMetaType::Short: case QMetaType::Short:
case QMetaType::UShort: case QMetaType::UShort:
case QMetaType::UChar: case QMetaType::UChar:
case QMetaType::ULong: case QMetaType::ULong:
case QMetaType::Long: case QMetaType::Long:
return 0; return 0;
case QVariant::Double: case QMetaType::Double:
case QMetaType::Float: case QMetaType::Float:
return 1; return 1;
default: default:
@ -2374,7 +2374,7 @@ QModelIndexList QAbstractItemModel::match(const QModelIndex &start, int role,
} else { // QString or regular expression based matching } else { // QString or regular expression based matching
if (matchType == Qt::MatchRegularExpression) { if (matchType == Qt::MatchRegularExpression) {
if (rx.pattern().isEmpty()) { if (rx.pattern().isEmpty()) {
if (value.type() == QVariant::RegularExpression) { if (value.userType() == QMetaType::QRegularExpression) {
rx = value.toRegularExpression(); rx = value.toRegularExpression();
} else { } else {
rx.setPattern(value.toString()); rx.setPattern(value.toString());

View File

@ -160,7 +160,7 @@ QAbstractEventDispatcher::~QAbstractEventDispatcher()
/*! /*!
Returns a pointer to the event dispatcher object for the specified 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 event dispatcher exists for the specified thread, this function
returns \nullptr. returns \nullptr.

View File

@ -603,7 +603,7 @@ static bool methodMatch(const QMetaObject *m, int handle,
* \internal * \internal
* helper function for indexOf{Method,Slot,Signal}, returns the relative index of the method within * helper function for indexOf{Method,Slot,Signal}, returns the relative index of the method within
* the baseObject * 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> template<int MethodType>
static inline int indexOfMethodRelative(const QMetaObject **baseObject, static inline int indexOfMethodRelative(const QMetaObject **baseObject,
@ -737,7 +737,7 @@ int QMetaObject::indexOfSignal(const char *signal) const
\internal \internal
Same as QMetaObject::indexOfSignal, but the result is the local offset to the base object. 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, int QMetaObjectPrivate::indexOfSignalRelative(const QMetaObject **baseObject,
const QByteArray &name, int argc, const QByteArray &name, int argc,
@ -2988,7 +2988,7 @@ int QMetaProperty::userType() const
if (type == QMetaType::UnknownType) { if (type == QMetaType::UnknownType) {
type = registerPropertyType(); type = registerPropertyType();
if (type == QMetaType::UnknownType) if (type == QMetaType::UnknownType)
return QVariant::Int; // Match behavior of QMetaType::type() return QMetaType::Int; // Match behavior of QMetaType::type()
} }
return type; return type;
} }
@ -3106,7 +3106,7 @@ QVariant QMetaProperty::read(const QObject *object) const
if (!object || !mobj) if (!object || !mobj)
return QVariant(); return QVariant();
uint t = QVariant::Int; uint t = QMetaType::Int;
if (isEnumType()) { if (isEnumType()) {
/* /*
try to create a QVariant that can be converted to this enum 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; return false;
QVariant v = value; QVariant v = value;
uint t = QVariant::Invalid; uint t = QMetaType::UnknownType;
if (isEnumType()) { if (isEnumType()) {
if (v.type() == QVariant::String) { if (v.userType() == QMetaType::QString) {
bool ok; bool ok;
if (isFlagType()) if (isFlagType())
v = QVariant(menum.keysToValue(value.toByteArray(), &ok)); 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)); v = QVariant(menum.keyToValue(value.toByteArray(), &ok));
if (!ok) if (!ok)
return false; 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)); int enumMetaTypeId = QMetaType::type(qualifiedName(menum));
if ((enumMetaTypeId == QMetaType::UnknownType) || (v.userType() != enumMetaTypeId) || !v.constData()) if ((enumMetaTypeId == QMetaType::UnknownType) || (v.userType() != enumMetaTypeId) || !v.constData())
return false; return false;
v = QVariant(*reinterpret_cast<const int *>(v.constData())); v = QVariant(*reinterpret_cast<const int *>(v.constData()));
} }
v.convert(QVariant::Int); v.convert(QMetaType::Int);
} else { } else {
int handle = priv(mobj->d.data)->propertyData + 3*idx; int handle = priv(mobj->d.data)->propertyData + 3*idx;
const char *typeName = nullptr; const char *typeName = nullptr;
@ -3578,6 +3578,21 @@ bool QMetaProperty::isFinal() const
return flags & Final; return flags & Final;
} }
/*!
\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 \obsolete

View File

@ -263,6 +263,7 @@ public:
bool isUser(const QObject *obj = nullptr) const; bool isUser(const QObject *obj = nullptr) const;
bool isConstant() const; bool isConstant() const;
bool isFinal() const; bool isFinal() const;
bool isRequired() const;
bool isFlagType() const; bool isFlagType() const;
bool isEnumType() const; bool isEnumType() const;

View File

@ -85,7 +85,8 @@ enum PropertyFlags {
User = 0x00100000, User = 0x00100000,
ResolveUser = 0x00200000, ResolveUser = 0x00200000,
Notify = 0x00400000, Notify = 0x00400000,
Revisioned = 0x00800000 Revisioned = 0x00800000,
Required = 0x01000000,
}; };
enum MethodFlags { enum MethodFlags {

View File

@ -254,6 +254,7 @@ struct DefinedTypesFilter {
\value QPolygon QPolygon \value QPolygon QPolygon
\value QPolygonF QPolygonF \value QPolygonF QPolygonF
\value QColor QColor \value QColor QColor
\value QColorSpace QColorSpace
\value QSizeF QSizeF \value QSizeF QSizeF
\value QRectF QRectF \value QRectF QRectF
\value QLine QLine \value QLine QLine
@ -458,7 +459,7 @@ struct DefinedTypesFilter {
\deprecated \deprecated
Constructs a value of the given type which is a copy of \a copy. 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, Deprecated, use the static function QMetaType::create(int type,
const void *copy) instead. const void *copy) instead.

View File

@ -182,6 +182,7 @@ inline Q_DECL_CONSTEXPR int qMetaTypeId();
F(QVector4D, 84, QVector4D) \ F(QVector4D, 84, QVector4D) \
F(QQuaternion, 85, QQuaternion) \ F(QQuaternion, 85, QQuaternion) \
F(QPolygonF, 86, QPolygonF) \ F(QPolygonF, 86, QPolygonF) \
F(QColorSpace, 87, QColorSpace) \
#define QT_FOR_EACH_STATIC_WIDGETS_CLASS(F)\ #define QT_FOR_EACH_STATIC_WIDGETS_CLASS(F)\
@ -440,7 +441,7 @@ public:
FirstCoreType = Bool, FirstCoreType = Bool,
LastCoreType = QCborMap, LastCoreType = QCborMap,
FirstGuiType = QFont, FirstGuiType = QFont,
LastGuiType = QPolygonF, LastGuiType = QColorSpace,
FirstWidgetsType = QSizePolicy, FirstWidgetsType = QSizePolicy,
LastWidgetsType = QSizePolicy, LastWidgetsType = QSizePolicy,
HighestInternalId = LastWidgetsType, HighestInternalId = LastWidgetsType,
@ -475,12 +476,12 @@ public:
QIcon = 69, QImage = 70, QPolygon = 71, QRegion = 72, QBitmap = 73, QIcon = 69, QImage = 70, QPolygon = 71, QRegion = 72, QBitmap = 73,
QCursor = 74, QKeySequence = 75, QPen = 76, QTextLength = 77, QTextFormat = 78, QCursor = 74, QKeySequence = 75, QPen = 76, QTextLength = 77, QTextFormat = 78,
QMatrix = 79, QTransform = 80, QMatrix4x4 = 81, QVector2D = 82, 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 // Widget types
QSizePolicy = 121, QSizePolicy = 121,
LastCoreType = QCborMap, LastCoreType = QCborMap,
LastGuiType = QPolygonF, LastGuiType = QColorSpace,
User = 1024 User = 1024
}; };
#endif #endif

View File

@ -70,7 +70,7 @@ public:
void setData(const QString &format, const QVariant &data); void setData(const QString &format, const QVariant &data);
QVariant getData(const QString &format) const; 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; QVector<QMimeDataStruct> dataList;
}; };
@ -108,23 +108,23 @@ QVariant QMimeDataPrivate::getData(const QString &format) const
return data; 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); 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 // Text data requested: fallback to URL data if available
if (format == QLatin1String("text/plain") && !data.isValid()) { if (format == QLatin1String("text/plain") && !data.isValid()) {
data = retrieveTypedData(textUriListLiteral(), QVariant::List); data = retrieveTypedData(textUriListLiteral(), QMetaType::QVariantList);
if (data.type() == QVariant::Url) { if (data.userType() == QMetaType::QUrl) {
data = QVariant(data.toUrl().toDisplayString()); data = QVariant(data.toUrl().toDisplayString());
} else if (data.type() == QVariant::List) { } else if (data.userType() == QMetaType::QVariantList) {
QString text; QString text;
int numUrls = 0; int numUrls = 0;
const QList<QVariant> list = data.toList(); const QList<QVariant> list = data.toList();
for (int i = 0; i < list.size(); ++i) { 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'); text += list.at(i).toUrl().toDisplayString() + QLatin1Char('\n');
++numUrls; ++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; return data;
// provide more conversion possiblities than just what QVariant provides // provide more conversion possiblities than just what QVariant provides
// URLs can be lists as well... // URLs can be lists as well...
if ((type == QVariant::Url && data.type() == QVariant::List) if ((type == QMetaType::QUrl && data.userType() == QMetaType::QVariantList)
|| (type == QVariant::List && data.type() == QVariant::Url)) || (type == QMetaType::QVariantList && data.userType() == QMetaType::QUrl))
return data; return data;
// images and pixmaps are interchangeable // images and pixmaps are interchangeable
if ((type == QVariant::Pixmap && data.type() == QVariant::Image) if ((type == QMetaType::QPixmap && data.userType() == QMetaType::QImage)
|| (type == QVariant::Image && data.type() == QVariant::Pixmap)) || (type == QMetaType::QImage && data.userType() == QMetaType::QPixmap))
return data; return data;
if (data.type() == QVariant::ByteArray) { if (data.userType() == QMetaType::QByteArray) {
// see if we can convert to the requested type // see if we can convert to the requested type
switch(type) { switch(type) {
#if QT_CONFIG(textcodec) #if QT_CONFIG(textcodec)
case QVariant::String: { case QMetaType::QString: {
const QByteArray ba = data.toByteArray(); const QByteArray ba = data.toByteArray();
QTextCodec *codec = QTextCodec::codecForName("utf-8"); QTextCodec *codec = QTextCodec::codecForName("utf-8");
if (format == QLatin1String("text/html")) if (format == QLatin1String("text/html"))
@ -162,17 +162,17 @@ QVariant QMimeDataPrivate::retrieveTypedData(const QString &format, QVariant::Ty
return codec->toUnicode(ba); return codec->toUnicode(ba);
} }
#endif // textcodec #endif // textcodec
case QVariant::Color: { case QMetaType::QColor: {
QVariant newData = data; QVariant newData = data;
newData.convert(QVariant::Color); newData.convert(QMetaType::QColor);
return newData; return newData;
} }
case QVariant::List: { case QMetaType::QVariantList: {
if (format != QLatin1String("text/uri-list")) if (format != QLatin1String("text/uri-list"))
break; break;
Q_FALLTHROUGH(); Q_FALLTHROUGH();
} }
case QVariant::Url: { case QMetaType::QUrl: {
QByteArray ba = data.toByteArray(); QByteArray ba = data.toByteArray();
// Qt 3.x will send text/uri-list with a trailing // Qt 3.x will send text/uri-list with a trailing
// null-terminator (that is *not* sent for any other // null-terminator (that is *not* sent for any other
@ -193,23 +193,23 @@ QVariant QMimeDataPrivate::retrieveTypedData(const QString &format, QVariant::Ty
break; break;
} }
} else if (type == QVariant::ByteArray) { } else if (type == QMetaType::QByteArray) {
// try to convert to bytearray // try to convert to bytearray
switch(data.type()) { switch (data.userType()) {
case QVariant::ByteArray: case QMetaType::QByteArray:
case QVariant::Color: case QMetaType::QColor:
return data.toByteArray(); return data.toByteArray();
case QVariant::String: case QMetaType::QString:
return data.toString().toUtf8(); return data.toString().toUtf8();
case QVariant::Url: case QMetaType::QUrl:
return data.toUrl().toEncoded(); return data.toUrl().toEncoded();
case QVariant::List: { case QMetaType::QVariantList: {
// has to be list of URLs // has to be list of URLs
QByteArray result; QByteArray result;
QList<QVariant> list = data.toList(); QList<QVariant> list = data.toList();
for (int i = 0; i < list.size(); ++i) { 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 += list.at(i).toUrl().toEncoded();
result += "\r\n"; result += "\r\n";
} }
@ -340,14 +340,14 @@ QMimeData::~QMimeData()
QList<QUrl> QMimeData::urls() const QList<QUrl> QMimeData::urls() const
{ {
Q_D(const QMimeData); Q_D(const QMimeData);
QVariant data = d->retrieveTypedData(textUriListLiteral(), QVariant::List); QVariant data = d->retrieveTypedData(textUriListLiteral(), QMetaType::QVariantList);
QList<QUrl> urls; QList<QUrl> urls;
if (data.type() == QVariant::Url) if (data.userType() == QMetaType::QUrl)
urls.append(data.toUrl()); urls.append(data.toUrl());
else if (data.type() == QVariant::List) { else if (data.userType() == QMetaType::QVariantList) {
QList<QVariant> list = data.toList(); QList<QVariant> list = data.toList();
for (int i = 0; i < list.size(); ++i) { 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()); urls.append(list.at(i).toUrl());
} }
} }
@ -400,11 +400,11 @@ bool QMimeData::hasUrls() const
QString QMimeData::text() const QString QMimeData::text() const
{ {
Q_D(const QMimeData); Q_D(const QMimeData);
QVariant utf8Text = d->retrieveTypedData(textPlainUtf8Literal(), QVariant::String); QVariant utf8Text = d->retrieveTypedData(textPlainUtf8Literal(), QMetaType::QString);
if (!utf8Text.isNull()) if (!utf8Text.isNull())
return utf8Text.toString(); return utf8Text.toString();
QVariant data = d->retrieveTypedData(textPlainLiteral(), QVariant::String); QVariant data = d->retrieveTypedData(textPlainLiteral(), QMetaType::QString);
return data.toString(); return data.toString();
} }
@ -440,7 +440,7 @@ bool QMimeData::hasText() const
QString QMimeData::html() const QString QMimeData::html() const
{ {
Q_D(const QMimeData); Q_D(const QMimeData);
QVariant data = d->retrieveTypedData(textHtmlLiteral(), QVariant::String); QVariant data = d->retrieveTypedData(textHtmlLiteral(), QMetaType::QString);
return data.toString(); return data.toString();
} }
@ -482,7 +482,7 @@ bool QMimeData::hasHtml() const
QVariant QMimeData::imageData() const QVariant QMimeData::imageData() const
{ {
Q_D(const QMimeData); 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 QVariant QMimeData::colorData() const
{ {
Q_D(const QMimeData); 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 QByteArray QMimeData::data(const QString &mimeType) const
{ {
Q_D(const QMimeData); Q_D(const QMimeData);
QVariant data = d->retrieveTypedData(mimeType, QVariant::ByteArray); QVariant data = d->retrieveTypedData(mimeType, QMetaType::QByteArray);
return data.toByteArray(); return data.toByteArray();
} }

File diff suppressed because it is too large Load Diff

View File

@ -362,7 +362,7 @@ class QVariantConstructor
FilteredConstructor(const QVariantConstructor &tc) FilteredConstructor(const QVariantConstructor &tc)
{ {
// ignore types that lives outside of the current library // ignore types that lives outside of the current library
tc.m_x->type = QVariant::Invalid; tc.m_x->type = QMetaType::UnknownType;
} }
}; };
public: public:
@ -430,7 +430,7 @@ public:
{} {}
~QVariantDestructor() ~QVariantDestructor()
{ {
m_d->type = QVariant::Invalid; m_d->type = QMetaType::UnknownType;
m_d->is_null = true; m_d->is_null = true;
m_d->is_shared = false; m_d->is_shared = false;
} }

View File

@ -1,6 +1,6 @@
/**************************************************************************** /****************************************************************************
** **
** Copyright (C) 2019 Intel Corporation. ** Copyright (C) 2020 Intel Corporation.
** Contact: https://www.qt.io/licensing/ ** Contact: https://www.qt.io/licensing/
** **
** This file is part of the QtCore module of the Qt Toolkit. ** 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 // Handle strings and byte arrays directly, to avoid creating a temporary
// dummy container to hold their data. // dummy container to hold their data.
int type = variant.userType(); int type = variant.userType();
if (type == QVariant::String) { if (type == QMetaType::QString) {
d->append(variant.toString()); d->append(variant.toString());
} else if (type == QVariant::ByteArray) { } else if (type == QMetaType::QByteArray) {
QByteArray ba = variant.toByteArray(); QByteArray ba = variant.toByteArray();
d->appendByteData(ba.constData(), ba.size(), QCborValue::ByteArray); d->appendByteData(ba.constData(), ba.size(), QCborValue::ByteArray);
} else { } else {
@ -698,48 +698,48 @@ static void appendVariant(QCborContainerPrivate *d, const QVariant &variant)
QCborValue QCborValue::fromVariant(const QVariant &variant) QCborValue QCborValue::fromVariant(const QVariant &variant)
{ {
switch (variant.userType()) { switch (variant.userType()) {
case QVariant::Invalid: case QMetaType::UnknownType:
return {}; return {};
case QMetaType::Nullptr: case QMetaType::Nullptr:
return nullptr; return nullptr;
case QVariant::Bool: case QMetaType::Bool:
return variant.toBool(); return variant.toBool();
case QMetaType::Short: case QMetaType::Short:
case QMetaType::UShort: case QMetaType::UShort:
case QVariant::Int: case QMetaType::Int:
case QVariant::LongLong: case QMetaType::LongLong:
case QVariant::UInt: case QMetaType::UInt:
return variant.toLongLong(); return variant.toLongLong();
case QVariant::ULongLong: case QMetaType::ULongLong:
if (variant.toULongLong() <= static_cast<uint64_t>(std::numeric_limits<qint64>::max())) if (variant.toULongLong() <= static_cast<uint64_t>(std::numeric_limits<qint64>::max()))
return variant.toLongLong(); return variant.toLongLong();
Q_FALLTHROUGH(); Q_FALLTHROUGH();
case QMetaType::Float: case QMetaType::Float:
case QVariant::Double: case QMetaType::Double:
return variant.toDouble(); return variant.toDouble();
case QVariant::String: case QMetaType::QString:
return variant.toString(); return variant.toString();
case QVariant::StringList: case QMetaType::QStringList:
return QCborArray::fromStringList(variant.toStringList()); return QCborArray::fromStringList(variant.toStringList());
case QVariant::ByteArray: case QMetaType::QByteArray:
return variant.toByteArray(); return variant.toByteArray();
case QVariant::DateTime: case QMetaType::QDateTime:
return QCborValue(variant.toDateTime()); return QCborValue(variant.toDateTime());
#ifndef QT_BOOTSTRAPPED #ifndef QT_BOOTSTRAPPED
case QVariant::Url: case QMetaType::QUrl:
return QCborValue(variant.toUrl()); return QCborValue(variant.toUrl());
#endif #endif
case QVariant::Uuid: case QMetaType::QUuid:
return QCborValue(variant.toUuid()); return QCborValue(variant.toUuid());
case QVariant::List: case QMetaType::QVariantList:
return QCborArray::fromVariantList(variant.toList()); return QCborArray::fromVariantList(variant.toList());
case QVariant::Map: case QMetaType::QVariantMap:
return QCborMap::fromVariantMap(variant.toMap()); return QCborMap::fromVariantMap(variant.toMap());
case QVariant::Hash: case QMetaType::QVariantHash:
return QCborMap::fromVariantHash(variant.toHash()); return QCborMap::fromVariantHash(variant.toHash());
#ifndef QT_BOOTSTRAPPED #ifndef QT_BOOTSTRAPPED
#if QT_CONFIG(regularexpression) #if QT_CONFIG(regularexpression)
case QVariant::RegularExpression: case QMetaType::QRegularExpression:
return QCborValue(variant.toRegularExpression()); return QCborValue(variant.toRegularExpression());
#endif #endif
case QMetaType::QJsonValue: case QMetaType::QJsonValue:

View File

@ -405,17 +405,17 @@ QJsonDocument QJsonDocument::fromVariant(const QVariant &variant)
{ {
QJsonDocument doc; QJsonDocument doc;
switch (variant.type()) { switch (variant.userType()) {
case QVariant::Map: case QMetaType::QVariantMap:
doc.setObject(QJsonObject::fromVariantMap(variant.toMap())); doc.setObject(QJsonObject::fromVariantMap(variant.toMap()));
break; break;
case QVariant::Hash: case QMetaType::QVariantHash:
doc.setObject(QJsonObject::fromVariantHash(variant.toHash())); doc.setObject(QJsonObject::fromVariantHash(variant.toHash()));
break; break;
case QVariant::List: case QMetaType::QVariantList:
doc.setArray(QJsonArray::fromVariantList(variant.toList())); doc.setArray(QJsonArray::fromVariantList(variant.toList()));
break; break;
case QVariant::StringList: case QMetaType::QStringList:
doc.d = qt_make_unique<QJsonDocumentPrivate>(); doc.d = qt_make_unique<QJsonDocumentPrivate>();
doc.d->value = QCborArray::fromStringList(variant.toStringList()); doc.d->value = QCborArray::fromStringList(variant.toStringList());
break; break;

View File

@ -1,6 +1,6 @@
/**************************************************************************** /****************************************************************************
** **
** Copyright (C) 2016 The Qt Company Ltd. ** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/ ** Contact: https://www.qt.io/licensing/
** **
** This file is part of the QtCore module of the Qt Toolkit. ** 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()) { switch (variant.userType()) {
case QMetaType::Nullptr: case QMetaType::Nullptr:
return QJsonValue(Null); return QJsonValue(Null);
case QVariant::Bool: case QMetaType::Bool:
return QJsonValue(variant.toBool()); return QJsonValue(variant.toBool());
case QMetaType::Short: case QMetaType::Short:
case QMetaType::UShort: case QMetaType::UShort:
case QVariant::Int: case QMetaType::Int:
case QVariant::UInt: case QMetaType::UInt:
case QVariant::LongLong: case QMetaType::LongLong:
return QJsonValue(variant.toLongLong()); return QJsonValue(variant.toLongLong());
case QVariant::ULongLong: case QMetaType::ULongLong:
if (variant.toULongLong() <= static_cast<uint64_t>(std::numeric_limits<qint64>::max())) if (variant.toULongLong() <= static_cast<uint64_t>(std::numeric_limits<qint64>::max()))
return QJsonValue(variant.toLongLong()); return QJsonValue(variant.toLongLong());
Q_FALLTHROUGH(); Q_FALLTHROUGH();
case QMetaType::Float: case QMetaType::Float:
case QVariant::Double: case QMetaType::Double:
return QJsonValue(variant.toDouble()); return QJsonValue(variant.toDouble());
case QVariant::String: case QMetaType::QString:
return QJsonValue(variant.toString()); return QJsonValue(variant.toString());
case QVariant::StringList: case QMetaType::QStringList:
return QJsonValue(QJsonArray::fromStringList(variant.toStringList())); return QJsonValue(QJsonArray::fromStringList(variant.toStringList()));
case QVariant::List: case QMetaType::QVariantList:
return QJsonValue(QJsonArray::fromVariantList(variant.toList())); return QJsonValue(QJsonArray::fromVariantList(variant.toList()));
case QVariant::Map: case QMetaType::QVariantMap:
return QJsonValue(QJsonObject::fromVariantMap(variant.toMap())); return QJsonValue(QJsonObject::fromVariantMap(variant.toMap()));
case QVariant::Hash: case QMetaType::QVariantHash:
return QJsonValue(QJsonObject::fromVariantHash(variant.toHash())); return QJsonValue(QJsonObject::fromVariantHash(variant.toHash()));
#ifndef QT_BOOTSTRAPPED #ifndef QT_BOOTSTRAPPED
case QVariant::Url: case QMetaType::QUrl:
return QJsonValue(variant.toUrl().toString(QUrl::FullyEncoded)); return QJsonValue(variant.toUrl().toString(QUrl::FullyEncoded));
case QVariant::Uuid: case QMetaType::QUuid:
return variant.toUuid().toString(QUuid::WithoutBraces); return variant.toUuid().toString(QUuid::WithoutBraces);
case QMetaType::QJsonValue: case QMetaType::QJsonValue:
return variant.toJsonValue(); return variant.toJsonValue();

View File

@ -1681,7 +1681,7 @@ QString QTextStream::readLine(qint64 maxlen)
\since 5.5 \since 5.5
Reads one line of text from the stream into \a line. 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 maximum allowed line length is set to \a maxlen. If
the stream contains lines longer than this, then the lines will be the stream contains lines longer than this, then the lines will be

View File

@ -50,6 +50,7 @@
#endif #endif
#include <qstack.h> #include <qstack.h>
#include <qbuffer.h> #include <qbuffer.h>
#include <qscopeguard.h>
#ifndef QT_BOOTSTRAPPED #ifndef QT_BOOTSTRAPPED
#include <qcoreapplication.h> #include <qcoreapplication.h>
#else #else
@ -68,6 +69,8 @@ public: \
{ return QString::fromLatin1(sourceText); } \ { return QString::fromLatin1(sourceText); } \
private: private:
#endif #endif
#include <private/qmemory_p.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
#include "qxmlstream_p.h" #include "qxmlstream_p.h"
@ -847,7 +850,7 @@ void QXmlStreamReaderPrivate::init()
#endif #endif
attributeStack.clear(); attributeStack.clear();
attributeStack.reserve(16); attributeStack.reserve(16);
entityParser = nullptr; entityParser.reset();
hasCheckedStartDocument = false; hasCheckedStartDocument = false;
normalizeLiterals = false; normalizeLiterals = false;
hasSeenTag = false; hasSeenTag = false;
@ -880,7 +883,7 @@ void QXmlStreamReaderPrivate::parseEntity(const QString &value)
if (!entityParser) if (!entityParser)
entityParser = new QXmlStreamReaderPrivate(q); entityParser = qt_make_unique<QXmlStreamReaderPrivate>(q);
else else
entityParser->init(); entityParser->init();
entityParser->inParseEntity = true; entityParser->inParseEntity = true;
@ -910,7 +913,6 @@ QXmlStreamReaderPrivate::~QXmlStreamReaderPrivate()
#endif #endif
free(sym_stack); free(sym_stack);
free(state_stack); free(state_stack);
delete entityParser;
} }
@ -1582,6 +1584,7 @@ QStringRef QXmlStreamReaderPrivate::namespaceForPrefix(const QStringRef &prefix)
*/ */
void QXmlStreamReaderPrivate::resolveTag() void QXmlStreamReaderPrivate::resolveTag()
{ {
const auto attributeStackCleaner = qScopeGuard([this](){ attributeStack.clear(); });
int n = attributeStack.size(); int n = attributeStack.size();
if (namespaceProcessing) { if (namespaceProcessing) {
@ -1649,7 +1652,10 @@ void QXmlStreamReaderPrivate::resolveTag()
if (attributes[j].name() == attribute.name() if (attributes[j].name() == attribute.name()
&& attributes[j].namespaceUri() == attribute.namespaceUri() && attributes[j].namespaceUri() == attribute.namespaceUri()
&& (namespaceProcessing || attributes[j].qualifiedName() == attribute.qualifiedName())) && (namespaceProcessing || attributes[j].qualifiedName() == attribute.qualifiedName()))
{
raiseWellFormedError(QXmlStream::tr("Attribute '%1' redefined.").arg(attribute.qualifiedName())); raiseWellFormedError(QXmlStream::tr("Attribute '%1' redefined.").arg(attribute.qualifiedName()));
return;
}
} }
} }
@ -1680,8 +1686,6 @@ void QXmlStreamReaderPrivate::resolveTag()
attribute.m_isDefault = true; attribute.m_isDefault = true;
attributes.append(attribute); attributes.append(attribute);
} }
attributeStack.clear();
} }
void QXmlStreamReaderPrivate::resolvePublicNamespaces() void QXmlStreamReaderPrivate::resolvePublicNamespaces()

View File

@ -981,7 +981,7 @@ public:
QString resolveUndeclaredEntity(const QString &name); QString resolveUndeclaredEntity(const QString &name);
void parseEntity(const QString &value); void parseEntity(const QString &value);
QXmlStreamReaderPrivate *entityParser; std::unique_ptr<QXmlStreamReaderPrivate> entityParser;
bool scanAfterLangleBang(); bool scanAfterLangleBang();
bool scanPublicOrSystem(); bool scanPublicOrSystem();

View File

@ -734,23 +734,23 @@ static void updateSystemPrivate()
globalLocaleData.m_script_id = res.toInt(); globalLocaleData.m_script_id = res.toInt();
res = sys_locale->query(QSystemLocale::DecimalPoint, QVariant()); res = sys_locale->query(QSystemLocale::DecimalPoint, QVariant());
if (!res.isNull()) if (!res.isNull() && !res.toString().isEmpty())
globalLocaleData.m_decimal = res.toString().at(0).unicode(); globalLocaleData.m_decimal = res.toString().at(0).unicode();
res = sys_locale->query(QSystemLocale::GroupSeparator, QVariant()); res = sys_locale->query(QSystemLocale::GroupSeparator, QVariant());
if (!res.isNull()) if (!res.isNull() && !res.toString().isEmpty())
globalLocaleData.m_group = res.toString().at(0).unicode(); globalLocaleData.m_group = res.toString().at(0).unicode();
res = sys_locale->query(QSystemLocale::ZeroDigit, QVariant()); res = sys_locale->query(QSystemLocale::ZeroDigit, QVariant());
if (!res.isNull()) if (!res.isNull() && !res.toString().isEmpty())
globalLocaleData.m_zero = res.toString().at(0).unicode(); globalLocaleData.m_zero = res.toString().at(0).unicode();
res = sys_locale->query(QSystemLocale::NegativeSign, QVariant()); res = sys_locale->query(QSystemLocale::NegativeSign, QVariant());
if (!res.isNull()) if (!res.isNull() && !res.toString().isEmpty())
globalLocaleData.m_minus = res.toString().at(0).unicode(); globalLocaleData.m_minus = res.toString().at(0).unicode();
res = sys_locale->query(QSystemLocale::PositiveSign, QVariant()); res = sys_locale->query(QSystemLocale::PositiveSign, QVariant());
if (!res.isNull()) if (!res.isNull() && !res.toString().isEmpty())
globalLocaleData.m_plus = res.toString().at(0).unicode(); globalLocaleData.m_plus = res.toString().at(0).unicode();
} }
#endif // !QT_NO_SYSTEMLOCALE #endif // !QT_NO_SYSTEMLOCALE
@ -2430,7 +2430,7 @@ QTime QLocale::toTime(const QString &string, const QString &format, QCalendar ca
{ {
QTime time; QTime time;
#if QT_CONFIG(datetimeparser) #if QT_CONFIG(datetimeparser)
QDateTimeParser dt(QVariant::Time, QDateTimeParser::FromString, cal); QDateTimeParser dt(QMetaType::QTime, QDateTimeParser::FromString, cal);
dt.setDefaultLocale(*this); dt.setDefaultLocale(*this);
if (dt.parseFormat(format)) if (dt.parseFormat(format))
dt.fromString(string, nullptr, &time); dt.fromString(string, nullptr, &time);
@ -2469,7 +2469,7 @@ QDate QLocale::toDate(const QString &string, const QString &format, QCalendar ca
{ {
QDate date; QDate date;
#if QT_CONFIG(datetimeparser) #if QT_CONFIG(datetimeparser)
QDateTimeParser dt(QVariant::Date, QDateTimeParser::FromString, cal); QDateTimeParser dt(QMetaType::QDate, QDateTimeParser::FromString, cal);
dt.setDefaultLocale(*this); dt.setDefaultLocale(*this);
if (dt.parseFormat(format)) if (dt.parseFormat(format))
dt.fromString(string, &date, nullptr); dt.fromString(string, &date, nullptr);
@ -2510,7 +2510,7 @@ QDateTime QLocale::toDateTime(const QString &string, const QString &format, QCal
QTime time; QTime time;
QDate date; QDate date;
QDateTimeParser dt(QVariant::DateTime, QDateTimeParser::FromString, cal); QDateTimeParser dt(QMetaType::QDateTime, QDateTimeParser::FromString, cal);
dt.setDefaultLocale(*this); dt.setDefaultLocale(*this);
if (dt.parseFormat(format) && dt.fromString(string, &date, &time)) if (dt.parseFormat(format) && dt.fromString(string, &date, &time))
return QDateTime(date, time); return QDateTime(date, time);
@ -4463,6 +4463,8 @@ QStringList QLocale::uiLanguages() const
for (const auto entry : qAsConst(uiLanguages)) for (const auto entry : qAsConst(uiLanguages))
locales.append(QLocale(entry)); locales.append(QLocale(entry));
} }
if (locales.isEmpty())
locales.append(systemLocale()->fallbackUiLocale());
} else } else
#endif #endif
{ {

View File

@ -234,16 +234,16 @@ QVariant QSystemLocale::query(QueryType type, QVariant in) const
case CurrencySymbol: case CurrencySymbol:
return lc_monetary.currencySymbol(QLocale::CurrencySymbolFormat(in.toUInt())); return lc_monetary.currencySymbol(QLocale::CurrencySymbolFormat(in.toUInt()));
case CurrencyToString: { case CurrencyToString: {
switch (in.type()) { switch (in.userType()) {
case QVariant::Int: case QMetaType::Int:
return lc_monetary.toCurrencyString(in.toInt()); return lc_monetary.toCurrencyString(in.toInt());
case QVariant::UInt: case QMetaType::UInt:
return lc_monetary.toCurrencyString(in.toUInt()); return lc_monetary.toCurrencyString(in.toUInt());
case QVariant::Double: case QMetaType::Double:
return lc_monetary.toCurrencyString(in.toDouble()); return lc_monetary.toCurrencyString(in.toDouble());
case QVariant::LongLong: case QMetaType::LongLong:
return lc_monetary.toCurrencyString(in.toLongLong()); return lc_monetary.toCurrencyString(in.toLongLong());
case QVariant::ULongLong: case QMetaType::ULongLong:
return lc_monetary.toCurrencyString(in.toULongLong()); return lc_monetary.toCurrencyString(in.toULongLong());
default: default:
break; break;

View File

@ -43,9 +43,9 @@
#if QT_CONFIG(regularexpression) #if QT_CONFIG(regularexpression)
# include <qregularexpression.h> # include <qregularexpression.h>
#endif #endif
#include <private/qduplicatetracker_p.h>
#include <algorithm> #include <algorithm>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
/*! \typedef QStringListIterator /*! \typedef QStringListIterator
@ -885,15 +885,13 @@ int QtPrivate::QStringList_removeDuplicates(QStringList *that)
{ {
int n = that->size(); int n = that->size();
int j = 0; int j = 0;
QSet<QString> seen;
QDuplicateTracker<QString> seen;
seen.reserve(n); seen.reserve(n);
int setSize = 0;
for (int i = 0; i < n; ++i) { for (int i = 0; i < n; ++i) {
const QString &s = that->at(i); const QString &s = that->at(i);
seen.insert(s); if (seen.hasSeen(s))
if (setSize == seen.size()) // unchanged size => was already seen
continue; continue;
++setSize;
if (j != i) if (j != i)
that->swapItemsAt(i, j); that->swapItemsAt(i, j);
++j; ++j;

View File

@ -48,7 +48,7 @@ SOURCES += \
NO_PCH_SOURCES += text/qstring_compat.cpp NO_PCH_SOURCES += text/qstring_compat.cpp
false: SOURCES += $$NO_PCH_SOURCES # Hack for QtCreator false: SOURCES += $$NO_PCH_SOURCES # Hack for QtCreator
!nacl:macos: { !nacl:darwin: {
SOURCES += text/qlocale_mac.mm SOURCES += text/qlocale_mac.mm
} }
else:unix { else:unix {

View File

@ -487,7 +487,7 @@ QRecursiveMutex::~QRecursiveMutex()
\fn QMutexLocker::QMutexLocker(QMutex *mutex) \fn QMutexLocker::QMutexLocker(QMutex *mutex)
Constructs a QMutexLocker and locks \a mutex. The mutex will be 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. QMutexLocker does nothing.
\sa QMutex::lock() \sa QMutex::lock()

View File

@ -614,7 +614,7 @@ void QThread::run()
priority. priority.
The \a priority argument can be any value in the \c 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 The effect of the \a priority parameter is dependent on the
operating system's scheduling policy. In particular, the \a priority operating system's scheduling policy. In particular, the \a priority
@ -626,6 +626,10 @@ void QThread::run()
*/ */
void QThread::setPriority(Priority priority) void QThread::setPriority(Priority priority)
{ {
if (priority == QThread::InheritPriority) {
qWarning("QThread::setPriority: Argument cannot be InheritPriority");
return;
}
Q_D(QThread); Q_D(QThread);
QMutexLocker locker(&d->mutex); QMutexLocker locker(&d->mutex);
if (!d->running) { if (!d->running) {

View File

@ -715,9 +715,7 @@ void QThreadPrivate::setPriority(QThread::Priority threadPriority)
prio = THREAD_PRIORITY_TIME_CRITICAL; prio = THREAD_PRIORITY_TIME_CRITICAL;
break; break;
case QThread::InheritPriority:
default: default:
qWarning("QThread::setPriority: Argument cannot be InheritPriority");
return; return;
} }

View File

@ -1791,7 +1791,7 @@ QDate QDate::fromString(const QString &string, const QString &format, QCalendar
{ {
QDate date; QDate date;
#if QT_CONFIG(datetimeparser) #if QT_CONFIG(datetimeparser)
QDateTimeParser dt(QVariant::Date, QDateTimeParser::FromString, cal); QDateTimeParser dt(QMetaType::QDate, QDateTimeParser::FromString, cal);
// dt.setDefaultLocale(QLocale::c()); ### Qt 6 // dt.setDefaultLocale(QLocale::c()); ### Qt 6
if (dt.parseFormat(format)) if (dt.parseFormat(format))
dt.fromString(string, &date, nullptr); dt.fromString(string, &date, nullptr);
@ -2537,7 +2537,7 @@ QTime QTime::fromString(const QString &string, const QString &format)
{ {
QTime time; QTime time;
#if QT_CONFIG(datetimeparser) #if QT_CONFIG(datetimeparser)
QDateTimeParser dt(QVariant::Time, QDateTimeParser::FromString, QCalendar()); QDateTimeParser dt(QMetaType::QTime, QDateTimeParser::FromString, QCalendar());
// dt.setDefaultLocale(QLocale::c()); ### Qt 6 // dt.setDefaultLocale(QLocale::c()); ### Qt 6
if (dt.parseFormat(format)) if (dt.parseFormat(format))
dt.fromString(string, nullptr, &time); dt.fromString(string, nullptr, &time);
@ -5482,7 +5482,7 @@ QDateTime QDateTime::fromString(const QString &string, const QString &format, QC
QTime time; QTime time;
QDate date; QDate date;
QDateTimeParser dt(QVariant::DateTime, QDateTimeParser::FromString, cal); QDateTimeParser dt(QMetaType::QDateTime, QDateTimeParser::FromString, cal);
// dt.setDefaultLocale(QLocale::c()); ### Qt 6 // dt.setDefaultLocale(QLocale::c()); ### Qt 6
if (dt.parseFormat(format) && dt.fromString(string, &date, &time)) if (dt.parseFormat(format) && dt.fromString(string, &date, &time))
return QDateTime(date, time); return QDateTime(date, time);

View File

@ -425,7 +425,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat)
switch (sect) { switch (sect) {
case 'H': case 'H':
case 'h': case 'h':
if (parserType != QVariant::Date) { if (parserType != QMetaType::QDate) {
const Section hour = (sect == 'h') ? Hour12Section : Hour24Section; const Section hour = (sect == 'h') ? Hour12Section : Hour24Section;
const SectionNode sn = { hour, i - add, countRepeat(newFormat, i, 2), 0 }; const SectionNode sn = { hour, i - add, countRepeat(newFormat, i, 2), 0 };
newSectionNodes.append(sn); newSectionNodes.append(sn);
@ -436,7 +436,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat)
} }
break; break;
case 'm': case 'm':
if (parserType != QVariant::Date) { if (parserType != QMetaType::QDate) {
const SectionNode sn = { MinuteSection, i - add, countRepeat(newFormat, i, 2), 0 }; const SectionNode sn = { MinuteSection, i - add, countRepeat(newFormat, i, 2), 0 };
newSectionNodes.append(sn); newSectionNodes.append(sn);
appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote); appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote);
@ -446,7 +446,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat)
} }
break; break;
case 's': case 's':
if (parserType != QVariant::Date) { if (parserType != QMetaType::QDate) {
const SectionNode sn = { SecondSection, i - add, countRepeat(newFormat, i, 2), 0 }; const SectionNode sn = { SecondSection, i - add, countRepeat(newFormat, i, 2), 0 };
newSectionNodes.append(sn); newSectionNodes.append(sn);
appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote); appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote);
@ -457,7 +457,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat)
break; break;
case 'z': case 'z':
if (parserType != QVariant::Date) { if (parserType != QMetaType::QDate) {
const SectionNode sn = { MSecSection, i - add, countRepeat(newFormat, i, 3) < 3 ? 1 : 3, 0 }; const SectionNode sn = { MSecSection, i - add, countRepeat(newFormat, i, 3) < 3 ? 1 : 3, 0 };
newSectionNodes.append(sn); newSectionNodes.append(sn);
appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote); appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote);
@ -468,7 +468,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat)
break; break;
case 'A': case 'A':
case 'a': case 'a':
if (parserType != QVariant::Date) { if (parserType != QMetaType::QDate) {
const bool cap = (sect == 'A'); const bool cap = (sect == 'A');
const SectionNode sn = { AmPmSection, i - add, (cap ? 1 : 0), 0 }; const SectionNode sn = { AmPmSection, i - add, (cap ? 1 : 0), 0 };
newSectionNodes.append(sn); newSectionNodes.append(sn);
@ -482,7 +482,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat)
} }
break; break;
case 'y': case 'y':
if (parserType != QVariant::Time) { if (parserType != QMetaType::QTime) {
const int repeat = countRepeat(newFormat, i, 4); const int repeat = countRepeat(newFormat, i, 4);
if (repeat >= 2) { if (repeat >= 2) {
const SectionNode sn = { repeat == 4 ? YearSection : YearSection2Digits, const SectionNode sn = { repeat == 4 ? YearSection : YearSection2Digits,
@ -496,7 +496,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat)
} }
break; break;
case 'M': case 'M':
if (parserType != QVariant::Time) { if (parserType != QMetaType::QTime) {
const SectionNode sn = { MonthSection, i - add, countRepeat(newFormat, i, 4), 0 }; const SectionNode sn = { MonthSection, i - add, countRepeat(newFormat, i, 4), 0 };
newSectionNodes.append(sn); newSectionNodes.append(sn);
newSeparators.append(unquote(newFormat.midRef(index, i - index))); newSeparators.append(unquote(newFormat.midRef(index, i - index)));
@ -506,7 +506,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat)
} }
break; break;
case 'd': case 'd':
if (parserType != QVariant::Time) { if (parserType != QMetaType::QTime) {
const int repeat = countRepeat(newFormat, i, 4); const int repeat = countRepeat(newFormat, i, 4);
const Section sectionType = (repeat == 4 ? DayOfWeekSectionLong const Section sectionType = (repeat == 4 ? DayOfWeekSectionLong
: (repeat == 3 ? DayOfWeekSectionShort : DaySection)); : (repeat == 3 ? DayOfWeekSectionShort : DaySection));
@ -519,7 +519,7 @@ bool QDateTimeParser::parseFormat(const QString &newFormat)
} }
break; break;
case 't': case 't':
if (parserType != QVariant::Time) { if (parserType != QMetaType::QTime) {
const SectionNode sn = { TimeZoneSection, i - add, countRepeat(newFormat, i, 4), 0 }; const SectionNode sn = { TimeZoneSection, i - add, countRepeat(newFormat, i, 4), 0 };
newSectionNodes.append(sn); newSectionNodes.append(sn);
appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote); appendSeparator(&newSeparators, newFormat, index, i - index, lastQuote);
@ -1252,7 +1252,7 @@ QDateTimeParser::scanString(const QDateTime &defaultValue,
return StateNode(); return StateNode();
} }
if (parserType != QVariant::Time) { if (parserType != QMetaType::QTime) {
if (year % 100 != year2digits && (isSet & YearSection2Digits)) { if (year % 100 != year2digits && (isSet & YearSection2Digits)) {
if (!(isSet & YearSection)) { if (!(isSet & YearSection)) {
year = (year / 100) * 100; year = (year / 100) * 100;
@ -1322,7 +1322,7 @@ QDateTimeParser::scanString(const QDateTime &defaultValue,
} }
} }
if (parserType != QVariant::Date) { if (parserType != QMetaType::QDate) {
if (isSet & Hour12Section) { if (isSet & Hour12Section) {
const bool hasHour = isSet & Hour24Section; const bool hasHour = isSet & Hour24Section;
if (ampm == -1) { 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 // 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). // 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(); qint64 msecs = when.toMSecsSinceEpoch();
// Fortunately, that gets a useful answer, even though when is invalid ... // Fortunately, that gets a useful answer, even though when is invalid ...
const QDateTime replace = const QDateTime replace =

View File

@ -82,7 +82,7 @@ public:
FromString, FromString,
DateTimeEdit 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), : currentSectionIndex(-1), cachedDay(-1), parserType(t),
fixday(false), spec(Qt::LocalTime), context(ctx), calendar(cal) fixday(false), spec(Qt::LocalTime), context(ctx), calendar(cal)
{ {
@ -295,7 +295,7 @@ protected: // for the benefit of QDateTimeEditPrivate
QStringList separators; QStringList separators;
QString displayFormat; QString displayFormat;
QLocale defaultLocale; QLocale defaultLocale;
QVariant::Type parserType; QMetaType::Type parserType;
bool fixday; bool fixday;
Qt::TimeSpec spec; // spec if used by QDateTimeEdit Qt::TimeSpec spec; // spec if used by QDateTimeEdit
Context context; Context context;

View File

@ -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 */

View File

@ -2128,4 +2128,11 @@ void QMapDataBase::freeData(QMapDataBase *d)
once in the returned list. 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 QT_END_NAMESPACE

View File

@ -12,6 +12,7 @@ HEADERS += \
tools/qcontainerfwd.h \ tools/qcontainerfwd.h \
tools/qcontainertools_impl.h \ tools/qcontainertools_impl.h \
tools/qcryptographichash.h \ tools/qcryptographichash.h \
tools/qduplicatetracker_p.h \
tools/qflatmap_p.h \ tools/qflatmap_p.h \
tools/qfreelist_p.h \ tools/qfreelist_p.h \
tools/qhash.h \ tools/qhash.h \

View File

@ -157,7 +157,7 @@ bool QDBusAbstractInterfacePrivate::property(const QMetaProperty &mp, void *retu
const int type = mp.userType(); const int type = mp.userType();
// is this metatype registered? // is this metatype registered?
const char *expectedSignature = ""; const char *expectedSignature = "";
if (int(mp.type()) != QMetaType::QVariant) { if (int(mp.userType()) != QMetaType::QVariant) {
expectedSignature = QDBusMetaType::typeToSignature(type); expectedSignature = QDBusMetaType::typeToSignature(type);
if (expectedSignature == nullptr) { if (expectedSignature == nullptr) {
qWarning("QDBusAbstractInterface: type %s must be registered with Qt D-Bus before it can be " qWarning("QDBusAbstractInterface: type %s must be registered with Qt D-Bus before it can be "

Some files were not shown because too many files have changed in this diff Show More