From a9ad005e1ec2bf34004ad3a53d86ed67217286e7 Mon Sep 17 00:00:00 2001
From: Jake <j@kedrahos.com>
Date: Fri, 14 Apr 2017 20:27:23 -0500
Subject: [PATCH] Move up/Move down

---
 groundStation/gui/MicroCART/mainwindow.cpp | 33 ++++++++++++++++++++++
 groundStation/gui/MicroCART/mainwindow.h   |  6 ++++
 groundStation/gui/MicroCART/mainwindow.ui  | 24 ++++++++++++++--
 3 files changed, 60 insertions(+), 3 deletions(-)

diff --git a/groundStation/gui/MicroCART/mainwindow.cpp b/groundStation/gui/MicroCART/mainwindow.cpp
index f68d25ea7..01f6bd1cb 100644
--- a/groundStation/gui/MicroCART/mainwindow.cpp
+++ b/groundStation/gui/MicroCART/mainwindow.cpp
@@ -325,3 +325,36 @@ void MainWindow::on_pbActualToWaypoint_clicked()
 
     setpointList->appendRow(new QStandardItem(str));
 }
+
+void MainWindow::on_pbMoveUp_clicked()
+{
+    if (findChild<QListView *>("setpointList")->currentIndex().isValid()) {
+        int current = findChild<QListView *>("setpointList")->currentIndex().row();
+        if (current > 0) {
+            setpointList->insertRow(current - 1, setpointList->takeItem(current));
+        }
+    }
+}
+
+void MainWindow::on_pbMoveDown_clicked()
+{
+    if (findChild<QListView *>("setpointList")->currentIndex().isValid()) {
+        int current = findChild<QListView *>("setpointList")->currentIndex().row();
+        if (current < (setpointList->rowCount() - 1)) {
+            setpointList->insertRow(current - 1, setpointList->takeItem(current));
+        }
+    }
+}
+
+void MainWindow::on_pbInsertSetpoint_clicked()
+{
+    int current = 0;
+    if (findChild<QListView *>("setpointList")->currentIndex().isValid()) {
+        current = findChild<QListView *>("setpointList")->currentIndex().row();
+    }
+
+    QString str("[" + findChild<QLineEdit *>("xActual")->text() + ", "+
+            findChild<QLineEdit *>("yActual")->text() + ", " +
+            findChild<QLineEdit *>("zActual")->text() + "]");
+    setpointList->insertRow(current, new QStandardItem(str));
+}
diff --git a/groundStation/gui/MicroCART/mainwindow.h b/groundStation/gui/MicroCART/mainwindow.h
index 5c5c38fe3..1e65d5174 100644
--- a/groundStation/gui/MicroCART/mainwindow.h
+++ b/groundStation/gui/MicroCART/mainwindow.h
@@ -59,6 +59,12 @@ private slots:
 
     void on_pbActualToWaypoint_clicked();
 
+    void on_pbMoveUp_clicked();
+
+    void on_pbMoveDown_clicked();
+
+    void on_pbInsertSetpoint_clicked();
+
 private:
     Ui::MainWindow *ui;
     pid_t backendPid;
diff --git a/groundStation/gui/MicroCART/mainwindow.ui b/groundStation/gui/MicroCART/mainwindow.ui
index 2476c75d5..829e4f072 100644
--- a/groundStation/gui/MicroCART/mainwindow.ui
+++ b/groundStation/gui/MicroCART/mainwindow.ui
@@ -660,7 +660,7 @@
             <item>
              <widget class="QPushButton" name="pbInsertSetpoint">
               <property name="enabled">
-               <bool>false</bool>
+               <bool>true</bool>
               </property>
               <property name="text">
                <string>Insert</string>
@@ -719,13 +719,13 @@
                <set>QAbstractItemView::NoEditTriggers</set>
               </property>
               <property name="dragEnabled">
-               <bool>true</bool>
+               <bool>false</bool>
               </property>
               <property name="dragDropOverwriteMode">
                <bool>false</bool>
               </property>
               <property name="dragDropMode">
-               <enum>QAbstractItemView::InternalMove</enum>
+               <enum>QAbstractItemView::NoDragDrop</enum>
               </property>
               <property name="defaultDropAction">
                <enum>Qt::MoveAction</enum>
@@ -739,6 +739,24 @@
               </property>
              </widget>
             </item>
+            <item>
+             <layout class="QHBoxLayout" name="horizontalLayout_2">
+              <item>
+               <widget class="QPushButton" name="pbMoveUp">
+                <property name="text">
+                 <string>Move Up</string>
+                </property>
+               </widget>
+              </item>
+              <item>
+               <widget class="QPushButton" name="pbMoveDown">
+                <property name="text">
+                 <string>Move Down</string>
+                </property>
+               </widget>
+              </item>
+             </layout>
+            </item>
             <item>
              <layout class="QHBoxLayout" name="horizontalLayout">
               <item>
-- 
GitLab