Support for copy-pasting specific fields on mobile

Initial implementation/prototype of copy-paste support for
Subsurface-mobile. The UI part is really lacking; right now the copy
button is initially visible and paste is achieved by long press on a
dive and clicking the paste button when it appears. Delete is currently
not possible at all, as I just failed to layout the buttons properly
using QML. It just sounds so simple, to put all the copy-paste-delete
buttons next to each other...

The data to be copied is currently hard-coded. A dialog to choose
inteded fields would be nice, but it'll take quite a bit effort to get
used to QML enough to be able to hack something together.

Anyway, this seems to work, even though the UI is not always reflecting
the paste without switching dives (when testing on laptop).

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
This commit is contained in:
Miika Turkia 2018-10-27 10:21:40 +03:00 committed by Dirk Hohndel
parent 49d1144336
commit 76a68f71a4
5 changed files with 116 additions and 1 deletions

View file

@ -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;