Revert "Add icon re-ordering support by hold and move"
authorJosé Bollo <jose.bollo@iot.bzh>
Wed, 26 Jul 2017 08:43:59 +0000 (10:43 +0200)
committerJosé Bollo <jose.bollo@iot.bzh>
Wed, 26 Jul 2017 08:43:59 +0000 (10:43 +0200)
This reverts commit e412b716601f96466ca786784facb558e28e92e4.

Change-Id: I46789eaa70e1fcbb1cfc153f3a5113a5f3131e59

homescreen/qml/Home.qml
homescreen/qml/IconItem.qml [deleted file]
homescreen/qml/qml.qrc
homescreen/src/applicationmodel.cpp
homescreen/src/applicationmodel.h

index de8b9bb..aa3a129 100644 (file)
@@ -31,7 +31,6 @@ Item {
     property int pid: -1
 
     GridView {
-        id: grid
         anchors.centerIn: parent
         width: cellHeight * 3
         height: cellHeight * 3
@@ -39,41 +38,27 @@ Item {
         cellHeight: 320
         interactive: false
 
-        model: ApplicationModel { id: applicationModel }
-        delegate: IconItem {
-            width: grid.cellWidth
-            height: grid.cellHeight
-        }
-
-        MouseArea {
-            id: loc
-            anchors.fill: parent
-            property string currentId: ''
-            property int newIndex: -1
-            property int index: grid.indexAt(loc.mouseX, loc.mouseY)
-            onPressAndHold: currentId = applicationModel.id(newIndex = index)
-            onReleased: {
-                if (currentId === '') {
-                    pid = launcher.launch(applicationModel.id(loc.index))
-                    if (1 < pid) {
-                        layoutHandler.makeMeVisible(pid)
+        model: ApplicationModel {}
+        delegate: MouseArea {
+            width: 320
+            height: 320
+            Image {
+                anchors.fill: parent
+                source: './images/HMI_AppLauncher_%1_%2-01.png'.arg(model.icon).arg(pressed ? 'Active' : 'Inactive')
+            }
+            onClicked: {
+                console.log("app is ", model.id)
+                pid = launcher.launch(model.id)
+                if (1 < pid) {
+                    layoutHandler.makeMeVisible(pid)
 
-                        applicationArea.visible = true
-                        appLauncherAreaLauncher.visible = false
-                        layoutHandler.showAppLayer(applicationModel.id(loc.index),  pid)
-                    }
-                    else {
-                        console.warn("app cannot be launched!")
-                    }
-                } else {
-                    currentId = ''
+                    applicationArea.visible = true
+                    appLauncherAreaLauncher.visible = false
+                    layoutHandler.showAppLayer(pid)
+                }
+                else {
+                    console.warn("app cannot be launched!")
                 }
-            }
-            onPositionChanged: {
-                if (loc.currentId === '') return
-                if (index < 0) return
-                if (index === newIndex) return
-                    applicationModel.move(newIndex, newIndex = index)
             }
         }
     }
diff --git a/homescreen/qml/IconItem.qml b/homescreen/qml/IconItem.qml
deleted file mode 100644 (file)
index 59131c0..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-import QtQuick 2.0
-
-Item {
-    id: main
-    Image {
-        id: item; parent: loc
-        x: main.x + 5; y: main.y + 5
-        width: main.width - 10; height: main.height - 10;
-        source: './images/HMI_AppLauncher_%1_%2-01.png'.arg(model.icon).arg(loc.pressed && (loc.index === model.index || loc.currentId === model.id) ? 'Active' : 'Inactive')
-        antialiasing: item.state !== ''
-        Behavior on x { enabled: item.state !== 'active'; NumberAnimation { duration: 400; easing.type: Easing.OutCubic } }
-        Behavior on y { enabled: item.state !== 'active'; NumberAnimation { duration: 400; easing.type: Easing.OutCubic } }
-        SequentialAnimation on rotation {
-            NumberAnimation { to:  5; duration: 100 }
-            NumberAnimation { to: -5; duration: 200 }
-            NumberAnimation { to:  0; duration: 100 }
-            running: loc.currentId !== '' && item.state !== 'active'
-            loops: Animation.Infinite; alwaysRunToEnd: true
-        }
-        states: [
-            State {
-                name: 'active'
-                when: loc.currentId == model.id
-                PropertyChanges { target: item; x: loc.mouseX - width/2; y: loc.mouseY - height/2; scale: 1.15; z: 10 }
-            },
-            State {
-                when: loc.currentId !== ''
-                PropertyChanges {
-                    target: item
-                    scale: 0.85
-                    opacity: 0.75
-                }
-            }
-        ]
-        transitions: Transition { NumberAnimation { properties: 'scale, opacity, x, y'; duration: 150; easing.type: Easing.OutCubic} }
-    }
-}
index c25e266..3d699e0 100644 (file)
@@ -10,6 +10,5 @@
         <file>ShortcutIcon.qml</file>
         <file>StatusArea.qml</file>
         <file>TopArea.qml</file>
-        <file>IconItem.qml</file>
     </qresource>
 </RCC>
index 417bc4c..c43e1bc 100644 (file)
@@ -114,31 +114,3 @@ 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;
-    }
-}
index 2414b7e..bffc4c9 100644 (file)
@@ -30,8 +30,6 @@ public:
 
     QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
     QHash<int, QByteArray> roleNames() const override;
-    Q_INVOKABLE QString id(int index) const;
-    Q_INVOKABLE void move(int from, int to);
 
 private:
     class Private;