┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews/kstandarditemlistwidget.cpp
diff options
context:
space:
mode:
authorDavid Faure <[email protected]>2012-07-20 12:09:04 +0200
committerEmmanuel Pescosta <[email protected]>2012-08-13 22:25:49 +0200
commiteb14263c480ea37c306a9ae6a7fda64875cfe418 (patch)
tree33f99e846e49379919d1829e84c156d301cbe58f /src/kitemviews/kstandarditemlistwidget.cpp
parent5fbe52c1518037ad3dbb89ba18f2a318aee114f4 (diff)
Fix bug 303375 - Dots in directory names treated as file extension.
Patch by Emmanuel Pescosta <[email protected]> BUG: 303375 REVIEW: 105575 FIXED-IN: 4.9.0
Diffstat (limited to 'src/kitemviews/kstandarditemlistwidget.cpp')
-rw-r--r--src/kitemviews/kstandarditemlistwidget.cpp24
1 files changed, 8 insertions, 16 deletions
diff --git a/src/kitemviews/kstandarditemlistwidget.cpp b/src/kitemviews/kstandarditemlistwidget.cpp
index d41b9161b..69c5602c7 100644
--- a/src/kitemviews/kstandarditemlistwidget.cpp
+++ b/src/kitemviews/kstandarditemlistwidget.cpp
@@ -581,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);
@@ -610,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);
}