mirror of https://github.com/qt/qtgrpc.git
QProtobufMessage: add setProperty() overloads taking rvalue QVariant
Allows to take advantage of the recently-added QMetaProperty::write() rvalue-QVariant overload. Task-number: QTBUG-112762 Change-Id: I4fc6cc10cd3949dcf924f75966c21066d82563ef Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This commit is contained in:
parent
dc69102f4f
commit
f6d54db96f
|
|
@ -99,6 +99,20 @@ bool QProtobufMessage::setProperty(QAnyStringView propertyName, const QVariant &
|
|||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
\overload
|
||||
\since 6.6
|
||||
*/
|
||||
bool QProtobufMessage::setProperty(QAnyStringView propertyName, QVariant &&value)
|
||||
{
|
||||
Q_D(QProtobufMessage);
|
||||
|
||||
if (auto mp = d->metaProperty(propertyName))
|
||||
return mp->writeOnGadget(this, std::move(value));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
Get the value of the property \a propertyName.
|
||||
|
||||
|
|
@ -239,6 +253,16 @@ bool QProtobufMessage::setProperty(
|
|||
return mp->writeOnGadget(this, value);
|
||||
}
|
||||
|
||||
bool QProtobufMessage::setProperty(const QtProtobufPrivate::QProtobufPropertyOrderingInfo &info,
|
||||
QVariant &&value)
|
||||
{
|
||||
Q_D(QProtobufMessage);
|
||||
const auto mp = d->metaProperty(info);
|
||||
if (!mp)
|
||||
return false;
|
||||
return mp->writeOnGadget(this, value);
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#include "moc_qprotobufmessage.cpp"
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ class QProtobufMessage
|
|||
public:
|
||||
Q_PROTOBUF_EXPORT QVariant property(QAnyStringView propertyName) const;
|
||||
Q_PROTOBUF_EXPORT bool setProperty(QAnyStringView propertyName, const QVariant &value);
|
||||
Q_PROTOBUF_EXPORT bool setProperty(QAnyStringView propertyName, QVariant &&value);
|
||||
|
||||
Q_REQUIRED_RESULT
|
||||
Q_PROTOBUF_EXPORT static QProtobufMessagePointer constructByName(const QString &messageType);
|
||||
|
|
@ -50,6 +51,8 @@ protected:
|
|||
QVariant property(const QtProtobufPrivate::QProtobufPropertyOrderingInfo &fieldInfo) const;
|
||||
bool setProperty(const QtProtobufPrivate::QProtobufPropertyOrderingInfo &fieldInfo,
|
||||
const QVariant &value);
|
||||
bool setProperty(const QtProtobufPrivate::QProtobufPropertyOrderingInfo &fieldInfo,
|
||||
QVariant &&value);
|
||||
|
||||
private:
|
||||
const QMetaObject *metaObject() const;
|
||||
|
|
|
|||
Loading…
Reference in New Issue