| Hi, I said some weeks ago, I should look at the handling of adding images. This is the first attempt in this direction. Best Robert |
From 7d18ecdf917a1a59e5c1de9b8eae113399d8fc3d Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" <[email protected]> Date: Fri, 11 Sep 2015 11:31:02 +0200 Subject: [PATCH] Add checkbox to force images to match dives
Give the user the possibility to attach images ot a dive even when the times do not match Signed-off-by: Robert C. Helling <[email protected]> --- dive.c | 4 ++-- dive.h | 2 +- qt-ui/divelistview.cpp | 2 +- qt-ui/shiftimagetimes.ui | 25 +++++++++++++++---------- qt-ui/simplewidgets.cpp | 11 +++++++++++ qt-ui/simplewidgets.h | 3 +++ 6 files changed, 33 insertions(+), 14 deletions(-) diff --git a/dive.c b/dive.c index 4e902d7..c81584e 100644 --- a/dive.c +++ b/dive.c @@ -2989,12 +2989,12 @@ bool picture_check_valid(char *filename, int shift_time) return false; } -void dive_create_picture(struct dive *dive, char *filename, int shift_time) +void dive_create_picture(struct dive *dive, char *filename, int shift_time, bool match_all) { timestamp_t timestamp = picture_get_timestamp(filename); if (!new_picture_for_dive(dive, filename)) return; - if (!dive_check_picture_time(dive, shift_time, timestamp)) + if (!match_all && !dive_check_picture_time(dive, shift_time, timestamp)) return; struct picture *picture = alloc_picture(); diff --git a/dive.h b/dive.h index c20b59b..fa95f67 100644 --- a/dive.h +++ b/dive.h @@ -377,7 +377,7 @@ struct picture { extern struct picture *alloc_picture(); extern bool dive_check_picture_time(struct dive *d, int shift_time, timestamp_t timestamp); -extern void dive_create_picture(struct dive *d, char *filename, int shift_time); +extern void dive_create_picture(struct dive *d, char *filename, int shift_time, bool match_all); extern void dive_add_picture(struct dive *d, struct picture *newpic); extern void dive_remove_picture(char *filename); extern unsigned int dive_get_picture_count(struct dive *d); diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp index c25bb17..2ee5f5d 100644 --- a/qt-ui/divelistview.cpp +++ b/qt-ui/divelistview.cpp @@ -925,7 +925,7 @@ void DiveListView::matchImagesToDives(QStringList fileNames) for_each_dive (j, dive) { if (!dive->selected) continue; - dive_create_picture(dive, copy_string(fileName.toUtf8().data()), shiftDialog.amount()); + dive_create_picture(dive, copy_string(fileName.toUtf8().data()), shiftDialog.amount(), shiftDialog.matchAll()); } } diff --git a/qt-ui/shiftimagetimes.ui b/qt-ui/shiftimagetimes.ui index 56a2228..d1adeb1 100644 --- a/qt-ui/shiftimagetimes.ui +++ b/qt-ui/shiftimagetimes.ui @@ -10,7 +10,7 @@ <x>0</x> <y>0</y> <width>693</width> - <height>606</height> + <height>669</height> </rect> </property> <property name="sizePolicy"> @@ -48,9 +48,9 @@ <hour>23</hour> <minute>59</minute> <second>59</second> - <year>2010</year> - <month>12</month> - <day>31</day> + <year>2000</year> + <month>1</month> + <day>1</day> </datetime> </property> <property name="minimumDateTime"> @@ -65,9 +65,9 @@ </property> <property name="maximumDate"> <date> - <year>2010</year> - <month>12</month> - <day>31</day> + <year>2000</year> + <month>1</month> + <day>1</day> </date> </property> <property name="minimumDate"> @@ -132,6 +132,13 @@ Not all images have timestamps in the range between </widget> </item> <item> + <widget class="QCheckBox" name="matchAllImages"> + <property name="text"> + <string>Load images even if the time does not match the dive time</string> + </property> + </widget> + </item> + <item> <widget class="QLabel" name="invalidLabel"> <property name="styleSheet"> <string notr="true">color: red; </string> @@ -246,9 +253,7 @@ Not all images have timestamps in the range between </item> </layout> </widget> - <resources> - <include location="../subsurface.qrc"/> - </resources> + <resources/> <connections> <connection> <sender>buttonBox</sender> diff --git a/qt-ui/simplewidgets.cpp b/qt-ui/simplewidgets.cpp index 99b4b2b..7e8bc40 100644 --- a/qt-ui/simplewidgets.cpp +++ b/qt-ui/simplewidgets.cpp @@ -312,12 +312,23 @@ void ShiftImageTimesDialog::dcDateTimeChanged(const QDateTime &newDateTime) setOffset(newDateTime.toTime_t() - dcImageEpoch); } +void ShiftImageTimesDialog::matchAllImagesToggled(bool state) +{ + matchAllImages = state; +} + +bool ShiftImageTimesDialog::matchAll() +{ + return matchAllImages; +} + ShiftImageTimesDialog::ShiftImageTimesDialog(QWidget *parent, QStringList fileNames) : QDialog(parent), fileNames(fileNames), m_amount(0) { ui.setupUi(this); connect(ui.buttonBox, SIGNAL(clicked(QAbstractButton *)), this, SLOT(buttonClicked(QAbstractButton *))); connect(ui.syncCamera, SIGNAL(clicked()), this, SLOT(syncCameraClicked())); connect(ui.timeEdit, SIGNAL(timeChanged(const QTime &)), this, SLOT(timeEditChanged(const QTime &))); + connect(ui.matchAllImages, SIGNAL(toggled(bool)), this, SLOT(matchAllImagesToggled(bool))); dcImageEpoch = (time_t)0; } diff --git a/qt-ui/simplewidgets.h b/qt-ui/simplewidgets.h index 17f6283..595c4cd 100644 --- a/qt-ui/simplewidgets.h +++ b/qt-ui/simplewidgets.h @@ -101,6 +101,7 @@ public: explicit ShiftImageTimesDialog(QWidget *parent, QStringList fileNames); time_t amount() const; void setOffset(time_t offset); + bool matchAll(); private slots: void buttonClicked(QAbstractButton *button); @@ -108,12 +109,14 @@ slots: void dcDateTimeChanged(const QDateTime &); void timeEditChanged(const QTime &time); void updateInvalid(); + void matchAllImagesToggled(bool); private: QStringList fileNames; Ui::ShiftImageTimesDialog ui; time_t m_amount; time_t dcImageEpoch; + bool matchAllImages; }; class URLDialog : public QDialog { -- 2.3.2 (Apple Git-55)
-- .oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oO Robert C. Helling Elite Master Course Theoretical and Mathematical Physics Scientific Coordinator Ludwig Maximilians Universitaet Muenchen, Dept. Physik Phone: +49 89 2180-4523 Theresienstr. 39, rm. B339 http://www.atdotde.de Enhance your privacy, use cryptography! My PGP keys have fingerprints A9D1 A01D 13A5 31FA 6515 BB44 0820 367C 36BC 0C1D and DCED 37B6 251C 7861 270D 5613 95C7 9D32 9A8D 9B8F |
signature.asc
Description: Message signed with OpenPGP using GPGMail
_______________________________________________ subsurface mailing list [email protected] http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface
