~cimi/unity8/card_touchdown

« back to all changes in this revision

Viewing changes to plugins/Unity/Launcher/launchermodel.cpp

  • Committer: Andrea Cimitan
  • Date: 2014-06-24 09:54:02 UTC
  • mfrom: (917.6.36 unity8)
  • Revision ID: andrea.cimitan@gmail.com-20140624095402-gaw0o3l8y9fmoqhz
[ Michał Sawicz ]
* Make so that fixedArtShapeSize actually fixes artShapeSize.
[ Albert Astals ]
* Add VerticalJournal integration to Dash/scopes/QML (LP: #1326467)
* Make so that fixedArtShapeSize actually fixes artShapeSize.
[ Mirco Müller ]
* Added the frontend-part of sound-hint support for notifications with
  updated QML-tests.
* New rebuild forced
[ Albert Astals ]
* Departments support (LP: #1320847)
[ Pawel Stolowski ]
* Extend the hack for click scope categories with the upcoming 'store'
  category: single-tap on results from the 'store' category should
  activate them, instead of requesting a preview. (LP: #1326292)
[ Albert Astals ]
* Drop the " Preview" suffix from Preview title As requested in
  https://bugs.launchpad.net/unity8/+bug/1316671 (LP: #1316671)
[ Michael Terry ]
* Revert split greeter for now.  We will bring it back as an option
  for Desktop, but use a big hammer revert right now to get Touch back
  in shape.
[ CI bot ]
* Fix build problems. Reviewed by: Michael Terry (LP: #1328850)
[ Michał Sawicz ]
* Make lockscreen buttons translatable.
[ Albert Astals ]
* Correctly mark these functions as overrides
* Remove connections to non existant signal
* Better test name
* Improvements for headerless categories LVPWH: No section name -> no
  header LVPWH: New hasSectionHeader context property for delegates
  GSV: Add topMargin if no hasSectionHeader (LP: #1326415)
* Make tryVerticalJournal, tryHorizontalJournal and tryOrganicGrid
  work again
[ Michael Zanetti ]
* Don't crash when we get an invalid app from ApplicationManager (LP:
  #1309162)
[ Andrea Cimitan ]
* Workaround for lp1324159 (LP: #1322233, #1324159)
[ CI bot ]
* Resync trunk
[ Florian Boucault ]
* Application startup: changed splash rectangle to be black instead of
  white and added a neat little animation. (LP: #1124265)

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
#include <unity/shell/application/ApplicationInfoInterface.h>
25
25
 
 
26
#include <QDebug>
 
27
 
26
28
using namespace unity::shell::application;
27
29
 
28
30
LauncherModel::LauncherModel(QObject *parent):
29
31
    LauncherModelInterface(parent),
30
 
    m_greeterMode(qgetenv("XDG_SESSION_CLASS") == "greeter"),
31
 
    m_backend(new LauncherBackend(m_greeterMode, this)),
 
32
    m_backend(new LauncherBackend(this)),
32
33
    m_appManager(0)
33
34
{
34
35
    connect(m_backend, SIGNAL(countChanged(QString,int)), SLOT(countChanged(QString,int)));
35
36
    connect(m_backend, SIGNAL(progressChanged(QString,int)), SLOT(progressChanged(QString,int)));
36
 
    connect(m_backend, SIGNAL(refreshApplications()), SLOT(refreshStoredApplications()));
37
37
 
38
 
    refreshStoredApplications();
 
38
    Q_FOREACH (const QString &entry, m_backend->storedApplications()) {
 
39
        LauncherItem *item = new LauncherItem(entry,
 
40
                                              m_backend->displayName(entry),
 
41
                                              m_backend->icon(entry),
 
42
                                              this);
 
43
        item->setPinned(true);
 
44
        m_list.append(item);
 
45
    }
39
46
}
40
47
 
41
48
LauncherModel::~LauncherModel()
134
141
        beginInsertRows(QModelIndex(), index, index);
135
142
        LauncherItem *item = new LauncherItem(appId,
136
143
                                              m_backend->displayName(appId),
137
 
                                              m_backend->icon(appId),
138
 
                                              !m_greeterMode);
 
144
                                              m_backend->icon(appId));
139
145
        item->setPinned(true);
140
146
        m_list.insert(index, item);
141
147
        endInsertRows();
211
217
    return "appid://" + package + "/" + app + "/current-user-version";
212
218
}
213
219
 
214
 
void LauncherModel::refreshStoredApplications()
215
 
{
216
 
    // First remove any existing ones
217
 
    QList<int> storedAppIndices;
218
 
    for (int i = 0; i < m_list.count(); ++i) {
219
 
        if (!m_list.at(i)->recent()) {
220
 
            storedAppIndices << i;
221
 
        }
222
 
    }
223
 
    int run = 0;
224
 
    while (storedAppIndices.count() > 0) {
225
 
        beginRemoveRows(QModelIndex(), storedAppIndices.first() - run, storedAppIndices.first() - run);
226
 
        m_list.takeAt(storedAppIndices.first() - run)->deleteLater();
227
 
        endRemoveRows();
228
 
        storedAppIndices.takeFirst();
229
 
        ++run;
230
 
    }
231
 
 
232
 
    // Now insert all stored apps at beginning of list
233
 
    QStringList storedApplications = m_backend->storedApplications();
234
 
    beginInsertRows(QModelIndex(), 0, storedApplications.size() - 1);
235
 
    run = 0;
236
 
    Q_FOREACH (const QString &entry, storedApplications) {
237
 
        LauncherItem *item = new LauncherItem(entry,
238
 
                                              m_backend->displayName(entry),
239
 
                                              m_backend->icon(entry),
240
 
                                              !m_greeterMode,
241
 
                                              this);
242
 
        item->setPinned(true);
243
 
        m_list.insert(run++, item);
244
 
    }
245
 
    endInsertRows();
246
 
}
247
 
 
248
220
ApplicationManagerInterface *LauncherModel::applicationManager() const
249
221
{
250
222
    return m_appManager;
337
309
    Q_UNUSED(parent);
338
310
 
339
311
    ApplicationInfoInterface *app = m_appManager->get(row);
 
312
    if (!app) {
 
313
        qWarning() << "LauncherModel received an applicationAdded signal, but there's no such application!";
 
314
        return;
 
315
    }
340
316
 
341
317
    bool found = false;
342
318
    Q_FOREACH(LauncherItem *item, m_list) {
348
324
    if (found) {
349
325
        // Shall we paint some running/recent app highlight? If yes, do it here.
350
326
    } else {
351
 
        LauncherItem *item = new LauncherItem(app->appId(), app->name(), app->icon().toString(), !m_greeterMode);
 
327
        LauncherItem *item = new LauncherItem(app->appId(), app->name(), app->icon().toString());
352
328
        item->setRecent(true);
353
329
        item->setFocused(app->focused());
354
330