diff --git a/plugins/autorefresh/autorefresh.cpp b/plugins/autorefresh/autorefresh.cpp --- a/plugins/autorefresh/autorefresh.cpp +++ b/plugins/autorefresh/autorefresh.cpp @@ -32,10 +32,6 @@ #include #include -//KDELibs4Support - -#include - AutoRefresh::AutoRefresh(QObject *parent, const QVariantList & /*args*/) : Plugin(parent) { @@ -121,7 +117,7 @@ KMessageBox::error(0, text, title); } else { // Get URL - KUrl url = part->url(); + QUrl url = part->url(); part->openUrl(url); } } diff --git a/plugins/dirfilter/dirfilterplugin.h b/plugins/dirfilter/dirfilterplugin.h --- a/plugins/dirfilter/dirfilterplugin.h +++ b/plugins/dirfilter/dirfilterplugin.h @@ -24,13 +24,12 @@ #include #include #include +#include -#include #include #include class QPushButton; -class KUrl; class KFileItemList; class KLineEdit; namespace KParts @@ -81,8 +80,8 @@ SessionManager(); ~SessionManager(); - Filters restore(const KUrl &url); - void save(const KUrl &url, const Filters &filters); + Filters restore(const QUrl &url); + void save(const QUrl &url, const Filters &filters); bool showCount; bool useMultipleFilters; diff --git a/plugins/dirfilter/dirfilterplugin.cpp b/plugins/dirfilter/dirfilterplugin.cpp --- a/plugins/dirfilter/dirfilterplugin.cpp +++ b/plugins/dirfilter/dirfilterplugin.cpp @@ -46,31 +46,31 @@ K_GLOBAL_STATIC(SessionManager, globalSessionManager) -static void generateKey(const KUrl &url, QString *key) +static void generateKey(const QUrl &url, QString *key) { if (url.isValid()) { - *key = url.protocol(); + *key = url.scheme(); *key += QLatin1Char(':'); - if (url.hasHost()) { + if (!url.host().isEmpty()) { *key += url.host(); *key += QLatin1Char(':'); } - if (url.hasPath()) { + if (!url.path().isEmpty()) { *key += url.path(); } } } -static void saveNameFilter(const KUrl &url, const QString &filter) +static void saveNameFilter(const QUrl &url, const QString &filter) { SessionManager::Filters f = globalSessionManager->restore(url); f.nameFilter = filter; globalSessionManager->save(url, f); } -static void saveTypeFilters(const KUrl &url, const QStringList &filters) +static void saveTypeFilters(const QUrl &url, const QStringList &filters) { SessionManager::Filters f = globalSessionManager->restore(url); f.typeFilters = filters; @@ -88,14 +88,14 @@ saveSettings(); } -SessionManager::Filters SessionManager::restore(const KUrl &url) +SessionManager::Filters SessionManager::restore(const QUrl &url) { QString key; generateKey(url, &key); return m_filters.value(key); } -void SessionManager::save(const KUrl &url, const Filters &filters) +void SessionManager::save(const QUrl &url, const Filters &filters) { QString key; generateKey(url, &key); diff --git a/plugins/domtreeviewer/domtreewindow.cpp b/plugins/domtreeviewer/domtreewindow.cpp --- a/plugins/domtreeviewer/domtreewindow.cpp +++ b/plugins/domtreeviewer/domtreewindow.cpp @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include @@ -48,6 +47,7 @@ #include #include #include +#include //KDELibs4Support #include @@ -285,19 +285,19 @@ void DOMTreeWindow::dragEnterEvent(QDragEnterEvent * event) { // accept uri drops only - event->setAccepted(KUrl::List::canDecode(event->mimeData())); + event->setAccepted(event->mimeData()->hasUrls()); } void DOMTreeWindow::dropEvent(QDropEvent * event) { // this is a very simplistic implementation of a drop event. we // will only accept a dropped URL. the Qt dnd code can do *much* // much more, so please read the docs there // see if we can decode a URI.. if not, just ignore it - KUrl::List urls = KUrl::List::fromMimeData(event->mimeData()); + QList urls = event->mimeData()->urls(); if (!urls.isEmpty()) { // okay, we have a URI.. process it - const KUrl &url = urls.first(); + const QUrl &url = urls.first(); #if 0 // load in the file load(url); diff --git a/plugins/fsview/fsview.h b/plugins/fsview/fsview.h --- a/plugins/fsview/fsview.h +++ b/plugins/fsview/fsview.h @@ -27,7 +27,6 @@ #include #include -#include #include #include @@ -115,7 +114,7 @@ // for color mode void addColorItems(QMenu *, int); - KUrl::List selectedUrls(); + QList selectedUrls(); public slots: void selected(TreeMapItem *); diff --git a/plugins/fsview/fsview.cpp b/plugins/fsview/fsview.cpp --- a/plugins/fsview/fsview.cpp +++ b/plugins/fsview/fsview.cpp @@ -28,7 +28,6 @@ #include #include #include -#include #include #include @@ -142,10 +141,10 @@ _path = QDir::cleanPath(_path); _pathDepth = _path.count('/'); - KUrl u; + QUrl u; u.setPath(_path); - if (!KUrlAuthorized::authorizeUrlAction(QStringLiteral("list"), KUrl(), u)) { - QString msg = KIO::buildErrorString(KIO::ERR_ACCESS_DENIED, u.prettyUrl()); + if (!KUrlAuthorized::authorizeUrlAction(QStringLiteral("list"), QUrl(), u)) { + QString msg = KIO::buildErrorString(KIO::ERR_ACCESS_DENIED, u.toDisplayString()); KMessageBox::sorry(this, msg); } @@ -157,13 +156,12 @@ requestUpdate(b); } -KUrl::List FSView::selectedUrls() +QList FSView::selectedUrls() { - KUrl::List urls; + QList urls; foreach (TreeMapItem *i, selection()) { - KUrl u; - u.setPath(((Inode *)i)->path()); + QUrl u = QUrl::fromLocalFile(((Inode *)i)->path()); urls.append(u); } return urls; diff --git a/plugins/fsview/fsview_part.cpp b/plugins/fsview/fsview_part.cpp --- a/plugins/fsview/fsview_part.cpp +++ b/plugins/fsview/fsview_part.cpp @@ -344,11 +344,10 @@ void FSViewPart::updateActions() { int canDel = 0, canCopy = 0, canMove = 0; - KUrl::List urls; + QList urls; foreach (TreeMapItem *i, _view->selection()) { - KUrl u; - u.setPath(((Inode *)i)->path()); + QUrl u = QUrl::fromLocalFile(((Inode *)i)->path()); urls.append(u); canCopy++; if (KProtocolManager::supportsDeleting(u)) { @@ -386,8 +385,7 @@ KFileItemList items; foreach (TreeMapItem *i, _view->selection()) { - KUrl u; - u.setPath(((Inode *)i)->path()); + QUrl u = QUrl::fromLocalFile(((Inode *)i)->path()); QString mimetype = ((Inode *)i)->mimeType().name(); const QFileInfo &info = ((Inode *)i)->fileInfo(); mode_t mode = @@ -449,7 +447,7 @@ void FSViewPart::slotProperties() { - KUrl::List urlList; + QList urlList; if (view()) { urlList = view()->selectedUrls(); } @@ -472,7 +470,7 @@ void FSViewBrowserExtension::del() { - const KUrl::List urls = _view->selectedUrls(); + const QList urls = _view->selectedUrls(); KIO::JobUiDelegate uiDelegate; uiDelegate.setWindow(_view); if (uiDelegate.askDeleteConfirmation(urls, @@ -497,7 +495,7 @@ if (uiDelegate.askDeleteConfirmation(urls, KIO::JobUiDelegate::Trash, KIO::JobUiDelegate::DefaultConfirmation)) { KIO::Job *job = KIO::trash(urls); - KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Trash, urls, KUrl("trash:/"), job); + KIO::FileUndoManager::self()->recordJob(KIO::FileUndoManager::Trash, urls, QUrl("trash:/"), job); KJobWidgets::setWindow(job, _view); job->ui()->setAutoErrorHandlingEnabled(true); connect(job, SIGNAL(result(KJob*)), @@ -551,8 +549,7 @@ return; } - KUrl url; - url.setPath(((Inode *)i)->path()); + QUrl url = QUrl::fromLocalFile(((Inode *)i)->path()); emit openUrlRequest(url); } diff --git a/plugins/fsview/inode.cpp b/plugins/fsview/inode.cpp --- a/plugins/fsview/inode.cpp +++ b/plugins/fsview/inode.cpp @@ -20,8 +20,6 @@ * FSView specialisaton of TreeMapItem class. */ -#include - #include #include #include @@ -423,7 +421,7 @@ } if (!_mimePixmapSet) { - KUrl u(path()); + QUrl u = QUrl::fromLocalFile(path()); _mimePixmap = KIconLoader::global()->loadMimeTypeIcon(KIO::iconNameForUrl(u), KIconLoader::Small); _mimePixmapSet = true; } diff --git a/plugins/fsview/scan.cpp b/plugins/fsview/scan.cpp --- a/plugins/fsview/scan.cpp +++ b/plugins/fsview/scan.cpp @@ -22,7 +22,6 @@ #include #include -#include #include #include @@ -269,9 +268,8 @@ return 0; } - KUrl u; - u.setPath(si->absPath); - if (!KUrlAuthorized::authorizeUrlAction(QStringLiteral("list"), KUrl(), u)) { + QUrl u = QUrl::fromLocalFile(si->absPath); + if (!KUrlAuthorized::authorizeUrlAction(QStringLiteral("list"), QUrl(), u)) { if (_parent) { _parent->subScanFinished(); } diff --git a/plugins/kimgalleryplugin/imgallerydialog.h b/plugins/kimgalleryplugin/imgallerydialog.h --- a/plugins/kimgalleryplugin/imgallerydialog.h +++ b/plugins/kimgalleryplugin/imgallerydialog.h @@ -23,7 +23,6 @@ #include -class KUrl; class KIntNumInput; class QCheckBox; class QLineEdit; @@ -58,7 +57,7 @@ int getColorDepth() const; const QString getTitle() const; - const KUrl getImageUrl() const; + const QUrl getImageUrl() const; const QString getCommentFile() const; const QString getFontName() const; const QString getFontSize() const; diff --git a/plugins/kimgalleryplugin/imgallerydialog.cpp b/plugins/kimgalleryplugin/imgallerydialog.cpp --- a/plugins/kimgalleryplugin/imgallerydialog.cpp +++ b/plugins/kimgalleryplugin/imgallerydialog.cpp @@ -32,7 +32,6 @@ #include #include -#include #include #include #include @@ -450,14 +449,14 @@ return m_title->text(); } -const KUrl KIGPDialog::getImageUrl() const +const QUrl KIGPDialog::getImageUrl() const { return m_imageNameReq->url(); } const QString KIGPDialog::getCommentFile() const { - return m_commentFileReq->url().path(); + return m_commentFileReq->url().toLocalFile(); } const QString KIGPDialog::getFontName() const diff --git a/plugins/kimgalleryplugin/imgalleryplugin.h b/plugins/kimgalleryplugin/imgalleryplugin.h --- a/plugins/kimgalleryplugin/imgalleryplugin.h +++ b/plugins/kimgalleryplugin/imgalleryplugin.h @@ -26,7 +26,6 @@ #include class QProgressDialog; -class KUrl; class KIGPDialog; class QTextStream; @@ -66,12 +65,12 @@ void createHead(QTextStream &stream); void createCSSSection(QTextStream &stream); - void createBody(QTextStream &stream, const QString &sourceDirName, const QStringList &subDirList, const QDir &imageDir, const KUrl &url, const QString &imageFormat); + void createBody(QTextStream &stream, const QString &sourceDirName, const QStringList &subDirList, const QDir &imageDir, const QUrl &url, const QString &imageFormat); bool createThumb(const QString &imgName, const QString &sourceDirName, const QString &imgGalleryDir, const QString &imageFormat); - bool createHtml(const KUrl &url, const QString &sourceDirName, int recursionLevel, const QString &imageFormat); - void deleteCancelledGallery(const KUrl &url, const QString &sourceDirName, int recursionLevel, const QString &imageFormat); + bool createHtml(const QUrl &url, const QString &sourceDirName, int recursionLevel, const QString &imageFormat); + void deleteCancelledGallery(const QUrl &url, const QString &sourceDirName, int recursionLevel, const QString &imageFormat); void loadCommentFile(); static QString extension(const QString &imageFormat); diff --git a/plugins/kimgalleryplugin/imgalleryplugin.cpp b/plugins/kimgalleryplugin/imgalleryplugin.cpp --- a/plugins/kimgalleryplugin/imgalleryplugin.cpp +++ b/plugins/kimgalleryplugin/imgalleryplugin.cpp @@ -32,7 +32,6 @@ #include #include #include -#include #include #include @@ -53,6 +52,10 @@ K_PLUGIN_FACTORY(KImGalleryPluginFactory, registerPlugin();) +static QString directory(const QUrl &url) { + return url.adjusted(QUrl::StripTrailingSlash).adjusted(QUrl::RemoveFilename).toLocalFile(); +} + KImGalleryPlugin::KImGalleryPlugin(QObject *parent, const QVariantList &) : KParts::Plugin(parent), m_commentMap(0) { @@ -88,7 +91,7 @@ m_useCommentFile = m_configDlg->useCommentFile(); m_imagesPerRow = m_configDlg->getImagesPerRow(); - KUrl url(m_configDlg->getImageUrl()); + QUrl url(m_configDlg->getImageUrl()); if (!url.isEmpty() && url.isValid()) { m_progressDlg = new QProgressDialog(m_part->widget()); QObject::connect(m_progressDlg, SIGNAL(canceled()), this, SLOT(slotCancelled())); @@ -171,10 +174,10 @@ } void KImGalleryPlugin::createBody(QTextStream &stream, const QString &sourceDirName, const QStringList &subDirList, - const QDir &imageDir, const KUrl &url, const QString &imageFormat) + const QDir &imageDir, const QUrl &url, const QString &imageFormat) { int numOfImages = imageDir.count(); - const QString imgGalleryDir = url.directory(); + const QString imgGalleryDir = directory(url); const QString today(KLocale::global()->formatDate(QDate::currentDate())); stream << "\n

