diff --git a/KDE5PORTING.html b/KDE5PORTING.html index dbb6ab2042..ddc8f8cadb 100644 --- a/KDE5PORTING.html +++ b/KDE5PORTING.html @@ -1,174 +1,177 @@
This document contains the changes you have to apply to programs written for
KDE 4.x when you want to port them to KDE Frameworks 5.
KStandardDirs "data" -> QStandardPaths::GenericDataLocation KStandardDirs "appdata" -> QStandardPaths::DataLocation KStandardDirs "config" -> QStandardPaths::ConfigLocationIf the resource is available in QStandardPaths (i.e. for all of the above), then the porting is simple:
KStandardDirs::locate("data", "kmyapp/my-data") -> QStandardPaths::locate(QStandardPaths::GenericDataLocation, "kmyapp/my-data") saveLocation -> writableLocation (note that you might have to mkpath it if it doesn't exist) locateLocal(type, file) -> writableLocation(type) + '/' + file (you might have to mkpath the directory)Otherwise, you need to use GenericDataLocation and add the subdirectory name manually.
dirs()->resourceDirs("xdgdata-apps") -> QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, "applications", QStandardPaths::LocateDirectory) dirs()->findAllResources("xdgdata-mime", file) -> QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, "mime/" + file) dirs()->findAllResources("xdgdata-mime", "foo/*.txt") -> QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation) + foreach + entryList, prepending the absolute path.When the code uses wildcard filters or the Recursive flag in findAllResources, you cannot port it to one line of QStandardPaths. Either keep using KStandardDirs, or write your own filtering (easy) or recursive listing (not as easy). An easy case is KStandardDirs::findExe -> QStandardPaths::findExecutable. Well, not so easy: it doesn't support looking into "libexec" at this point. To be resolved.
QMimeDatabase db; // All the methods need a db instance, but it's very cheap to create, on stack is fine. KMimeType::Ptr mime -> QMimeType mime if (mime) -> if (mime.isValid()) KMimeType::mimeType(name) -> db.mimeTypeForName(name) KMimeType::mimeType(name, DontResolveAlias) -> db.mimeTypeForName(name) // there is no separate mime object for the alias KMimeType::findByUrl(url) -> db.findByUrl(url) KMimeType::findByPath(path) -> db.findByFile(path) KMimeType::findByPath(path, 0, true) -> db.findByName(path) // TODO: delayed mimetype determination says conflicting globs should return default. KMimeType::findByContent(data) -> db.findByData(data) KMimeType::findByNameAndContent(name, data_or_device) -> db.findByNameAndData(name, data_or_device) KMimeType::findByFileContent(path) -> QFile f(path); if (f.open(QIODevice::ReadOnly)) db.findByData(&f) mime->name() == KMimeType::defaultMimeType() -> mime.isDefault() KMimeType::extractKnownExtension(fileName) -> db.suffixForFileName(fileName)
KCompressionDevice::CompressionType type = KFilterDev::compressionTypeForMimeType(mimeType); KCompressionDevice flt(&file, false, type);
KFilterDev dev(fileName)