Frameworks/Epics/Splitting kdelibs/Common Solutions: Difference between revisions
No edit summary |
No edit summary |
||
Line 63: | Line 63: | ||
== KComponentData == | |||
Replace KComponentData and use a QString instead | |||
For example : | |||
explicit KLockFile(const QString &file, const KComponentData &componentName = KGlobal::mainComponent()); | |||
Can be replaced by : | |||
explicit KLockFile(const QString &file, const QString &componentName = QString()); | |||
== KMimeType == | == KMimeType == |
Revision as of 20:08, 3 December 2011
KDebug/KWarning
Replace KDebug by QDebug. Replace KWarning by QWarning.
the traces shouldn't be activated in release mode.
For example :
kWarning(7041) << "warning message"
Can be replaced by :
qWarning() << "warning message"
KTemporaryFile
Replace KTemporaryFile by QTemporaryFile.
For example :
tmpFile = new KTemporaryFile(); tmpFile->setPrefix(QLatin1String("prefix-")); tmpFile->setSuffix(QLatin1String(".txt"));
Can be replaced by :
tmpFile = new QTemporaryFile(); tmpFile->setFileTemplate(QLatin1String("prefix-XXXXXX.txt"));
KStandardPaths
Replace KStandardPaths by QStandardPath.
For example to replace findAllResources :
const QStringList magicFiles = KGlobal::dirs()->findAllResources("xdgdata-mime", QLatin1String("magic"));
You have this solution :
const QStringList magicFiles = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation,QLatin1String("mime/magic"));
Another example to replace locateLocal :
const QString pathDefaultMimeType = KGlobal::dirs()->locateLocal("xdgdata-mime", defaultMimeType+QLatin1String(".xml"));
You have this solution :
const QString pathDefaultMimeType = QStandardPaths::storageLocation(QStandardPaths::GenericDataLocation) + QLatin1String("/mime/") + defaultMimeType + QLatin1String(".xml");
Another example to replace findExe:
const QString umd = KStandardDirs::findExe(QString::fromLatin1("update-mime-database"));
You have this solution :
const QString umd = QStandardPaths::findExecutable(QString::fromLatin1("update-mime-database"));
KComponentData
Replace KComponentData and use a QString instead
For example :
explicit KLockFile(const QString &file, const KComponentData &componentName = KGlobal::mainComponent());
Can be replaced by :
explicit KLockFile(const QString &file, const QString &componentName = QString());
KMimeType
Work in progress. Not yet in Qt5 or libinqt5, so this dependency has no solution yet.
KSaveFile
Work in progress. Not yet in Qt5 or libinqt5, so this dependency has no solution yet.