cleanup: remove thumbnail conversion function

The chances that their are still users of the old thumbnail
format (i.e. all thumbnails saved in the hash file) are basically
0. If there are they will just get their thumbnails rebuilt
when opening the individual dives.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2022-10-30 21:31:38 +01:00
parent b63073e203
commit df5bf728f9

View file

@ -36,7 +36,6 @@
#include <QApplication>
#include <QTextDocument>
#include <QPainter>
#include <QProgressDialog> // TODO: remove with convertThumbnails()
#include <QSvgRenderer>
#include <cstdarg>
#include <cstdint>
@ -1072,45 +1071,6 @@ extern "C" char *hashfile_name_string()
return copy_qstring(hashfile_name());
}
// During a transition period, convert old thumbnail-hashes to individual files
// TODO: remove this code in due course
static void convertThumbnails(const QHash <QString, QImage> &thumbnails)
{
if (thumbnails.empty())
return;
// This is a singular occurrence, therefore translating the strings seems not worth it
QProgressDialog progress("Convert thumbnails...", "Abort", 0, thumbnails.size());
progress.setWindowModality(Qt::WindowModal);
int count = 0;
for (const QString &name: thumbnails.keys()) {
const QImage thumbnail = thumbnails[name];
if (thumbnail.isNull())
continue;
// This is duplicate code (see qt-models/divepicturemodel.cpp)
// Not a problem, since this routine will be removed in due course.
QString filename = thumbnailFileName(name);
if (filename.isEmpty())
continue;
QSaveFile file(filename);
if (!file.open(QIODevice::WriteOnly))
return;
QDataStream stream(&file);
quint32 type = MEDIATYPE_PICTURE;
stream << type;
stream << thumbnail;
file.commit();
progress.setValue(++count);
if (progress.wasCanceled())
break;
}
}
// TODO: This is a temporary helper struct. Remove in due course with convertLocalFilename().
struct HashToFile {
QByteArray hash;
@ -1129,7 +1089,7 @@ static void convertLocalFilename(const QHash<QString, QByteArray> &hashOf, const
return;
// Create a vector of hash/filename pairs and sort by hash.
// Elements can than be accessed with binary search.
// Elements can then be accessed with binary search.
QHash<QByteArray, QString> canonicalFilenameByHash;
QVector<HashToFile> h2f;
h2f.reserve(hashOf.size());
@ -1166,7 +1126,6 @@ void read_hashes()
stream >> localFilenameOf;
locker.unlock();
hashfile.close();
convertThumbnails(thumbnailCache);
convertLocalFilename(hashOf, localFilenameByHash);
}
QMutexLocker locker(&hashOfMutex);