on 68559d2 help sign in
unity8/plugins/Unity/Launcher/appdrawermodel.cpp
45 lines 1.3 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 m_list.last()->setKeywords(info.keywords);
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 RoleKeywords:
38 return m_list.at(index.row())->keywords();
39 case RoleUsage:
40 // FIXME: u-a-l needs to provide API for usage stats.
41 return qrand();
42 }
44 return QVariant();