File indexing completed on 2025-01-26 05:00:54

0001 /*
0002  *   SPDX-FileCopyrightText: 2021 Alexander Lohnau <alexander.lohnau@gmx.de>
0003  *
0004  *   SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #pragma once
0008 
0009 #include <QDBusArgument>
0010 #include <QList>
0011 #include <QString>
0012 #include <QVariantMap>
0013 
0014 enum Type {
0015     NoMatch = 0,
0016     CompletionMatch = 10,
0017     PossibleMatch = 30,
0018     InformationalMatch = 50,
0019     HelperMatch = 70,
0020     ExactMatch = 100,
0021 };
0022 
0023 struct RemoteMatch {
0024     // sssuda{sv}
0025     QString id;
0026     QString text;
0027     QString iconName;
0028     Type type = NoMatch;
0029     qreal relevance = 0;
0030     QVariantMap properties;
0031 };
0032 
0033 typedef QList<RemoteMatch> RemoteMatches;
0034 
0035 struct RemoteAction {
0036     QString id;
0037     QString text;
0038     QString iconName;
0039 };
0040 
0041 typedef QList<RemoteAction> RemoteActions;
0042 
0043 inline QDBusArgument &operator<<(QDBusArgument &argument, const RemoteMatch &match)
0044 {
0045     argument.beginStructure();
0046     argument << match.id;
0047     argument << match.text;
0048     argument << match.iconName;
0049     argument << match.type;
0050     argument << match.relevance;
0051     argument << match.properties;
0052     argument.endStructure();
0053     return argument;
0054 }
0055 
0056 inline const QDBusArgument &operator>>(const QDBusArgument &argument, RemoteMatch &match)
0057 {
0058     argument.beginStructure();
0059     argument >> match.id;
0060     argument >> match.text;
0061     argument >> match.iconName;
0062     uint type;
0063     argument >> type;
0064     match.type = (Type)type;
0065     argument >> match.relevance;
0066     argument >> match.properties;
0067     argument.endStructure();
0068 
0069     return argument;
0070 }
0071 
0072 inline QDBusArgument &operator<<(QDBusArgument &argument, const RemoteAction &action)
0073 {
0074     argument.beginStructure();
0075     argument << action.id;
0076     argument << action.text;
0077     argument << action.iconName;
0078     argument.endStructure();
0079     return argument;
0080 }
0081 
0082 inline const QDBusArgument &operator>>(const QDBusArgument &argument, RemoteAction &action)
0083 {
0084     argument.beginStructure();
0085     argument >> action.id;
0086     argument >> action.text;
0087     argument >> action.iconName;
0088     argument.endStructure();
0089     return argument;
0090 }
0091 
0092 Q_DECLARE_METATYPE(RemoteMatch)
0093 Q_DECLARE_METATYPE(RemoteMatches)
0094 Q_DECLARE_METATYPE(RemoteAction)
0095 Q_DECLARE_METATYPE(RemoteActions)