fix(libappdata): 解决第一次启动时应用重复的问题
This commit is contained in:
parent
c0639b8845
commit
1522068a28
|
@ -56,7 +56,7 @@ private Q_SLOTS:
|
|||
|
||||
private:
|
||||
static void addInfoToApp(const QMap<UkuiSearch::ApplicationProperty::Property, QVariant> &info, DataEntity &app);
|
||||
bool isFiltered(const UkuiSearch::ApplicationPropertyMap &appInfo) const;
|
||||
bool isFilterAccepted(const UkuiSearch::ApplicationPropertyMap &appInfo) const;
|
||||
|
||||
private:
|
||||
AppDatabaseInterface *q {nullptr};
|
||||
|
@ -126,12 +126,12 @@ void AppDatabaseWorkerPrivate::addInfoToApp(const UkuiSearch::ApplicationPropert
|
|||
app.setLaunched(info.value(UkuiSearch::ApplicationProperty::Property::Launched).toInt());
|
||||
}
|
||||
|
||||
bool AppDatabaseWorkerPrivate::isFiltered(const UkuiSearch::ApplicationPropertyMap &appInfo) const
|
||||
bool AppDatabaseWorkerPrivate::isFilterAccepted(const UkuiSearch::ApplicationPropertyMap &appInfo) const
|
||||
{
|
||||
QMapIterator<UkuiSearch::ApplicationProperty::Property, QVariant> iterator(filter);
|
||||
while (iterator.hasNext()) {
|
||||
iterator.next();
|
||||
if (appInfo.value(iterator.key()) == iterator.value()) {
|
||||
if (appInfo.value(iterator.key()) != iterator.value()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -170,7 +170,7 @@ void AppDatabaseWorkerPrivate::onAppDatabaseAdded(const QStringList &infos)
|
|||
DataEntityVector apps;
|
||||
for (const QString &appid : infos) {
|
||||
const UkuiSearch::ApplicationPropertyMap appInfo = appDatabase->getInfo(appid, properties);
|
||||
if (isFiltered(appInfo)) {
|
||||
if (!isFilterAccepted(appInfo)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -120,8 +120,15 @@ const AppDatabaseInterface *BasicAppModel::databaseInterface() const
|
|||
|
||||
void BasicAppModel::onAppAdded(const DataEntityVector &apps)
|
||||
{
|
||||
beginInsertRows(QModelIndex(), m_apps.size(), m_apps.size() + apps.size() - 1);
|
||||
m_apps.append(apps);
|
||||
DataEntityVector appItems;
|
||||
for (auto const & app : apps) {
|
||||
if (indexOfApp(app.id()) < 0) {
|
||||
appItems.append(app);
|
||||
}
|
||||
}
|
||||
if (appItems.isEmpty()) return;
|
||||
beginInsertRows(QModelIndex(), m_apps.size(), m_apps.size() + appItems.size() - 1);
|
||||
m_apps.append(appItems);
|
||||
endInsertRows();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue