diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2018-06-10 16:40:23 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-07-04 02:27:36 +0800 |
commit | 09fd5c40d1ad8a33efcfc829cf445ed1de9e4ff0 (patch) | |
tree | 28d216898ee6065f58a23b2a536f085104ddaa7c /desktop-widgets/findmovedimagesdialog.h | |
parent | f3ef38ca0d6db6f7e022a0e565f7460ed22f431e (diff) | |
download | subsurface-09fd5c40d1ad8a33efcfc829cf445ed1de9e4ff0.tar.gz |
Dive pictures: implement FindMovedImagesDialog
Move the find-moved-images functions into a new translation unit
and present the user with the identified matches before applying
them.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/findmovedimagesdialog.h')
-rw-r--r-- | desktop-widgets/findmovedimagesdialog.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/desktop-widgets/findmovedimagesdialog.h b/desktop-widgets/findmovedimagesdialog.h new file mode 100644 index 000000000..9cae6e8fd --- /dev/null +++ b/desktop-widgets/findmovedimagesdialog.h @@ -0,0 +1,49 @@ +// SPDX-License-Identifier: GPL-2.0 +#ifndef FINDMOVEDIMAGES_H +#define FINDMOVEDIMAGES_H + +#include "ui_findmovedimagesdialog.h" +#include <QFutureWatcher> +#include <QVector> +#include <QMap> +#include <QAtomicInteger> + +class FindMovedImagesDialog : public QDialog { + Q_OBJECT +public: + FindMovedImagesDialog(QWidget *parent = 0); +private +slots: + void on_scanButton_clicked(); + void apply(); + void on_buttonBox_rejected(); + void setProgress(double progress, QString path); + void searchDone(); +private: + struct Match { + QString originalFilename; + QString localFilename; + int matchingPathItems; + }; + struct ImageMatch { + QString localFilename; + int score; + }; + struct ImagePath { + QString fullPath; + QString filenameUpperCase; + ImagePath() = default; // For some reason QVector<...>::reserve() needs a default constructor!? + ImagePath(const QString &path); + inline bool operator<(const ImagePath &path2) const; + }; + Ui::FindMovedImagesDialog ui; + QFutureWatcher<QVector<Match>> watcher; + QVector<Match> matches; + QAtomicInt stopScanning; + QScopedPointer<QFontMetrics> fontMetrics; // Needed to format elided paths + + void learnImage(const QString &filename, QMap<QString, ImageMatch> &matches, const QVector<ImagePath> &imagePaths); + QVector<Match> learnImages(const QString &dir, int maxRecursions, QVector<QString> imagePaths); +}; + +#endif |