[Digikam-devel] [Bug 141961] Long comments truncated in slideshow
Gilles Caulier
caulier.gilles at gmail.com
Tue Feb 20 15:25:31 GMT 2007
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
http://bugs.kde.org/show_bug.cgi?id=141961
caulier.gilles gmail com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |FIXED
------- Additional Comments From caulier.gilles gmail com 2007-02-20 16:25 -------
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:
More information about the Digikam-devel
mailing list