on abc03e9 help sign in
unity8/plugins/Unity/Launcher/appdrawermodel.cpp
39 lines 1.0 kB history raw
1#include "appdrawermodel.h"
2#include "ualwrapper.h"
4#include <QDebug>
6#include <ubuntu-app-launch/registry.h>
8AppDrawerModel::AppDrawerModel(QObject *parent):
9 AppDrawerModelInterface(parent)
11 Q_FOREACH (const QString &appId, UalWrapper::installedApps()) {
12 UalWrapper::AppInfo info = UalWrapper::getApplicationInfo(appId);
13 if (!info.valid) {
14 qWarning() << "Failed to get app info for app" << appId;
15 continue;
16 }
17 m_list.append(new LauncherItem(appId, info.name, info.icon, this));
18 qDebug() << "added" << appId;
19 }
22int AppDrawerModel::rowCount(const QModelIndex &parent) const
24 return m_list.count();
27QVariant AppDrawerModel::data(const QModelIndex &index, int role) const
29 switch (role) {
30 case RoleAppId:
31 return m_list.at(index.row())->appId();
32 case RoleName:
33 return m_list.at(index.row())->name();
34 case RoleIcon:
35 return m_list.at(index.row())->icon();
36 }
38 return QVariant();