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);