diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-08-16 09:32:23 -0600 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-08-16 10:07:06 -0600 |
commit | 34fceb4a1ba8c9cffbcc02caf40961a65efa3db7 (patch) | |
tree | 5caf92855c3e42d43473447006a542f8206c42d2 /qt-ui | |
parent | dd49e3a9a92e3d1a1534a870e9e3b588845fb364 (diff) | |
download | subsurface-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')
-rw-r--r-- | qt-ui/divecomponentselection.ui | 165 | ||||
-rw-r--r-- | qt-ui/mainwindow.cpp | 15 | ||||
-rw-r--r-- | qt-ui/mainwindow.h | 4 | ||||
-rw-r--r-- | qt-ui/mainwindow.ui | 18 | ||||
-rw-r--r-- | qt-ui/simplewidgets.cpp | 42 | ||||
-rw-r--r-- | qt-ui/simplewidgets.h | 14 |
6 files changed, 258 insertions, 0 deletions
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 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>DiveComponentSelectionDialog</class> + <widget class="QDialog" name="DiveComponentSelectionDialog"> + <property name="windowModality"> + <enum>Qt::WindowModal</enum> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>308</width> + <height>263</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="windowTitle"> + <string>Component selection</string> + </property> + <property name="windowIcon"> + <iconset> + <normalon>:/subsurface-icon</normalon> + </iconset> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QGroupBox" name="groupBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>Which components would you like to copy</string> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QCheckBox" name="location"> + <property name="text"> + <string>Location</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QCheckBox" name="suit"> + <property name="text"> + <string>Suit</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QCheckBox" name="gps"> + <property name="text"> + <string>GPS coordinates</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QCheckBox" name="cylinders"> + <property name="text"> + <string>Cylinders</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QCheckBox" name="divemaster"> + <property name="text"> + <string>Divemaster</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QCheckBox" name="weights"> + <property name="text"> + <string>Weights</string> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QCheckBox" name="buddy"> + <property name="text"> + <string>Buddy</string> + </property> + </widget> + </item> + <item row="4" column="0"> + <widget class="QCheckBox" name="rating"> + <property name="text"> + <string>Rating</string> + </property> + </widget> + </item> + <item row="5" column="0"> + <widget class="QCheckBox" name="visibility"> + <property name="text"> + <string>Visibility</string> + </property> + </widget> + </item> + <item row="6" column="0"> + <widget class="QCheckBox" name="notes"> + <property name="text"> + <string>Notes</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </widget> + <resources> + <include location="../subsurface.qrc"/> + </resources> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>DiveComponentSelectionDialog</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>DiveComponentSelectionDialog</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui> 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; } </property> <addaction name="actionAddDive"/> <addaction name="actionDivePlanner"/> + <addaction name="copy"/> + <addaction name="paste"/> <addaction name="separator"/> <addaction name="actionRenumber"/> <addaction name="actionAutoGroup"/> @@ -879,6 +881,22 @@ p, li { white-space: pre-wrap; } <string>Ctrl++</string> </property> </action> + <action name="copy"> + <property name="text"> + <string>&Copy dive components</string> + </property> + <property name="shortcut"> + <string>Ctrl+C</string> + </property> + </action> + <action name="paste"> + <property name="text"> + <string>&Paste dive components</string> + </property> + <property name="shortcut"> + <string>Ctrl+V</string> + </property> + </action> <action name="actionRenumber"> <property name="text"> <string>&Renumber</string> 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); |