From 9b9480eb83171842d9d9cf50fa89bd477a79a579 Mon Sep 17 00:00:00 2001 From: qiqi49 Date: Mon, 26 Aug 2024 15:15:12 +0800 Subject: [PATCH] =?UTF-8?q?fix(issues:I9ITES):=E8=A7=A3=E5=86=B3=E6=8B=96?= =?UTF-8?q?=E6=8B=BD=E6=B7=BB=E5=8A=A0=E6=88=96=E5=8F=B3=E9=94=AE=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=88=B0=E6=94=B6=E8=97=8F=E5=8C=BA=E5=9F=9F,UI?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E5=8D=A1=E9=A1=BF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/extension/favorite/app-favorite-model.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/extension/favorite/app-favorite-model.cpp b/src/extension/favorite/app-favorite-model.cpp index aaea837..ef3ddb8 100644 --- a/src/extension/favorite/app-favorite-model.cpp +++ b/src/extension/favorite/app-favorite-model.cpp @@ -129,9 +129,12 @@ void AppFavoritesModel::updateFavoritesApps(const DataEntity &app, const QModelI if (app.id().isEmpty()) { return; } + QPersistentModelIndex index(sourceIndex); if (app.favorite() > 0 && !FavoriteFolderHelper::instance()->containApp(app.id())) { - QPersistentModelIndex index(sourceIndex); + if (m_favoritesApps.contains(index)) { + return; + } addFavoriteApp(index); FavoritesConfig::instance().insertValue(APP_ID_SCHEME + index.data(DataEntity::Id).toString()); @@ -139,8 +142,6 @@ void AppFavoritesModel::updateFavoritesApps(const DataEntity &app, const QModelI if (FavoriteFolderHelper::instance()->containApp(app.id())) { FavoriteFolderHelper::instance()->removeAppFromFolder(app.id()); } - - QPersistentModelIndex index(sourceIndex); removeFavoriteApp(index); } } @@ -365,6 +366,8 @@ void AppFavoritesModel::addAppToFavorites(const QString &id, const int &index) if (id.isEmpty()) { return; } + QPersistentModelIndex modelIndex(m_sourceModel->index(m_sourceModel->indexOfApp(id))); + addFavoriteApp(modelIndex); m_sourceModel->databaseInterface()->fixAppToFavorite(id, 1);