[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [apper] /: Fix getting icons from Appstream
From:       Daniel Nicoletti <null () kde ! org>
Date:       2018-01-19 20:30:36
Message-ID: E1ecdJ6-0003Zd-54 () code ! kde ! org
[Download RAW message or body]

Git commit b3f58307a1468f277dee7da1dc94ac3f4f1d74a8 by Daniel Nicoletti.
Committed on 19/01/2018 at 20:30.
Pushed by dantti into branch 'master'.

Fix getting icons from Appstream

M  +1    -1    Apper/CMakeLists.txt
M  +11   -13   Apper/PackageDetails.cpp
M  +1    -1    Apper/PackageDetails.h
M  +2    -2    Apper/ScreenShotViewer.cpp
M  +2    -2    Apper/ScreenShotViewer.h
M  +1    -1    apperd/CMakeLists.txt
M  +140  -119  libapper/AppStream.cpp
M  +14   -20   libapper/AppStream.h
M  +3    -10   libapper/CMakeLists.txt
M  +23   -11   libapper/PackageModel.cpp

https://commits.kde.org/apper/b3f58307a1468f277dee7da1dc94ac3f4f1d74a8

diff --git a/Apper/CMakeLists.txt b/Apper/CMakeLists.txt
index 132549b..2b71603 100644
--- a/Apper/CMakeLists.txt
+++ b/Apper/CMakeLists.txt
@@ -43,7 +43,7 @@ add_executable(apper
 target_link_libraries(apper
     KF5::IconThemes
     KF5::DBusAddons
-    ${PackageKitQt5_LIBRARIES}
+    PK::packagekitqt5
     apper_private
 )
 
diff --git a/Apper/PackageDetails.cpp b/Apper/PackageDetails.cpp
index 3a36763..28de201 100644
--- a/Apper/PackageDetails.cpp
+++ b/Apper/PackageDetails.cpp
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2009-2011 by Daniel Nicoletti                           *
+ *   Copyright (C) 2009-2018 by Daniel Nicoletti                           *
  *   dantti12@gmail.com                                                    *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
@@ -321,10 +321,9 @@ void PackageDetails::setPackage(const QModelIndex &index)
 
 void PackageDetails::on_screenshotL_clicked()
 {
-    QString url;
-    url = screenshot(Transaction::packageName(m_packageID));
-    if (!url.isNull()) {
-        ScreenShotViewer *view = new ScreenShotViewer(url);
+    const QUrl url = screenshot(Transaction::packageName(m_packageID));
+    if (!url.isEmpty()) {
+        auto view = new ScreenShotViewer(url);
         view->setWindowTitle(m_appName);
         view->show();
     }
@@ -735,13 +734,13 @@ QString PackageDetails::thumbnail(const QString &pkgName) const
 #endif
 }
 
-QString PackageDetails::screenshot(const QString &pkgName) const
+QUrl PackageDetails::screenshot(const QString &pkgName) const
 {
 #ifndef HAVE_APPSTREAM
     Q_UNUSED(pkgName)
-    return QString();
+    return QUrl();
 #else
-    return QString();// AppStream::instance()->screenshot(pkgName);
+    return AppStreamHelper::instance()->screenshot(pkgName);
 #endif
 }
 
@@ -757,11 +756,10 @@ void PackageDetails::description(const PackageKit::Details \
                &details)
     // FIXME: The whole AppStream handling sucks badly, since it was added later
     // and on to of the package-based model. So we can't respect the "multiple apps
     // in one package" case here.
-    QList<AppStream::Application> apps;
-//    apps = AppStream::instance()->applications(Transaction::packageName(m_packageID));
                
-    for (const AppStream::Application &app : apps) {
-        if (!app.description.isEmpty()) {
-            m_detailsDescription = app.description;
+    const QList<AppStream::Component> apps = \
AppStreamHelper::instance()->applications(Transaction::packageName(m_packageID)); +   \
for (const AppStream::Component &app : apps) { +        if \
(!app.description().isEmpty()) { +            m_detailsDescription = \
app.description();  break;
         }
     }
diff --git a/Apper/PackageDetails.h b/Apper/PackageDetails.h
index c85a094..a900499 100644
--- a/Apper/PackageDetails.h
+++ b/Apper/PackageDetails.h
@@ -78,7 +78,7 @@ private:
     void setupDescription();
     QVector<QPair<QString, QString> > locateApplication(const QString &_relPath, \
const QString &menuId) const;  QString thumbnail(const QString &pkgName) const;
-    QString screenshot(const QString &pkgName) const;
+    QUrl screenshot(const QString &pkgName) const;
 
     Ui::PackageDetails *ui;
     QActionGroup *m_actionGroup;
diff --git a/Apper/ScreenShotViewer.cpp b/Apper/ScreenShotViewer.cpp
index b274017..ef2206b 100644
--- a/Apper/ScreenShotViewer.cpp
+++ b/Apper/ScreenShotViewer.cpp
@@ -33,7 +33,7 @@
 
 #include "ClickableLabel.h"
 
-ScreenShotViewer::ScreenShotViewer(const QString &url, QWidget *parent)
+ScreenShotViewer::ScreenShotViewer(const QUrl &url, QWidget *parent)
  : QScrollArea(parent)
 {
     m_screenshotL = new ClickableLabel(this);
@@ -52,7 +52,7 @@ ScreenShotViewer::ScreenShotViewer(const QString &url, QWidget \
*parent)  //    tempFile->setPrefix("appgetfull");
 //    tempFile->setSuffix(".png");
     tempFile->open();
-    KIO::FileCopyJob *job = KIO::file_copy(QUrl(url),
+    KIO::FileCopyJob *job = KIO::file_copy(url,
                                            QUrl(tempFile->fileName()),
                                            -1,
                                            KIO::Overwrite | KIO::HideProgressInfo);
diff --git a/Apper/ScreenShotViewer.h b/Apper/ScreenShotViewer.h
index 7abe280..bde2b04 100644
--- a/Apper/ScreenShotViewer.h
+++ b/Apper/ScreenShotViewer.h
@@ -1,5 +1,5 @@
 /***************************************************************************
- *   Copyright (C) 2009-2010 by Daniel Nicoletti                           *
+ *   Copyright (C) 2009-2018 by Daniel Nicoletti                           *
  *   dantti12@gmail.com                                                    *
  *                                                                         *
  *   This program is free software; you can redistribute it and/or modify  *
@@ -33,7 +33,7 @@ class ScreenShotViewer : public QScrollArea
 {
 Q_OBJECT
 public:
-    explicit ScreenShotViewer(const QString &url, QWidget *parent = 0);
+    explicit ScreenShotViewer(const QUrl &url, QWidget *parent = nullptr);
     ~ScreenShotViewer();
 
 private Q_SLOTS:
diff --git a/apperd/CMakeLists.txt b/apperd/CMakeLists.txt
index 665b3c9..495f033 100644
--- a/apperd/CMakeLists.txt
+++ b/apperd/CMakeLists.txt
@@ -25,8 +25,8 @@ target_link_libraries(kded_apperd
     KF5::KIOFileWidgets
     KF5::Notifications
     KF5::DBusAddons
-    ${PackageKitQt5_LIBRARIES}
     PW::KWorkspace
+    PK::packagekitqt5
     apper_private
 )
 
diff --git a/libapper/AppStream.cpp b/libapper/AppStream.cpp
index eecc763..fb94a28 100644
--- a/libapper/AppStream.cpp
+++ b/libapper/AppStream.cpp
@@ -22,128 +22,137 @@
 #include <config.h>
 
 #include <AppStreamQt/pool.h>
+#include <AppStreamQt/icon.h>
+#include <AppStreamQt/image.h>
+#include <AppStreamQt/screenshot.h>
 
 #include "AppStream.h"
 
 #include <QApplication>
+#include <QLoggingCategory>
 
-AppStream* AppStream::m_instance = 0;
+Q_DECLARE_LOGGING_CATEGORY(APPER_LIB)
 
-AppStream* AppStream::instance()
+AppStreamHelper* AppStreamHelper::m_instance = 0;
+
+AppStreamHelper* AppStreamHelper::instance()
 {
     if(!m_instance) {
-        m_instance = new AppStream(qApp);
+        m_instance = new AppStreamHelper(qApp);
         m_instance->open();
     }
 
     return m_instance;
 }
 
-AppStream::AppStream(QObject *parent)
+AppStreamHelper::AppStreamHelper(QObject *parent)
  : QObject(parent)
 {
 #ifdef HAVE_APPSTREAM
     // create new AppStream metadata pool
-    m_pool = APPSTREAMQT_();
+    m_pool = new AppStream::Pool(this);
 #endif //HAVE_APPSTREAM
 }
 
-AppStream::~AppStream()
+AppStreamHelper::~AppStreamHelper()
 {
-#ifdef HAVE_APPSTREAM
-    g_object_unref(m_pool);
-#endif
 }
 
-bool AppStream::open()
+bool AppStreamHelper::open()
 {
-#ifdef HAVE_APPSTREAM
-    g_autoptr(GError) error = NULL;
-
-    as_pool_load (m_pool, NULL, &error);
-    if (error != NULL) {
-        qWarning("Unable to open AppStream metadata pool: %s", error->message);
-        return false;
-    }
-
-    // cache application data (we should actually search the data directly via \
                as_pool_search()...)
-    auto cptArray = as_pool_get_components(m_pool);
-    if (cptArray == NULL) {
-        qWarning("AppStream application array way NULL! (This should never \
happen)"); +#ifdef HAVE_APPSTREAM    
+    QString error;
+    if (!m_pool->load(&error)) {
+        qCWarning(APPER_LIB) << "Unable to open AppStream metadata pool:" << error;
         return false;
     }
 
-    for (uint i = 0; i < cptArray->len; i++) {
-        auto cpt = AS_COMPONENT (g_ptr_array_index(cptArray, i));
-        // we only want apps at time
-        auto cptKind = as_component_get_kind (cpt);
-        if ((cptKind != AS_COMPONENT_KIND_DESKTOP_APP) &&
-            (cptKind != AS_COMPONENT_KIND_CONSOLE_APP) &&
-            (cptKind != AS_COMPONENT_KIND_WEB_APP))
-            continue;
-
-        Application app;
-        // Application name
-        app.name = QString::fromUtf8(as_component_get_name(cpt));
-
-        // Package name
-        auto pkgnameC = as_component_get_pkgname(cpt);
-        QString pkgName;
-        if (pkgnameC != NULL)
-            pkgName = QString::fromUtf8(pkgnameC);
-
-        // Desktop file
-        app.id = QString::fromUtf8(as_component_get_id(cpt));
-
-        // Summary
-        app.summary = QString::fromUtf8(as_component_get_summary(cpt));
-
-        // Description
-        app.description = QString::fromUtf8(as_component_get_description(cpt));
-
-        // Application stock icon
-        auto icons = as_component_get_icons(cpt);
-        for (uint i = 0; i < icons->len; i++) {
-            auto icon = AS_ICON (g_ptr_array_index (icons, i));
-            if (as_icon_get_kind (icon) != AS_ICON_KIND_STOCK)
-                 app.icon_url = QString::fromUtf8(as_icon_get_filename (icon));
+//    // cache application data (we should actually search the data directly via \
as_pool_search()...) +//    auto cptArray = as_pool_get_components(m_pool);
+//    if (cptArray == NULL) {
+//        qWarning("AppStream application array way NULL! (This should never \
happen)"); +//        return false;
+//    }
+
+//    for (uint i = 0; i < cptArray->len; i++) {
+//        auto cpt = AS_COMPONENT (g_ptr_array_index(cptArray, i));
+//        // we only want apps at time
+//        auto cptKind = as_component_get_kind (cpt);
+//        if ((cptKind != AS_COMPONENT_KIND_DESKTOP_APP) &&
+//            (cptKind != AS_COMPONENT_KIND_CONSOLE_APP) &&
+//            (cptKind != AS_COMPONENT_KIND_WEB_APP))
+//            continue;
+
+//        Application app;
+//        // Application name
+//        app.name = QString::fromUtf8(as_component_get_name(cpt));
+
+//        // Package name
+//        auto pkgnameC = as_component_get_pkgname(cpt);
+//        QString pkgName;
+//        if (pkgnameC != NULL)
+//            pkgName = QString::fromUtf8(pkgnameC);
+
+//        // Desktop file
+//        app.id = QString::fromUtf8(as_component_get_id(cpt));
+
+//        // Summary
+//        app.summary = QString::fromUtf8(as_component_get_summary(cpt));
+
+//        // Description
+//        app.description = QString::fromUtf8(as_component_get_description(cpt));
+
+//        // Application stock icon
+//        auto icons = as_component_get_icons(cpt);
+//        for (uint i = 0; i < icons->len; i++) {
+//            auto icon = AS_ICON (g_ptr_array_index (icons, i));
+//            if (as_icon_get_kind (icon) != AS_ICON_KIND_STOCK)
+//                 app.icon_url = QString::fromUtf8(as_icon_get_filename (icon));
+//        }
+
+//        // Application categories
+//        app.categories = QStringList();
+//        auto cats = as_component_get_categories(cpt);
+//        for (uint i = 0; i < cats->len; i++) {
+//            auto category = (const gchar*) g_ptr_array_index (cats, i);
+//            app.categories << QString::fromUtf8(category);
+//        }
+
+//        // add default screenshot urls
+//        auto scrs = as_component_get_screenshots (cpt);
+
+//        // find default screenshot, if possible (otherwise we get a random one)
+//        AsScreenshot *scr = NULL;
+//        for (uint i = 0; i < scrs->len; i++) {
+//            scr = AS_SCREENSHOT (g_ptr_array_index (scrs, i));
+//            if (as_screenshot_get_kind (scr) == AS_SCREENSHOT_KIND_DEFAULT)
+//                break;
+//        }
+
+//        if (scr != NULL) {
+//            auto imgs = as_screenshot_get_images (scr);
+//            for (uint i = 0; i < imgs->len; i++) {
+//                auto img = AS_IMAGE (g_ptr_array_index (imgs, i));
+//                if ((as_image_get_kind (img) == AS_IMAGE_KIND_SOURCE) && \
(app.screenshot.isEmpty())) { +//                    app.screenshot = \
QString::fromUtf8(as_image_get_url (img)); +//                } else if \
((as_image_get_kind (img) == AS_IMAGE_KIND_THUMBNAIL) && (app.thumbnail.isEmpty())) { \
+//                    app.thumbnail = QString::fromUtf8(as_image_get_url (img)); +// \
} +
+//                if ((!app.screenshot.isEmpty()) && (!app.thumbnail.isEmpty()))
+//                    break;
+//            }
+//        }
+
+//        m_appInfo.insertMulti(pkgName, app);
+//    }
+
+    const QList<AppStream::Component> apps = \
m_pool->componentsByKind(AppStream::Component::KindDesktopApp); +    for (const \
AppStream::Component &app : apps) { +        const QStringList pkgNames = \
app.packageNames(); +        for (const QString &pkgName : pkgNames) {
+            m_appInfo.insertMulti(pkgName, app);
         }
-
-        // Application categories
-        app.categories = QStringList();
-        auto cats = as_component_get_categories(cpt);
-        for (uint i = 0; i < cats->len; i++) {
-            auto category = (const gchar*) g_ptr_array_index (cats, i);
-            app.categories << QString::fromUtf8(category);
-        }
-
-        // add default screenshot urls
-        auto scrs = as_component_get_screenshots (cpt);
-
-        // find default screenshot, if possible (otherwise we get a random one)
-        AsScreenshot *scr = NULL;
-        for (uint i = 0; i < scrs->len; i++) {
-            scr = AS_SCREENSHOT (g_ptr_array_index (scrs, i));
-            if (as_screenshot_get_kind (scr) == AS_SCREENSHOT_KIND_DEFAULT)
-                break;
-        }
-
-        if (scr != NULL) {
-            auto imgs = as_screenshot_get_images (scr);
-            for (uint i = 0; i < imgs->len; i++) {
-                auto img = AS_IMAGE (g_ptr_array_index (imgs, i));
-                if ((as_image_get_kind (img) == AS_IMAGE_KIND_SOURCE) && \
                (app.screenshot.isEmpty())) {
-                    app.screenshot = QString::fromUtf8(as_image_get_url (img));
-                } else if ((as_image_get_kind (img) == AS_IMAGE_KIND_THUMBNAIL) && \
                (app.thumbnail.isEmpty())) {
-                    app.thumbnail = QString::fromUtf8(as_image_get_url (img));
-                }
-
-                if ((!app.screenshot.isEmpty()) && (!app.thumbnail.isEmpty()))
-                    break;
-            }
-        }
-
-        m_appInfo.insertMulti(pkgName, app);
     }
 
     return true;
@@ -152,47 +161,49 @@ bool AppStream::open()
 #endif
 }
 
-QList<AppStream::Application> AppStream::applications(const QString &pkgName) const
+QList<AppStream::Component> AppStreamHelper::applications(const QString &pkgName) \
const  {
     return m_appInfo.values(pkgName);
 }
 
-QString AppStream::genericIcon(const QString &pkgName) const
+QString AppStreamHelper::genericIcon(const QString &pkgName) const
 {
     if (m_appInfo.contains(pkgName)) {
-        foreach (const Application &app, applications(pkgName)) {
-            if (!app.icon_url.isEmpty()) {
-                return app.icon_url;
-            }
-        }
+//        const QList<AppStream::Component> apps = applications(pkgName);
+//        for (const AppStream::Component &app : apps) {
+//            if (!app.icon_url.isEmpty()) {
+//                return app.icon_url;
+//            }
+//        }
     }
 
     return QString();
 }
 
-QStringList AppStream::findPkgNames(const CategoryMatcher &parser) const
+QStringList AppStreamHelper::findPkgNames(const CategoryMatcher &parser) const
 {
     QStringList packages;
 
-    QHash<QString, Application>::const_iterator i = m_appInfo.constBegin();
-    while (i != m_appInfo.constEnd()) {
-        if (parser.match(i.value().categories)) {
-//            kDebug() << i.key() << categories;
-            packages << i.key();
-        }
-        ++i;
-    }
+//    QHash<QString, Application>::const_iterator i = m_appInfo.constBegin();
+//    while (i != m_appInfo.constEnd()) {
+//        if (parser.match(i.value().categories)) {
+////            kDebug() << i.key() << categories;
+//            packages << i.key();
+//        }
+//        ++i;
+//    }
 
     return packages;
 }
 
-QString AppStream::thumbnail(const QString &pkgName) const
+QString AppStreamHelper::thumbnail(const QString &pkgName) const
 {
 #ifdef HAVE_APPSTREAM
-    QString url = "";
+    QString url = QLatin1String("");
     if (m_appInfo.contains(pkgName)) {
-        Application app = m_appInfo.value(pkgName);
-        url = app.thumbnail;
+        AppStream::Component app = m_appInfo.value(pkgName);
+//        )
+//        url = app.icon();
     }
 
     return url;
@@ -202,18 +213,28 @@ QString AppStream::thumbnail(const QString &pkgName) const
 #endif //HAVE_APPSTREAM
 }
 
-QString AppStream::screenshot(const QString &pkgName) const
+QUrl AppStreamHelper::screenshot(const QString &pkgName) const
 {
+    QUrl url;
 #ifdef HAVE_APPSTREAM
-    QString url = "";
     if (m_appInfo.contains(pkgName)) {
-        Application app = m_appInfo.value(pkgName);
-        url = app.screenshot;
+        AppStream::Component app = m_appInfo.value(pkgName);
+        const QList<AppStream::Screenshot> screenshots = app.screenshots();
+        for (const AppStream::Screenshot &screenshot : screenshots) {
+            const QList<AppStream::Image> images = screenshot.images();
+            for (const AppStream::Image &image : images) {
+                url = image.url();
+                break;
+            }
+
+            if (screenshot.isDefault() && !url.isEmpty()) {
+                break;
+            }
+        }
     }
 
-    return url;
 #else
     Q_UNUSED(pkgName)
-    return QString();
 #endif //HAVE_APPSTREAM
+    return url;
 }
diff --git a/libapper/AppStream.h b/libapper/AppStream.h
index f7e68d2..0f87ca4 100644
--- a/libapper/AppStream.h
+++ b/libapper/AppStream.h
@@ -24,42 +24,36 @@
 
 #include "CategoryMatcher.h"
 
+#include <AppStreamQt/component.h>
+
 #include <QObject>
 #include <QHash>
 
-struct _AsPool;
+namespace AppStream {
+class Pool;
+}
 
 struct _AsScreenshotService;
 typedef struct _AsScreenshotService AsScreenshotService;
 
-class Q_DECL_EXPORT AppStream : public QObject {
+class Q_DECL_EXPORT AppStreamHelper : public QObject {
     public:
-        struct Application {
-            QString name;
-            QString summary;
-            QString description;
-            QString icon_url;
-            QString id;
-            QStringList categories;
-            QString screenshot;
-            QString thumbnail;
-        };
-        static AppStream* instance();
-        virtual ~AppStream();
+        static AppStreamHelper* instance();
+        virtual ~AppStreamHelper();
         bool open();
 
-        QList<Application> applications(const QString &pkgName) const;
+        QList<AppStream::Component> applications(const QString &pkgName) const;
         QString genericIcon(const QString &pkgName) const;
         QStringList findPkgNames(const CategoryMatcher &parser) const;
         QString thumbnail(const QString &pkgName) const;
-        QString screenshot(const QString &pkgName) const;
+        QUrl screenshot(const QString &pkgName) const;
 
     private:
-        explicit AppStream(QObject *parent = 0);
-        _AsPool *m_pool;
+        explicit AppStreamHelper(QObject *parent = 0);
+        AppStream::Pool *m_pool;
 
-        QHash<QString, Application> m_appInfo;
-        static AppStream         *m_instance;
+        QHash<QString, AppStream::Component> m_appInfo;
+        static AppStreamHelper         *m_instance;
 };
 
 #endif // APPSTREAM_H
diff --git a/libapper/CMakeLists.txt b/libapper/CMakeLists.txt
index b0c8685..6581778 100644
--- a/libapper/CMakeLists.txt
+++ b/libapper/CMakeLists.txt
@@ -36,11 +36,9 @@ set(libapper_SRCS
 )
 
 if(APPSTREAM)
-#    pkg_check_modules(GLIB2 REQUIRED glib-2.0>=2.36)
-#    pkg_check_modules(APPSTREAM REQUIRED appstream>=0.10.0)
     find_package(AppStreamQt REQUIRED)
 
-#    set(libapper_SRCS ${libapper_SRCS} AppStream.cpp)
+    set(libapper_SRCS ${libapper_SRCS} AppStream.cpp)
 endif()
 
 ki18n_wrap_ui(libapper_SRCS
@@ -54,19 +52,14 @@ ki18n_wrap_ui(libapper_SRCS
 
 add_library(apper_private SHARED ${libapper_SRCS})
 
-include_directories(${CMAKE_CURRENT_BINARY_DIR}
-    ${GLIB2_INCLUDE_DIR}
-    ${APPSTREAM_INCLUDE_DIRS}
-)
-
 target_link_libraries(apper_private
     KF5::WidgetsAddons
     KF5::KIOFileWidgets
     KF5::IconThemes
     KF5::I18n
     Qt5::Core
-    ${PackageKitQt5_LIBRARIES}
-    ${APPSTREAM_LIBRARIES}
+    PK::packagekitqt5
+    AppStreamQt
 )
 
 install(TARGETS apper_private DESTINATION ${CMAKE_INSTALL_LIBDIR}/apper)
diff --git a/libapper/PackageModel.cpp b/libapper/PackageModel.cpp
index 9f63ff5..f343946 100644
--- a/libapper/PackageModel.cpp
+++ b/libapper/PackageModel.cpp
@@ -37,6 +37,7 @@
 #include <KFormat>
 
 #ifdef HAVE_APPSTREAM
+#include <AppStreamQt/icon.h>
 #include <AppStream.h>
 #endif
 
@@ -45,6 +46,8 @@
 
 using namespace PackageKit;
 
+Q_DECLARE_LOGGING_CATEGORY(APPER_LIB)
+
 PackageModel::PackageModel(QObject *parent)
 : QAbstractItemModel(parent),
   m_finished(false),
@@ -100,12 +103,12 @@ void PackageModel::addPackage(Transaction::Info info, const \
QString &packageID,  }
 
 #ifdef HAVE_APPSTREAM
-    QList<AppStream::Application> applications;
+    QList<AppStream::Component> applications;
     if (!m_checkable) {
         const QString packageName = Transaction::packageName(packageID);
-//        applications = AppStream::instance()->applications(packageName);
+        applications = AppStreamHelper::instance()->applications(packageName);
 
-        for (const AppStream::Application &app : applications) {
+        for (const AppStream::Component &app : applications) {
             InternalPackage iPackage;
             iPackage.info = info;
             iPackage.packageID = packageID;
@@ -114,18 +117,27 @@ void PackageModel::addPackage(Transaction::Info info, const \
QString &packageID,  iPackage.arch = Transaction::packageArch(packageID);
             iPackage.repo = Transaction::packageData(packageID);
             iPackage.isPackage = false;
-            if (app.name.isEmpty()) {
+            if (app.name().isEmpty()) {
                 iPackage.displayName = packageName;
             } else {
-                iPackage.displayName = app.name;
+                iPackage.displayName = app.name();
             }
-            if (app.summary.isEmpty()) {
+            if (app.summary().isEmpty()) {
                 iPackage.summary = summary;
             } else {
-                iPackage.summary = app.summary;
+                iPackage.summary = app.summary();
+            }
+
+            const QList<AppStream::Icon> icons = app.icons();
+            for (const AppStream::Icon &icon : icons) {
+                if (icon.url().isEmpty()) {
+                    iPackage.icon = icon.name();
+                } else {
+                    iPackage.icon = icon.url().toLocalFile();
+                }
+                break;
             }
-            iPackage.icon  = app.icon_url;
-            iPackage.appId = app.id;
+            iPackage.appId = app.id();
             iPackage.size  = 0;
 
             if (selected) {
@@ -149,11 +161,11 @@ void PackageModel::addPackage(Transaction::Info info, const \
QString &packageID,  iPackage.summary = summary;
 
 #ifdef HAVE_APPSTREAM
-//        iPackage.icon = AppStream::instance()->genericIcon(iPackage.pkgName);
+        iPackage.icon = AppStreamHelper::instance()->genericIcon(iPackage.pkgName);
 
         if (m_checkable) {
             // in case of updates model only check if it's an app
-//            applications = AppStream::instance()->applications(iPackage.pkgName);
+            applications = \
AppStreamHelper::instance()->applications(iPackage.pkgName);  if \
(!applications.isEmpty()) {  iPackage.isPackage = false;
             }


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic