Modified text rect calculation.
authorJussi Laitinen <jupe@l3l7588.ixonos.local>
Tue, 31 Aug 2010 08:47:56 +0000 (11:47 +0300)
committerJussi Laitinen <jupe@l3l7588.ixonos.local>
Tue, 31 Aug 2010 08:47:56 +0000 (11:47 +0300)
src/ui/extendedlistitem.cpp

index 0f8c8fb..c83384a 100644 (file)
@@ -88,24 +88,28 @@ QRect ExtendedListItem::boundingRect(const QString &text)
 
     QStringList rows = text.split('\n');
 
-    for (int i = 1; i < rows.count(); ++i) {
-        qWarning() << "jep";
-        QRect textRowRect = textMetrics.boundingRect(rows.at(i));
-        textRect.setHeight(textRect.height() + textRowRect.height());
-    }
+//    for (int i = 1; i < rows.count(); ++i) {
+//        qWarning() << "jep";
+//        QRect textRowRect = textMetrics.boundingRect(rows.at(i));
+//        textRect.setHeight(textRect.height() + textRowRect.height());
+//    }
 
     QStringList words = text.split(" ");
-    QString rowText;
-    for (int i = 0; i < words.count(); ++i) {
-        if (i == words.count() -1)
-            rowText.append(words.at(i));
-        else
-            rowText.append(words.at(i) + " ");
-        if (textMetrics.width(rowText) > m_subItemTextWidth) {
+    QString rowText = words.at(0);
+    for (int i = 1; i < words.count(); ++i) {
+        if (rowText.contains("\n")) {
+            textRect.setHeight(textRect.height() + textMetrics.height());
+            //rowText.clear();
+            rowText = words.at(i);
+        }
+        else if (textMetrics.width(rowText) > m_subItemTextWidth) {
             textRect.setHeight(textRect.height() + textMetrics.height());
             rowText = words.at(i);
+            rowText.remove("\n");
             qWarning() << "hep";
         }
+        else
+            rowText.append(" " + words.at(i));
     }
 
     return textRect;