From 12d6d64c3b881c1fb78f844c32c95f10033aa403 Mon Sep 17 00:00:00 2001 From: JunjieBai Date: Mon, 4 Jul 2022 17:38:59 +0800 Subject: [PATCH] Change the pos if the override of QDbusArgument's operator>> in order to avoid others who use the app-info-table include dbus. --- libsearch/app-db-common.h | 23 +------------- libsearch/app-info-dbus-argument.h | 31 +++++++++++++++++++ libsearch/libsearch.pro | 1 + .../ukui-search-app-data-service.cpp | 1 + 4 files changed, 34 insertions(+), 22 deletions(-) create mode 100644 libsearch/app-info-dbus-argument.h diff --git a/libsearch/app-db-common.h b/libsearch/app-db-common.h index fba443b..00a1ee0 100644 --- a/libsearch/app-db-common.h +++ b/libsearch/app-db-common.h @@ -2,8 +2,6 @@ #define APPDBCOMMON_H #include -#include -#include namespace UkuiSearch { @@ -12,6 +10,7 @@ namespace UkuiSearch { struct AppInfoResult { +public: QString desktopPath; QString iconName; QString appLocalName; @@ -23,27 +22,7 @@ struct AppInfoResult int lock; AppInfoResult() : top(0), favorite(0), launchTimes(0), lock(0) {} - friend QDBusArgument &operator << (QDBusArgument &argument, const AppInfoResult &infoResult) - { - argument.beginStructure(); - argument << infoResult.desktopPath << infoResult.iconName << infoResult.appLocalName << infoResult.firstLetter - << infoResult.category << infoResult.top << infoResult.favorite << infoResult.launchTimes << infoResult.lock; - argument.endStructure(); - return argument; - } - - friend const QDBusArgument &operator >> (const QDBusArgument &argument, AppInfoResult &infoResult) - { - argument.beginStructure(); - argument >> infoResult.desktopPath >> infoResult.iconName >> infoResult.appLocalName >> infoResult.firstLetter - >> infoResult.category >> infoResult.top >> infoResult.favorite >> infoResult.launchTimes >> infoResult.lock; - - argument.endStructure(); - return argument; - } - }; - } Q_DECLARE_METATYPE(UkuiSearch::AppInfoResult) diff --git a/libsearch/app-info-dbus-argument.h b/libsearch/app-info-dbus-argument.h new file mode 100644 index 0000000..161e5d7 --- /dev/null +++ b/libsearch/app-info-dbus-argument.h @@ -0,0 +1,31 @@ +#ifndef APPINFODBUSARGUMENT_H +#define APPINFODBUSARGUMENT_H + +#include +#include "app-db-common.h" + +namespace UkuiSearch { + + QDBusArgument &operator << (QDBusArgument &argument, const AppInfoResult &infoResult) + { + argument.beginStructure(); + argument << infoResult.desktopPath << infoResult.iconName << infoResult.appLocalName << infoResult.firstLetter + << infoResult.category << infoResult.top << infoResult.favorite << infoResult.launchTimes << infoResult.lock; + argument.endStructure(); + return argument; + } + + const QDBusArgument &operator >> (const QDBusArgument &argument, AppInfoResult &infoResult) + { + argument.beginStructure(); + argument >> infoResult.desktopPath >> infoResult.iconName >> infoResult.appLocalName >> infoResult.firstLetter + >> infoResult.category >> infoResult.top >> infoResult.favorite >> infoResult.launchTimes >> infoResult.lock; + + argument.endStructure(); + return argument; + } + +} + + +#endif // APPINFODBUSARGUMENT_H diff --git a/libsearch/libsearch.pro b/libsearch/libsearch.pro index 18b3069..21661ec 100644 --- a/libsearch/libsearch.pro +++ b/libsearch/libsearch.pro @@ -51,6 +51,7 @@ SOURCES += \ HEADERS += \ app-db-common.h \ + app-info-dbus-argument.h \ common.h \ file-utils.h \ global-settings.h \ diff --git a/ukui-search-app-data-service/ukui-search-app-data-service.cpp b/ukui-search-app-data-service/ukui-search-app-data-service.cpp index 1acef86..e2d6ae3 100644 --- a/ukui-search-app-data-service/ukui-search-app-data-service.cpp +++ b/ukui-search-app-data-service/ukui-search-app-data-service.cpp @@ -1,6 +1,7 @@ #include "ukui-search-app-data-service.h" #include "app-db-manager.h" #include "signal-transformer.h" +#include "app-info-dbus-argument.h" #include #include