diff options
-rw-r--r-- | core/dive.c | 3 | ||||
-rw-r--r-- | core/dive.h | 2 | ||||
-rw-r--r-- | desktop-widgets/simplewidgets.cpp | 22 | ||||
-rw-r--r-- | desktop-widgets/simplewidgets.h | 1 |
4 files changed, 16 insertions, 12 deletions
diff --git a/core/dive.c b/core/dive.c index 67cfc5fa5..0c185efa5 100644 --- a/core/dive.c +++ b/core/dive.c @@ -3871,12 +3871,11 @@ bool dive_check_picture_time(const struct dive *d, int shift_time, timestamp_t t return false; } -bool picture_check_valid(const char *filename, int shift_time) +bool picture_check_valid_time(timestamp_t timestamp, int shift_time) { int i; struct dive *dive; - timestamp_t timestamp = picture_get_timestamp(filename); for_each_dive (i, dive) if (dive->selected && dive_check_picture_time(dive, shift_time, timestamp)) return true; diff --git a/core/dive.h b/core/dive.h index 277050f5e..3344aaf35 100644 --- a/core/dive.h +++ b/core/dive.h @@ -382,7 +382,7 @@ extern void dive_create_picture(struct dive *d, const char *filename, int shift_ extern void dive_add_picture(struct dive *d, struct picture *newpic); extern bool dive_remove_picture(struct dive *d, const char *filename); extern unsigned int dive_get_picture_count(struct dive *d); -extern bool picture_check_valid(const char *filename, int shift_time); +extern bool picture_check_valid_time(timestamp_t timestamp, int shift_time); extern void dive_set_geodata_from_picture(struct dive *d, struct picture *pic); extern void picture_free(struct picture *picture); diff --git a/desktop-widgets/simplewidgets.cpp b/desktop-widgets/simplewidgets.cpp index 79a3cc069..64845712d 100644 --- a/desktop-widgets/simplewidgets.cpp +++ b/desktop-widgets/simplewidgets.cpp @@ -354,6 +354,11 @@ ShiftImageTimesDialog::ShiftImageTimesDialog(QWidget *parent, QStringList fileNa connect(ui.matchAllImages, SIGNAL(toggled(bool)), this, SLOT(matchAllImagesToggled(bool))); dcImageEpoch = (time_t)0; + // Get times of all files. 0 means that the time couldn't be determined. + int numFiles = fileNames.size(); + timestamps.resize(numFiles); + for (int i = 0; i < numFiles; ++i) + timestamps[i] = picture_get_timestamp(qPrintable(fileNames[i])); updateInvalid(); } @@ -375,7 +380,6 @@ void ShiftImageTimesDialog::setOffset(time_t offset) void ShiftImageTimesDialog::updateInvalid() { - timestamp_t timestamp; bool allValid = true; ui.warningLabel->hide(); ui.invalidFilesText->hide(); @@ -389,17 +393,17 @@ void ShiftImageTimesDialog::updateInvalid() } ui.invalidFilesText->append(tr("\nFiles with inappropriate date/time") + ":"); - Q_FOREACH (const QString &fileName, fileNames) { - if (picture_check_valid(qPrintable(fileName), m_amount)) + int numFiles = fileNames.size(); + for (int i = 0; i < numFiles; ++i) { + if (picture_check_valid_time(timestamps[i], m_amount)) continue; - // We've found invalid image - timestamp = picture_get_timestamp(qPrintable(fileName)); - time_first.setTime_t(timestamp + m_amount); - if (timestamp == 0) - ui.invalidFilesText->append(fileName + " - " + tr("No Exif date/time found")); + // We've found an invalid image + time_first.setTime_t(timestamps[i] + m_amount); + if (timestamps[i] == 0) + ui.invalidFilesText->append(fileNames[i] + " - " + tr("No Exif date/time found")); else - ui.invalidFilesText->append(fileName + " - " + time_first.toString()); + ui.invalidFilesText->append(fileNames[i] + " - " + time_first.toString()); allValid = false; } diff --git a/desktop-widgets/simplewidgets.h b/desktop-widgets/simplewidgets.h index 526e2be50..e8c999c40 100644 --- a/desktop-widgets/simplewidgets.h +++ b/desktop-widgets/simplewidgets.h @@ -118,6 +118,7 @@ slots: private: QStringList fileNames; + QVector<timestamp_t> timestamps; Ui::ShiftImageTimesDialog ui; time_t m_amount; time_t dcImageEpoch; |