diff options
-rw-r--r-- | mobile-widgets/qml/DiveList.qml | 81 | ||||
-rw-r--r-- | mobile-widgets/qml/mobile-resources.qrc | 2 | ||||
-rw-r--r-- | mobile-widgets/qmlmanager.cpp | 28 | ||||
-rw-r--r-- | mobile-widgets/qmlmanager.h | 4 | ||||
-rwxr-xr-x | scripts/mobilecomponents.sh | 2 |
5 files changed, 116 insertions, 1 deletions
diff --git a/mobile-widgets/qml/DiveList.qml b/mobile-widgets/qml/DiveList.qml index 6ffeee020..41b56601c 100644 --- a/mobile-widgets/qml/DiveList.qml +++ b/mobile-widgets/qml/DiveList.qml @@ -118,9 +118,13 @@ Kirigami.ScrollablePage { } property bool deleteButtonVisible: false + property bool copyButtonVisible: true // TODO: false + property bool pasteButtonVisible: false onPressAndHold: { - deleteButtonVisible = true + deleteButtonVisible = false // TODO: true + copyButtonVisible = false // TODO: true + pasteButtonVisible = true timer.restart() } Item { @@ -195,6 +199,77 @@ Kirigami.ScrollablePage { } } Rectangle { + id: copyButton + visible: copyButtonVisible + height: diveListEntry.height - 2 * Kirigami.Units.smallSpacing + width: height - 3 * Kirigami.Units.smallSpacing + color: subsurfaceTheme.lightDrawerColor + antialiasing: true + radius: Kirigami.Units.smallSpacing + anchors { + left: diveListEntry.right + right: parent.right + verticalCenter: diveListEntry.verticalCenter + verticalCenterOffset: Kirigami.Units.smallSpacing / 2 + } + Kirigami.Icon { + anchors { + horizontalCenter: parent.horizontalCenter + verticalCenter: parent.verticalCenter + } + source: ":/icons/edit-copy" + width: parent.height + height: width + } + MouseArea { + anchors.fill: parent + enabled: parent.visible + onClicked: { + deleteButtonVisible = false + copyButtonVisible = false + pasteButtonVisible = false + timer.stop() + manager.copyDiveData(dive.id) + } + } + } + Rectangle { + id: pasteButton + visible: pasteButtonVisible + height: diveListEntry.height - 2 * Kirigami.Units.smallSpacing + width: height - 3 * Kirigami.Units.smallSpacing + color: subsurfaceTheme.contrastAccentColor + antialiasing: true + radius: Kirigami.Units.smallSpacing + anchors { + left: diveListEntry.right + right: parent.right + verticalCenter: diveListEntry.verticalCenter + verticalCenterOffset: Kirigami.Units.smallSpacing / 2 + } + Kirigami.Icon { + anchors { + horizontalCenter: parent.horizontalCenter + verticalCenter: parent.verticalCenter + } + source: ":/icons/edit-paste" + width: parent.height + height: width + } + MouseArea { + anchors.fill: parent + enabled: parent.visible + onClicked: { + deleteButtonVisible = false + copyButtonVisible = false + pasteButtonVisible = false + timer.stop() + manager.pasteDiveData(dive.id) + } + } + } + Rectangle { + id: deleteButton visible: deleteButtonVisible height: diveListEntry.height - 2 * Kirigami.Units.smallSpacing width: height - 3 * Kirigami.Units.smallSpacing @@ -221,6 +296,8 @@ Kirigami.ScrollablePage { enabled: parent.visible onClicked: { deleteButtonVisible = false + copyButtonVisible = false + pasteButtonVisible = false timer.stop() manager.deleteDive(dive.id) } @@ -231,6 +308,8 @@ Kirigami.ScrollablePage { interval: 4000 onTriggered: { deleteButtonVisible = false + copyButtonVisible = false + pasteButtonVisible = false } } } diff --git a/mobile-widgets/qml/mobile-resources.qrc b/mobile-widgets/qml/mobile-resources.qrc index a40f74b8d..beb1d93f0 100644 --- a/mobile-widgets/qml/mobile-resources.qrc +++ b/mobile-widgets/qml/mobile-resources.qrc @@ -75,6 +75,8 @@ <file alias="icons/list-add.svg">kirigami/icons/list-add.svg</file> <file alias="icons/overflow-menu.svg">kirigami/icons/overflow-menu.svg</file> <file alias="icons/trash-empty.svg">kirigami/icons/trash-empty.svg</file> + <file alias="icons/edit-copy.svg">kirigami/icons/edit-copy.svg</file> + <file alias="icons/edit-paste.svg">kirigami/icons/edit-paste.svg</file> <file alias="icons/view-readermode.svg">kirigami/icons/view-readermode.svg</file> </qresource> diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp index 8ce1a4616..573517e70 100644 --- a/mobile-widgets/qmlmanager.cpp +++ b/mobile-widgets/qmlmanager.cpp @@ -1322,6 +1322,34 @@ void QMLManager::deleteDive(int id) changesNeedSaving(); } +void QMLManager::copyDiveData(int id) +{ + m_copyPasteDive = get_dive_by_uniq_id(id); + if (!m_copyPasteDive) { + appendTextToLog("trying to copy non-existing dive"); + return; + } + + // TODO: selection dialog for the data to be copied + what.divemaster = true; + what.buddy = true; + what.suit = true; + what.tags = true; + what.cylinders = true; + what.weights = true; +} + +void QMLManager::pasteDiveData(int id) +{ + struct dive *d = get_dive_by_uniq_id(id); + if (!d) { + appendTextToLog("trying to paste to non-existing dive"); + return; + } + selective_copy_dive(m_copyPasteDive, d, what, false); + changesNeedSaving(); +} + void QMLManager::cancelDownloadDC() { import_thread_cancelled = true; diff --git a/mobile-widgets/qmlmanager.h b/mobile-widgets/qmlmanager.h index 98282425d..ca638e02c 100644 --- a/mobile-widgets/qmlmanager.h +++ b/mobile-widgets/qmlmanager.h @@ -163,6 +163,8 @@ public slots: void saveChangesLocal(); void saveChangesCloud(bool forceRemoteSync); void deleteDive(int id); + void copyDiveData(int id); + void pasteDiveData(int id); bool undoDelete(int id); QString addDive(); void addDiveAborted(int id); @@ -224,6 +226,8 @@ private: bool m_btEnabled; void updateAllGlobalLists(); QString m_pluggedInDeviceName; + struct dive *m_copyPasteDive; + struct dive_components what; #if defined(Q_OS_ANDROID) || defined(Q_OS_IOS) QString appLogFileName; diff --git a/scripts/mobilecomponents.sh b/scripts/mobilecomponents.sh index 25ef29b07..8de2d9bb4 100755 --- a/scripts/mobilecomponents.sh +++ b/scripts/mobilecomponents.sh @@ -44,6 +44,8 @@ cp $BREEZE/icons/actions/16/view-readermode.svg $MC/icons cp $BREEZE/icons/actions/24/application-menu.svg $MC/icons cp $BREEZE/icons/actions/22/gps.svg $MC/icons cp $BREEZE/icons/actions/24/trash-empty.svg $MC/icons +cp $BREEZE/icons/actions/24/edit-copy.svg $MC/icons +cp $BREEZE/icons/actions/24/edit-paste.svg $MC/icons cp $BREEZE/icons/actions/24/list-add.svg $MC/icons cp $BREEZE/icons/actions/22/handle-left.svg $MC/icons cp $BREEZE/icons/actions/22/handle-right.svg $MC/icons |