mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-02 23:25:53 +08:00
Issue #15 Added CVariant::matches()
If the contained object type has a matches() method, CVariant::matches() will call that method and return its result. (This is a utility to allow using CVariant to represent an event subscription.)
This commit is contained in:
@@ -533,6 +533,26 @@ namespace BlackMisc
|
||||
return toIcon().toPixmap();
|
||||
}
|
||||
|
||||
bool CVariant::matches(const CVariant &value) const
|
||||
{
|
||||
if (! isValid()) { return false; }
|
||||
auto *meta = getValueObjectMetaInfo();
|
||||
if (! meta)
|
||||
{
|
||||
CLogMessage(this).warning(u"Invalid type for CVariant::matches: %1") << typeName();
|
||||
return false;
|
||||
}
|
||||
try
|
||||
{
|
||||
return meta->matches(data(), value);
|
||||
}
|
||||
catch (const Private::CVariantException &ex)
|
||||
{
|
||||
CLogMessage(this).debug() << ex.what();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
QVariant fixQVariantFromDbusArgument(const QVariant &variant, int localUserType, const QString &typeName)
|
||||
{
|
||||
if (localUserType == static_cast<int>(QVariant::Invalid))
|
||||
|
||||
Reference in New Issue
Block a user