From aee23999ac89a55b022b8984f72eb32dc1a99fd0 Mon Sep 17 00:00:00 2001 From: iaom Date: Mon, 27 Nov 2023 11:20:16 +0800 Subject: [PATCH] =?UTF-8?q?fix(libsearch):=E8=A7=A3=E5=86=B3=E7=BC=96?= =?UTF-8?q?=E8=AF=91=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libsearch/appdata/app-info-dbus-argument.h | 140 +++++++++--------- libsearch/appdata/app-info-table.cpp | 7 +- libsearch/appdata/application-property.h | 3 + .../searchtasks/file-content-search-task.h | 1 + 4 files changed, 76 insertions(+), 75 deletions(-) diff --git a/libsearch/appdata/app-info-dbus-argument.h b/libsearch/appdata/app-info-dbus-argument.h index 9bc2c1f..a94a09f 100644 --- a/libsearch/appdata/app-info-dbus-argument.h +++ b/libsearch/appdata/app-info-dbus-argument.h @@ -22,79 +22,75 @@ #include #include "application-property.h" -namespace UkuiSearch { - - QDBusArgument &operator << (QDBusArgument &argument, const ApplicationProperty::Property &property) { - argument.beginStructure(); - argument << static_cast(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(value); - return argument; - } - - QDBusArgument &operator << (QDBusArgument &argument, const ApplicationPropertyMap &appPropertyInfo) - { - argument.beginMap(/*qMetaTypeId()*/QVariant::Int, qMetaTypeId()); - for (auto i = appPropertyInfo.constBegin(); i != appPropertyInfo.constEnd(); ++i) { - QDBusVariant dbusVariant(i.value()); - argument.beginMapEntry(); - argument << static_cast(i.key()) << dbusVariant; - argument.endMapEntry(); - } - argument.endMap(); - return argument; - } - - const QDBusArgument &operator >> (const QDBusArgument &argument, ApplicationPropertyMap &appPropertyInfo) - { - argument.beginMap(); - while (!argument.atEnd()) { - int key; - QVariant value; - argument.beginMapEntry(); - argument >> key >> value; - argument.endMapEntry(); - appPropertyInfo.insert(static_cast(key), value); - } - argument.endMap(); - return argument; - } - - QDBusArgument &operator << (QDBusArgument &argument, const ApplicationInfoMap &appInfo) - { - argument.beginMap(QVariant::String, qMetaTypeId()); - 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; - ApplicationPropertyMap value; - argument.beginMapEntry(); - argument >> key >> value; - argument.endMapEntry(); - appInfo.insert(key, value); - } - argument.endMap(); - return argument; - } +using namespace UkuiSearch; +QDBusArgument &operator << (QDBusArgument &argument, const UkuiSearch::ApplicationProperty::Property &property) { + argument.beginStructure(); + argument << static_cast(property); + argument.endStructure(); + return argument; } +const QDBusArgument &operator >> (const QDBusArgument &argument, UkuiSearch::ApplicationProperty::Property &property) { + int value; + argument.beginStructure(); + argument >> value; + argument.endStructure(); + property = static_cast(value); + return argument; +} +QDBusArgument &operator << (QDBusArgument &argument, const ApplicationPropertyMap &appPropertyInfo) +{ + argument.beginMap(/*qMetaTypeId()*/QVariant::Int, qMetaTypeId()); + for (auto i = appPropertyInfo.constBegin(); i != appPropertyInfo.constEnd(); ++i) { + QDBusVariant dbusVariant(i.value()); + argument.beginMapEntry(); + argument << static_cast(i.key()) << dbusVariant; + argument.endMapEntry(); + } + argument.endMap(); + return argument; +} + +const QDBusArgument &operator >> (const QDBusArgument &argument, ApplicationPropertyMap &appPropertyInfo) +{ + argument.beginMap(); + while (!argument.atEnd()) { + int key; + QVariant value; + argument.beginMapEntry(); + argument >> key >> value; + argument.endMapEntry(); + appPropertyInfo.insert(static_cast(key), value); + } + argument.endMap(); + return argument; +} + +QDBusArgument &operator << (QDBusArgument &argument, const ApplicationInfoMap &appInfo) +{ + argument.beginMap(QVariant::String, qMetaTypeId()); + 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; + ApplicationPropertyMap value; + argument.beginMapEntry(); + argument >> key >> value; + argument.endMapEntry(); + appInfo.insert(key, value); + } + argument.endMap(); + return argument; +} #endif // APPINFODBUSARGUMENT_H diff --git a/libsearch/appdata/app-info-table.cpp b/libsearch/appdata/app-info-table.cpp index 8aa0fa2..741e6c7 100644 --- a/libsearch/appdata/app-info-table.cpp +++ b/libsearch/appdata/app-info-table.cpp @@ -25,10 +25,11 @@ static AppInfoTable *global_intance = nullptr; AppInfoTablePrivate::AppInfoTablePrivate(AppInfoTable *parent) : QObject(parent), q(parent), m_database(new QSqlDatabase()) { //dbus接收数据库信号 - qRegisterMetaType("ApplicationPropertyMap"); + qRegisterMetaType("ApplicationProperty::Property"); + qRegisterMetaType("ApplicationInfoMap"); + qRegisterMetaType("ApplicationPropertyMap"); + qDBusRegisterMetaType(); qDBusRegisterMetaType(); - - qRegisterMetaType("ApplicationInfoMap"); qDBusRegisterMetaType(); m_signalTransInterface = new QDBusInterface("com.ukui.search.appdb.service", diff --git a/libsearch/appdata/application-property.h b/libsearch/appdata/application-property.h index b81d799..c475e24 100644 --- a/libsearch/appdata/application-property.h +++ b/libsearch/appdata/application-property.h @@ -24,6 +24,7 @@ #include #include #include +#include namespace UkuiSearch { namespace ApplicationProperty { @@ -61,5 +62,7 @@ typedef QMap ApplicationPropertyMap; typedef QMap ApplicationInfoMap; // desktopFile->ApplicationPropertyMap } Q_DECLARE_METATYPE(UkuiSearch::ApplicationProperty::Property) +Q_DECLARE_METATYPE(UkuiSearch::ApplicationPropertyMap) Q_DECLARE_METATYPE(UkuiSearch::ApplicationInfoMap) +Q_DECLARE_METATYPE(UkuiSearch::ApplicationProperties) #endif // APPLICATIONPROPERTY_H diff --git a/libsearch/searchinterface/searchtasks/file-content-search-task.h b/libsearch/searchinterface/searchtasks/file-content-search-task.h index c453d5e..2c9dc9b 100644 --- a/libsearch/searchinterface/searchtasks/file-content-search-task.h +++ b/libsearch/searchinterface/searchtasks/file-content-search-task.h @@ -35,6 +35,7 @@ namespace UkuiSearch { class FileContentSearchTask : public SearchTaskPluginIface { + Q_OBJECT public: explicit FileContentSearchTask(QObject *parent = nullptr);