diff --git a/src/models/appitem.cpp b/src/models/appitem.cpp index 33d783de..cf0c4d91 100644 --- a/src/models/appitem.cpp +++ b/src/models/appitem.cpp @@ -4,6 +4,8 @@ #include "appitem.h" +#include + AppItem::AppItem(const QString &freedesktopId) : QStandardItem() { @@ -47,7 +49,12 @@ const QString AppItem::iconName() const void AppItem::setIconName(const QString &iconName) { - setData(iconName.isEmpty() ? "application-x-desktop" : iconName, AppItem::IconNameRole); + QString name = iconName; + if (QFileInfo(iconName).isAbsolute()) { + name = QUrl::fromLocalFile(iconName).toString(); // path ==> file://path + } + + setData(iconName.isEmpty() ? "application-x-desktop" : name, AppItem::IconNameRole); } const QStringList AppItem::categories() const diff --git a/src/models/appsmodel.cpp b/src/models/appsmodel.cpp index 7dcc1127..83894c89 100644 --- a/src/models/appsmodel.cpp +++ b/src/models/appsmodel.cpp @@ -197,14 +197,17 @@ QVariant AppsModel::data(const QModelIndex &index, int role) const void AppsModel::updateModelData() { - // TODO release icon's cache when gtk's icon-theme.cache is updated. - IconUtils::tryUpdateIconCache(); + beginResetModel(); + qDebug() << "reset model."; + QList items(allAppInfosShouldBeShown()); cleanUpInvalidApps(items); QList duplicatedItems = updateItems(items); for (AppItem * item : std::as_const(duplicatedItems)) { delete item; } + + endResetModel(); } // the caller manage the return values' ownership (i.e. might need to free them)