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>
This commit is contained in:
Dirk Hohndel 2014-08-16 09:32:23 -06:00
parent dd49e3a9a9
commit 34fceb4a1b
7 changed files with 260 additions and 1 deletions

View file

@ -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>

View file

@ -114,6 +114,8 @@ MainWindow::MainWindow() : QMainWindow(),
#ifdef NO_PRINTING #ifdef NO_PRINTING
ui.menuFile->removeAction(ui.actionPrint); ui.menuFile->removeAction(ui.actionPrint);
#endif #endif
memset(&copyPasteDive, 0, sizeof(copyPasteDive));
memset(&what, 0, sizeof(what));
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()
@ -1300,3 +1302,16 @@ void MainWindow::setEnabledToolbar(bool arg1)
Q_FOREACH(QToolButton *b, toolBar) Q_FOREACH(QToolButton *b, toolBar)
b->setEnabled(arg1); b->setEnabled(arg1);
} }
void MainWindow::on_copy_triggered()
{
// open dialog to select what gets copied
// copy the displayed dive
DiveComponentSelection dialog(this, &copyPasteDive, &what);
dialog.exec();
}
void MainWindow::on_paste_triggered()
{
// take the data in our copyPasteDive and apply it to selected dives
}

View file

@ -143,6 +143,8 @@ slots:
void on_profTogglePicture_clicked(bool triggered); void on_profTogglePicture_clicked(bool triggered);
void on_profTankbar_clicked(bool triggered); void on_profTankbar_clicked(bool triggered);
void on_actionExport_triggered(); void on_actionExport_triggered();
void on_copy_triggered();
void on_paste_triggered();
protected: protected:
void closeEvent(QCloseEvent *); void closeEvent(QCloseEvent *);
@ -185,6 +187,8 @@ private:
bool plannerStateClean(); bool plannerStateClean();
void setupForAddAndPlan(const char *model); void setupForAddAndPlan(const char *model);
QDialog *survey; QDialog *survey;
struct dive copyPasteDive;
struct dive_components what;
}; };
#endif // MAINWINDOW_H #endif // MAINWINDOW_H

View file

@ -720,6 +720,8 @@ p, li { white-space: pre-wrap; }
</property> </property>
<addaction name="actionAddDive"/> <addaction name="actionAddDive"/>
<addaction name="actionDivePlanner"/> <addaction name="actionDivePlanner"/>
<addaction name="copy"/>
<addaction name="paste"/>
<addaction name="separator"/> <addaction name="separator"/>
<addaction name="actionRenumber"/> <addaction name="actionRenumber"/>
<addaction name="actionAutoGroup"/> <addaction name="actionAutoGroup"/>
@ -879,6 +881,22 @@ p, li { white-space: pre-wrap; }
<string>Ctrl++</string> <string>Ctrl++</string>
</property> </property>
</action> </action>
<action name="copy">
<property name="text">
<string>&amp;Copy dive components</string>
</property>
<property name="shortcut">
<string>Ctrl+C</string>
</property>
</action>
<action name="paste">
<property name="text">
<string>&amp;Paste dive components</string>
</property>
<property name="shortcut">
<string>Ctrl+V</string>
</property>
</action>
<action name="actionRenumber"> <action name="actionRenumber">
<property name="text"> <property name="text">
<string>&amp;Renumber</string> <string>&amp;Renumber</string>

View file

@ -411,3 +411,45 @@ void DateWidget::keyPressEvent(QKeyEvent *event)
QWidget::keyPressEvent(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);
}
}

View file

@ -11,6 +11,7 @@ class QAbstractButton;
#include "ui_renumber.h" #include "ui_renumber.h"
#include "ui_shifttimes.h" #include "ui_shifttimes.h"
#include "ui_shiftimagetimes.h" #include "ui_shiftimagetimes.h"
#include "ui_divecomponentselection.h"
#include "exif.h" #include "exif.h"
class MinMaxAvgWidget : public QWidget { class MinMaxAvgWidget : public QWidget {
@ -112,6 +113,19 @@ private:
QCalendarWidget *calendarWidget; 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(); bool isGnome3Session();
QImage grayImage(const QImage& coloredImg); QImage grayImage(const QImage& coloredImg);

View file

@ -198,7 +198,8 @@ FORMS = \
qt-ui/searchbar.ui \ qt-ui/searchbar.ui \
qt-ui/divelogexportdialog.ui \ qt-ui/divelogexportdialog.ui \
qt-ui/plannerSettings.ui \ qt-ui/plannerSettings.ui \
qt-ui/usersurvey.ui qt-ui/usersurvey.ui \
qt-ui/divecomponentselection.ui
# Nether usermanual or printing is supported on android right now # Nether usermanual or printing is supported on android right now
android: FORMS -= qt-ui/printoptions.ui android: FORMS -= qt-ui/printoptions.ui