Port away from deprecated KIO::UDSEntry::insert()

Summary:
Using replace for DesktopProtocol::prepareUDSEntry(), as we have
no guarantee that certain fields are not set elsewhere in the call chain

Test Plan: Both kio-slave still work

Reviewers: #plasma, chinmoyr

Reviewed By: chinmoyr

Subscribers: chinmoyr, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D18632
parent 52cbdeff
......@@ -57,29 +57,29 @@ extern "C" {
static void createFileEntry(KIO::UDSEntry& entry, const KService::Ptr& service, const QUrl& parentUrl)
{
entry.clear();
entry.insert(KIO::UDSEntry::UDS_NAME, KIO::encodeFileName(service->name()));
entry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFREG);
entry.fastInsert(KIO::UDSEntry::UDS_NAME, KIO::encodeFileName(service->name()));
entry.fastInsert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFREG);
const QString fileUrl = parentUrl.url() + '/' + service->desktopEntryName();
entry.insert(KIO::UDSEntry::UDS_URL, fileUrl);
entry.insert(KIO::UDSEntry::UDS_ACCESS, 0500);
entry.insert(KIO::UDSEntry::UDS_MIME_TYPE, QStringLiteral("application/x-desktop"));
entry.insert(KIO::UDSEntry::UDS_SIZE, 0);
entry.fastInsert(KIO::UDSEntry::UDS_URL, fileUrl);
entry.fastInsert(KIO::UDSEntry::UDS_ACCESS, 0500);
entry.fastInsert(KIO::UDSEntry::UDS_MIME_TYPE, QStringLiteral("application/x-desktop"));
entry.fastInsert(KIO::UDSEntry::UDS_SIZE, 0);
const QString localPath = QStandardPaths::locate(QStandardPaths::ApplicationsLocation, QStringLiteral("%1.desktop").arg(service->desktopEntryName()));
entry.insert(KIO::UDSEntry::UDS_LOCAL_PATH, localPath);
entry.insert(KIO::UDSEntry::UDS_MODIFICATION_TIME, time(nullptr));
entry.insert(KIO::UDSEntry::UDS_ICON_NAME, service->icon());
entry.fastInsert(KIO::UDSEntry::UDS_LOCAL_PATH, localPath);
entry.fastInsert(KIO::UDSEntry::UDS_MODIFICATION_TIME, time(nullptr));
entry.fastInsert(KIO::UDSEntry::UDS_ICON_NAME, service->icon());
}
static void createDirEntry(KIO::UDSEntry& entry, const QString& name, const QString& url, const QString& mime, const QString& iconName)
{
entry.clear();
entry.insert( KIO::UDSEntry::UDS_NAME, name );
entry.insert( KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR );
entry.insert( KIO::UDSEntry::UDS_ACCESS, 0500 );
entry.insert( KIO::UDSEntry::UDS_MIME_TYPE, mime );
entry.fastInsert( KIO::UDSEntry::UDS_NAME, name );
entry.fastInsert( KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR );
entry.fastInsert( KIO::UDSEntry::UDS_ACCESS, 0500 );
entry.fastInsert( KIO::UDSEntry::UDS_MIME_TYPE, mime );
if (!url.isEmpty())
entry.insert( KIO::UDSEntry::UDS_URL, url );
entry.insert( KIO::UDSEntry::UDS_ICON_NAME, iconName );
entry.fastInsert( KIO::UDSEntry::UDS_URL, url );
entry.fastInsert( KIO::UDSEntry::UDS_ICON_NAME, iconName );
}
ApplicationsProtocol::ApplicationsProtocol( const QByteArray &protocol, const QByteArray &pool, const QByteArray &app)
......
......@@ -166,21 +166,21 @@ void DesktopProtocol::prepareUDSEntry(KIO::UDSEntry &entry, bool listing) const
const QString name = file.readName();
if (!name.isEmpty())
entry.insert(KIO::UDSEntry::UDS_DISPLAY_NAME, name);
entry.replace(KIO::UDSEntry::UDS_DISPLAY_NAME, name);
if (file.noDisplay() || !file.tryExec())
entry.insert(KIO::UDSEntry::UDS_HIDDEN, 1);
entry.replace(KIO::UDSEntry::UDS_HIDDEN, 1);
}
// Set a descriptive display name for the root item
if (requestedUrl().path() == QLatin1String("/")
&& entry.stringValue(KIO::UDSEntry::UDS_NAME) == QLatin1String(".")) {
entry.insert(KIO::UDSEntry::UDS_DISPLAY_NAME, i18n("Desktop Folder"));
entry.replace(KIO::UDSEntry::UDS_DISPLAY_NAME, i18n("Desktop Folder"));
}
// Set the target URL to the local path
QUrl localUrl(QUrl::fromLocalFile(entry.stringValue(KIO::UDSEntry::UDS_LOCAL_PATH)));
entry.insert(KIO::UDSEntry::UDS_TARGET_URL, localUrl.toString());
entry.replace(KIO::UDSEntry::UDS_TARGET_URL, localUrl.toString());
}
void DesktopProtocol::rename(const QUrl &_src, const QUrl &_dest, KIO::JobFlags flags)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment