From d3a792e7a9c41a6710a953ea4af266d41ee9d261 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 22 Jul 2015 09:00:30 +0200 Subject: [PATCH] Fix QString-related warnings in quick designer support. designer/qquickdesignersupportmetainfo.cpp: In static member function 'static bool QQuickDesignerSupportMetaInfo::isSubclassOf(QObject*, const QByteArray&)': designer/qquickdesignersupportmetainfo.cpp:50:51: warning: 'bool QString::operator==(const QByteArray&) const' is deprecated (declared at /depot/fkleint/qt-5/qtbase/include/QtCore/../../src/corelib/tools/qstring.h:1229) [-Wdeprecated-declarations] designer/qquickdesignersupportitems.cpp: In function 'void stopAnimation(QObject*)': designer/qquickdesignersupportitems.cpp:62:35: warning: 'QString::QString(const char*)' is deprecated (declared at /depot/fkleint/qt-5/qtbase/include/QtCore/../../src/corelib/tools/qstring.h:653) [-Wdeprecated-declarations] designer/qquickdesignersupportitems.cpp:63:33: warning: 'QString::QString(const char*)' is deprecated (declared at /depot/fkleint/qt-5/qtbase/include/QtCore/../../src/corelib/tools/qstring.h:653) [-Wdeprecated-declarations] designer/qquickdesignersupportitems.cpp: In function 'void allSubObjects(QObject*, QObjectList&)': designer/qquickdesignersupportitems.cpp:93:62: warning: 'bool operator!=(const char*, QLatin1String)' is deprecated (declared at /depot/fkleint/qt-5/qtbase/include/QtCore/../../src/corelib/tools/qstring.h:1192) [-Wdeprecated-declarations] designer/qquickdesignersupportitems.cpp: In function 'QQmlType* getQmlType(const QString&, int, int)': designer/qquickdesignersupportitems.cpp:166:78: warning: 'QString::QString(const QByteArray&)' is deprecated (declared at /depot/fkleint/qt-5/qtbase/include/QtCore/../../src/corelib/tools/qstring.h:656) [-Wdeprecated-declarations] designer/qquickdesignersupportitems.cpp: In static member function 'static QObject* QQuickDesignerSupportItems::createPrimitive(const QString&, int, int, QQmlContext*)': designer/qquickdesignersupportitems.cpp:223:41: warning: 'QString::QString(const char*)' is deprecated (declared at /depot/fkleint/qt-5/qtbase/include/QtCore/../../src/corelib/tools/qstring.h:653) [-Wdeprecated-declarations] designer/qquickdesignersupportitems.cpp: In static member function 'static void QQuickDesignerSupportItems::disableTransition(QObject*)': designer/qquickdesignersupportitems.cpp:295:42: warning: 'QString::QString(const char*)' is deprecated (declared at /depot/fkleint/qt-5/qtbase/include/QtCore/../../src/corelib/tools/qstring.h:653) [-Wdeprecated-declarations] designer/qquickdesignersupportitems.cpp:296:44: warning: 'QString::QString(const char*)' is deprecated (declared at /depot/fkleint/qt-5/qtbase/include/QtCore/../../src/corelib/tools/qstring.h:653) [-Wdeprecated-declarations] designer/qquickdesignersupportproperties.cpp: In static member function 'static QQuickDesignerSupport::PropertyNameList QQuickDesignerSupportProperties::propertyNameListForWritableProperties(QObject*, const PropertyName&, QObjectList*)': designer/qquickdesignersupportproperties.cpp:145:47: warning: 'bool QString::operator!=(const char*) const' is deprecated (declared at /depot/fkleint/qt-5/qtbase/include/QtCore/../../src/corelib/tools/qstring.h:1166) [-Wdeprecated-declarations] designer/qquickdesignersupportstates.cpp: In static member function 'static bool QQuickDesignerSupportStates::isStateActive(QObject*, QQmlContext*)': designer/qquickdesignersupportstates.cpp:50:50: warning: 'QString::QString(const char*)' is deprecated (declared at /depot/fkleint/qt-5/qtbase/include/QtCore/../../src/corelib/tools/qstring.h:653) [-Wdeprecated-declarations] designer/qquickdesignersupportstates.cpp: In static member function 'static void QQuickDesignerSupportStates::activateState(QObject*, QQmlContext*)': designer/qquickdesignersupportstates.cpp:64:50: warning: 'QString::QString(const char*)' is deprecated (declared at /depot/fkleint/qt-5/qtbase/include/QtCore/../../src/corelib/tools/qstring.h:653) [-Wdeprecated-declarations] designer/qquickdesignercustomobjectdata.cpp: In member function 'void QQuickDesignerCustomObjectData::populateResetHashes()': designer/qquickdesignercustomobjectdata.cpp:146:93: warning: 'QString::QString(const QByteArray&)' is deprecated (declared at /depot/fkleint/qt-5/qtbase/include/QtCore/../../src/corelib/tools/qstring.h:656) [-Wdeprecated-declarations] designer/qquickdesignercustomobjectdata.cpp: In member function 'void QQuickDesignerCustomObjectData::doResetProperty(QQmlContext*, const PropertyName&)': designer/qquickdesignercustomobjectdata.cpp:170:58: warning: 'QString::QString(const QByteArray&)' is deprecated (declared at /depot/fkleint/qt-5/qtbase/include/QtCore/../../src/corelib/tools/qstring.h:656) [-Wdeprecated-declarations] designer/qquickdesignercustomobjectdata.cpp: In member function 'bool QQuickDesignerCustomObjectData::hasBindingForProperty(QQmlContext*, const PropertyName&, bool*) const': designer/qquickdesignercustomobjectdata.cpp:227:58: warning: 'QString::QString(const QByteArray&)' is deprecated (declared at /depot/fkleint/qt-5/qtbase/include/QtCore/../../src/corelib/tools/qstring.h:656) [-Wdeprecated-declarations] designer/qquickdesignercustomobjectdata.cpp: In member function 'void QQuickDesignerCustomObjectData::setPropertyBinding(QQmlContext*, const PropertyName&, const QString&)': designer/qquickdesignercustomobjectdata.cpp:244:58: warning: 'QString::QString(const QByteArray&)' is deprecated (declared at /depot/fkleint/qt-5/qtbase/include/QtCore/../../src/corelib/tools/qstring.h:656) [-Wdeprecated-declarations] designer/qquickdesignercustomobjectdata.cpp:259:55: warning: 'QString::QString(const char*)' is deprecated (declared at /depot/fkleint/qt-5/qtbase/include/QtCore/../../src/corelib/tools/qstring.h:653) [-Wdeprecated-declarations] designer/qquickdesignersupportpropertychanges.cpp: In static member function 'static void QQuickDesignerSupportPropertyChanges::changeValue(QObject*, const PropertyName&, const QVariant&)': designer/qquickdesignersupportpropertychanges.cpp:91:52: warning: 'QString::QString(const QByteArray&)' is deprecated (declared at /depot/fkleint/qt-5/qtbase/include/QtCore/../../src/corelib/tools/qstring.h:656) [-Wdeprecated-declarations] designer/qquickdesignersupportpropertychanges.cpp: In static member function 'static void QQuickDesignerSupportPropertyChanges::changeExpression(QObject*, const PropertyName&, const QString&)': designer/qquickdesignersupportpropertychanges.cpp:103:62: warning: 'QString::QString(const QByteArray&)' is deprecated (declared at /depot/fkleint/qt-5/qtbase/include/QtCore/../../src/corelib/tools/qstring.h:656) [-Wdeprecated-declarations] Change-Id: Icdaec28b5bea23244303b082217660c38aefa40f Reviewed-by: Thomas Hartmann --- src/quick/designer/qquickdesignercustomobjectdata.cpp | 10 +++++----- src/quick/designer/qquickdesignersupportitems.cpp | 15 ++++++++------- src/quick/designer/qquickdesignersupportmetainfo.cpp | 2 +- src/quick/designer/qquickdesignersupportproperties.cpp | 2 +- .../designer/qquickdesignersupportpropertychanges.cpp | 4 ++-- src/quick/designer/qquickdesignersupportstates.cpp | 4 ++-- 6 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/quick/designer/qquickdesignercustomobjectdata.cpp b/src/quick/designer/qquickdesignercustomobjectdata.cpp index cdd587b..1666ffb 100644 --- a/src/quick/designer/qquickdesignercustomobjectdata.cpp +++ b/src/quick/designer/qquickdesignercustomobjectdata.cpp @@ -143,7 +143,7 @@ void QQuickDesignerCustomObjectData::populateResetHashes() QQuickDesignerSupportProperties::propertyNameListForWritableProperties(object()); Q_FOREACH (const QQuickDesignerSupport::PropertyName &propertyName, propertyNameList) { - QQmlProperty property(object(), propertyName, QQmlEngine::contextForObject(object())); + QQmlProperty property(object(), QString::fromUtf8(propertyName), QQmlEngine::contextForObject(object())); QQmlAbstractBinding::Ptr binding = QQmlAbstractBinding::Ptr(QQmlPropertyPrivate::binding(property)); @@ -167,7 +167,7 @@ QVariant QQuickDesignerCustomObjectData::getResetValue(const QQuickDesignerSuppo void QQuickDesignerCustomObjectData::doResetProperty(QQmlContext *context, const QQuickDesignerSupport::PropertyName &propertyName) { - QQmlProperty property(object(), propertyName, context); + QQmlProperty property(object(), QString::fromUtf8(propertyName), context); if (!property.isValid()) return; @@ -224,7 +224,7 @@ bool QQuickDesignerCustomObjectData::hasBindingForProperty(QQmlContext *context, if (QQuickDesignerSupportProperties::isPropertyBlackListed(propertyName)) return false; - QQmlProperty property(object(), propertyName, context); + QQmlProperty property(object(), QString::fromUtf8(propertyName), context); bool hasBinding = QQmlPropertyPrivate::binding(property); @@ -241,7 +241,7 @@ void QQuickDesignerCustomObjectData::setPropertyBinding(QQmlContext *context, const QQuickDesignerSupport::PropertyName &propertyName, const QString &expression) { - QQmlProperty property(object(), propertyName, context); + QQmlProperty property(object(), QString::fromUtf8(propertyName), context); if (!property.isValid()) return; @@ -256,7 +256,7 @@ void QQuickDesignerCustomObjectData::setPropertyBinding(QQmlContext *context, binding->update(); if (binding->hasError()) { if (property.property().userType() == QVariant::String) - property.write(QVariant(QString("#%1#").arg(expression))); + property.write(QVariant(QLatin1Char('#') + expression + QLatin1Char('#'))); } } else { diff --git a/src/quick/designer/qquickdesignersupportitems.cpp b/src/quick/designer/qquickdesignersupportitems.cpp index d5e848b..4f23fe6 100644 --- a/src/quick/designer/qquickdesignersupportitems.cpp +++ b/src/quick/designer/qquickdesignersupportitems.cpp @@ -59,8 +59,8 @@ static void stopAnimation(QObject *object) QQuickAbstractAnimation *animation = qobject_cast(object); QQmlTimer *timer = qobject_cast(object); if (transition) { - transition->setFromState(""); - transition->setToState(""); + transition->setFromState(QString()); + transition->setToState(QString()); } else if (animation) { // QQuickScriptAction *scriptAimation = qobject_cast(animation); // if (scriptAimation) FIXME @@ -90,7 +90,7 @@ static void allSubObjects(QObject *object, QObjectList &objectList) if (metaProperty.isReadable() && metaProperty.isWritable() && QQmlMetaType::isQObject(metaProperty.userType())) { - if (metaProperty.name() != QLatin1String("parent")) { + if (qstrcmp(metaProperty.name(), "parent")) { QObject *propertyObject = QQmlMetaType::toQObject(metaProperty.read(object)); allSubObjects(propertyObject, objectList); } @@ -163,7 +163,7 @@ static bool isWindow(QObject *object) { static QQmlType *getQmlType(const QString &typeName, int majorNumber, int minorNumber) { - return QQmlMetaType::qmlType(typeName.toUtf8(), majorNumber, minorNumber); + return QQmlMetaType::qmlType(typeName, majorNumber, minorNumber); } static bool isCrashingType(QQmlType *type) @@ -220,7 +220,7 @@ QObject *QQuickDesignerSupportItems::createPrimitive(const QString &typeName, in if (!object) { qWarning() << "QuickDesigner: Cannot create an object of type" - << QString("%1 %2,%3").arg(typeName).arg(majorNumber).arg(minorNumber) + << QString::fromLatin1("%1 %2,%3").arg(typeName).arg(majorNumber).arg(minorNumber) << "- type isn't known to declarative meta type system"; } @@ -292,8 +292,9 @@ void QQuickDesignerSupportItems::disableTransition(QObject *object) { QQuickTransition *transition = qobject_cast(object); Q_ASSERT(transition); - transition->setToState("invalidState"); - transition->setFromState("invalidState"); + const QString invalidState = QLatin1String("invalidState"); + transition->setToState(invalidState); + transition->setFromState(invalidState); } void QQuickDesignerSupportItems::disableBehaivour(QObject *object) diff --git a/src/quick/designer/qquickdesignersupportmetainfo.cpp b/src/quick/designer/qquickdesignersupportmetainfo.cpp index 5044130..c6c7ed3 100644 --- a/src/quick/designer/qquickdesignersupportmetainfo.cpp +++ b/src/quick/designer/qquickdesignersupportmetainfo.cpp @@ -47,7 +47,7 @@ bool QQuickDesignerSupportMetaInfo::isSubclassOf(QObject *object, const QByteArr while (metaObject) { QQmlType *qmlType = QQmlMetaType::qmlType(metaObject); - if (qmlType && qmlType->qmlTypeName() == superTypeName) // ignore version numbers + if (qmlType && qmlType->qmlTypeName() == QLatin1String(superTypeName)) // ignore version numbers return true; if (metaObject->className() == superTypeName) diff --git a/src/quick/designer/qquickdesignersupportproperties.cpp b/src/quick/designer/qquickdesignersupportproperties.cpp index e471b0e..300ad6d 100644 --- a/src/quick/designer/qquickdesignersupportproperties.cpp +++ b/src/quick/designer/qquickdesignersupportproperties.cpp @@ -142,7 +142,7 @@ QQuickDesignerSupport::PropertyNameList QQuickDesignerSupportProperties::propert QMetaProperty metaProperty = metaObject->property(index); QQmlProperty declarativeProperty(object, QLatin1String(metaProperty.name())); if (declarativeProperty.isValid() && !declarativeProperty.isWritable() && declarativeProperty.propertyTypeCategory() == QQmlProperty::Object) { - if (declarativeProperty.name() != "parent") { + if (declarativeProperty.name() != QLatin1String("parent")) { QObject *childObject = QQmlMetaType::toQObject(declarativeProperty.read()); if (childObject) propertyNameList.append(propertyNameListForWritableProperties(childObject, diff --git a/src/quick/designer/qquickdesignersupportpropertychanges.cpp b/src/quick/designer/qquickdesignersupportpropertychanges.cpp index 997582a..b8706fc 100644 --- a/src/quick/designer/qquickdesignersupportpropertychanges.cpp +++ b/src/quick/designer/qquickdesignersupportpropertychanges.cpp @@ -88,7 +88,7 @@ void QQuickDesignerSupportPropertyChanges::changeValue(QObject *propertyChanges, if (!propertyChange) return; - propertyChange->changeValue(propertyName, value); + propertyChange->changeValue(QString::fromUtf8(propertyName), value); } void QQuickDesignerSupportPropertyChanges::changeExpression(QObject *propertyChanges, @@ -100,7 +100,7 @@ void QQuickDesignerSupportPropertyChanges::changeExpression(QObject *propertyCha if (!propertyChange) return; - propertyChange->changeExpression(propertyName, expression); + propertyChange->changeExpression(QString::fromUtf8(propertyName), expression); } QObject *QQuickDesignerSupportPropertyChanges::stateObject(QObject *propertyChanges) diff --git a/src/quick/designer/qquickdesignersupportstates.cpp b/src/quick/designer/qquickdesignersupportstates.cpp index 2b4fc97..b75ec71 100644 --- a/src/quick/designer/qquickdesignersupportstates.cpp +++ b/src/quick/designer/qquickdesignersupportstates.cpp @@ -47,7 +47,7 @@ bool QQuickDesignerSupportStates::isStateActive(QObject *object, QQmlContext *co QQuickStateGroup *stateGroup = stateObject->stateGroup(); - QQmlProperty property(object, "name", context); + QQmlProperty property(object, QLatin1String("name"), context); return stateObject && stateGroup && stateGroup->state() == property.read(); } @@ -61,7 +61,7 @@ void QQuickDesignerSupportStates::activateState(QObject *object, QQmlContext *co QQuickStateGroup *stateGroup = stateObject->stateGroup(); - QQmlProperty property(object, "name", context); + QQmlProperty property(object, QLatin1String("name"), context); stateGroup->setState(property.read().toString()); } -- 2.7.4