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