┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews
diff options
context:
space:
mode:
Diffstat (limited to 'src/kitemviews')
-rw-r--r--src/kitemviews/kfileitemmodel.cpp58
-rw-r--r--src/kitemviews/private/kpixmapmodifier.cpp7
2 files changed, 21 insertions, 44 deletions
diff --git a/src/kitemviews/kfileitemmodel.cpp b/src/kitemviews/kfileitemmodel.cpp
index c8bac0b9d..1824fa8e8 100644
--- a/src/kitemviews/kfileitemmodel.cpp
+++ b/src/kitemviews/kfileitemmodel.cpp
@@ -15,7 +15,6 @@
#include "views/draganddrophelper.h"
#include <KDirLister>
-#include <KFileMetaData/UserMetaData>
#include <KIO/Job>
#include <KIO/ListJob>
#include <KLocalizedString>
@@ -750,41 +749,15 @@ void KFileItemModel::expandParentDirectories(const QUrl &url)
m_urlsToExpand.insert(urlToExpand);
}
- auto expandUrlAfterInserted = [this](const QUrl &url) {
- // need to wait for the item to be added to the model
- QMetaObject::Connection *connection = new QMetaObject::Connection;
- *connection = connect(this, &KFileItemModel::itemsInserted, this, [this, url, connection](const KItemRangeList &ranges) {
- int idx = -1;
- for (const KItemRange &it : ranges) {
- for (int i = 0; i < it.count; ++i) {
- if (fileItem(it.index + i).url() == url) {
- idx = it.index + i;
- break;
- }
- }
- if (idx != -1) {
- break;
- }
- }
-
- if (idx != -1) {
- setExpanded(idx, true);
- disconnect(*connection);
- delete connection;
- }
- });
- };
-
// KDirLister::open() must called at least once to trigger an initial
// loading. The pending URLs that must be restored are handled
// in slotCompleted().
- for (const auto &url : std::as_const(m_urlsToExpand)) {
- const int idx = index(url);
- if (idx >= 0) {
+ QSetIterator<QUrl> it2(m_urlsToExpand);
+ while (it2.hasNext()) {
+ const int idx = index(it2.next());
+ if (idx >= 0 && !isExpanded(idx)) {
setExpanded(idx, true);
- } else {
- // expand to url asynchronously
- expandUrlAfterInserted(url);
+ break;
}
}
}
@@ -1839,8 +1812,8 @@ void KFileItemModel::emitItemsChangedAndTriggerResorting(const KItemRangeList &i
void KFileItemModel::resetRoles()
{
- for (bool &i : m_requestRole) {
- i = false;
+ for (int i = 0; i < RolesCount; ++i) {
+ m_requestRole[i] = false;
}
}
@@ -1921,7 +1894,14 @@ QHash<QByteArray, QVariant> KFileItemModel::retrieveData(const KFileItem &item,
}
if (m_requestRole[NameRole]) {
- data.insert(sharedValue("text"), item.text());
+ QString displayName = item.text();
+ if (ContentDisplaySettings::hideFileExtensions() && !isDir) {
+ const int dotIndex = displayName.lastIndexOf(QLatin1Char('.'));
+ if (dotIndex > 0) {
+ displayName = displayName.left(dotIndex);
+ }
+ }
+ data.insert(sharedValue("text"), displayName);
}
if (m_requestRole[ExtensionRole] && !isDir) {
@@ -2043,14 +2023,6 @@ QHash<QByteArray, QVariant> KFileItemModel::retrieveData(const KFileItem &item,
data.insert(sharedValue("type"), folderMimeType);
}
- if (m_requestRole[RatingRole] && item.isLocalFile()) {
- KFileMetaData::UserMetaData md(item.localPath());
- const int rating = md.rating();
- if (rating > 0) {
- data.insert(sharedValue("rating"), rating);
- }
- }
-
return data;
}
diff --git a/src/kitemviews/private/kpixmapmodifier.cpp b/src/kitemviews/private/kpixmapmodifier.cpp
index bf316b880..96aea26d4 100644
--- a/src/kitemviews/private/kpixmapmodifier.cpp
+++ b/src/kitemviews/private/kpixmapmodifier.cpp
@@ -15,6 +15,8 @@
#include "kpixmapmodifier.h"
+#include "dolphin_iconsmodesettings.h"
+
#include <QGuiApplication>
#include <QImage>
#include <QPainter>
@@ -281,7 +283,10 @@ void KPixmapModifier::scale(QPixmap &pixmap, const QSize &scaledSize)
return;
}
qreal dpr = pixmap.devicePixelRatio();
- pixmap = pixmap.scaled(scaledSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
+ const Qt::TransformationMode mode = IconsModeSettings::usePixelatedScaling()
+ ? Qt::FastTransformation
+ : Qt::SmoothTransformation;
+ pixmap = pixmap.scaled(scaledSize, Qt::KeepAspectRatio, mode);
pixmap.setDevicePixelRatio(dpr);
}