Skip to content
  • Milian Wolff's avatar
    Port from KUrl to QUrl. · 715d09e5
    Milian Wolff authored
    Based on the initial patch by Dāvis Mosāns, many thanks for that!
    There where many things left to do though and the following should
    be read by everyone who wants to port a plugin to KUrl:
    
    Add -DQT_NO_URL_CAST_FROM_STRING to your project, otherwise you
    are doomed to long debug sessions.
    
    Always be explicit when constructing a QUrl out of a QString.
    Think about what the QString represents. Most of the cases we only
    care about absolute paths, potentially with a remote host and protocol.
    In such a case, the QUrl::fromUserInput is the correct choice. If its
    a local file, i.e. comes out of QDir, QFileInfo etc., always use
    QUrl::fromLocalFile. Generally, if your plugin only works with local
    files, use the latter. *Never* use the QUrl(QString) constructor,
    except if you really want to concstruct a relative URL. A common
    pitfall is e.g. QUrl(IndexedString(...)). Always prefer
    IndexedString::toUrl() instead.
    
    Note that there are, sadly, far too many places in our code base
    which abuse QUrl for general "Path" handling. If possible, rewrite
    your code to use KDevelop::Path in such a case. It's also much
    simpler to port the KUrl to Path directly.
    
    REVIEW: 120123
    715d09e5