From f3ef38ca0d6db6f7e022a0e565f7460ed22f431e Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sun, 10 Jun 2018 16:39:47 +0200 Subject: Dive pictures: remove hashes In the last commits, the canonical-to-local filename map was made independent from the image hashes and the location of moved images was based on filename not hashes. The hashes are now in principle unused (except for conversion of old-style local filename lookups). Therefore, remove the hashes in this commit. This makes addition of images distinctly faster. Signed-off-by: Berthold Stoeger --- desktop-widgets/divelistview.cpp | 3 +-- desktop-widgets/mainwindow.cpp | 12 +++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'desktop-widgets') diff --git a/desktop-widgets/divelistview.cpp b/desktop-widgets/divelistview.cpp index ded3acbc7..bf4a5d8cf 100644 --- a/desktop-widgets/divelistview.cpp +++ b/desktop-widgets/divelistview.cpp @@ -986,9 +986,8 @@ void DiveListView::loadImageFromURL(QUrl url) return; } - // Since we already downloaded the image we can cache it as well. QCryptographicHash hash(QCryptographicHash::Sha1); - hash.addData(imageData); + hash.addData(url.toString().toUtf8()); QString path = QStandardPaths::standardLocations(QStandardPaths::CacheLocation).first(); QDir dir(path); if (!dir.exists()) diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index c0c79b00d..dcd7aff32 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -701,9 +701,9 @@ void MainWindow::on_actionCloudOnline_triggered() updateCloudOnlineStatus(); } -static void learnImageDirs(QStringList dirnames) +static void learnImageDirs(QStringList dirnames, QVector imageFilenames) { - learnImages(dirnames, 10); + learnImages(dirnames, 10, imageFilenames); DivePictureModel::instance()->updateDivePictures(); } @@ -720,7 +720,13 @@ void MainWindow::on_actionHash_images_triggered() dirnames = dialog.selectedFiles(); if (dirnames.isEmpty()) return; - future = QtConcurrent::run(learnImageDirs,dirnames); + QVector 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); -- cgit v1.2.3-70-g09d2