X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/39cfd051ef25f3a90fdfa411325829ca119a421c..6a4d4463b8e7ed09b5a93e1199e7630e49e80071:/src/kitemviews/kfileitemmodelrolesupdater.cpp diff --git a/src/kitemviews/kfileitemmodelrolesupdater.cpp b/src/kitemviews/kfileitemmodelrolesupdater.cpp index 5c212a984..c6ce877e3 100644 --- a/src/kitemviews/kfileitemmodelrolesupdater.cpp +++ b/src/kitemviews/kfileitemmodelrolesupdater.cpp @@ -23,9 +23,8 @@ #include #include -#include +#include #include -#include #include #include #include @@ -45,7 +44,6 @@ #ifdef HAVE_BALOO #include "private/kbaloorolesprovider.h" #include - #include #include #endif @@ -97,7 +95,7 @@ KFileItemModelRolesUpdater::KFileItemModelRolesUpdater(KFileItemModel* model, QO { Q_ASSERT(model); - const KConfigGroup globalConfig(KGlobal::config(), "PreviewSettings"); + const KConfigGroup globalConfig(KSharedConfig::openConfig(), "PreviewSettings"); m_enabledPlugins = globalConfig.readEntry("Plugins", QStringList() << "directorythumbnail" << "imagethumbnail" @@ -495,7 +493,7 @@ void KFileItemModelRolesUpdater::slotGotPreview(const KFileItem& item, const QPi const QString mimeTypeGroup = mimeType.left(slashIndex); if (mimeTypeGroup == QLatin1String("image")) { if (m_enlargeSmallPreviews) { - KPixmapModifier::applyFrame(scaledPixmap, m_iconSize); + KPixmapModifier::applyFrame(scaledPixmap, m_iconSize * qApp->devicePixelRatio()); } else { // Assure that small previews don't get enlarged. Instead they // should be shown centered within the frame. @@ -504,7 +502,7 @@ void KFileItemModelRolesUpdater::slotGotPreview(const KFileItem& item, const QPi scaledPixmap.height() < contentSize.height(); if (enlargingRequired) { QSize frameSize = scaledPixmap.size(); - frameSize.scale(m_iconSize, Qt::KeepAspectRatio); + frameSize.scale(m_iconSize * qApp->devicePixelRatio(), Qt::KeepAspectRatio); QPixmap largeFrame(frameSize); largeFrame.fill(Qt::transparent); @@ -512,19 +510,20 @@ void KFileItemModelRolesUpdater::slotGotPreview(const KFileItem& item, const QPi KPixmapModifier::applyFrame(largeFrame, frameSize); QPainter painter(&largeFrame); - painter.drawPixmap((largeFrame.width() - scaledPixmap.width()) / 2, - (largeFrame.height() - scaledPixmap.height()) / 2, + painter.drawPixmap((largeFrame.width() - scaledPixmap.width() / scaledPixmap.devicePixelRatio()) / 2, + (largeFrame.height() - scaledPixmap.height() / scaledPixmap.devicePixelRatio()) / 2, scaledPixmap); scaledPixmap = largeFrame; } else { // The image must be shrinked as it is too large to fit into // the available icon size - KPixmapModifier::applyFrame(scaledPixmap, m_iconSize); + KPixmapModifier::applyFrame(scaledPixmap, m_iconSize * qApp->devicePixelRatio()); } } } else { - KPixmapModifier::scale(scaledPixmap, m_iconSize); + KPixmapModifier::scale(scaledPixmap, m_iconSize * qApp->devicePixelRatio()); } + scaledPixmap.setDevicePixelRatio(qApp->devicePixelRatio()); QHash data = rolesData(item); @@ -705,21 +704,8 @@ void KFileItemModelRolesUpdater::applyChangedBalooRoles(const QString& itemUrl) return; } - Baloo::FileFetchJob* job = new Baloo::FileFetchJob(item.localPath()); - connect(job, &Baloo::FileFetchJob::finished, this, &KFileItemModelRolesUpdater::applyChangedBalooRolesJobFinished); - job->setProperty("item", QVariant::fromValue(item)); - job->start(); -#else -#ifndef Q_CC_MSVC - Q_UNUSED(itemUrl); -#endif -#endif -} - -void KFileItemModelRolesUpdater::applyChangedBalooRolesJobFinished(KJob* kjob) -{ -#ifdef HAVE_BALOO - const KFileItem item = kjob->property("item").value(); + Baloo::File file(item.localPath()); + file.load(); const KBalooRolesProvider& rolesProvider = KBalooRolesProvider::instance(); QHash data; @@ -731,8 +717,7 @@ void KFileItemModelRolesUpdater::applyChangedBalooRolesJobFinished(KJob* kjob) data.insert(role, QVariant()); } - Baloo::FileFetchJob* job = static_cast(kjob); - QHashIterator it(rolesProvider.roleValues(job->file(), m_roles)); + QHashIterator it(rolesProvider.roleValues(file, m_roles)); while (it.hasNext()) { it.next(); data.insert(it.key(), it.value()); @@ -744,6 +729,10 @@ void KFileItemModelRolesUpdater::applyChangedBalooRolesJobFinished(KJob* kjob) m_model->setData(index, data); connect(m_model, &KFileItemModel::itemsChanged, this, &KFileItemModelRolesUpdater::slotItemsChanged); +#else +#ifndef Q_CC_MSVC + Q_UNUSED(itemUrl); +#endif #endif } @@ -753,7 +742,7 @@ void KFileItemModelRolesUpdater::slotDirectoryContentsCountReceived(const QStrin const bool getIsExpandableRole = m_roles.contains("isExpandable"); if (getSizeRole || getIsExpandableRole) { - const int index = m_model->index(KUrl(path)); + const int index = m_model->index(QUrl::fromLocalFile(path)); if (index >= 0) { QHash data;