on xenial help sign in
get rid of the applicationmodel. not needed any more
f598fb9Michael Zanetti
plugins/Unity/CMakeLists.txt−1
@@ -49,4 +49,3 @@ install(FILES qmldir
49
49
50
50
51add_subdirectory(Launcher)
51add_subdirectory(Launcher)
52−
plugins/Unity/Launcher/CMakeLists.txt−1
@@ -17,7 +17,6 @@ set(QMLLAUNCHERPLUGIN_SRC
17 ${UNITY_API_DIR}/unity/shell/launcher/LauncherItemInterface.h
17 ${UNITY_API_DIR}/unity/shell/launcher/LauncherItemInterface.h
18 ${UNITY_API_DIR}/unity/shell/launcher/LauncherModelInterface.h
18 ${UNITY_API_DIR}/unity/shell/launcher/LauncherModelInterface.h
19 backend/launcherbackend.cpp
19 backend/launcherbackend.cpp
20− backend/applicationlistmodel.cpp
21 )
20 )
22
21
23add_library(UnityLauncher-qml MODULE
22add_library(UnityLauncher-qml MODULE
plugins/Unity/Launcher/backend/applicationlistmodel.cppdeleted−40
@@ -1,40 +0,0 @@
1−#include "applicationlistmodel.h"
2−
3−#include <QDebug>
4−
5−ApplicationListModel::ApplicationListModel(QObject *parent):
6− QAbstractListModel(parent)
7−{
8−
9−}
10−
11−void ApplicationListModel::addApplication(const QString &appId, int index)
12−{
13− beginInsertRows(QModelIndex(), index, index);
14− qDebug() << "inserting" << appId << "at" << index;
15− m_list.insert(index, appId);
16− endInsertRows();
17−}
18−
19−void ApplicationListModel::removeApplication(const QString &appId)
20−{
21−
22−}
23−
24−void ApplicationListModel::moveApplication(const QString &appId, int newIndex)
25−{
26−
27−}
28−
29−int ApplicationListModel::rowCount(const QModelIndex &parent) const
30−{
31− return m_list.count();
32−}
33−
34−QVariant ApplicationListModel::data(const QModelIndex &index, int role) const
35−{
36− if (role == RoleAppId) {
37− return m_list.at(index.row());
38− }
39− return QVariant();
40−}
plugins/Unity/Launcher/backend/applicationlistmodel.hdeleted−62
@@ -1,62 +0,0 @@
1−/* Copyright (C) 2013 Canonical, Ltd.
2− *
3− * Authors:
4− * Michael Zanetti <michael.zanetti@canonical.com>
5− *
6− * This program is free software; you can redistribute it and/or modify
7− * it under the terms of the GNU General Public License as published by
8− * the Free Software Foundation; version 3.
9− *
10− * This program is distributed in the hope that it will be useful,
11− * but WITHOUT ANY WARRANTY; without even the implied warranty of
12− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13− * GNU General Public License for more details.
14− *
15− * You should have received a copy of the GNU General Public License
16− * along with this program. If not, see <http://www.gnu.org/licenses/>.
17− */
18−
19−#ifndef APPLICATIONLISTMODEL_H
20−#define APPLICATIONLISTMODEL_H
21−
22−#include <QAbstractListModel>
23−
24−class ApplicationListModel: public QAbstractListModel
25−{
26− Q_OBJECT
27−public:
28− enum Roles {
29− RoleAppId = Qt::UserRole +1
30− };
31−
32− explicit ApplicationListModel(QObject *parent = 0);
33−
34− /**
35− * @brief Add an application to the list of applications.
36− * @param appId The ID of the application to be added.
37− */
38− void addApplication(const QString &appId, int index);
39−
40− /**
41− * @brief Remove an application from the list of applications.
42− * @param appId The ID of the application to be removed.
43− */
44− void removeApplication(const QString &appId);
45−
46− /**
47− * @brief Move an application within the list
48− * @param appId The ID of the application to be moved.
49− * @param newIndex The new position for the entry.
50− */
51− void moveApplication(const QString &appId, int newIndex);
52−
53−
54− int rowCount(const QModelIndex &parent = QModelIndex()) const;
55− QVariant data(const QModelIndex &index, int role) const;
56−
57−private:
58− QList<QString> m_list;
59−};
60−
61−#endif // APPLICATIONLISTMODEL_H
62−
plugins/Unity/Launcher/backend/launcherbackend.cpp+1−1
@@ -1,6 +1,6 @@
1#include "launcherbackend.h"
1#include "launcherbackend.h"
2
2
3−#include "applicationlistmodel.h"
3+#include <QHash>
4
4
5LauncherBackend::LauncherBackend(QObject *parent):
5LauncherBackend::LauncherBackend(QObject *parent):
6 QObject(parent)
6 QObject(parent)
plugins/Unity/Launcher/launchermodel.cpp+3−3
@@ -20,7 +20,6 @@
20#include "launchermodel.h"
20#include "launchermodel.h"
21#include "launcheritem.h"
21#include "launcheritem.h"
22#include "backend/launcherbackend.h"
22#include "backend/launcherbackend.h"
23−#include "backend/applicationlistmodel.h"
24
23
25#include <QDebug>
24#include <QDebug>
26
25
@@ -80,9 +79,10 @@ void LauncherModel::move(int oldIndex, int newIndex)
80
79
81 // Mark moved app as pinned
80 // Mark moved app as pinned
82 LauncherItem *movedItem = m_list.at(newIndex);
81 LauncherItem *movedItem = m_list.at(newIndex);
83− if (!m_backend->isPinned(movedItem->desktopFile()) {
82+ if (!m_backend->isPinned(movedItem->desktopFile())) {
84 m_backend->setPinned(m_list.at(newIndex)->desktopFile(), true);
83 m_backend->setPinned(m_list.at(newIndex)->desktopFile(), true);
85− emit dataChanged(QModelIndex(), newIndex, newIndex);
84+ QModelIndex modelIndex = index(newIndex);
85+ Q_EMIT dataChanged(modelIndex, modelIndex);
86 }
86 }
87
87
88 // Store new order
88 // Store new order