" << m_configDlg->getTitle().toHtmlEscaped() << "

" << endl; @@ -258,7 +261,7 @@ stream << "\n\n" << endl; } -bool KImGalleryPlugin::createHtml(const KUrl &url, const QString &sourceDirName, int recursionLevel, const QString &imageFormat) +bool KImGalleryPlugin::createHtml(const QUrl &url, const QString &sourceDirName, int recursionLevel, const QString &imageFormat) { if (m_cancelled) { return false; @@ -279,17 +282,17 @@ if (currentDir == QLatin1String(".") || currentDir == QLatin1String("..")) { continue; //disregard the "." and ".." directories } - QDir subDir = QDir(url.directory() + '/' + currentDir); + QDir subDir = QDir(directory(url) + '/' + currentDir); if (!subDir.exists()) { - subDir.setPath(url.directory()); + subDir.setPath(directory(url)); if (!(subDir.mkdir(currentDir/*, false*/))) { KMessageBox::sorry(m_part->widget(), i18n("Could not create folder: %1", subDir.path())); continue; } else { - subDir.setPath(url.directory() + '/' + currentDir); + subDir.setPath(directory(url) + '/' + currentDir); } } - if (!createHtml(KUrl(subDir.path() + '/' + url.fileName()), sourceDirName + '/' + currentDir, + if (!createHtml(QUrl::fromLocalFile(subDir.path() + '/' + url.fileName()), sourceDirName + '/' + currentDir, recursionLevel > 1 ? recursionLevel - 1 : 0, imageFormat)) { return false; } @@ -308,7 +311,7 @@ QDir imageDir(sourceDirName, filter.toLatin1(), QDir::Name | QDir::IgnoreCase, QDir::Files | QDir::Readable); - const QString imgGalleryDir = url.directory(); + const QString imgGalleryDir = directory(url); kDebug(90170) << "imgGalleryDir: " << imgGalleryDir; // Create the "thumbs" subdirectory if necessary @@ -341,12 +344,16 @@ return !m_cancelled; } else { - KMessageBox::sorry(m_part->widget(), i18n("Could not open file: %1", url.path(KUrl::AddTrailingSlash))); + QString path = url.toLocalFile(); + if (!path.endsWith("/")) { + path += '/'; + } + KMessageBox::sorry(m_part->widget(), i18n("Could not open file: %1", path)); return false; } } -void KImGalleryPlugin::deleteCancelledGallery(const KUrl &url, const QString &sourceDirName, int recursionLevel, const QString &imageFormat) +void KImGalleryPlugin::deleteCancelledGallery(const QUrl &url, const QString &sourceDirName, int recursionLevel, const QString &imageFormat) { if (m_recurseSubDirectories && (recursionLevel >= 0)) { QStringList subDirList; @@ -358,13 +365,13 @@ if (*it == QLatin1String(".") || *it == QLatin1String("..") || *it == QLatin1String("thumbs") || (m_copyFiles && *it == QLatin1String("images"))) { continue; //disregard the "." and ".." directories } - deleteCancelledGallery(KUrl(url.directory() + '/' + *it + '/' + url.fileName()), + deleteCancelledGallery(QUrl::fromLocalFile(directory(url) + '/' + *it + '/' + url.fileName()), sourceDirName + '/' + *it, recursionLevel > 1 ? recursionLevel - 1 : 0, imageFormat); } } - const QString imgGalleryDir = url.directory(); + const QString imgGalleryDir = directory(url); QDir thumb_dir(imgGalleryDir + QLatin1String("/thumbs/")); QDir images_dir(imgGalleryDir + QLatin1String("/images/")); QDir imageDir(sourceDirName, QStringLiteral("*.png *.PNG *.gif *.GIF *.jpg *.JPG *.jpeg *.JPEG *.bmp *.BMP"), @@ -448,9 +455,9 @@ const QString pixPath = sourceDirName + QLatin1String("/") + imgName; if (m_copyFiles) { - KUrl srcURL = KUrl(pixPath); + QUrl srcURL = QUrl::fromLocalFile(pixPath); //kDebug(90170) << "srcURL: " << srcURL; - KUrl destURL = KUrl(imgGalleryDir + QLatin1String("/images/") + imgName); + QUrl destURL = QUrl::fromLocalFile(imgGalleryDir + QLatin1String("/images/") + imgName); //kDebug(90170) << "destURL: " << destURL; KIO::NetAccess::file_copy(srcURL, destURL, static_cast(parent())->widget()); } diff --git a/plugins/minitools/minitoolsplugin.h b/plugins/minitools/minitoolsplugin.h --- a/plugins/minitools/minitoolsplugin.h +++ b/plugins/minitools/minitoolsplugin.h @@ -25,7 +25,6 @@ #include #include -#include #include #include diff --git a/plugins/rellinks/plugin_rellinks.cpp b/plugins/rellinks/plugin_rellinks.cpp --- a/plugins/rellinks/plugin_rellinks.cpp +++ b/plugins/rellinks/plugin_rellinks.cpp @@ -41,7 +41,6 @@ #include #include #include -#include #include #include // local includes @@ -52,6 +51,10 @@ K_PLUGIN_FACTORY(RelLinksFactory, registerPlugin();) #include +static QUrl resolvedUrl(const QUrl &base, const QString& rel) { + return QUrl(base).resolved(QUrl(rel)); +} + Q_DECLARE_METATYPE(DOM::Element); /** Constructor of the plugin. */ @@ -382,9 +385,9 @@ QString title = e.getAttribute("title").string(); QString hreflang = e.getAttribute("hreflang").string(); - KUrl ref(m_part->url(), href); + QUrl ref(resolvedUrl(m_part->url(), href)); if (title.isEmpty()) { - title = ref.prettyUrl(); + title = ref.toDisplayString(); } // escape ampersand before settings as action title, otherwise the menu entry will interpret it as an @@ -473,8 +476,8 @@ } QString href = rx.cap(1) + nval_str + rx.cap(3); - KUrl ref(m_part->url(), href); - QString title = i18n("[Autodetected] %1", ref.prettyUrl()); + QUrl ref(resolvedUrl(m_part->url(), href)); + QString title = i18n("[Autodetected] %1", ref.toDisplayString()); DOM::Element e = m_part->document().createElement("link"); e.setAttribute("href", href); QAction *a = actionCollection()->action(QStringLiteral("rellinks_next")); @@ -488,8 +491,8 @@ nval_str.prepend(zeros.left(lenval - nval_str.length())); } QString href = rx.cap(1) + nval_str + rx.cap(3); - KUrl ref(m_part->url(), href); - QString title = i18n("[Autodetected] %1", ref.prettyUrl()); + QUrl ref(resolvedUrl(m_part->url(), href)); + QString title = i18n("[Autodetected] %1", ref.toDisplayString()); e = m_part->document().createElement("link"); e.setAttribute("href", href); QAction *a = actionCollection()->action(QStringLiteral("rellinks_prev")); @@ -508,7 +511,7 @@ return; } QString href = e.getAttribute("href").string(); - KUrl url(part->url(), href); + QUrl url(resolvedUrl(part->url(), href)); QString target = e.getAttribute("target").string(); // URL arguments @@ -520,9 +523,9 @@ if (url.isValid()) { part->browserExtension()->openUrlRequest(url, arguments, browserArguments); } else { - KUrl baseURL = part->baseURL(); - QString endURL = url.prettyUrl(); - KUrl realURL = KUrl(baseURL, endURL); + QUrl baseURL = part->baseURL(); + QString endURL = url.toDisplayString(); + QUrl realURL = resolvedUrl(baseURL, endURL); part->browserExtension()->openUrlRequest(realURL, arguments, browserArguments); } diff --git a/plugins/searchbar/OpenSearchManager.h b/plugins/searchbar/OpenSearchManager.h --- a/plugins/searchbar/OpenSearchManager.h +++ b/plugins/searchbar/OpenSearchManager.h @@ -23,10 +23,6 @@ #include #include -//KDELibs4Support -#include - - class OpenSearchEngine; /** diff --git a/plugins/searchbar/opensearch/OpenSearchEngine.h b/plugins/searchbar/opensearch/OpenSearchEngine.h --- a/plugins/searchbar/opensearch/OpenSearchEngine.h +++ b/plugins/searchbar/opensearch/OpenSearchEngine.h @@ -24,7 +24,7 @@ #include #include -#include +#include class QScriptEngine; @@ -44,13 +44,13 @@ QString searchUrlTemplate() const; void setSearchUrlTemplate(const QString &searchUrl); - KUrl searchUrl(const QString &searchTerm) const; + QUrl searchUrl(const QString &searchTerm) const; bool providesSuggestions() const; QString suggestionsUrlTemplate() const; void setSuggestionsUrlTemplate(const QString &suggestionsUrl); - KUrl suggestionsUrl(const QString &searchTerm) const; + QUrl suggestionsUrl(const QString &searchTerm) const; QList searchParameters() const; void setSearchParameters(const QList &searchParameters); diff --git a/plugins/searchbar/opensearch/OpenSearchEngine.cpp b/plugins/searchbar/opensearch/OpenSearchEngine.cpp --- a/plugins/searchbar/opensearch/OpenSearchEngine.cpp +++ b/plugins/searchbar/opensearch/OpenSearchEngine.cpp @@ -82,13 +82,13 @@ m_searchUrlTemplate = searchUrlTemplate; } -KUrl OpenSearchEngine::searchUrl(const QString &searchTerm) const +QUrl OpenSearchEngine::searchUrl(const QString &searchTerm) const { if (m_searchUrlTemplate.isEmpty()) { - return KUrl(); + return QUrl(); } - KUrl retVal = KUrl::fromEncoded(parseTemplate(searchTerm, m_searchUrlTemplate).toUtf8()); + QUrl retVal = QUrl::fromEncoded(parseTemplate(searchTerm, m_searchUrlTemplate).toUtf8()); QList::const_iterator end = m_searchParameters.constEnd(); QList::const_iterator i = m_searchParameters.constBegin(); @@ -114,13 +114,13 @@ m_suggestionsUrlTemplate = suggestionsUrlTemplate; } -KUrl OpenSearchEngine::suggestionsUrl(const QString &searchTerm) const +QUrl OpenSearchEngine::suggestionsUrl(const QString &searchTerm) const { if (m_suggestionsUrlTemplate.isEmpty()) { - return KUrl(); + return QUrl(); } - KUrl retVal = KUrl::fromEncoded(parseTemplate(searchTerm, m_suggestionsUrlTemplate).toUtf8()); + QUrl retVal = QUrl::fromEncoded(parseTemplate(searchTerm, m_suggestionsUrlTemplate).toUtf8()); QList::const_iterator end = m_suggestionsParameters.constEnd(); QList::const_iterator i = m_suggestionsParameters.constBegin(); diff --git a/plugins/shellcmdplugin/kshellcmdplugin.cpp b/plugins/shellcmdplugin/kshellcmdplugin.cpp --- a/plugins/shellcmdplugin/kshellcmdplugin.cpp +++ b/plugins/shellcmdplugin/kshellcmdplugin.cpp @@ -31,10 +31,6 @@ #include #include -//KDELibs4Support -#include - - KShellCmdPlugin::KShellCmdPlugin(QObject *parent, const QVariantList &) : KParts::Plugin(parent) { @@ -57,7 +53,7 @@ return; } - KUrl url = KIO::NetAccess::mostLocalUrl(part->url(), NULL); + QUrl url = KIO::NetAccess::mostLocalUrl(part->url(), NULL); if (!url.isLocalFile()) { KMessageBox::sorry(part->widget(), i18n("Executing shell commands works only on local directories.")); return; diff --git a/plugins/validators/plugin_validators.h b/plugins/validators/plugin_validators.h --- a/plugins/validators/plugin_validators.h +++ b/plugins/validators/plugin_validators.h @@ -31,14 +31,13 @@ #include "validatorsdialog.h" #include +#include #include -//KDELibs4Support -#include class KActionMenu; -class KUrl; + namespace KIO { class Job; @@ -84,9 +83,9 @@ // +-> Order dependency. KParts::ReadOnlyPart *m_part; // | - KUrl m_WWWValidatorUrl, m_WWWValidatorUploadUrl; - KUrl m_CSSValidatorUrl, m_CSSValidatorUploadUrl; - KUrl m_linkValidatorUrl; + QUrl m_WWWValidatorUrl, m_WWWValidatorUploadUrl; + QUrl m_CSSValidatorUrl, m_CSSValidatorUploadUrl; + QUrl m_linkValidatorUrl; QAction *m_validateHtmlUri, *m_validateHtmlUpload; QAction *m_validateCssUri, *m_validateCssUpload; @@ -101,8 +100,8 @@ bool canValidateByUpload() const; bool canValidateLocally() const; QString documentSource() const; - void validateByUri(const KUrl &url); - void validateByUpload(const KUrl &url, const QList > &formData); + void validateByUri(const QUrl &url); + void validateByUpload(const QUrl &url, const QList > &formData); bool doExternalValidationChecks(); void addStatusBarIcon(); void removeStatusBarIcon(); diff --git a/plugins/validators/plugin_validators.cpp b/plugins/validators/plugin_validators.cpp --- a/plugins/validators/plugin_validators.cpp +++ b/plugins/validators/plugin_validators.cpp @@ -226,11 +226,11 @@ void PluginValidators::setURLs() { - m_WWWValidatorUrl = KUrl(getWWWValidatorUrl()); - m_CSSValidatorUrl = KUrl(getCSSValidatorUrl()); - m_WWWValidatorUploadUrl = KUrl(getWWWValidatorUploadUrl()); - m_CSSValidatorUploadUrl = KUrl(getCSSValidatorUploadUrl()); - m_linkValidatorUrl = KUrl(getLinkValidatorUrl()); + m_WWWValidatorUrl = QUrl(getWWWValidatorUrl()); + m_CSSValidatorUrl = QUrl(getCSSValidatorUrl()); + m_WWWValidatorUploadUrl = QUrl(getWWWValidatorUploadUrl()); + m_CSSValidatorUploadUrl = QUrl(getCSSValidatorUploadUrl()); + m_linkValidatorUrl = QUrl(getLinkValidatorUrl()); } void PluginValidators::slotStarted(KIO::Job *) @@ -433,15 +433,15 @@ m_configDialog->show(); } -void PluginValidators::validateByUri(const KUrl &url) +void PluginValidators::validateByUri(const QUrl &url) { if (!doExternalValidationChecks()) { return; } - KUrl partUrl = m_part->url(); - KUrl validatorUrl(url); - if (partUrl.hasPass()) { + QUrl partUrl = m_part->url(); + QUrl validatorUrl(url); + if (!partUrl.password().isEmpty()) { KMessageBox::sorry( m_part->widget(), i18n("The selected URL cannot be verified because it contains " @@ -460,7 +460,7 @@ emit ext->openUrlRequest(validatorUrl, urlArgs, browserArgs); } -void PluginValidators::validateByUpload(const KUrl &validatorUrl, const QList > &formData) +void PluginValidators::validateByUpload(const QUrl &validatorUrl, const QList > &formData) { KParts::BrowserExtension *ext = KParts::BrowserExtension::childObject(m_part); KParts::OpenUrlArguments urlArgs; @@ -525,7 +525,7 @@ } // Get URL - KUrl partUrl = m_part->url(); + QUrl partUrl = m_part->url(); if (!partUrl.isValid()) { // Just in case ;) const QString title = i18nc("@title:window", "Malformed URL"); const QString text = i18n("The URL you entered is not valid, please " diff --git a/plugins/webarchiver/archivedialog.h b/plugins/webarchiver/archivedialog.h --- a/plugins/webarchiver/archivedialog.h +++ b/plugins/webarchiver/archivedialog.h @@ -34,7 +34,7 @@ class QWidget; class KHTMLPart; class ArchiveViewBase; -class KUrl; +class QUrl; class KTar; class QTextStream; @@ -68,15 +68,15 @@ static NonCDataAttr non_cdata_attr; - KIO::Job *startDownload(const KUrl &url, KHTMLPart *part); + KIO::Job *startDownload(const QUrl &url, KHTMLPart *part); public: // Frame handling typedef QHash Name2Part; private: - typedef QHash URL2Part; + typedef QHash URL2Part; struct PartFrameData { Name2Part framesWithName; @@ -89,8 +89,8 @@ // Stylesheets - typedef QHash< KUrl, DOM::CSSStyleSheet > CSSURLSet; - typedef QHash< QString, KUrl > RawHRef2FullURL; + typedef QHash< QUrl, DOM::CSSStyleSheet > CSSURLSet; + typedef QHash< QString, QUrl > RawHRef2FullURL; typedef QHash< DOM::CSSStyleSheet, RawHRef2FullURL > URLsInStyleSheet; typedef QHash< DOM::Element, RawHRef2FullURL > URLsInStyleElement; typedef QHash< DOM::Node, DOM::CSSStyleSheet > Node2StyleSheet; @@ -116,7 +116,7 @@ : tarName(_tarName), part(_part) { } }; - typedef QMap< KUrl, DownloadInfo > UrlTarMap; + typedef QMap< QUrl, DownloadInfo > UrlTarMap; typedef QList< UrlTarMap::Iterator > DownloadList; struct AttrElem { @@ -155,10 +155,10 @@ void obtainPartURLsLower(const DOM::Node &pNode, int level, RecurseData &data); void obtainStyleSheetURLsLower(DOM::CSSStyleSheet styleSheet, RecurseData &data); - bool insertTranslateURL(const KUrl &fullURL, RecurseData &data); + bool insertTranslateURL(const QUrl &fullURL, RecurseData &data); bool insertHRefFromStyleSheet(const QString &hrefRaw, RawHRef2FullURL &raw2full, - const KUrl &fullURL, RecurseData &data); - void parseStyleDeclaration(const KUrl &baseURL, DOM::CSSStyleDeclaration decl, + const QUrl &fullURL, RecurseData &data); + void parseStyleDeclaration(const QUrl &baseURL, DOM::CSSStyleDeclaration decl, RawHRef2FullURL &urls, RecurseData &data /*, bool verbose = false*/); bool saveTopFrame(); @@ -172,6 +172,8 @@ static bool hasAttrWithValue(const DOM::Element &elem, const QString &attrName, const QString &attrValue); static bool hasChildNode(const DOM::Node &pNode, const QString &nodeName); static AttrList::Iterator getAttribute(AttrList &attrList, const QString &attr); + + static bool hasSubUrl(const QUrl &url); /** * completes a potentially partial URL in a HTML document (like <img href="...") @@ -196,7 +198,7 @@ * * @return fully qualified URL of @p partURL relative to the HTML document in @c data.part */ - static KUrl absoluteURL(const QString &partURL, RecurseData &data); + static QUrl absoluteURL(const QString &partURL, RecurseData &data); /** * TODO KDE4 is this in KHTML function available now? @@ -219,7 +221,7 @@ * * Checks if an embedded link like <img src="..." should be loaded */ - static bool urlCheckFailed(KHTMLPart *part, const KUrl &fullURL); + static bool urlCheckFailed(KHTMLPart *part, const QUrl &fullURL); /** * Escapes HTML characters. Does not forget " as @ref Qt::escape() does. diff --git a/plugins/webarchiver/archivedialog.cpp b/plugins/webarchiver/archivedialog.cpp --- a/plugins/webarchiver/archivedialog.cpp +++ b/plugins/webarchiver/archivedialog.cpp @@ -32,7 +32,7 @@ // * use QHash instead of QMap; get rid of Ordered<> class // * fixed crash / assertion on Konqueror exit after a webpage was archived // See comment about KHTMLView parent widget in plugin_webarchiver.cpp -// * Using KDE4/Qt4 KUrl::equals() and QUrl::fragment() to compare Urls +// * Using KDE4/Qt4 QUrl::equals() and QUrl::fragment() to compare Urls // * KHTML stores comment with a trailing '-'. Looks like some off-by-one bug. // * Add mimetype indicating suffix to downloaded files. @@ -75,7 +75,6 @@ #include "webarchiverdebug.h" //KDELibs4Support -#include #include // Set to true if you have a patched http-io-slave that has @@ -176,9 +175,9 @@ } setMainWidget(m_widget); - KUrl srcURL = part->url(); + QUrl srcURL = part->url(); m_widget->urlLabel->setText(QStringLiteral("" + - KStringHandler::csqueeze(srcURL.prettyUrl(), 80) + ""); + KStringHandler::csqueeze(srcURL.toDisplayString(), 80) + ""); m_widget->targetLabel->setText(QStringLiteral("" + KStringHandler::csqueeze(filename, 80) + ""); @@ -215,7 +214,7 @@ // m_objects.reserve(m_url2tar.size() - m_cssURLs.size()); FOR_ITER(UrlTarMap, m_url2tar, u2t_it) { - const KUrl &url = u2t_it.key(); + const QUrl &url = u2t_it.key(); DownloadInfo &info = u2t_it.value(); assert(info.tarName.isNull()); @@ -258,7 +257,7 @@ } else { m_dlurl2tar_it = (*m_objects_it); - const KUrl &url = m_dlurl2tar_it.key(); + const QUrl &url = m_dlurl2tar_it.key(); DownloadInfo &info = m_dlurl2tar_it.value(); assert(m_dlurl2tar_it != m_url2tar.end()); @@ -273,7 +272,7 @@ KIO::StoredTransferJob *job = qobject_cast(_job); Q_ASSERT(job == m_job); m_job = NULL; - const KUrl &url = m_dlurl2tar_it.key(); + const QUrl &url = m_dlurl2tar_it.key(); DownloadInfo &info = m_dlurl2tar_it.value(); assert(info.tarName.isNull()); @@ -285,7 +284,7 @@ QByteArray data(job->data()); const QString &tarName = info.tarName; -// qCDebug(WEBARCHIVERPLUGIN_LOG) << "downloaded " << url.prettyUrl() << "size=" << data.size() << "mimetype" << mimetype; +// qCDebug(WEBARCHIVERPLUGIN_LOG) << "downloaded " << url.toDisplayString() << "size=" << data.size() << "mimetype" << mimetype; error = ! m_tarBall->writeFile(tarName, data, archivePerms, QString::null, QString::null, m_archiveTime, m_archiveTime, m_archiveTime); if (error) { @@ -312,7 +311,7 @@ } else { // QTimer::singleShot(3000, this, SLOT(slotDownloadStyleSheetsDelay())); - const KUrl &url = m_styleSheets_it.key(); + const QUrl &url = m_styleSheets_it.key(); m_dlurl2tar_it = m_url2tar.find(url); assert(m_dlurl2tar_it != m_url2tar.end()); DownloadInfo &info = m_dlurl2tar_it.value(); @@ -328,7 +327,7 @@ KIO::StoredTransferJob *job = qobject_cast(_job); Q_ASSERT(job == m_job); m_job = NULL; - const KUrl &url = m_dlurl2tar_it.key(); + const QUrl &url = m_dlurl2tar_it.key(); DownloadInfo &info = m_dlurl2tar_it.value(); bool error = job->error(); @@ -370,11 +369,11 @@ downloadStyleSheets(); } -KIO::Job *ArchiveDialog::startDownload(const KUrl &url, KHTMLPart *part) +KIO::Job *ArchiveDialog::startDownload(const QUrl &url, KHTMLPart *part) { QTreeWidgetItem *twi = new QTreeWidgetItem; twi->setText(0, i18n("Downloading")); - twi->setText(1, url.prettyUrl()); + twi->setText(1, url.toDisplayString()); QTreeWidget *tw = m_widget->progressView; tw->insertTopLevelItem(0, twi); @@ -458,7 +457,7 @@ struct GetURL : public GetFromPart { GetURL(const KHTMLPart *child) : GetFromPart(child) { } - operator KUrl() + operator QUrl() { return child->url(); } @@ -534,13 +533,13 @@ FOR_ITER(URLsInStyleSheet, m_URLsInStyleSheet, ss2u_it) { qCDebug(WEBARCHIVERPLUGIN_LOG) << "raw URLs in sheet='" << ss2u_it.key().href(); FOR_ITER(RawHRef2FullURL, ss2u_it.data(), c2f_it) { - qCDebug(WEBARCHIVERPLUGIN_LOG) << " url='" << c2f_it.key() << "' -> '" << c2f_it.data().prettyUrl(); + qCDebug(WEBARCHIVERPLUGIN_LOG) << " url='" << c2f_it.key() << "' -> '" << c2f_it.data().toDisplayString(); } } FOR_ITER(URLsInStyleElement, m_URLsInStyleElement, e2u_it) { qCDebug(WEBARCHIVERPLUGIN_LOG) << "raw URLs in style-element:"; FOR_ITER(RawHRef2FullURL, e2u_it.data(), c2f_it) { - qCDebug(WEBARCHIVERPLUGIN_LOG) << " url='" << c2f_it.key() << "' -> '" << c2f_it.data().prettyUrl(); + qCDebug(WEBARCHIVERPLUGIN_LOG) << " url='" << c2f_it.key() << "' -> '" << c2f_it.data().toDisplayString(); } } #endif @@ -577,16 +576,16 @@ // Remove that URL from the stylesheet qCDebug(WEBARCHIVERPLUGIN_LOG) << "stylesheet: invalid @import url('" << cir.href() << "')"; - raw2full.insert(cir.href().string(), KUrl()); + raw2full.insert(cir.href().string(), QUrl()); } else { qCDebug(WEBARCHIVERPLUGIN_LOG) << "stylesheet: @import url('" << cir.href() << "') found"; QString href = cir.href().string(); Q_ASSERT(!href.isNull()); - KUrl fullURL = importSheet.baseUrl(); + QUrl fullURL = importSheet.baseUrl(); bool inserted = insertHRefFromStyleSheet(href, raw2full, fullURL, data); if (inserted) { m_cssURLs.insert(fullURL, importSheet); @@ -644,7 +643,7 @@ QString href = css.href().string(); if (! href.isNull()) { QString href = css.href().string(); - KUrl fullUrl = css.baseUrl(); + QUrl fullUrl = css.baseUrl(); qCDebug(WEBARCHIVERPLUGIN_LOG) << "top-level stylesheet='" << href; bool inserted = insertTranslateURL(fullUrl, data); if (inserted) { @@ -703,9 +702,9 @@ // URL has no 'name' attribute. This frame cannot(?) change, so 'src' should // identify it unambigously - KUrl _frameURL = absoluteURL((*eurls.frameURL).value, data); + QUrl _frameURL = absoluteURL((*eurls.frameURL).value, data); if (!urlCheckFailed(data.part, _frameURL)) { - data.partFrameData->framesWithURLOnly.insert(_frameURL.url(), 0); + data.partFrameData->framesWithURLOnly.insert(QUrl(_frameURL.url()), 0); } } else { @@ -732,7 +731,7 @@ // Kill insecure/invalid links. Frames are treated separately. -bool ArchiveDialog::insertTranslateURL(const KUrl &fullURL, RecurseData &data) +bool ArchiveDialog::insertTranslateURL(const QUrl &fullURL, RecurseData &data) { if (!urlCheckFailed(data.part, fullURL)) { // qCDebug(WEBARCHIVERPLUGIN_LOG) << "adding '" << fullURL << "' to to-be-downloaded URLs"; @@ -745,25 +744,25 @@ } bool ArchiveDialog::insertHRefFromStyleSheet(const QString &hrefRaw, RawHRef2FullURL &raw2full, - const KUrl &fullURL, RecurseData &data) + const QUrl &fullURL, RecurseData &data) { bool inserted = insertTranslateURL(fullURL, data); #if 0 if (inserted) { qCDebug(WEBARCHIVERPLUGIN_LOG) << "stylesheet: found url='" - << fullURL.prettyUrl() << "' hrefRaw='" << hrefRaw; + << fullURL.toDisplayString() << "' hrefRaw='" << hrefRaw; } else { qCDebug(WEBARCHIVERPLUGIN_LOG) << "stylesheet: killing insecure/invalid url='" - << fullURL.prettyUrl() << "' hrefRaw='" << hrefRaw; + << fullURL.toDisplayString() << "' hrefRaw='" << hrefRaw; } #endif - raw2full.insert(hrefRaw, inserted ? fullURL : KUrl()); + raw2full.insert(hrefRaw, inserted ? fullURL : QUrl()); return inserted; } -void ArchiveDialog::parseStyleDeclaration(const KUrl &baseURL, DOM::CSSStyleDeclaration decl, +void ArchiveDialog::parseStyleDeclaration(const QUrl &baseURL, DOM::CSSStyleDeclaration decl, RawHRef2FullURL &raw2full, RecurseData &data /*, bool verbose*/) { for (int k = 0; k != static_cast(decl.length()); ++k) { @@ -782,7 +781,7 @@ QString parsedURL = parseURL(href); // qCDebug(WEBARCHIVERPLUGIN_LOG) << "found URL='" << val << "' extracted='" << parsedURL << "'"; - insertHRefFromStyleSheet(href, raw2full, KUrl(baseURL, parsedURL), data); + insertHRefFromStyleSheet(href, raw2full, QUrl(baseURL).resolved(QUrl(parsedURL)), data); } } } @@ -922,8 +921,8 @@ // make URLs in hyperref links absolute if (eurls.absURL != invalid) { - KUrl baseurl = absoluteURL(QLatin1String(""), data); - KUrl newurl = KUrl(baseurl, parseURL((*eurls.absURL).value)); + QUrl baseurl = absoluteURL(QLatin1String(""), data); + QUrl newurl = QUrl(baseurl).resolved(QUrl(parseURL((*eurls.absURL).value))); if (urlCheckFailed(data.part, newurl)) { (*eurls.absURL).value = QLatin1String(""); qCDebug(WEBARCHIVERPLUGIN_LOG) << "removing invalid/insecure href='" << newurl << "'"; @@ -933,8 +932,8 @@ // This is slow of course and there would be only a difference if there is some suburl. // Since we discard any urls with suburls for security reasons QUrl::fragment() is sufficient. // - assert(! newurl.hasSubUrl()); // @see urlCheckFailed() - if (newurl.hasFragment() && baseurl.equals(newurl, KUrl::CompareWithoutFragment)) { + assert(! hasSubUrl(newurl)); // @see urlCheckFailed() + if (newurl.hasFragment() && baseurl.matches(newurl, QUrl::RemoveFragment)) { (*eurls.absURL).value = QStringLiteral("#") + newurl.fragment(); } else { (*eurls.absURL).value = newurl.url(); @@ -947,7 +946,7 @@ // NOTE This is a bit inefficient, because the URL is computed twice, here and when obtaining all // URLs first. However it is necessary, because two URLs that look different in the HTML frames (for // example absolute and relative) may resolve to the same absolute URL - KUrl fullURL = absoluteURL(parseURL((*eurls.transURL).value), data); + QUrl fullURL = absoluteURL(parseURL((*eurls.transURL).value), data); UrlTarMap::Iterator it = m_url2tar.find(fullURL); if (it == m_url2tar.end()) { @@ -963,7 +962,7 @@ // Check stylesheet s if (eurls.cssURL != invalid) { - KUrl fullURL = absoluteURL((*eurls.cssURL).value, data); + QUrl fullURL = absoluteURL((*eurls.cssURL).value, data); UrlTarMap::Iterator it = m_url2tar.find(fullURL); if (it == m_url2tar.end()) { @@ -1010,7 +1009,7 @@ } else if (eurls.frameURL != invalid) { URL2Part &u2f = data.partFrameData->framesWithURLOnly; - KUrl fullURL = absoluteURL((*eurls.frameURL).value, data); + QUrl fullURL = absoluteURL((*eurls.frameURL).value, data); URL2Part::Iterator u2f_part = u2f.find(fullURL); if (u2f_part == u2f.end()) { @@ -1149,7 +1148,7 @@ { FOR_CONST_ITER(RawHRef2FullURL, raw2full, r2f_it) { const QString &raw = r2f_it.key(); - const KUrl &fullURL = r2f_it.value(); + const QUrl &fullURL = r2f_it.value(); if (fullURL.isValid()) { UrlTarMap::Iterator utm_it = m_url2tar.find(fullURL); if (utm_it != m_url2tar.end()) { @@ -1277,12 +1276,12 @@ return attrList.end(); } -KUrl ArchiveDialog::absoluteURL(const QString &partURL, RecurseData &data) +QUrl ArchiveDialog::absoluteURL(const QString &partURL, RecurseData &data) { if (data.baseSeen) { - return KUrl(data.document.completeURL(partURL).string()); + return QUrl(data.document.completeURL(partURL).string()); } else { - return KUrl(data.part->url(), partURL); + return QUrl(data.part->url()).resolved(QUrl(partURL)); } } @@ -1307,17 +1306,13 @@ return result; } -bool ArchiveDialog::urlCheckFailed(KHTMLPart *part, const KUrl &fullURL) +bool ArchiveDialog::urlCheckFailed(KHTMLPart *part, const QUrl &fullURL) { if (!fullURL.isValid()) { return true; } -// kDebug() << fullURL.prettyUrl() << " hasSubURL()=" << fullURL.hasSubUrl(); - if (fullURL.hasSubUrl()) { - return true; - } - QString prot = fullURL.protocol(); + QString prot = fullURL.scheme(); bool protFile = (prot == QLatin1String("file")); if (part->onlyLocalReferences() && !protFile) { return true; @@ -1378,4 +1373,3 @@ } return filename; } - diff --git a/plugins/webarchiver/webarchivecreator.cpp b/plugins/webarchiver/webarchivecreator.cpp --- a/plugins/webarchiver/webarchivecreator.cpp +++ b/plugins/webarchiver/webarchivecreator.cpp @@ -31,9 +31,6 @@ #include #include -// KDELibs4Support -#include - #include "webarchivecreator.moc" extern "C" @@ -63,10 +60,9 @@ m_html->setJavaEnabled(false); m_html->setPluginsEnabled(false); } - KUrl url; - url.setProtocol(QStringLiteral("tar")); - url.setPath(path); - url.addPath(QStringLiteral("index.html")); + QUrl url; + url.setScheme(QStringLiteral("tar")); + url.setPath(path + '/' + QStringLiteral("index.html")); m_html->openUrl(url); m_completed = false; int timerId = startTimer(5000);