converting value objects to/from QVariant

refs #81
This commit is contained in:
Klaus Basan
2013-12-13 19:58:51 +00:00
committed by Mathew Sutcliffe
parent 0518e680c3
commit 67a5dbfe48
31 changed files with 457 additions and 0 deletions

View File

@@ -43,6 +43,23 @@ namespace BlackMisc
return this->convertToQString();
}
/*
* Return backing streamable object (if any)
*/
const CValueObject *CValueObject::fromQVariant(const QVariant &qv)
{
if (!qv.isValid()) return nullptr;
QVariant::Type t = qv.type();
uint ut = qv.userType();
if (t != QVariant::UserType) return nullptr; // not a user type
if (ut <= QVariant::UserType) return nullptr; // complex Qt type
if (qv.canConvert<QDBusArgument>()) return nullptr; // not unstreamed yet
// this cast cannot be dynamic, so the aboce conditions are crucical
const CValueObject *vo = static_cast<const CValueObject *>(qv.constData());
return vo;
}
/*
* from DBus
*/