on 2fa3cce help sign in
unity8/plugins/Unity/Launcher/appdrawermodel.cpp
43 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 Q_UNUSED(parent)
25 return m_list.count();
28QVariant AppDrawerModel::data(const QModelIndex &index, int role) const
30 switch (role) {
31 case RoleAppId:
32 return m_list.at(index.row())->appId();
33 case RoleName:
34 return m_list.at(index.row())->name();
35 case RoleIcon:
36 return m_list.at(index.row())->icon();
37 case RoleUsage:
38 // FIXME: u-a-l needs to provide API for usage stats.
39 return qrand();
40 }
42 return QVariant();