summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-08-17 08:26:09 -0600
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-08-17 11:58:11 -0600
commit29f50c6aeeb31dfad7510d240e27905a9f62670d (patch)
treefb3315e456ad5470eb209cc1c24043636bd4bd0e /qt-ui
parent822eb7558dd7ab4c3dbb86b63be547cdbc2ebb47 (diff)
downloadsubsurface-29f50c6aeeb31dfad7510d240e27905a9f62670d.tar.gz
Cut'n'paste for dive data: implement paste side
This should correctly set all the values and puts us in edit mode. Testing so far looks good for both single dive and multiple dives selected (i.e., you can paste into multiple dives). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/maintab.cpp40
-rw-r--r--qt-ui/maintab.h2
-rw-r--r--qt-ui/mainwindow.cpp2
3 files changed, 44 insertions, 0 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index e403e0b93..5002a2880 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -1173,3 +1173,43 @@ void MainTab::removeSelectedPhotos()
QString fileUrl = photoIndex.data(Qt::DisplayPropertyRole).toString();
DivePictureModel::instance()->removePicture(fileUrl);
}
+
+#define SHOW_SELECTIVE(_component) \
+ if (what._component) \
+ ui._component->setText(displayed_dive._component);
+
+void MainTab::showAndTriggerEditSelective(struct dive_components what)
+{
+ // take the data in our copyPasteDive and apply it to selected dives
+ enableEdition();
+ SHOW_SELECTIVE(location);
+ SHOW_SELECTIVE(buddy);
+ SHOW_SELECTIVE(divemaster);
+ SHOW_SELECTIVE(suit);
+ if (what.notes) {
+ QString tmp(displayed_dive.notes);
+ if (tmp.contains("<table"))
+ ui.notes->setHtml(tmp);
+ else
+ ui.notes->setPlainText(tmp);
+ }
+ if (what.rating)
+ ui.rating->setCurrentStars(displayed_dive.rating);
+ if (what.visibility)
+ ui.visibility->setCurrentStars(displayed_dive.visibility);
+ if (what.gps)
+ updateGpsCoordinates(&displayed_dive);
+ if (what.tags) {
+ char buf[1024];
+ taglist_get_tagstring(displayed_dive.tag_list, buf, 1024);
+ ui.tagWidget->setText(QString(buf));
+ }
+ if (what.cylinders) {
+ cylindersModel->updateDive();
+ cylindersModel->changed = true;
+ }
+ if (what.weights) {
+ weightModel->updateDive();
+ weightModel->changed = true;
+ }
+}
diff --git a/qt-ui/maintab.h b/qt-ui/maintab.h
index f3aec5458..93bb1c949 100644
--- a/qt-ui/maintab.h
+++ b/qt-ui/maintab.h
@@ -49,6 +49,8 @@ public:
bool isEditing();
void updateCoordinatesText(qreal lat, qreal lon);
void nextInputField(QKeyEvent *event);
+ void showAndTriggerEditSelective(struct dive_components what);
+
signals:
void addDiveFinished();
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index 29212564b..9912d60bd 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -1314,4 +1314,6 @@ void MainWindow::on_copy_triggered()
void MainWindow::on_paste_triggered()
{
// take the data in our copyPasteDive and apply it to selected dives
+ selective_copy_dive(&copyPasteDive, &displayed_dive, what, false);
+ ui.InfoWidget->showAndTriggerEditSelective(what);
}