diff --git a/drawzone.cpp b/drawzone.cpp --- a/drawzone.cpp +++ b/drawzone.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -857,7 +858,7 @@ } void DrawZone::dragEnterEvent(QDragEnterEvent*e) { - KUrl::List uris = KUrl::List::fromMimeData( e->mimeData() ); + QList uris = e->mimeData()->urls(); if ( uris.isEmpty() ) return; @@ -871,7 +872,7 @@ } void DrawZone::dropEvent( QDropEvent* e) { - KUrl::List urlList = KUrl::List::fromMimeData( e->mimeData() ); + QList urlList = e->mimeData()->urls(); // A file from konqueror was dropped if (!urlList.isEmpty()) { imageMapEditor->openFile(urlList.first()); diff --git a/imagemapchoosedialog.h b/imagemapchoosedialog.h --- a/imagemapchoosedialog.h +++ b/imagemapchoosedialog.h @@ -21,7 +21,7 @@ #include #include -#include +#include #include "kimagemapeditor.h" @@ -41,13 +41,13 @@ QLineEdit *mapNameEdit; QList maps; QList images; - KUrl baseUrl; + QUrl baseUrl; void initImageListTable(QLayout*); public: ImageMapChooseDialog(QWidget* parent,QList _maps, - QList _images, const KUrl & _baseUrl); + QList _images, const QUrl & _baseUrl); ~ImageMapChooseDialog(); - KUrl pixUrl; + QUrl pixUrl; MapTag* currentMap; protected slots: void slotImageChanged(); diff --git a/imagemapchoosedialog.cpp b/imagemapchoosedialog.cpp --- a/imagemapchoosedialog.cpp +++ b/imagemapchoosedialog.cpp @@ -17,6 +17,7 @@ #include "imagemapchoosedialog.h" #include +#include #include #include #include @@ -34,7 +35,7 @@ QWidget* parent, QList _maps, QList _images, - const KUrl & _baseUrl) + const QUrl & _baseUrl) : QDialog(parent) { qCDebug(KIMAGEMAPEDITOR_LOG) << "ImageMapChooseDialog::ImageMapChooseDialog"; @@ -203,7 +204,12 @@ if (images.at(i)->contains("src")) { QString str = images.at(i)->value("src"); // relative url - pixUrl=KUrl(baseUrl,str); + if (baseUrl.path().isEmpty() | !baseUrl.path().endsWith('/')) { + pixUrl=QUrl(baseUrl.path() + '/').resolved(QUrl(str)); + } + else { + pixUrl=baseUrl.resolved(QUrl(str)); + } pix=QImage(pixUrl.path()); double zoom1=1; double zoom2=1; diff --git a/imageslistview.h b/imageslistview.h --- a/imageslistview.h +++ b/imageslistview.h @@ -21,7 +21,7 @@ #include #include -#include +#include #include "kimagemapeditor.h" @@ -92,16 +92,16 @@ /** * Sets the base URL of all images */ - void setBaseUrl(const KUrl & url) { _baseUrl = url; }; + void setBaseUrl(const QUrl & url) { _baseUrl = url; }; protected slots: void slotSelectionChanged(); signals: - void imageSelected(const KUrl &); + void imageSelected(const QUrl &); protected: - KUrl _baseUrl; + QUrl _baseUrl; /** * Finds the first ImageListViewItem with the given ImageTag diff --git a/imageslistview.cpp b/imageslistview.cpp --- a/imageslistview.cpp +++ b/imageslistview.cpp @@ -21,7 +21,6 @@ // Qt #include - // KDE Frameworks #include #include "kimagemapeditor_debug.h" @@ -139,7 +138,12 @@ QTreeWidgetItem* item = selectedItems().first(); QString src = item->text(0); - emit imageSelected(KUrl(_baseUrl,src)); + if (_baseUrl.path().isEmpty() | !_baseUrl.path().endsWith('/')) { + emit imageSelected(QUrl(_baseUrl.path() + '/').resolved(QUrl(src))); + } + else { + emit imageSelected(_baseUrl.resolved(QUrl(src))); + } } ImageTag* ImagesListView::selectedImage() { diff --git a/kimagemapeditor.h b/kimagemapeditor.h --- a/kimagemapeditor.h +++ b/kimagemapeditor.h @@ -28,7 +28,7 @@ #include #include -#include +#include #include "kimearea.h" @@ -196,7 +196,7 @@ * If it's an HTML file openURL is called * If it's an Image, the image is added to the image list */ - void openFile(const KUrl &); + void openFile(const QUrl &); /** * Opens the last URL the user worked with. @@ -210,8 +210,8 @@ protected: void init(); - bool openHTMLFile(const KUrl &); - void saveImageMap(const KUrl &); + bool openHTMLFile(const QUrl &); + void saveImageMap(const QUrl &); /** * Returns a language dependent background picture, with @@ -232,7 +232,7 @@ HtmlContent _htmlContent; // the url of the working image; - KUrl _imageUrl; + QUrl _imageUrl; QString _mapName; QImage _backgroundImage; @@ -335,7 +335,7 @@ HtmlImgElement* findHtmlImgElement(ImageTag*); HtmlMapElement* findHtmlMapElement(const QString &); void deleteAllMaps(); - void addImage(const KUrl &); + void addImage(const QUrl &); void setImageActionsEnabled(bool); void setMapActionsEnabled(bool); @@ -353,7 +353,7 @@ void slotShowMapPopupMenu(const QPoint &); void slotShowImagePopupMenu(const QPoint &); void slotConfigChanged(); - void setPicture(const KUrl & url); + void setPicture(const QUrl & url); void setMap(const QString &); void setMapName(const QString & s); diff --git a/kimagemapeditor.cpp b/kimagemapeditor.cpp --- a/kimagemapeditor.cpp +++ b/kimagemapeditor.cpp @@ -165,8 +165,8 @@ this, SLOT(slotShowMapPopupMenu(QPoint))); - connect( imagesListView, SIGNAL(imageSelected(KUrl)), - this, SLOT(setPicture(KUrl))); + connect( imagesListView, &ImagesListView::imageSelected, + this, QOverload::of(&KImageMapEditor::setPicture)); connect( imagesListView, SIGNAL(customContextMenuRequested(QPoint)), @@ -402,7 +402,7 @@ } void KImageMapEditor::openLastURL(const KConfigGroup & config) { - KUrl lastURL ( config.readPathEntry("lastopenurl", QString()) ); + QUrl lastURL ( config.readPathEntry("lastopenurl", QString()) ); QString lastMap = config.readEntry("lastactivemap"); QString lastImage = config.readPathEntry("lastactiveimage", QString()); @@ -1436,7 +1436,7 @@ } -void KImageMapEditor::setPicture(const KUrl & url) { +void KImageMapEditor::setPicture(const QUrl & url) { _imageUrl=url; if (QFileInfo(url.path()).exists()) { QImage img(url.path()); @@ -1592,7 +1592,7 @@ delete dialog; } -void KImageMapEditor::openFile(const KUrl & url) { +void KImageMapEditor::openFile(const QUrl & url) { if ( ! url.isEmpty()) { QMimeDatabase db; QMimeType openedFileType = db.mimeTypeForUrl(url); @@ -1622,7 +1622,7 @@ i18n("Web File (*.png *.jpg *.jpeg *.gif *.htm *.html);;Images (*.png *.jpg *.jpeg *.gif *.bmp *.xbm *.xpm *.pnm *.mng);;" "HTML Files (*.htm *.html);;All Files (*)")); - openFile(KUrl( fileName )); + openFile(QUrl::fromUserInput( fileName )); } @@ -1657,37 +1657,23 @@ void KImageMapEditor::fileSaveAs() { - KUrl url = QFileDialog::getSaveFileUrl(widget(), QString(), QUrl(), i18n("HTML File (*.htm *.html);;Text File (*.txt);;All Files (*)" )); + QUrl url = QFileDialog::getSaveFileUrl(widget(), QString(), QUrl(), i18n("HTML File (*.htm *.html);;Text File (*.txt);;All Files (*)" )); if (url.isEmpty() || !url.isValid()) { return; } QFileInfo fileInfo(url.path()); - if ( fileInfo.exists() ) - { - if (KMessageBox::warningContinueCancel(widget(), - i18n("The file %1 already exists.
Do you want to overwrite it?
", fileInfo.fileName()), - i18n("Overwrite File?"), KGuiItem(i18n("Overwrite")))==KMessageBox::Cancel) - return; - - if(!fileInfo.isWritable()) { - KMessageBox::sorry(widget(), i18n("You do not have write permission for the file %1.", fileInfo.fileName())); - return; - } - } - - saveAs(url); recentFilesAction->addUrl(url); } bool KImageMapEditor::openFile() { - KUrl u = url(); + QUrl u = url(); QFileInfo fileInfo(u.path()); if ( !fileInfo.exists() ) @@ -1873,7 +1859,7 @@ } -bool KImageMapEditor::openHTMLFile(const KUrl & url) +bool KImageMapEditor::openHTMLFile(const QUrl & url) { QFile f(url.path()); if ( !f.exists () ) @@ -1957,7 +1943,7 @@ f.close(); - KUrl imageUrl; + QUrl imageUrl; map = 0L; @@ -1970,8 +1956,14 @@ if (images.count() > 1) { ImageTag* imgTag = images.first(); if (imgTag) { - if (imgTag->contains("src")) - imageUrl = KUrl(url,imgTag->value("src")); + if (imgTag->contains("src")) { + if (url.path().isEmpty() | !url.path().endsWith('/')) { + imageUrl = QUrl(url.path() + '/').resolved(QUrl(imgTag->value("src"))); + } + else { + imageUrl = url.resolved(QUrl(imgTag->value("src"))); + } + } } } @@ -1989,7 +1981,12 @@ QString usemapName = usemap.right(usemap.length()-1); if (usemapName == mapTag->name) { if (imageTag->contains("src")) { - imageUrl = KUrl(url,imageTag->value("src")); + if (url.path().isEmpty() | !url.path().endsWith('/')) { + imageUrl = QUrl(url.path() + '/').resolved(QUrl(imageTag->value("src"))); + } + else { + imageUrl = url.resolved(QUrl(imageTag->value("src"))); + } found = true; } } @@ -2331,14 +2328,14 @@ the Free Software Foundation; either version 2 of the License, or (at your option) any later version. */ -static KUrl toRelative(const KUrl& urlToConvert,const KUrl& baseURL) +static QUrl toRelative(const QUrl& urlToConvert,const QUrl& baseURL) { - KUrl resultURL = urlToConvert; - if (urlToConvert.protocol() == baseURL.protocol()) + QUrl resultURL = urlToConvert; + if (urlToConvert.scheme() == baseURL.scheme()) { QString path = urlToConvert.path(); - QString basePath = baseURL.path(KUrl::AddTrailingSlash); - if (path.startsWith("/")) + QString basePath = baseURL.path().endsWith('/') ? baseURL.path() : baseURL.path() + '/'; + if (path.startsWith("/") && basePath != "/") { path.remove(0, 1); basePath.remove(0, 1); @@ -2371,24 +2368,24 @@ resultURL.setPath(QDir::cleanPath(path)); } - if (urlToConvert.path().endsWith('/')) resultURL.adjustPath(KUrl::AddTrailingSlash); + if (urlToConvert.path().endsWith('/')) resultURL.setPath(resultURL.path() + '/'); return resultURL; } -void KImageMapEditor::saveImageMap(const KUrl & url) +void KImageMapEditor::saveImageMap(const QUrl & url) { QFileInfo fileInfo(url.path()); - if (!QFileInfo(url.directory()).isWritable()) { + if (!QFileInfo(url.adjusted(QUrl::RemoveFilename|QUrl::StripTrailingSlash).path()).isWritable()) { KMessageBox::error(widget(), i18n("The file %1 could not be saved, because you do not have the required write permissions.", url.path())); return; } if (!backupFileCreated) { QString backupFile = url.path()+'~'; - KIO::file_copy(url, KUrl(backupFile ), -1, KIO::Overwrite | KIO::HideProgressInfo); + KIO::file_copy(url, QUrl::fromUserInput(backupFile ), -1, KIO::Overwrite | KIO::HideProgressInfo); backupFileCreated = true; } @@ -2410,7 +2407,7 @@ << "\n" << " " << getHTMLImageMap() << "\n" - << " picture().width() << "\"" << " height=\"" << drawZone->picture().height() << "\">\n" @@ -2788,11 +2785,11 @@ } -void KImageMapEditor::addImage(const KUrl & imgUrl) { +void KImageMapEditor::addImage(const QUrl & imgUrl) { if (imgUrl.isEmpty()) return; - QString relativePath ( toRelative(imgUrl, KUrl( url().adjusted(QUrl::RemoveFilename).path() )).path() ); + QString relativePath ( toRelative(imgUrl, QUrl( url().adjusted(QUrl::RemoveFilename).path() )).path() ); QString imgHtml = QString(""); ImageTag* imgTag = new ImageTag(); @@ -2831,7 +2828,7 @@ void KImageMapEditor::imageAdd() { - KUrl imgUrl = QFileDialog::getOpenFileUrl(widget(), i18n("Select image"), + QUrl imgUrl = QFileDialog::getOpenFileUrl(widget(), i18n("Select image"), QUrl(), i18n("Images (*.png *.jpg *.jpeg *.gif *.bmp *.xbm *.xpm *.pnm *.mng);;All Files (*)")); addImage(imgUrl); } @@ -2850,7 +2847,7 @@ ImageTag* selected = imagesListView->selectedImage(); if (selected) { if (selected->contains("src")) { - setPicture(KUrl(selected->value("src"))); + setPicture(QUrl(selected->value("src"))); } } } diff --git a/kimedialogs.cpp b/kimedialogs.cpp --- a/kimedialogs.cpp +++ b/kimedialogs.cpp @@ -438,7 +438,7 @@ } void AreaDialog::slotChooseHref() { - KUrl url = QFileDialog::getOpenFileUrl(this, i18n("Choose File"), QString(), i18n("All Files (*)")); + QUrl url = QFileDialog::getOpenFileUrl(this, i18n("Choose File"), QString(), i18n("All Files (*)")); if (!url.isEmpty()) { hrefEdit->setText(url.url()); } diff --git a/kimeshell.h b/kimeshell.h --- a/kimeshell.h +++ b/kimeshell.h @@ -20,7 +20,7 @@ #include #include -#include +#include class KImageMapEditor; @@ -33,7 +33,7 @@ virtual ~KimeShell(); void setStdout(bool b); - void openFile(const KUrl & url); + void openFile(const QUrl & url); /** * Opens the last open file, if the diff --git a/kimeshell.cpp b/kimeshell.cpp --- a/kimeshell.cpp +++ b/kimeshell.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include "drawzone.h" #include "kimagemapeditor.h" // the KPart @@ -80,8 +81,7 @@ QApplication::sendEvent( m_part, &ev ); //setCentralWidget(part->widget()); qCDebug(KIMAGEMAPEDITOR_LOG) << "KimeShell starting 3"; - if (!initialGeometrySet()) - resize( QSize(725, 525).expandedTo(minimumSizeHint())); + resize( QSize(725, 525).expandedTo(minimumSizeHint())); connect( m_part, SIGNAL(setStatusBarText(QString)), this, SLOT(slotSetStatusBarText(QString))); @@ -157,7 +157,7 @@ }; } -void KimeShell::openFile(const KUrl & url) +void KimeShell::openFile(const QUrl & url) { m_part->openFile(url); } @@ -174,7 +174,7 @@ void KimeShell::fileOpen() { - KUrl url = QFileDialog::getOpenFileUrl(this, i18n("Choose Picture to Open"), QString(), + QUrl url = QFileDialog::getOpenFileUrl(this, i18n("Choose Picture to Open"), QString(), i18n("Web File (*.png *.jpg *.jpeg *.gif *.htm *.html);;Images (*.png *.jpg *.jpeg *.gif *.bmp *.xbm *.xpm *.pnm *.mng);;" "HTML Files (*.htm *.html);;All Files (*)")); if (!url.isEmpty()) { @@ -217,7 +217,7 @@ void KimeShell::writeConfig(KConfigGroup &config) { saveMainWindowSettings(config); - saveWindowSize(config); + KWindowConfig::saveWindowSize(windowHandle(), config); // writeDockConfig(config); config.sync(); diff --git a/main.cpp b/main.cpp --- a/main.cpp +++ b/main.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -86,7 +87,7 @@ kimeShell->setStdout(parser.isSet("stdout")); kimeShell->readConfig(); kimeShell->show(); - kimeShell->openFile(parser.positionalArguments().at(i)); + kimeShell->openFile(QUrl::fromUserInput(parser.positionalArguments().at(i), QDir::currentPath(), QUrl::AssumeLocalFile)); } }