X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/b2defa2f98468fcb9491ef7c3b96e340bb6bfa92..14f17839ab2dc3ddca8af1c66eaeb40df5ab9f3f:/src/kitemviews/kfileitemlistwidget.cpp diff --git a/src/kitemviews/kfileitemlistwidget.cpp b/src/kitemviews/kfileitemlistwidget.cpp index d94117e4c..b4e0895f2 100644 --- a/src/kitemviews/kfileitemlistwidget.cpp +++ b/src/kitemviews/kfileitemlistwidget.cpp @@ -67,7 +67,8 @@ QString KFileItemListWidgetInformant::roleText(const QByteArray &role, const QHa if (values.value("isDir").toBool()) { if (!roleValue.isNull() && roleValue != -1) { // The item represents a directory. - if (ContentDisplaySettings::directorySizeCount() || roleValue == -2 /* size is invalid */) { + if (ContentDisplaySettings::directorySizeMode() == ContentDisplaySettings::EnumDirectorySizeMode::ContentCount + || roleValue == -2 /* size is invalid */) { // Show the number of sub directories instead of the file size of the directory. const int count = values.value("count").toInt(); text = i18ncp("@item:intable", "%1 item", "%1 items", count); @@ -161,33 +162,32 @@ QFont KFileItemListWidget::customizedFont(const QFont &baseFont) const int KFileItemListWidget::selectionLength(const QString &text) const { - // Select the text without MIME-type extension - int selectionLength = text.length(); - // If item is a directory, use the whole text length for // selection (ignore all points) if (data().value("isDir").toBool()) { - return selectionLength; + return numberOfUnicodeCharactersIn(text); } + int indexOfExtension = text.length(); + QMimeDatabase db; const QString extension = db.suffixForFileName(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('.')); + indexOfExtension = text.lastIndexOf(QLatin1Char('.')); // If no point could be found, use whole text length for selection. - if (selectionLength < 1) { - selectionLength = text.length(); + if (indexOfExtension < 1) { + indexOfExtension = text.length(); } } else { - selectionLength -= extension.length() + 1; + indexOfExtension -= extension.length() + 1; } - return selectionLength; + return numberOfUnicodeCharactersIn(text.left(indexOfExtension)); } void KFileItemListWidget::hoverSequenceStarted()