2023-03-10 17:47:04 +08:00
|
|
|
#ifndef APPINFODBUSARGUMENT_H
|
|
|
|
#define APPINFODBUSARGUMENT_H
|
|
|
|
|
|
|
|
#include <QDBusArgument>
|
|
|
|
#include "application-property.h"
|
|
|
|
|
|
|
|
namespace UkuiSearch {
|
|
|
|
|
|
|
|
QDBusArgument &operator << (QDBusArgument &argument, const ApplicationProperty::Property &property) {
|
|
|
|
argument.beginStructure();
|
|
|
|
argument << static_cast<int>(property);
|
|
|
|
argument.endStructure();
|
|
|
|
return argument;
|
|
|
|
}
|
|
|
|
|
|
|
|
const QDBusArgument &operator >> (const QDBusArgument &argument, ApplicationProperty::Property &property) {
|
|
|
|
int value;
|
|
|
|
argument.beginStructure();
|
|
|
|
argument >> value;
|
|
|
|
argument.endStructure();
|
|
|
|
property = static_cast<ApplicationProperty::Property>(value);
|
|
|
|
return argument;
|
|
|
|
}
|
|
|
|
|
2023-03-15 16:39:38 +08:00
|
|
|
QDBusArgument &operator << (QDBusArgument &argument, const ApplicationPropertyMap &appPropertyInfo)
|
2023-03-10 17:47:04 +08:00
|
|
|
{
|
|
|
|
argument.beginMap(/*qMetaTypeId<ApplicationProperty::Property>()*/QVariant::Int, qMetaTypeId<QDBusVariant>());
|
|
|
|
for (auto i = appPropertyInfo.constBegin(); i != appPropertyInfo.constEnd(); ++i) {
|
|
|
|
QDBusVariant dbusVariant(i.value());
|
|
|
|
argument.beginMapEntry();
|
|
|
|
argument << static_cast<int>(i.key()) << dbusVariant;
|
|
|
|
argument.endMapEntry();
|
|
|
|
}
|
|
|
|
argument.endMap();
|
|
|
|
return argument;
|
|
|
|
}
|
|
|
|
|
2023-03-15 16:39:38 +08:00
|
|
|
const QDBusArgument &operator >> (const QDBusArgument &argument, ApplicationPropertyMap &appPropertyInfo)
|
2023-03-10 17:47:04 +08:00
|
|
|
{
|
|
|
|
argument.beginMap();
|
|
|
|
while (!argument.atEnd()) {
|
|
|
|
int key;
|
|
|
|
QVariant value;
|
|
|
|
argument.beginMapEntry();
|
|
|
|
argument >> key >> value;
|
|
|
|
argument.endMapEntry();
|
|
|
|
appPropertyInfo.insert(static_cast<ApplicationProperty::Property>(key), value);
|
|
|
|
}
|
|
|
|
argument.endMap();
|
|
|
|
return argument;
|
|
|
|
}
|
|
|
|
|
|
|
|
QDBusArgument &operator << (QDBusArgument &argument, const ApplicationInfoMap &appInfo)
|
|
|
|
{
|
2023-03-15 16:39:38 +08:00
|
|
|
argument.beginMap(QVariant::String, qMetaTypeId<ApplicationPropertyMap>());
|
2023-03-10 17:47:04 +08:00
|
|
|
for (auto i = appInfo.constBegin(); i != appInfo.constEnd(); ++i) {
|
|
|
|
argument.beginMapEntry();
|
|
|
|
argument << i.key() << i.value();
|
|
|
|
argument.endMapEntry();
|
|
|
|
}
|
|
|
|
argument.endMap();
|
|
|
|
return argument;
|
|
|
|
}
|
|
|
|
|
|
|
|
const QDBusArgument &operator >> (const QDBusArgument &argument, ApplicationInfoMap &appInfo)
|
|
|
|
{
|
|
|
|
argument.beginMap();
|
|
|
|
while (!argument.atEnd()) {
|
|
|
|
QString key;
|
2023-03-15 16:39:38 +08:00
|
|
|
ApplicationPropertyMap value;
|
2023-03-10 17:47:04 +08:00
|
|
|
argument.beginMapEntry();
|
|
|
|
argument >> key >> value;
|
|
|
|
argument.endMapEntry();
|
|
|
|
appInfo.insert(key, value);
|
|
|
|
}
|
|
|
|
argument.endMap();
|
|
|
|
return argument;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif // APPINFODBUSARGUMENT_H
|