~dantti/apper/master

« back to all changes in this revision

Viewing changes to libapper/AppStream.cpp

  • Committer: Daniel Nicoletti
  • Date: 2018-02-19 20:43:40 UTC
  • Revision ID: git-v1:3e7d4d95845dc6e46919455c0fe691a90dcc3dff
Some more autos and fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
196
196
    return packages;
197
197
}
198
198
 
199
 
QString AppStreamHelper::thumbnail(const QString &pkgName) const
 
199
QUrl AppStreamHelper::thumbnail(const QString &pkgName) const
200
200
{
 
201
    QUrl url;
201
202
#ifdef HAVE_APPSTREAM
202
 
    QString url = QLatin1String("");
203
203
    if (m_appInfo.contains(pkgName)) {
204
204
        AppStream::Component app = m_appInfo.value(pkgName);
205
 
//        )
206
 
//        url = app.icon();
 
205
        const QList<AppStream::Screenshot> screenshots = app.screenshots();
 
206
        for (const AppStream::Screenshot &screenshot : screenshots) {
 
207
            const QList<AppStream::Image> images = screenshot.images();
 
208
            for (const AppStream::Image &image : images) {
 
209
                if (image.kind() == AppStream::Image::KindThumbnail) {
 
210
                    url = image.url();
 
211
                    break;
 
212
                }
 
213
            }
 
214
 
 
215
            if (screenshot.isDefault() && !url.isEmpty()) {
 
216
                break;
 
217
            }
 
218
        }
207
219
    }
208
220
 
209
221
    return url;
210
222
#else
211
223
    Q_UNUSED(pkgName)
212
 
    return QString();
 
224
    return url;
213
225
#endif //HAVE_APPSTREAM
214
226
}
215
227