]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Merge branch 'KDE/4.14'
authorFrank Reininghaus <frank78ac@googlemail.com>
Tue, 12 Aug 2014 07:23:24 +0000 (09:23 +0200)
committerFrank Reininghaus <frank78ac@googlemail.com>
Tue, 12 Aug 2014 07:23:24 +0000 (09:23 +0200)
src/dolphintabpage.cpp
src/kitemviews/kstandarditemlistwidget.cpp
src/views/dolphinview.cpp

index d1184a9f2c53063999b4f693002388cc71c3f6db..23e33c95833b308222afec9f93c8121ea8489928 100644 (file)
@@ -187,6 +187,10 @@ QByteArray DolphinTabPage::saveState() const
 
 void DolphinTabPage::restoreState(const QByteArray& state)
 {
+    if (state.isEmpty()) {
+        return;
+    }
+
     QByteArray sd = state;
     QDataStream stream(&sd, QIODevice::ReadOnly);
 
index 998acc06655fd37932cfb2be3d087b4ebe05adfa..6407efc225c14d1cd2da8f3b60b43eb678ab5aae 100644 (file)
@@ -1136,14 +1136,24 @@ void KStandardItemListWidget::updateIconsLayoutTextCache()
             const int textLength = line.textStart() + line.textLength();
             if (textLength < nameText.length()) {
                 // Elide the last line of the text
-                QString lastTextLine = nameText.mid(line.textStart());
-                lastTextLine = m_customizedFontMetrics.elidedText(lastTextLine,
-                                                                  Qt::ElideRight,
-                                                                  maxWidth);
-                const QString elidedText = nameText.left(line.textStart()) + lastTextLine;
-                nameTextInfo->staticText.setText(elidedText);
-
-                const qreal lastLineWidth = m_customizedFontMetrics.boundingRect(lastTextLine).width();
+                qreal elidingWidth = maxWidth;
+                qreal lastLineWidth;
+                do {
+                    QString lastTextLine = nameText.mid(line.textStart());
+                    lastTextLine = m_customizedFontMetrics.elidedText(lastTextLine,
+                                                                      Qt::ElideRight,
+                                                                      elidingWidth);
+                    const QString elidedText = nameText.left(line.textStart()) + lastTextLine;
+                    nameTextInfo->staticText.setText(elidedText);
+
+                    lastLineWidth = m_customizedFontMetrics.boundingRect(lastTextLine).width();
+
+                    // We do the text eliding in a loop with decreasing width (1 px / iteration)
+                    // to avoid problems related to different width calculation code paths
+                    // within Qt. (see bug 337104)
+                    elidingWidth -= 1.0;
+                } while (lastLineWidth > maxWidth);
+
                 nameWidth = qMax(nameWidth, lastLineWidth);
             }
             break;
index c1f585da9448cf8955355db9120921b6130b8e29..02b8815e07a8e7377991d600fc8ba41e4cc89f05 100644 (file)
@@ -1289,11 +1289,11 @@ void DolphinView::updateViewState()
                 m_view->scrollToItem(currentIndex);
                 m_scrollToCurrentItem = false;
             }
-
-            m_currentItemUrl = KUrl();
         } else {
             selectionManager->setCurrentItem(0);
         }
+
+        m_currentItemUrl = KUrl();
     }
 
     if (!m_restoredContentsPosition.isNull()) {