aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/simplewidgets.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-08-16 09:32:23 -0600
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-08-16 10:07:06 -0600
commit34fceb4a1ba8c9cffbcc02caf40961a65efa3db7 (patch)
tree5caf92855c3e42d43473447006a542f8206c42d2 /qt-ui/simplewidgets.cpp
parentdd49e3a9a92e3d1a1534a870e9e3b588845fb364 (diff)
downloadsubsurface-34fceb4a1ba8c9cffbcc02caf40961a65efa3db7.tar.gz
Cut'n'paste for dive data: implement copy side
Admittedly not very useful without working paste, but it's progress. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/simplewidgets.cpp')
-rw-r--r--qt-ui/simplewidgets.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/qt-ui/simplewidgets.cpp b/qt-ui/simplewidgets.cpp
index 217291277..a10092ff6 100644
--- a/qt-ui/simplewidgets.cpp
+++ b/qt-ui/simplewidgets.cpp
@@ -411,3 +411,45 @@ void DateWidget::keyPressEvent(QKeyEvent *event)
QWidget::keyPressEvent(event);
}
}
+
+#define COMPONENT_FROM_UI(_component) what->_component = ui._component->isChecked()
+#define UI_FROM_COMPONENT(_component) ui._component->setChecked(what->_component)
+
+DiveComponentSelection::DiveComponentSelection(QWidget *parent, struct dive *target, struct dive_components *_what):
+ targetDive(target)
+{
+ ui.setupUi(this);
+ what = _what;
+ UI_FROM_COMPONENT(location);
+ UI_FROM_COMPONENT(gps);
+ UI_FROM_COMPONENT(divemaster);
+ UI_FROM_COMPONENT(buddy);
+ UI_FROM_COMPONENT(rating);
+ UI_FROM_COMPONENT(visibility);
+ UI_FROM_COMPONENT(notes);
+ UI_FROM_COMPONENT(suit);
+ UI_FROM_COMPONENT(cylinders);
+ UI_FROM_COMPONENT(weights);
+ connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton *)), this, SLOT(buttonClicked(QAbstractButton *)));
+ QShortcut *close = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_W), this);
+ connect(close, SIGNAL(activated()), this, SLOT(close()));
+ QShortcut *quit = new QShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q), this);
+ connect(quit, SIGNAL(activated()), parent, SLOT(close()));
+}
+
+void DiveComponentSelection::buttonClicked(QAbstractButton *button)
+{
+ if (ui.buttonBox->buttonRole(button) == QDialogButtonBox::AcceptRole) {
+ COMPONENT_FROM_UI(location);
+ COMPONENT_FROM_UI(gps);
+ COMPONENT_FROM_UI(divemaster);
+ COMPONENT_FROM_UI(buddy);
+ COMPONENT_FROM_UI(rating);
+ COMPONENT_FROM_UI(visibility);
+ COMPONENT_FROM_UI(notes);
+ COMPONENT_FROM_UI(suit);
+ COMPONENT_FROM_UI(cylinders);
+ COMPONENT_FROM_UI(weights);
+ selective_copy_dive(&displayed_dive, targetDive, *what);
+ }
+}