Frameworks/Epics/Splitting kdelibs/Common Solutions: Difference between revisions

From KDE Community Wiki
(Created page with "== KDebug == Replace KDebug by QDebug and the traces shouldn't be activated in release mode. == KWarning == Replace KWarning by QWarning and the traces shouldn't be activated ...")
 
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
== KDebug ==
== KDebug/KWarning ==


Replace KDebug by QDebug and the traces shouldn't be activated in release mode.
Replace KDebug by QDebug.
Replace KWarning by QWarning.


== KWarning ==
the traces shouldn't be activated in release mode.


Replace KWarning by QWarning and the traces shouldn't be activated in release mode.
For example :


for example :
    kWarning(7041) << "warning message"
 
kWarning(7041) << "warning message"


Can be replaced by :
Can be replaced by :


qWarning() << "warning message"
    qWarning() << "warning message"


== KTemporaryFile ==
== KTemporaryFile ==


Replace KTemporaryFile by QTemporaryFile
Replace KTemporaryFile by QTemporaryFile.


for example :  
For example :  


   tmpFile = new KTemporaryFile();
   tmpFile = new KTemporaryFile();
Line 30: Line 29:
   tmpFile->setFileTemplate(QLatin1String("prefix-XXXXXX.txt"));
   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 ==
== KMimeType ==


Working progress
Work in progress.
 
Not yet in Qt5 or libinqt5, so this dependency has no solution yet.


== KSaveFile ==
== KSaveFile ==


Working progress
Work in progress.
Not yet in Qt5 or libinqt5, so this dependency has no solution yet.

Latest revision as of 20:09, 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.