mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-27 20:58:47 +00:00
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:
parent
b63073e203
commit
df5bf728f9
1 changed files with 1 additions and 42 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue