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>
This commit is contained in:
Berthold Stoeger 2018-06-10 16:40:23 +02:00 committed by Dirk Hohndel
parent f3ef38ca0d
commit 09fd5c40d1
9 changed files with 535 additions and 125 deletions

View file

@ -42,6 +42,7 @@
#include "desktop-widgets/divelogimportdialog.h"
#include "desktop-widgets/divelogexportdialog.h"
#include "desktop-widgets/usersurvey.h"
#include "desktop-widgets/findmovedimagesdialog.h"
#include "core/divesitehelpers.h"
#include "core/windowtitleupdate.h"
#include "desktop-widgets/locationinformation.h"
@ -108,7 +109,8 @@ MainWindow::MainWindow() : QMainWindow(),
helpView(0),
#endif
state(VIEWALL),
survey(0)
survey(0),
findMovedImagesDialog(0)
{
Q_ASSERT_X(m_Instance == NULL, "MainWindow", "MainWindow recreated!");
m_Instance = this;
@ -701,37 +703,6 @@ void MainWindow::on_actionCloudOnline_triggered()
updateCloudOnlineStatus();
}
static void learnImageDirs(QStringList dirnames, QVector<QString> imageFilenames)
{
learnImages(dirnames, 10, imageFilenames);
DivePictureModel::instance()->updateDivePictures();
}
void MainWindow::on_actionHash_images_triggered()
{
QFuture<void> future;
QFileDialog dialog(this, tr("Traverse image directories"), lastUsedDir());
dialog.setFileMode(QFileDialog::Directory);
dialog.setViewMode(QFileDialog::Detail);
dialog.setLabelText(QFileDialog::Accept, tr("Scan"));
dialog.setLabelText(QFileDialog::Reject, tr("Cancel"));
QStringList dirnames;
if (dialog.exec())
dirnames = dialog.selectedFiles();
if (dirnames.isEmpty())
return;
QVector<QString> imageFilenames;
int i;
struct dive *dive;
for_each_dive (i, dive)
FOR_EACH_PICTURE(dive)
imageFilenames.append(QString(picture->filename));
future = QtConcurrent::run(learnImageDirs, dirnames, imageFilenames);
MainWindow::instance()->getNotificationWidget()->showNotification(tr("Scanning images...(this can take a while)"), KMessageWidget::Information);
MainWindow::instance()->getNotificationWidget()->setFuture(future);
}
ProfileWidget2 *MainWindow::graphics() const
{
return qobject_cast<ProfileWidget2*>(applicationState["Default"].topRight->layout()->itemAt(1)->widget());
@ -1375,6 +1346,13 @@ void MainWindow::on_actionUserSurvey_triggered()
survey->show();
}
void MainWindow::on_actionHash_images_triggered()
{
if(!findMovedImagesDialog)
findMovedImagesDialog = new FindMovedImagesDialog(this);
findMovedImagesDialog->show();
}
QString MainWindow::filter_open()
{
QString f;