summaryrefslogtreecommitdiffstats
path: root/homescreen/src/applicationmodel.cpp
diff options
context:
space:
mode:
authorJan-Simon Moeller <jsmoeller@linuxfoundation.org>2017-05-24 08:50:33 +0000
committerGerrit Code Review <gerrit@automotivelinux.org>2017-05-24 08:50:33 +0000
commitfbdd80c3c6fd9b27ce1cbe21941baa8a643050fe (patch)
tree5e3eafbb1331c52b4606d99fb2ab731b4263dd0f /homescreen/src/applicationmodel.cpp
parent79e0139fb399b5af1342783ed6abb61aff6e28dd (diff)
parente412b716601f96466ca786784facb558e28e92e4 (diff)
Merge "Add icon re-ordering support by hold and move"dab_3.99.1dab/3.99.13.99.1
Diffstat (limited to 'homescreen/src/applicationmodel.cpp')
-rw-r--r--homescreen/src/applicationmodel.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/homescreen/src/applicationmodel.cpp b/homescreen/src/applicationmodel.cpp
index c43e1bc..417bc4c 100644
--- a/homescreen/src/applicationmodel.cpp
+++ b/homescreen/src/applicationmodel.cpp
@@ -114,3 +114,31 @@ QHash<int, QByteArray> ApplicationModel::roleNames() const
roles[Qt::UserRole] = "id";
return roles;
}
+
+QString ApplicationModel::id(int i) const
+{
+ return data(index(i), Qt::UserRole).toString();
+}
+
+void ApplicationModel::move(int from, int to)
+{
+ QModelIndex parent;
+ if (to < 0 || to > rowCount()) return;
+ if (from < to) {
+ if (!beginMoveRows(parent, from, from, parent, to + 1)) {
+ qDebug() << from << to << false;
+ return;
+ }
+ d->data.move(from, to);
+ endMoveRows();
+ } else if (from > to) {
+ if (!beginMoveRows(parent, from, from, parent, to)) {
+ qDebug() << from << to << false;
+ return;
+ }
+ d->data.move(from, to);
+ endMoveRows();
+ } else {
+ qDebug() << from << to << false;
+ }
+}