on 4e43d62 help sign in
unity8/plugins/Unity/Launcher/appdrawermodel.cpp
42 lines 1.2 kB history raw
1#include "appdrawermodel.h"
2#include "ualwrapper.h"
4#include <QDebug>
5#include <QDateTime>
7AppDrawerModel::AppDrawerModel(QObject *parent):
8 AppDrawerModelInterface(parent)
9{
10 Q_FOREACH (const QString &appId, UalWrapper::installedApps()) {
11 UalWrapper::AppInfo info = UalWrapper::getApplicationInfo(appId);
12 if (!info.valid) {
13 qWarning() << "Failed to get app info for app" << appId;
14 continue;
15 }
16 m_list.append(new LauncherItem(appId, info.name, info.icon, this));
17 qDebug() << "added" << appId;
18 }
19 qsrand(QDateTime::currentMSecsSinceEpoch() / 100);
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 case RoleUsage:
37 // FIXME: u-a-l needs to provide API for usage stats.
38 return qrand();
39 }
41 return QVariant();