aboutsummaryrefslogtreecommitdiffstats
path: root/homescreen/src/applicationmodel.cpp
diff options
context:
space:
mode:
authorTasuku Suzuki <tasuku.suzuki@qt.io>2017-05-23 14:24:35 +0900
committerTasuku Suzuki <tasuku.suzuki@qt.io>2017-05-23 14:51:05 +0900
commite412b716601f96466ca786784facb558e28e92e4 (patch)
treead6d64f47bcd3ee7db434f2745407fed28b4cb2c /homescreen/src/applicationmodel.cpp
parent226982d32f334189b4f465a720a297548a42c077 (diff)
Add icon re-ordering support by hold and move
Change-Id: Ieb6bf721932e36e4ea69cd56d59019ed8fed13ba Signed-off-by: Tasuku Suzuki <tasuku.suzuki@qt.io>
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;
+ }
+}