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/divecomponentselection.ui | 165 ++++++++++++++++++++++++++++++++++++++++ qt-ui/mainwindow.cpp | 15 ++++ qt-ui/mainwindow.h | 4 + qt-ui/mainwindow.ui | 18 +++++ qt-ui/simplewidgets.cpp | 42 ++++++++++ qt-ui/simplewidgets.h | 14 ++++ 6 files changed, 258 insertions(+) create mode 100644 qt-ui/divecomponentselection.ui (limited to 'qt-ui') diff --git a/qt-ui/divecomponentselection.ui b/qt-ui/divecomponentselection.ui new file mode 100644 index 000000000..644a1fef2 --- /dev/null +++ b/qt-ui/divecomponentselection.ui @@ -0,0 +1,165 @@ + + + DiveComponentSelectionDialog + + + Qt::WindowModal + + + + 0 + 0 + 308 + 263 + + + + + 0 + 0 + + + + Component selection + + + + :/subsurface-icon + + + + + + + + 0 + 0 + + + + Which components would you like to copy + + + + + + Location + + + + + + + Suit + + + + + + + GPS coordinates + + + + + + + Cylinders + + + + + + + Divemaster + + + + + + + Weights + + + + + + + Buddy + + + + + + + Rating + + + + + + + Visibility + + + + + + + Notes + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + buttonBox + accepted() + DiveComponentSelectionDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + DiveComponentSelectionDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index 687fc778d..29212564b 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -114,6 +114,8 @@ MainWindow::MainWindow() : QMainWindow(), #ifdef NO_PRINTING ui.menuFile->removeAction(ui.actionPrint); #endif + memset(©PasteDive, 0, sizeof(copyPasteDive)); + memset(&what, 0, sizeof(what)); } MainWindow::~MainWindow() @@ -1300,3 +1302,16 @@ void MainWindow::setEnabledToolbar(bool arg1) Q_FOREACH(QToolButton *b, toolBar) b->setEnabled(arg1); } + +void MainWindow::on_copy_triggered() +{ + // open dialog to select what gets copied + // copy the displayed dive + DiveComponentSelection dialog(this, ©PasteDive, &what); + dialog.exec(); +} + +void MainWindow::on_paste_triggered() +{ + // take the data in our copyPasteDive and apply it to selected dives +} diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h index 9081bf457..40d82afb9 100644 --- a/qt-ui/mainwindow.h +++ b/qt-ui/mainwindow.h @@ -143,6 +143,8 @@ slots: void on_profTogglePicture_clicked(bool triggered); void on_profTankbar_clicked(bool triggered); void on_actionExport_triggered(); + void on_copy_triggered(); + void on_paste_triggered(); protected: void closeEvent(QCloseEvent *); @@ -185,6 +187,8 @@ private: bool plannerStateClean(); void setupForAddAndPlan(const char *model); QDialog *survey; + struct dive copyPasteDive; + struct dive_components what; }; #endif // MAINWINDOW_H diff --git a/qt-ui/mainwindow.ui b/qt-ui/mainwindow.ui index 5faac083b..63d78c702 100644 --- a/qt-ui/mainwindow.ui +++ b/qt-ui/mainwindow.ui @@ -720,6 +720,8 @@ p, li { white-space: pre-wrap; } + + @@ -879,6 +881,22 @@ p, li { white-space: pre-wrap; } Ctrl++ + + + &Copy dive components + + + Ctrl+C + + + + + &Paste dive components + + + Ctrl+V + + &Renumber 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); + } +} diff --git a/qt-ui/simplewidgets.h b/qt-ui/simplewidgets.h index 58c9199a5..b41189fe5 100644 --- a/qt-ui/simplewidgets.h +++ b/qt-ui/simplewidgets.h @@ -11,6 +11,7 @@ class QAbstractButton; #include "ui_renumber.h" #include "ui_shifttimes.h" #include "ui_shiftimagetimes.h" +#include "ui_divecomponentselection.h" #include "exif.h" class MinMaxAvgWidget : public QWidget { @@ -112,6 +113,19 @@ private: QCalendarWidget *calendarWidget; }; +class DiveComponentSelection : public QDialog { + Q_OBJECT +public: + explicit DiveComponentSelection(QWidget *parent, struct dive *target, struct dive_components *_what); +private +slots: + void buttonClicked(QAbstractButton *button); +private: + Ui::DiveComponentSelectionDialog ui; + struct dive *targetDive; + struct dive_components *what; +}; + bool isGnome3Session(); QImage grayImage(const QImage& coloredImg); -- cgit v1.2.3-70-g09d2