@@ -25,22 +25,33 @@ MockLauncherModel::MockLauncherModel(QObject* parent): LauncherModelInterface(pa
2525 MockLauncherItem *item = new MockLauncherItem("phone-app", "/usr/share/applications/phone-app.desktop", "Phone", "phone-app", this);
2626 m_list.append(item);
2727 item = new MockLauncherItem("camera-app", "/usr/share/applications/camera-app.desktop", "Camera", "camera", this);
28+ item->setCount(1234567);
29+ item->setProgress(150);
2830 m_list.append(item);
2931 item = new MockLauncherItem("gallery-app", "/usr/share/applications/gallery-app.desktop", "Gallery", "gallery", this);
32+ item->setProgress(100);
3033 m_list.append(item);
3134 item = new MockLauncherItem("facebook-webapp", "/usr/share/applications/facebook-webapp.desktop", "Facebook", "facebook", this);
35+ item->setCount(123456);
3236 m_list.append(item);
3337 item = new MockLauncherItem("webbrowser-app", "/usr/share/applications/webbrowser-app.desktop", "Browser", "browser", this);
38+ item->setProgress(50);
3439 m_list.append(item);
3540 item = new MockLauncherItem("twitter-webapp", "/usr/share/applications/twitter-webapp.desktop", "Twitter", "twitter", this);
41+ item->setCount(12345);
3642 m_list.append(item);
3743 item = new MockLauncherItem("gmail-webapp", "/usr/share/applications/gmail-webapp.desktop", "GMail", "gmail", this);
44+ item->setCount(123);
3845 m_list.append(item);
3946 item = new MockLauncherItem("ubuntu-weather-app", "/usr/share/applications/ubuntu-weather-app.desktop", "Weather", "weather", this);
47+ item->setCount(12);
48+ item->setProgress(10);
4049 m_list.append(item);
4150 item = new MockLauncherItem("notes-app", "/usr/share/applications/notes-app.desktop", "Notepad", "notepad", this);
51+ item->setProgress(0);
4252 m_list.append(item);
4353 item = new MockLauncherItem("calendar-app", "/usr/share/applications/calendar-app.desktop","Calendar", "calendar", this);
54+ item->setCount(1);
4455 m_list.append(item);
4556}
4657
@@ -91,9 +102,29 @@ unity::shell::launcher::LauncherItemInterface *MockLauncherModel::get(int index)
91102
92103void MockLauncherModel::move(int oldIndex, int newIndex)
93104{
94− beginMoveRows(QModelIndex(), oldIndex, oldIndex, QModelIndex(), newIndex);
105+ // Make sure its not moved outside the lists
106+ if (newIndex < 0) {
107+ newIndex = 0;
108+ }
109+ if (newIndex >= m_list.count()) {
110+ newIndex = m_list.count()-1;
111+ }
112+
113+ // Nothing to do?
114+ if (oldIndex == newIndex) {
115+ return;
116+ }
117+
118+ // QList's and QAbstractItemModel's move implementation differ when moving an item up the list :/
119+ // While QList needs the index in the resulting list, beginMoveRows expects it to be in the current list
120+ // adjust the model's index by +1 in case we're moving upwards
121+ int newModelIndex = newIndex > oldIndex ? newIndex+1 : newIndex;
122+
123+ beginMoveRows(QModelIndex(), oldIndex, oldIndex, QModelIndex(), newModelIndex);
95124 m_list.move(oldIndex, newIndex);
96125 endMoveRows();
126+
127+ pin(m_list.at(newIndex)->appId());
97128}
98129
99130void MockLauncherModel::pin(const QString &appId, int index)