diff options
author | 2019-02-02 15:42:57 +0100 | |
---|---|---|
committer | 2019-04-08 09:54:39 +0300 | |
commit | 403c920f29ba9ba877b1d59c85b8905addd28762 (patch) | |
tree | 37173e45e96f5647fd7c20c5113d13c795fa713a /desktop-widgets/simplewidgets.cpp | |
parent | c6732e9b269f977c08eb0d8b8d14b3822c3b5449 (diff) | |
download | subsurface-403c920f29ba9ba877b1d59c85b8905addd28762.tar.gz |
Copy dive description to clipboard
Upon "Copy dive", store a text description of the items
on the system clipboard.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Diffstat (limited to 'desktop-widgets/simplewidgets.cpp')
-rw-r--r-- | desktop-widgets/simplewidgets.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/desktop-widgets/simplewidgets.cpp b/desktop-widgets/simplewidgets.cpp index 42747cd3e..cc156def6 100644 --- a/desktop-widgets/simplewidgets.cpp +++ b/desktop-widgets/simplewidgets.cpp @@ -10,6 +10,7 @@ #include <QAction> #include <QDesktopServices> #include <QToolTip> +#include <QClipboard> #include "core/file.h" #include "desktop-widgets/mainwindow.h" @@ -490,6 +491,50 @@ void DiveComponentSelection::buttonClicked(QAbstractButton *button) COMPONENT_FROM_UI(cylinders); COMPONENT_FROM_UI(weights); selective_copy_dive(&displayed_dive, targetDive, *what, true); + QClipboard *clipboard = QApplication::clipboard(); + QTextStream text; + QString cliptext; + text.setString(&cliptext); + if (what->divesite) + text << tr("Dive site: ") << displayed_dive.dive_site->name << "\n"; + if (what->divemaster) + text << tr("Dive master: ") << displayed_dive.divemaster << "\n"; + if (what->buddy) + text << tr("Buddy: ") << displayed_dive.buddy << "\n"; + if (what->rating) + text << tr("Rating: ") + QString("*").repeated(displayed_dive.rating) << "\n"; + if (what->visibility) + text << tr("Visibility: ") + QString("*").repeated(displayed_dive.visibility) << "\n"; + if (what->notes) + text << tr("Notes:\n") << displayed_dive.notes << "\n"; + if (what->suit) + text << tr("Suit: ") << displayed_dive.suit << "\n"; + if (what-> tags) { + text << tr("Tags: "); + tag_entry *entry = displayed_dive.tag_list; + while (entry) { + text << entry->tag->name << " "; + entry = entry->next; + } + text << "\n"; + } + if (what->cylinders) { + int cyl; + text << tr("Cylinders:\n"); + for (cyl = 0; cyl < MAX_CYLINDERS; cyl++) { + if (is_cylinder_used(&displayed_dive, cyl)) + text << displayed_dive.cylinder[cyl].type.description << " " << gasname(displayed_dive.cylinder[cyl].gasmix) << "\n"; + } + } + if (what->weights) { + int w; + text << tr("Weights:\n"); + for (w = 0; w < MAX_WEIGHTSYSTEMS; w++) { + if (displayed_dive.weightsystem[w].weight.grams) + text << displayed_dive.weightsystem[w].description << displayed_dive.weightsystem[w].weight.grams / 1000 << "kg\n"; + } + } + clipboard->setText(cliptext); } } |