Commit 63a22d07 authored by David Lerch's avatar David Lerch
Browse files

Add support for fixed-length sequence loops to ThumbSequenceCreator

parent 6caba73f
......@@ -235,9 +235,14 @@ void ThumbnailProtocol::get(const QUrl &url)
}
ThumbSequenceCreator* sequenceCreator = dynamic_cast<ThumbSequenceCreator*>(creator);
if(sequenceCreator)
if (sequenceCreator) {
sequenceCreator->setSequenceIndex(sequenceIndex());
const float wp = sequenceCreator->sequenceIndexWraparoundPoint();
setMetaData("sequenceIndexWraparoundPoint", QString().setNum(wp));
setMetaData("handlesSequences", QStringLiteral("1"));
}
if (!creator->create(info.canonicalFilePath(), m_width, m_height, img)) {
error(KIO::ERR_INTERNAL, i18n("Cannot create thumbnail for %1", info.canonicalFilePath()));
return;
......@@ -473,6 +478,7 @@ QImage ThumbnailProtocol::thumbForDirectory(const QString& directory)
QImage firstThumbnail;
int validThumbnails = 0;
int totalValidThumbs = -1;
while (true) {
QDirIterator dir(directory, QDir::Files | QDir::Readable);
......@@ -537,6 +543,12 @@ QImage ThumbnailProtocol::thumbForDirectory(const QString& directory)
}
}
if (!dir.hasNext() && totalValidThumbs < 0) {
// We iterated over the entire directory for the first time, so now we know how many thumbs
// were actually created.
totalValidThumbs = skipped+validThumbnails;
}
if (validThumbnails > 0) {
break;
}
......@@ -554,6 +566,14 @@ QImage ThumbnailProtocol::thumbForDirectory(const QString& directory)
p.end();
if (totalValidThumbs >= 0) {
// We only know this once we've iterated over the entire directory, so this will only be
// set for large enough sequence indices.
const int wraparoundPoint = (totalValidThumbs-1)/visibleCount + 1;
setMetaData("sequenceIndexWraparoundPoint", QString().setNum(wraparoundPoint));
}
setMetaData("handlesSequences", QStringLiteral("1"));
if (validThumbnails == 0) {
// Eventually propagate the contained items from a sub-directory
QDirIterator dir(directory, QDir::Dirs);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment