From 34fceb4a1ba8c9cffbcc02caf40961a65efa3db7 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sat, 16 Aug 2014 09:32:23 -0600 Subject: 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 --- qt-ui/simplewidgets.cpp | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'qt-ui/simplewidgets.cpp') 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); + } +} -- cgit v1.2.3-70-g09d2