Summary: | Long comments truncated in slideshow | ||
---|---|---|---|
Product: | [Applications] digikam | Reporter: | krienke |
Component: | Plugin-Generic-SlideShow | Assignee: | Digikam Developers <digikam-bugs-null> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | openSUSE | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | 0.9.1 | |
Sentry Crash Report: |
Description
krienke
2007-02-20 08:01:54 UTC
SVN commit 635665 by cgilles: digikam from trunk : Native SlideShow tool : print long comment on the screen using multilines. BUG: 141961 M +61 -3 slideshow.cpp M +1 -0 slideshow.h --- trunk/extragear/graphics/digikam/utilities/slideshow/slideshow.cpp #635664:635665 @@ -18,7 +18,7 @@ * * ============================================================ */ -#define MAXSTRINGLEN 60 +#define MAXSTRINGLEN 80 // Qt includes. @@ -320,8 +320,7 @@ if (d->settings.printComment) { str = d->settings.pictInfoMap[d->currentImage].comment; - if (str.length() > MAXSTRINGLEN) str = str.left(MAXSTRINGLEN-3) + "..."; - printInfoText(p, offset, str); + printComments(p, offset, str); } // Display the Make and Model. @@ -469,6 +468,65 @@ } } +void SlideShow::printComments(QPainter &p, int &offset, const QString& comments) +{ + QStringList commentsByLines; + + uint commentsIndex = 0; // Comments QString index + + while (commentsIndex < comments.length()) + { + QString newLine; + bool breakLine = false; // End Of Line found + uint currIndex; // Comments QString current index + + // Check miminal lines dimension + + uint commentsLinesLengthLocal = MAXSTRINGLEN; + + for (currIndex = commentsIndex; currIndex < comments.length() && !breakLine; currIndex++ ) + { + if( comments[currIndex] == QChar('\n') || comments[currIndex].isSpace() ) + breakLine = true; + } + + if (commentsLinesLengthLocal <= (currIndex - commentsIndex)) + commentsLinesLengthLocal = (currIndex - commentsIndex); + + breakLine = false; + + for (currIndex = commentsIndex ; currIndex <= commentsIndex + commentsLinesLengthLocal && + currIndex < comments.length() && !breakLine ; + currIndex++ ) + { + breakLine = (comments[currIndex] == QChar('\n')) ? true : false; + + if (breakLine) + newLine.append(QString(" ")); + else + newLine.append(comments[currIndex]); + } + + commentsIndex = currIndex; // The line is ended + + if (commentsIndex != comments.length()) + { + while (!newLine.endsWith(" ")) + { + newLine.truncate(newLine.length() - 1); + commentsIndex--; + } + } + + commentsByLines.prepend(newLine.stripWhiteSpace()); + } + + for (int i = 0 ; i < (int)commentsByLines.count() ; i++ ) + { + printInfoText(p, offset, commentsByLines[i]); + } +} + void SlideShow::paintEvent(QPaintEvent *) { bitBlt(this, 0, 0, &d->pixmap, --- trunk/extragear/graphics/digikam/utilities/slideshow/slideshow.h #635664:635665 @@ -74,6 +74,7 @@ void preloadNextImage(); void updatePixmap(); void printInfoText(QPainter &p, int &offset, const QString& str); + void printComments(QPainter &p, int &offset, const QString& comments); private: |