┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews/kstandarditemlistwidget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/kitemviews/kstandarditemlistwidget.cpp')
-rw-r--r--src/kitemviews/kstandarditemlistwidget.cpp33
1 files changed, 15 insertions, 18 deletions
diff --git a/src/kitemviews/kstandarditemlistwidget.cpp b/src/kitemviews/kstandarditemlistwidget.cpp
index 5b0a0b741..69c5602c7 100644
--- a/src/kitemviews/kstandarditemlistwidget.cpp
+++ b/src/kitemviews/kstandarditemlistwidget.cpp
@@ -464,6 +464,11 @@ QFont KStandardItemListWidget::customizedFont(const QFont& baseFont) const
return baseFont;
}
+QPalette::ColorRole KStandardItemListWidget::normalTextColorPalette() const
+{
+ return QPalette::Text;
+}
+
void KStandardItemListWidget::setTextColor(const QColor& color)
{
if (color != m_customTextColor) {
@@ -480,7 +485,7 @@ QColor KStandardItemListWidget::textColor() const
}
const QPalette::ColorGroup group = isActiveWindow() ? QPalette::Active : QPalette::Inactive;
- const QPalette::ColorRole role = isSelected() ? QPalette::HighlightedText : QPalette::Text;
+ const QPalette::ColorRole role = isSelected() ? QPalette::HighlightedText : normalTextColorPalette();
return styleOption().palette.brush(group, role).color();
}
@@ -576,6 +581,11 @@ void KStandardItemListWidget::siblingsInformationChanged(const QBitArray& curren
m_dirtyLayout = true;
}
+int KStandardItemListWidget::selectionLength(const QString& text) const
+{
+ return text.length();
+}
+
void KStandardItemListWidget::editedRoleChanged(const QByteArray& current, const QByteArray& previous)
{
Q_UNUSED(previous);
@@ -605,25 +615,12 @@ void KStandardItemListWidget::editedRoleChanged(const QByteArray& current, const
QTextOption textOption = textInfo->staticText.textOption();
m_roleEditor->document()->setDefaultTextOption(textOption);
- // Select the text without MIME-type extension
- // TODO: This is file-item-specific and should be moved
- // into KFileItemListWidget.
- int selectionLength = text.length();
-
- const QString extension = KMimeType::extractKnownExtension(text);
- if (extension.isEmpty()) {
- // For an unknown extension just exclude the extension after
- // the last point. This does not work for multiple extensions like
- // *.tar.gz but usually this is anyhow a known extension.
- selectionLength = text.lastIndexOf(QLatin1Char('.'));
- } else {
- selectionLength -= extension.length() + 1;
- }
+ const int textSelectionLength = selectionLength(text);
- if (selectionLength > 0) {
+ if (textSelectionLength > 0) {
QTextCursor cursor = m_roleEditor->textCursor();
cursor.movePosition(QTextCursor::StartOfBlock);
- cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, selectionLength);
+ cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, textSelectionLength);
m_roleEditor->setTextCursor(cursor);
}
@@ -1037,7 +1034,7 @@ void KStandardItemListWidget::updateIconsLayoutTextCache()
const QString elidedText = m_customizedFontMetrics.elidedText(text, Qt::ElideRight, maxWidth);
textInfo->staticText.setText(elidedText);
requiredWidth = m_customizedFontMetrics.width(elidedText);
- } else if (role == "rating") {
+ } else if (role == "rating") {
// Use the width of the rating pixmap, because the rating text is empty.
requiredWidth = m_rating.width();
}