mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
09fd5c40d1
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>
49 lines
1.3 KiB
C++
49 lines
1.3 KiB
C++
// 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
|