diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index be156da..882c3cc 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -105,7 +105,9 @@ qt_add_resources(appOPC_UA_Browser "icons"
PREFIX "/"
FILES font/Swansea.ttf
font/SwanseaBold.ttf
+ icons/keyboard_arrow_down.svg
icons/arrow_right.svg
+ icons/keyboard_arrow_up.svg
icons/back.svg
icons/bolt.svg
icons/cancel.svg
diff --git a/src/icons/keyboard_arrow_down.svg b/src/icons/keyboard_arrow_down.svg
new file mode 100644
index 0000000..60482b6
--- /dev/null
+++ b/src/icons/keyboard_arrow_down.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/src/icons/keyboard_arrow_down.svg.license b/src/icons/keyboard_arrow_down.svg.license
new file mode 100644
index 0000000..c6127c5
--- /dev/null
+++ b/src/icons/keyboard_arrow_down.svg.license
@@ -0,0 +1,3 @@
+SPDX-FileCopyrightText: 2023 Google LLC
+
+SPDX-License-Identifier: Apache-2.0
diff --git a/src/icons/keyboard_arrow_up.svg b/src/icons/keyboard_arrow_up.svg
new file mode 100644
index 0000000..01321a1
--- /dev/null
+++ b/src/icons/keyboard_arrow_up.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/src/icons/keyboard_arrow_up.svg.license b/src/icons/keyboard_arrow_up.svg.license
new file mode 100644
index 0000000..c6127c5
--- /dev/null
+++ b/src/icons/keyboard_arrow_up.svg.license
@@ -0,0 +1,3 @@
+SPDX-FileCopyrightText: 2023 Google LLC
+
+SPDX-License-Identifier: Apache-2.0
diff --git a/src/languages/English_en_GB.ts b/src/languages/English_en_GB.ts
index 2f501e4..4b968b4 100644
--- a/src/languages/English_en_GB.ts
+++ b/src/languages/English_en_GB.ts
@@ -389,7 +389,7 @@
-
+
@@ -491,7 +491,7 @@
-
+
diff --git a/src/languages/German_de_DE.ts b/src/languages/German_de_DE.ts
index b675ae9..4c598b4 100644
--- a/src/languages/German_de_DE.ts
+++ b/src/languages/German_de_DE.ts
@@ -389,7 +389,7 @@
Hinzufügen
-
+
Alle ausgewählten Eventfelder
@@ -491,7 +491,7 @@
Zurück
-
+
Löschen
diff --git a/src/monitoreditemmodel.cpp b/src/monitoreditemmodel.cpp
index 173c351..aeb9798 100644
--- a/src/monitoreditemmodel.cpp
+++ b/src/monitoreditemmodel.cpp
@@ -176,3 +176,14 @@ QList MonitoredItemModel::eventFilters(
return filters;
}
+
+void MonitoredItemModel::moveItem(int currentIndex, int newIndex)
+{
+ if (currentIndex < 0 || newIndex < 0 || newIndex == currentIndex || newIndex >= mItems.size())
+ return;
+
+ beginMoveRows(QModelIndex(), currentIndex, currentIndex, QModelIndex(),
+ newIndex > currentIndex ? newIndex + 1 : newIndex);
+ mItems.move(currentIndex, newIndex);
+ endMoveRows();
+}
diff --git a/src/monitoreditemmodel.h b/src/monitoreditemmodel.h
index d9308f7..d6efd2e 100644
--- a/src/monitoreditemmodel.h
+++ b/src/monitoreditemmodel.h
@@ -39,6 +39,8 @@ class MonitoredItemModel : public QAbstractListModel
QList eventFilters();
+ Q_INVOKABLE void moveItem(int currentIndex, int newIndex);
+
signals:
void updated();
diff --git a/src/qml/DashboardView.qml b/src/qml/DashboardView.qml
index 5698a37..d1364ee 100644
--- a/src/qml/DashboardView.qml
+++ b/src/qml/DashboardView.qml
@@ -239,10 +239,10 @@ Rectangle {
}
Component {
- id: eventDragDelegate
+ id: eventDelegate
MouseArea {
- id: eventDragArea
+ id: eventMouseArea
property bool held: false
required property string name
@@ -291,15 +291,10 @@ Rectangle {
height: content.height
width: content.width
- cursorShape: eventDragArea.isAddItem ? Qt.PointingHandCursor : Qt.ArrowCursor
-
- drag.target: held ? content : undefined
-
- onPressAndHold: held = !eventDragArea.isAddItem
- onReleased: held = false
+ cursorShape: eventMouseArea.isAddItem ? Qt.PointingHandCursor : Qt.ArrowCursor
onClicked: {
- if (eventDragArea.isAddItem) {
+ if (eventMouseArea.isAddItem) {
view.addEvents()
}
}
@@ -307,15 +302,10 @@ Rectangle {
Rectangle {
id: content
- Drag.active: eventDragArea.held
- Drag.source: eventDragArea
- Drag.hotSpot.x: width / 2
- Drag.hotSpot.y: height / 2
-
width: itemWidth * 2 + 10
implicitHeight: Math.max(80, eventColumn.height)
radius: 5
- color: eventDragArea.held ? view.theme.item.backgroundHeld : eventDragArea.hasError ? view.theme.item.backgroundError : view.theme.item.background
+ color: eventMouseArea.hasError ? view.theme.item.backgroundError : view.theme.item.background
Behavior on color {
ColorAnimation {
@@ -323,29 +313,13 @@ Rectangle {
}
}
- states: State {
- when: eventDragArea.held
-
- ParentChange {
- target: content
- parent: view
- }
- AnchorChanges {
- target: content
- anchors {
- horizontalCenter: undefined
- verticalCenter: undefined
- }
- }
- }
-
Column {
id: eventColumn
width: parent.width
padding: 5
spacing: 5
- visible: !eventDragArea.isAddItem
+ visible: !eventMouseArea.isAddItem
RowLayout {
id: eventRow
@@ -354,7 +328,7 @@ Rectangle {
Text {
Layout.fillWidth: true
color: view.theme.item.textColor
- text: eventDragArea.name
+ text: eventMouseArea.name
font {
pointSize: 12
bold: true
@@ -362,6 +336,36 @@ Rectangle {
elide: Text.ElideRight
}
+ IconImage {
+ Layout.alignment: Qt.AlignVCenter
+ sourceSize.width: 24
+ sourceSize.height: 24
+ source: "qrc:/icons/keyboard_arrow_down.svg"
+ color: view.theme.item.textColor
+ visible: index !== visualModel.count - 2
+
+ MouseArea {
+ anchors.fill: parent
+ cursorShape: Qt.PointingHandCursor
+ onClicked: visualModel.model.moveItem(index, index + 1)
+ }
+ }
+
+ IconImage {
+ Layout.alignment: Qt.AlignVCenter
+ sourceSize.width: 24
+ sourceSize.height: 24
+ source: "qrc:/icons/keyboard_arrow_up.svg"
+ color: view.theme.item.textColor
+ visible: index !== 0
+
+ MouseArea {
+ anchors.fill: parent
+ cursorShape: Qt.PointingHandCursor
+ onClicked: visualModel.model.moveItem(index, index - 1)
+ }
+ }
+
IconImage {
Layout.alignment: Qt.AlignVCenter
sourceSize.width: 24
@@ -373,7 +377,7 @@ Rectangle {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: visualModel.model.clearEventsForItem(
- eventDragArea.index)
+ eventMouseArea.index)
}
}
@@ -388,13 +392,13 @@ Rectangle {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
onClicked: visualModel.model.disableMonitoring(
- eventDragArea.index)
+ eventMouseArea.index)
}
}
}
Repeater {
- model: eventDragArea.lastEventStrings
+ model: eventMouseArea.lastEventStrings
delegate: Rectangle {
required property string modelData
@@ -432,24 +436,11 @@ Rectangle {
anchors.centerIn: parent
sourceSize.width: 48
sourceSize.height: 48
- visible: eventDragArea.isAddItem
+ visible: eventMouseArea.isAddItem
source: "qrc:/icons/plus.svg"
color: view.theme.item.textColor
}
}
-
- DropArea {
- anchors.fill: parent
- anchors.margins: 10
-
- onEntered: drag => {
- if (!eventDragArea.isAddItem) {
- visualModel.items.move(
- drag.source.DelegateModel.itemsIndex,
- eventDragArea.DelegateModel.itemsIndex)
- }
- }
- }
}
}
@@ -457,7 +448,7 @@ Rectangle {
id: visualModel
model: (tabBar.currentItem === null) ? null : tabBar.currentMonitoringModel
- delegate: tabBar.currentType === DashboardItem.DashboardType.Events ? eventDragDelegate : dragDelegate
+ delegate: tabBar.currentType === DashboardItem.DashboardType.Events ? eventDelegate : dragDelegate
}
Flickable {