Bug 141961 - Long comments truncated in slideshow
Summary: Long comments truncated in slideshow
Status: RESOLVED FIXED
Alias: None
Product: digikam
Classification: Applications
Component: Plugin-Generic-SlideShow (show other bugs)
Version: unspecified
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: Digikam Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-02-20 08:01 UTC by krienke
Modified: 2017-07-15 15:21 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In: 0.9.1


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description krienke 2007-02-20 08:01:54 UTC
Version:           0.9.1-rc1 (using KDE KDE 3.5.6)
Installed from:    SuSE RPMs
Compiler:          gcc 4.1.2 
OS:                Linux

When a comment in a photo is longer than about 60 characters and this photo is shown using the new great slideshow tool then this comment is tuncated (actually "..." replaces the rest of what is not shown) when displayed in the slide show.  

Actually the comment should be displayed as is and not be truncated. When a photo is in portrait orientation there really is no need to truncate the comment at all, since there is room enough beneath the photo. If the photo is in protrait orientation, the comment should be formatted into several lines.
Comment 1 caulier.gilles 2007-02-20 16:25:30 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: