]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kstandarditemlistwidget.cpp
Make main view react to context menu events
[dolphin.git] / src / kitemviews / kstandarditemlistwidget.cpp
index 52df17ad32ca6b3e495140f5574ee93bc51cdf39..54e1fa50b3bbb9a09af416cfbd12d0a04cb17ea0 100644 (file)
@@ -821,6 +821,7 @@ void KStandardItemListWidget::editedRoleChanged(const QByteArray &current, const
         rect.setWidth(parent->width() - rect.left());
     }
     m_roleEditor->setGeometry(rect.toRect());
+    m_roleEditor->autoAdjustSize();
     m_roleEditor->show();
     m_roleEditor->setFocus();
 }
@@ -1205,6 +1206,16 @@ QString KStandardItemListWidget::elideRightKeepExtension(const QString &text, in
     return m_customizedFontMetrics.elidedText(text, Qt::ElideRight, elidingWidth);
 }
 
+QString KStandardItemListWidget::escapeString(const QString &text) const
+{
+    QString escaped(text);
+
+    const QChar returnSymbol(0x21b5);
+    escaped.replace('\n', returnSymbol);
+
+    return escaped;
+}
+
 void KStandardItemListWidget::updateIconsLayoutTextCache()
 {
     //      +------+
@@ -1227,7 +1238,7 @@ void KStandardItemListWidget::updateIconsLayoutTextCache()
     // Initialize properties for the "text" role. It will be used as anchor
     // for initializing the position of the other roles.
     TextInfo *nameTextInfo = m_textInfo.value("text");
-    const QString nameText = KStringHandler::preProcessWrap(values["text"].toString());
+    const QString nameText = KStringHandler::preProcessWrap(escapeString(values["text"].toString()));
     nameTextInfo->staticText.setText(nameText);
 
     // Calculate the number of lines required for the name and the required width
@@ -1348,7 +1359,7 @@ void KStandardItemListWidget::updateCompactLayoutTextCache()
     qreal y = qRound((widgetHeight - textLinesHeight) / 2);
     const qreal maxWidth = size().width() - x - option.padding;
     for (const QByteArray &role : std::as_const(m_sortedVisibleRoles)) {
-        const QString text = roleText(role, values);
+        const QString text = escapeString(roleText(role, values));
         TextInfo *textInfo = m_textInfo.value(role);
         textInfo->staticText.setText(text);
 
@@ -1407,6 +1418,7 @@ void KStandardItemListWidget::updateDetailsLayoutTextCache()
 
         const bool isTextRole = (role == "text");
         if (isTextRole) {
+            text = escapeString(text);
             availableTextWidth -= firstColumnInc - sidePadding();
         }