From 0b644ed20d1f6045945d7e2dbbcc91880139cb3c Mon Sep 17 00:00:00 2001 From: keke <243768648@qq.com> Date: Tue, 28 Feb 2023 10:36:17 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=BD=AF=E4=BB=B6=E5=8C=85=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E5=B7=B2=E5=AE=89=E8=A3=85=E5=88=A4=E6=96=AD=E6=9C=89?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/appmanagercommon.cpp | 5 +++++ src/common/appmanagercommon.h | 2 ++ src/job/appmanagerjob.cpp | 6 +++--- src/pkgmonitor/pkgmonitor.cpp | 2 +- src/pkgmonitor/pkgmonitor.h | 2 ++ 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/common/appmanagercommon.cpp b/src/common/appmanagercommon.cpp index 9175bca..dd3d745 100644 --- a/src/common/appmanagercommon.cpp +++ b/src/common/appmanagercommon.cpp @@ -70,3 +70,8 @@ QString AM::formatBytes(qint64 input, int prec) } return flowValueStr; } + +bool AM::judgePkgIsInstalledFromStr(const QString &str) +{ + return str.contains("installed") && !str.contains("not-installed"); +} diff --git a/src/common/appmanagercommon.h b/src/common/appmanagercommon.h index 25ecb70..e2e21e1 100644 --- a/src/common/appmanagercommon.h +++ b/src/common/appmanagercommon.h @@ -99,4 +99,6 @@ PinyinInfo getPinYinInfoFromStr(const QString &words); void popupNormalSysNotify(const QString &summary, const QString &body); // 格式化容量 QString formatBytes(qint64 input, int prec); +// 从状态字符串中判断包是否已安装 +bool judgePkgIsInstalledFromStr(const QString &str); } // namespace AM diff --git a/src/job/appmanagerjob.cpp b/src/job/appmanagerjob.cpp index 14bab5f..5d2eac2 100644 --- a/src/job/appmanagerjob.cpp +++ b/src/job/appmanagerjob.cpp @@ -550,7 +550,7 @@ bool AppManagerJob::getPkgInfoListFromFile(QList &pkgInfoList, const QS } if (lineText.startsWith("Status: ")) { - pkgInfo.isInstalled = lineText.contains("installed"); + pkgInfo.isInstalled = judgePkgIsInstalledFromStr(lineText); continue; } @@ -576,7 +576,7 @@ bool AppManagerJob::getPkgInfoListFromFile(QList &pkgInfoList, const QS } if (lineText.startsWith("Status: ")) { - pkgInfo.isInstalled = lineText.contains("installed"); + pkgInfo.isInstalled = judgePkgIsInstalledFromStr(lineText); pkgInfo.isHoldVersion = lineText.contains("hold"); continue; } @@ -681,7 +681,7 @@ bool AppManagerJob::getInstalledPkgInfo(PkgInfo &pkgInfo, const QString &pkgName } if (lineText.startsWith("Status: ")) { - pkgInfo.isInstalled = lineText.contains("installed"); + pkgInfo.isInstalled = judgePkgIsInstalledFromStr(lineText); pkgInfo.isHoldVersion = lineText.contains("hold"); continue; } diff --git a/src/pkgmonitor/pkgmonitor.cpp b/src/pkgmonitor/pkgmonitor.cpp index bb709e9..08c30ad 100644 --- a/src/pkgmonitor/pkgmonitor.cpp +++ b/src/pkgmonitor/pkgmonitor.cpp @@ -171,7 +171,7 @@ QSet PkgMonitor::getCurrentInstalledPkgNameSet() const } if (lineText.startsWith("Status: ")) { - isInstalled = lineText.contains("installed"); + isInstalled = AM::judgePkgIsInstalledFromStr(lineText); continue; } diff --git a/src/pkgmonitor/pkgmonitor.h b/src/pkgmonitor/pkgmonitor.h index 59f8f3c..9eb01d1 100644 --- a/src/pkgmonitor/pkgmonitor.h +++ b/src/pkgmonitor/pkgmonitor.h @@ -1,5 +1,7 @@ #pragma once +#include "../common/appmanagercommon.h" + #include #include #include -- Gitee