summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukáš Tinkl <lukas@kde.org>2015-01-29 19:55:57 (GMT)
committerLukáš Tinkl <lukas@kde.org>2015-01-29 19:55:57 (GMT)
commitfd6a35486e60f5f727fb70e05403b650fc13163c (patch)
treeaab136f73da4bf0409e2dc8f3c7a22494bb736b7
parentec8c2900ff518330a85f67f9f13bde50db224540 (diff)
port KUrl -> QUrl
-rw-r--r--CMakeLists.txt4
-rw-r--r--active/components/documentitem.cpp11
-rw-r--r--active/components/pageitem.cpp6
-rw-r--r--autotests/addremoveannotationtest.cpp2
-rw-r--r--autotests/annotationstest.cpp2
-rw-r--r--autotests/documenttest.cpp2
-rw-r--r--autotests/editannotationcontentstest.cpp2
-rw-r--r--autotests/editformstest.cpp2
-rw-r--r--autotests/mainshelltest.cpp10
-rw-r--r--autotests/modifyannotationpropertiestest.cpp2
-rw-r--r--autotests/parttest.cpp6
-rw-r--r--autotests/searchtest.cpp2
-rw-r--r--autotests/shelltest.cpp29
-rw-r--r--autotests/translateannotationtest.cpp2
-rw-r--r--core/audioplayer.cpp10
-rw-r--r--core/audioplayer_p.h4
-rw-r--r--core/bookmarkmanager.cpp78
-rw-r--r--core/bookmarkmanager.h22
-rw-r--r--core/document.cpp29
-rw-r--r--core/document.h10
-rw-r--r--core/document_p.h6
-rw-r--r--core/script/kjs_document.cpp4
-rw-r--r--core/script/kjs_util.cpp24
-rw-r--r--generators/chm/generator_chm.cpp16
-rw-r--r--generators/chm/kio-msits/msits.cpp14
-rw-r--r--generators/chm/kio-msits/msits.h10
-rw-r--r--generators/dvi/dviRenderer.cpp2
-rw-r--r--generators/dvi/dviRenderer.h6
-rw-r--r--generators/dvi/generator_dvi.cpp2
-rw-r--r--generators/dvi/psgs.cpp4
-rw-r--r--generators/dvi/psgs.h4
-rw-r--r--generators/epub/epubdocument.cpp4
-rw-r--r--generators/epub/epubdocument.h4
-rw-r--r--generators/kimgio/tests/kimgiotest.cpp2
-rw-r--r--generators/xps/generator_xps.cpp8
-rw-r--r--kdocumentviewer.h4
-rw-r--r--part.cpp65
-rw-r--r--part.h15
-rw-r--r--shell/shell.cpp4
-rw-r--r--ui/bookmarklist.cpp36
-rw-r--r--ui/bookmarklist.h8
-rw-r--r--ui/formwidgets.cpp4
-rw-r--r--ui/presentationwidget.cpp1
-rw-r--r--ui/propertiesdialog.cpp1
-rw-r--r--ui/thumbnaillist.cpp1
-rw-r--r--ui/videowidget.cpp16
46 files changed, 242 insertions, 258 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0e776b3..d9bb450 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,7 +1,5 @@
project(okular)
-
-
cmake_minimum_required(VERSION 2.8.12)
set(QT_MIN_VERSION "5.2.0")
@@ -194,7 +192,7 @@ target_link_libraries(okularcore
)
if(LibKScreen_FOUND)
-# target_link_libraries(okularcore KF5::LibKScreen)
+ target_link_libraries(okularcore KF5::LibKScreen)
endif(LibKScreen_FOUND)
set_target_properties(okularcore PROPERTIES VERSION 6.0.0 SOVERSION 6 )
diff --git a/active/components/documentitem.cpp b/active/components/documentitem.cpp
index 0d625ca..95ead1f 100644
--- a/active/components/documentitem.cpp
+++ b/active/components/documentitem.cpp
@@ -41,9 +41,9 @@ DocumentItem::DocumentItem(QObject *parent)
connect(m_document, SIGNAL(searchFinished(int,Okular::Document::SearchStatus)),
this, SLOT(searchFinished(int,Okular::Document::SearchStatus)));
- connect(m_document->bookmarkManager(), SIGNAL(bookmarksChanged(KUrl)),
+ connect(m_document->bookmarkManager(), SIGNAL(bookmarksChanged(QUrl)),
this, SIGNAL(bookmarkedPagesChanged()));
- connect(m_document->bookmarkManager(), SIGNAL(bookmarksChanged(KUrl)),
+ connect(m_document->bookmarkManager(), SIGNAL(bookmarksChanged(QUrl)),
this, SIGNAL(bookmarksChanged()));
}
@@ -58,7 +58,7 @@ void DocumentItem::setPath(const QString &path)
//TODO: remote urls
//TODO: password
QMimeDatabase db;
- m_document->openDocument(path, KUrl(path), db.mimeTypeForUrl(QUrl(path)));
+ m_document->openDocument(path, QUrl::fromLocalFile(path), db.mimeTypeForUrl(QUrl::fromLocalFile(path)));
m_tocModel->fill(m_document->documentSynopsis());
m_tocModel->setCurrentViewport(m_document->viewport());
@@ -79,7 +79,8 @@ QString DocumentItem::windowTitleForDocument() const
{
// If 'DocumentTitle' should be used, check if the document has one. If
// either case is false, use the file name.
- QString title = Okular::Settings::displayDocumentNameOrPath() == Okular::Settings::EnumDisplayDocumentNameOrPath::Path ? m_document->currentDocument().pathOrUrl() : m_document->currentDocument().fileName();
+ QString title = Okular::Settings::displayDocumentNameOrPath() == Okular::Settings::EnumDisplayDocumentNameOrPath::Path ?
+ m_document->currentDocument().toDisplayString(QUrl::PreferLocalFile) : m_document->currentDocument().fileName();
if (Okular::Settings::displayDocumentTitle()) {
const QString docTitle = m_document->metaData( "DocumentTitle" ).toString();
@@ -94,7 +95,7 @@ QString DocumentItem::windowTitleForDocument() const
QString DocumentItem::path() const
{
- return m_document->currentDocument().prettyUrl();
+ return m_document->currentDocument().toDisplayString();
}
void DocumentItem::setCurrentPage(int page)
diff --git a/active/components/pageitem.cpp b/active/components/pageitem.cpp
index fb6c570..feb3039 100644
--- a/active/components/pageitem.cpp
+++ b/active/components/pageitem.cpp
@@ -113,7 +113,7 @@ void PageItem::setDocument(DocumentItem *doc)
m_documentItem = doc;
Observer *observer = m_isThumbnail ? m_documentItem.data()->thumbnailObserver() : m_documentItem.data()->pageviewObserver();
connect(observer, SIGNAL(pageChanged(int, int)), this, SLOT(pageHasChanged(int, int)));
- connect(doc->document()->bookmarkManager(), SIGNAL(bookmarksChanged(KUrl)),
+ connect(doc->document()->bookmarkManager(), SIGNAL(bookmarksChanged(QUrl)),
this, SLOT(checkBookmarksChanged()));
setPageNumber(0);
emit documentChanged();
@@ -212,7 +212,7 @@ QStringList PageItem::bookmarks() const
void PageItem::goToBookmark(const QString &bookmark)
{
- Okular::DocumentViewport viewPort(KUrl(bookmark).htmlRef());
+ Okular::DocumentViewport viewPort(QUrl::fromUserInput(bookmark).fragment(QUrl::FullyDecoded));
setPageNumber(viewPort.pageNumber);
//Are we in a flickable?
@@ -226,7 +226,7 @@ void PageItem::goToBookmark(const QString &bookmark)
QPointF PageItem::bookmarkPosition(const QString &bookmark) const
{
- Okular::DocumentViewport viewPort(KUrl(bookmark).htmlRef());
+ Okular::DocumentViewport viewPort(QUrl::fromUserInput(bookmark).fragment(QUrl::FullyDecoded));
if (viewPort.pageNumber != m_viewPort.pageNumber) {
return QPointF(-1, -1);
diff --git a/autotests/addremoveannotationtest.cpp b/autotests/addremoveannotationtest.cpp
index a999e83..e0208f9 100644
--- a/autotests/addremoveannotationtest.cpp
+++ b/autotests/addremoveannotationtest.cpp
@@ -42,7 +42,7 @@ void AddRemoveAnnotationTest::init()
const QString testFile = KDESRCDIR "data/file1.pdf";
QMimeDatabase db;
const QMimeType mime = db.mimeTypeForFile( testFile );
- QCOMPARE( m_document->openDocument(testFile, KUrl(), mime), Okular::Document::OpenSuccess );
+ QCOMPARE( m_document->openDocument(testFile, QUrl(), mime), Okular::Document::OpenSuccess );
}
void AddRemoveAnnotationTest::cleanup()
diff --git a/autotests/annotationstest.cpp b/autotests/annotationstest.cpp
index f07449a..83fda9d 100644
--- a/autotests/annotationstest.cpp
+++ b/autotests/annotationstest.cpp
@@ -43,7 +43,7 @@ void AnnotationTest::initTestCase()
const QString testFile = KDESRCDIR "data/file1.pdf";
QMimeDatabase db;
const QMimeType mime = db.mimeTypeForFile( testFile );
- QCOMPARE( m_document->openDocument(testFile, KUrl(), mime), Okular::Document::OpenSuccess );
+ QCOMPARE( m_document->openDocument(testFile, QUrl(), mime), Okular::Document::OpenSuccess );
}
void AnnotationTest::cleanupTestCase()
diff --git a/autotests/documenttest.cpp b/autotests/documenttest.cpp
index 22ae454..80aa393 100644
--- a/autotests/documenttest.cpp
+++ b/autotests/documenttest.cpp
@@ -39,7 +39,7 @@ void DocumentTest::testCloseDuringRotationJob()
Okular::DocumentObserver *dummyDocumentObserver = new Okular::DocumentObserver();
m_document->addObserver( dummyDocumentObserver );
- m_document->openDocument( testFile, KUrl(), mime );
+ m_document->openDocument( testFile, QUrl(), mime );
m_document->setRotation( 1 );
// Tell ThreadWeaver not to start any new job
diff --git a/autotests/editannotationcontentstest.cpp b/autotests/editannotationcontentstest.cpp
index a89d55a..6eb2ac2 100644
--- a/autotests/editannotationcontentstest.cpp
+++ b/autotests/editannotationcontentstest.cpp
@@ -108,7 +108,7 @@ void EditAnnotationContentsTest::init()
const QString testFile = KDESRCDIR "data/file1.pdf";
QMimeDatabase db;
const QMimeType mime = db.mimeTypeForFile( testFile );
- QCOMPARE( m_document->openDocument(testFile, KUrl(), mime), Okular::Document::OpenSuccess );
+ QCOMPARE( m_document->openDocument(testFile, QUrl(), mime), Okular::Document::OpenSuccess );
// Undo and Redo should be unavailable when docuemnt is first opened.
QVERIFY( !m_document->canUndo() );
diff --git a/autotests/editformstest.cpp b/autotests/editformstest.cpp
index 9896e71..caaa3b8 100644
--- a/autotests/editformstest.cpp
+++ b/autotests/editformstest.cpp
@@ -68,7 +68,7 @@ void EditFormsTest::init()
const QString testFile = KDESRCDIR "data/formSamples.pdf";
QMimeDatabase db;
const QMimeType mime = db.mimeTypeForFile( testFile );
- QCOMPARE( m_document->openDocument(testFile, KUrl(), mime), Okular::Document::OpenSuccess );
+ QCOMPARE( m_document->openDocument(testFile, QUrl(), mime), Okular::Document::OpenSuccess );
// Undo and Redo should be unavailable when docuemnt is first opened.
QVERIFY( !m_document->canUndo() );
diff --git a/autotests/mainshelltest.cpp b/autotests/mainshelltest.cpp
index 19a09f2..f0569e0 100644
--- a/autotests/mainshelltest.cpp
+++ b/autotests/mainshelltest.cpp
@@ -117,12 +117,12 @@ void MainShellTest::init()
Okular::Settings::self()->setDefaults();
// Clean docdatas
- QList<KUrl> urls;
- urls << KUrl("file://" KDESRCDIR "data/file1.pdf");
- urls << KUrl("file://" KDESRCDIR "data/tocreload.pdf");
- urls << KUrl("file://" KDESRCDIR "data/contents.epub");
+ QList<QUrl> urls;
+ urls << QUrl::fromUserInput("file://" KDESRCDIR "data/file1.pdf");
+ urls << QUrl::fromUserInput("file://" KDESRCDIR "data/tocreload.pdf");
+ urls << QUrl::fromUserInput("file://" KDESRCDIR "data/contents.epub");
- foreach (const KUrl &url, urls)
+ foreach (const QUrl &url, urls)
{
QFileInfo fileReadTest( url.toLocalFile() );
const QString docDataPath = Okular::DocumentPrivate::docDataFileName(url, fileReadTest.size());
diff --git a/autotests/modifyannotationpropertiestest.cpp b/autotests/modifyannotationpropertiestest.cpp
index 322732b..b8ea32a 100644
--- a/autotests/modifyannotationpropertiestest.cpp
+++ b/autotests/modifyannotationpropertiestest.cpp
@@ -54,7 +54,7 @@ void ModifyAnnotationPropertiesTest::init()
const QString testFile = KDESRCDIR "data/file1.pdf";
QMimeDatabase db;
const QMimeType mime = db.mimeTypeForFile( testFile );
- QCOMPARE( m_document->openDocument(testFile, KUrl(), mime), Okular::Document::OpenSuccess );
+ QCOMPARE( m_document->openDocument(testFile, QUrl(), mime), Okular::Document::OpenSuccess );
// Undo and Redo should be unavailable when docuemnt is first opened.
QVERIFY( !m_document->canUndo() );
diff --git a/autotests/parttest.cpp b/autotests/parttest.cpp
index 0b5156f..dd64a1c 100644
--- a/autotests/parttest.cpp
+++ b/autotests/parttest.cpp
@@ -139,8 +139,8 @@ void PartTest::testFowardPDF()
QCOMPARE(part.m_document->currentPage(), 0u);
part.closeUrl();
- KUrl u(pdfResult);
- u.setHTMLRef("src:100" + texDestination);
+ QUrl u(QUrl::fromLocalFile(pdfResult));
+ u.setFragment("src:100" + texDestination);
part.openUrl(u);
QCOMPARE(part.m_document->currentPage(), 1u);
}
@@ -188,7 +188,7 @@ int main(int argc, char *argv[])
KAboutData aboutData( QByteArray("qttest"), i18n("KDE Test Program"), QByteArray("version") );
QApplication app( argc, argv );
app.setApplicationName( QLatin1String("qttest") );
- qRegisterMetaType<KUrl>(); /*as done by kapplication*/
+ qRegisterMetaType<QUrl>(); /*as done by kapplication*/
qRegisterMetaType<QList<QUrl>>();
Okular::PartTest test;
KGlobal::ref(); /* don't quit qeventloop after closing a mainwindow */
diff --git a/autotests/searchtest.cpp b/autotests/searchtest.cpp
index 944a116..df87cf6 100644
--- a/autotests/searchtest.cpp
+++ b/autotests/searchtest.cpp
@@ -175,7 +175,7 @@ void SearchTest::test311232()
const QString testFile = KDESRCDIR "data/file1.pdf";
QMimeDatabase db;
const QMimeType mime = db.mimeTypeForFile( testFile );
- d.openDocument(testFile, KUrl(), mime);
+ d.openDocument(testFile, QUrl(), mime);
const int searchId = 0;
d.searchText(searchId, " i ", true, Qt::CaseSensitive, Okular::Document::NextMatch, false, QColor());
diff --git a/autotests/shelltest.cpp b/autotests/shelltest.cpp
index 9a4a86c..0f750ae 100644
--- a/autotests/shelltest.cpp
+++ b/autotests/shelltest.cpp
@@ -15,21 +15,12 @@
#include "../shell/shellutils.h"
-namespace QTest
+static const QUrl makeUrlFromCwd( const QString& u, const QString& ref = QString() )
{
-template<>
-char* toString( const KUrl& url )
-{
- return qstrdup( url.url().toLocal8Bit().constData() );
-}
-}
-
-static const KUrl makeUrlFromCwd( const QString& u, const QString& ref = QString() )
-{
- KUrl url( KUrl( QDir::currentPath() + '/' ), u );
+ QUrl url( QUrl::fromLocalFile( QDir::currentPath() + '/' + u ));
if ( !ref.isEmpty() )
- url.setRef( ref );
- url.cleanPath();
+ url.setFragment( ref );
+ url.setPath(QDir::cleanPath(url.path()));
return url;
}
@@ -56,7 +47,7 @@ class ShellTest
void ShellTest::initTestCase()
{
- qRegisterMetaType<KUrl>();
+ qRegisterMetaType<QUrl>();
KCmdLineArgs::setCwd( QDir::currentPath().toLocal8Bit() );
}
@@ -65,7 +56,7 @@ void ShellTest::testUrlArgs_data()
{
QTest::addColumn<QString>( "arg" );
QTest::addColumn<bool>( "exists" );
- QTest::addColumn<KUrl>( "resUrl" );
+ QTest::addColumn<QUrl>( "resUrl" );
// local files
QTest::newRow( "foo.pdf, exist" )
@@ -87,7 +78,7 @@ void ShellTest::testUrlArgs_data()
QTest::newRow( "#207461" )
<< "file:///tmp/file%20with%20spaces.pdf"
<< true
- << KUrl( "file:///tmp/file%20with%20spaces.pdf" );
+ << QUrl( "file:///tmp/file%20with%20spaces.pdf" );
// non-local files
QTest::newRow( "http://kde.org/foo.pdf" )
@@ -105,16 +96,16 @@ void ShellTest::testUrlArgs_data()
QTest::newRow( "#207461" )
<< "http://homepages.inf.ed.ac.uk/mef/file%20with%20spaces.pdf"
<< true
- << KUrl( "http://homepages.inf.ed.ac.uk/mef/file%20with%20spaces.pdf" );
+ << QUrl( "http://homepages.inf.ed.ac.uk/mef/file%20with%20spaces.pdf" );
}
void ShellTest::testUrlArgs()
{
QFETCH( QString, arg );
QFETCH( bool, exists );
- QFETCH( KUrl, resUrl );
+ QFETCH( QUrl, resUrl );
- KUrl url = ShellUtils::urlFromArg( arg, exists ? fileExist_always_Func : fileExist_never_Func );
+ QUrl url = ShellUtils::urlFromArg( arg, exists ? fileExist_always_Func : fileExist_never_Func );
QCOMPARE( url, resUrl );
}
diff --git a/autotests/translateannotationtest.cpp b/autotests/translateannotationtest.cpp
index 1a897f3..bb609d3 100644
--- a/autotests/translateannotationtest.cpp
+++ b/autotests/translateannotationtest.cpp
@@ -110,7 +110,7 @@ void TranslateAnnotationTest::init()
const QString testFile = KDESRCDIR "data/file1.pdf";
QMimeDatabase db;
const QMimeType mime = db.mimeTypeForFile( testFile );
- QCOMPARE( m_document->openDocument(testFile, KUrl(), mime), Okular::Document::OpenSuccess );
+ QCOMPARE( m_document->openDocument(testFile, QUrl(), mime), Okular::Document::OpenSuccess );
// Undo and Redo should be unavailable when docuemnt is first opened.
QVERIFY( !m_document->canUndo() );
diff --git a/core/audioplayer.cpp b/core/audioplayer.cpp
index 8ae2fd7..25f58ff 100644
--- a/core/audioplayer.cpp
+++ b/core/audioplayer.cpp
@@ -129,15 +129,15 @@ bool AudioPlayerPrivate::play( const SoundInfo& si )
{
int newid = newId();
m_mapper.setMapping( data->m_mediaobject, newid );
- KUrl newurl;
- if ( KUrl::isRelativeUrl( url ) )
+ QUrl newurl;
+ if ( QUrl::fromUserInput(url).isRelative() )
{
- newurl = m_currentDocument;
- newurl.setFileName( url );
+ newurl = m_currentDocument.adjusted(QUrl::RemoveFilename);
+ newurl.setPath(newurl.path() + url );
}
else
{
- newurl = url;
+ newurl = QUrl::fromLocalFile(url);
}
data->m_mediaobject->setCurrentSource( newurl );
m_playing.insert( newid, data );
diff --git a/core/audioplayer_p.h b/core/audioplayer_p.h
index 32fe4de..bc325f7 100644
--- a/core/audioplayer_p.h
+++ b/core/audioplayer_p.h
@@ -13,7 +13,7 @@
// qt/kde includes
#include <qhash.h>
#include <qsignalmapper.h>
-#include <kurl.h>
+#include <QUrl>
class QBuffer;
class PlayData;
@@ -41,7 +41,7 @@ public:
QHash< int, PlayData * > m_playing;
QSignalMapper m_mapper;
- KUrl m_currentDocument;
+ QUrl m_currentDocument;
AudioPlayer::State m_state;
};
diff --git a/core/bookmarkmanager.cpp b/core/bookmarkmanager.cpp
index ccfba8d..1d8b71f 100644
--- a/core/bookmarkmanager.cpp
+++ b/core/bookmarkmanager.cpp
@@ -15,10 +15,9 @@
#include <kbookmarkaction.h>
#include <kbookmarkmanager.h>
#include <kbookmarkmenu.h>
-#include <QtCore/QDebug>
+#include <QDebug>
#include <QGuiApplication>
-
-#include <kurl.h>
+#include <QUrl>
#include <QStandardPaths>
// local includes
@@ -112,24 +111,26 @@ class BookmarkManager::Private : public KBookmarkOwner
virtual bool enableOption(BookmarkOption option) const;
virtual void openBookmark( const KBookmark & bm, Qt::MouseButtons, Qt::KeyboardModifiers );
- QHash<KUrl, QString>::iterator bookmarkFind( const KUrl& url, bool doCreate, KBookmarkGroup *result = 0);
+ QHash<QUrl, QString>::iterator bookmarkFind( const QUrl& url, bool doCreate, KBookmarkGroup *result = 0);
// slots
void _o_changed( const QString & groupAddress, const QString & caller );
BookmarkManager * q;
- KUrl url;
+ QUrl url;
QHash<int,int> urlBookmarks;
DocumentPrivate * document;
QString file;
KBookmarkManager * manager;
- QHash<KUrl, QString> knownFiles;
+ QHash<QUrl, QString> knownFiles;
};
-static inline KUrl urlForGroup(const KBookmark &group)
+static inline QUrl urlForGroup(const KBookmark &group)
{
- if ( group.url().isValid() ) return group.url();
- else return KUrl( group.fullText() );
+ if ( group.url().isValid() )
+ return group.url();
+ else
+ return QUrl::fromUserInput( group.fullText() );
}
BookmarkManager::BookmarkManager( DocumentPrivate * document )
@@ -161,8 +162,7 @@ QUrl BookmarkManager::Private::currentUrl() const
QString BookmarkManager::Private::currentTitle() const
{
-#pragma message("KF5 porting: check if QUrl usage is right")
- return url.isLocalFile() ? url.toLocalFile() : url.prettyUrl();
+ return url.toDisplayString();
}
bool BookmarkManager::Private::enableOption(BookmarkOption option) const
@@ -183,9 +183,9 @@ void BookmarkManager::Private::_o_changed( const QString & groupAddress, const Q
if ( groupAddress.isEmpty() )
return;
- KUrl referurl;
+ QUrl referurl;
// first, try to find the bookmark group whom change notification was just received
- QHash<KUrl, QString>::iterator it = knownFiles.begin(), itEnd = knownFiles.end();
+ QHash<QUrl, QString>::iterator it = knownFiles.begin(), itEnd = knownFiles.end();
for ( ; it != itEnd; ++it )
{
if ( it.value() == groupAddress )
@@ -249,7 +249,7 @@ QList<QUrl> BookmarkManager::files() const
return ret;
}
-KBookmark::List BookmarkManager::bookmarks( const KUrl& url ) const
+KBookmark::List BookmarkManager::bookmarks(const QUrl &url ) const
{
KBookmark::List ret;
KBookmarkGroup group = d->manager->root();
@@ -313,7 +313,7 @@ KBookmark BookmarkManager::bookmark( const DocumentViewport &viewport ) const
return KBookmark();
KBookmarkGroup thebg;
- QHash<KUrl, QString>::iterator it = d->bookmarkFind( d->url, false, &thebg );
+ QHash<QUrl, QString>::iterator it = d->bookmarkFind( d->url, false, &thebg );
if ( it == d->knownFiles.end() )
return KBookmark();
@@ -338,9 +338,9 @@ void BookmarkManager::save() const
emit const_cast<BookmarkManager*>( this )->saved();
}
-QHash<KUrl, QString>::iterator BookmarkManager::Private::bookmarkFind( const KUrl& url, bool doCreate, KBookmarkGroup *result )
+QHash<QUrl, QString>::iterator BookmarkManager::Private::bookmarkFind( const QUrl& url, bool doCreate, KBookmarkGroup *result )
{
- QHash<KUrl, QString>::iterator it = knownFiles.find( url );
+ QHash<QUrl, QString>::iterator it = knownFiles.find( url );
if ( it == knownFiles.end() )
{
// if the url we want to add a new entry for is not in the hash of the
@@ -353,7 +353,7 @@ QHash<KUrl, QString>::iterator BookmarkManager::Private::bookmarkFind( const KUr
if ( bm.isSeparator() || !bm.isGroup() )
continue;
- KUrl tmpurl( urlForGroup( bm ) );
+ QUrl tmpurl( urlForGroup( bm ) );
if ( tmpurl == url )
{
// got it! place it the hash of known files
@@ -369,7 +369,7 @@ QHash<KUrl, QString>::iterator BookmarkManager::Private::bookmarkFind( const KUr
{
// folder not found :(
// then, in a single step create a new folder and add it in our cache :)
- QString purl = url.isLocalFile() ? url.toLocalFile() : url.prettyUrl();
+ QString purl = url.isLocalFile() ? url.toLocalFile() : url.toDisplayString();
KBookmarkGroup newbg = root.createNewFolder( purl );
newbg.setUrl( url );
it = knownFiles.insert( url, newbg.address() );
@@ -400,7 +400,7 @@ void BookmarkManager::addBookmark( const DocumentViewport &vp )
addBookmark( d->url, vp );
}
-bool BookmarkManager::addBookmark( const KUrl& referurl, const Okular::DocumentViewport& vp, const QString& title )
+bool BookmarkManager::addBookmark(const QUrl &referurl, const Okular::DocumentViewport& vp, const QString& title )
{
if ( !referurl.isValid() || !vp.isValid() )
return false;
@@ -409,7 +409,7 @@ bool BookmarkManager::addBookmark( const KUrl& referurl, const Okular::DocumentV
return false;
KBookmarkGroup thebg;
- QHash<KUrl, QString>::iterator it = d->bookmarkFind( referurl, true, &thebg );
+ QHash<QUrl, QString>::iterator it = d->bookmarkFind( referurl, true, &thebg );
Q_ASSERT( it != d->knownFiles.end() );
int count = 0; // Number of bookmarks in the current page
@@ -448,8 +448,8 @@ bool BookmarkManager::addBookmark( const KUrl& referurl, const Okular::DocumentV
else
newtitle = title;
- KUrl newurl = referurl;
- newurl.setHTMLRef( vp.toString() );
+ QUrl newurl = referurl;
+ newurl.setFragment(vp.toString(), QUrl::DecodedMode);
thebg.addBookmark( newtitle, newurl, QString() );
if ( referurl == d->document->m_url )
{
@@ -481,7 +481,7 @@ void BookmarkManager::removeBookmark( const DocumentViewport &vp )
void BookmarkManager::renameBookmark( KBookmark* bm, const QString& newName)
{
KBookmarkGroup thebg;
- QHash<KUrl, QString>::iterator it = d->bookmarkFind( d->url, false, &thebg );
+ QHash<QUrl, QString>::iterator it = d->bookmarkFind( d->url, false, &thebg );
Q_ASSERT ( it != d->knownFiles.end() );
if ( it == d->knownFiles.end() )
return;
@@ -490,13 +490,13 @@ void BookmarkManager::renameBookmark( KBookmark* bm, const QString& newName)
d->manager->emitChanged( thebg );
}
-void BookmarkManager::renameBookmark( const KUrl& referurl, const QString& newName )
+void BookmarkManager::renameBookmark(const QUrl &referurl, const QString& newName )
{
if ( !referurl.isValid() )
return;
KBookmarkGroup thebg;
- QHash<KUrl, QString>::iterator it = d->bookmarkFind( referurl, false, &thebg );
+ QHash<QUrl, QString>::iterator it = d->bookmarkFind( referurl, false, &thebg );
Q_ASSERT ( it != d->knownFiles.end() );
if ( it == d->knownFiles.end() )
return;
@@ -505,16 +505,16 @@ void BookmarkManager::renameBookmark( const KUrl& referurl, const QString& newNa
d->manager->emitChanged( thebg );
}
-QString BookmarkManager::titleForUrl( const KUrl& referurl ) const
+QString BookmarkManager::titleForUrl(const QUrl &referurl ) const
{
KBookmarkGroup thebg;
- QHash<KUrl, QString>::iterator it = d->bookmarkFind( referurl, false, &thebg );
+ QHash<QUrl, QString>::iterator it = d->bookmarkFind( referurl, false, &thebg );
Q_ASSERT( it != d->knownFiles.end() );
return thebg.fullText();
}
-int BookmarkManager::removeBookmark( const KUrl& referurl, const KBookmark& bm )
+int BookmarkManager::removeBookmark(const QUrl &referurl, const KBookmark& bm )
{
if ( !referurl.isValid() || bm.isNull() || bm.isGroup() || bm.isSeparator() )
return -1;
@@ -524,7 +524,7 @@ int BookmarkManager::removeBookmark( const KUrl& referurl, const KBookmark& bm )
return -1;
KBookmarkGroup thebg;
- QHash<KUrl, QString>::iterator it = d->bookmarkFind( referurl, false, &thebg );
+ QHash<QUrl, QString>::iterator it = d->bookmarkFind( referurl, false, &thebg );
if ( it == d->knownFiles.end() )
return -1;
@@ -540,13 +540,13 @@ int BookmarkManager::removeBookmark( const KUrl& referurl, const KBookmark& bm )
return vp.pageNumber;
}
-void BookmarkManager::removeBookmarks( const KUrl& referurl, const KBookmark::List& list )
+void BookmarkManager::removeBookmarks(const QUrl &referurl, const KBookmark::List& list )
{
if ( !referurl.isValid() || list.isEmpty() )
return;
KBookmarkGroup thebg;
- QHash<KUrl, QString>::iterator it = d->bookmarkFind( referurl, false, &thebg );
+ QHash<QUrl, QString>::iterator it = d->bookmarkFind( referurl, false, &thebg );
if ( it == d->knownFiles.end() )
return;
@@ -588,7 +588,7 @@ void BookmarkManager::removeBookmarks( const KUrl& referurl, const KBookmark::Li
d->manager->emitChanged( thebg );
}
-QList< QAction * > BookmarkManager::actionsForUrl( const KUrl& url ) const
+QList< QAction * > BookmarkManager::actionsForUrl(const QUrl &url ) const
{
QList< QAction * > ret;
KBookmarkGroup group = d->manager->root();
@@ -611,12 +611,12 @@ QList< QAction * > BookmarkManager::actionsForUrl( const KUrl& url ) const
return ret;
}
-void BookmarkManager::setUrl( const KUrl& url )
+void BookmarkManager::setUrl(const QUrl &url )
{
d->url = url;
d->urlBookmarks.clear();
KBookmarkGroup thebg;
- QHash<KUrl, QString>::iterator it = d->bookmarkFind( url, false, &thebg );
+ QHash<QUrl, QString>::iterator it = d->bookmarkFind( url, false, &thebg );
if ( it != d->knownFiles.end() )
{
for ( KBookmark bm = thebg.first(); !bm.isNull(); bm = thebg.next( bm ) )
@@ -636,7 +636,7 @@ void BookmarkManager::setUrl( const KUrl& url )
bool BookmarkManager::setPageBookmark( int page )
{
KBookmarkGroup thebg;
- QHash<KUrl, QString>::iterator it = d->bookmarkFind( d->url, true, &thebg );
+ QHash<QUrl, QString>::iterator it = d->bookmarkFind( d->url, true, &thebg );
Q_ASSERT( it != d->knownFiles.end() );
bool found = false;
@@ -656,8 +656,8 @@ bool BookmarkManager::setPageBookmark( int page )
d->urlBookmarks[ page ]++;
DocumentViewport vp;
vp.pageNumber = page;
- KUrl newurl = d->url;
- newurl.setHTMLRef( vp.toString() );
+ QUrl newurl = d->url;
+ newurl.setFragment(vp.toString(), QUrl::DecodedMode);
thebg.addBookmark( QString::fromLatin1( "#" ) + QString::number( vp.pageNumber + 1 ), newurl, QString() );
added = true;
d->manager->emitChanged( thebg );
@@ -668,7 +668,7 @@ bool BookmarkManager::setPageBookmark( int page )
bool BookmarkManager::removePageBookmark( int page )
{
KBookmarkGroup thebg;
- QHash<KUrl, QString>::iterator it = d->bookmarkFind( d->url, false, &thebg );
+ QHash<QUrl, QString>::iterator it = d->bookmarkFind( d->url, false, &thebg );
if ( it == d->knownFiles.end() )
return false;
diff --git a/core/bookmarkmanager.h b/core/bookmarkmanager.h
index ecd11cd..85d5fcd 100644
--- a/core/bookmarkmanager.h
+++ b/core/bookmarkmanager.h
@@ -13,7 +13,7 @@
#include <kbookmark.h>
#include "okularcore_export.h"
-#include <kurl.h>
+#include <QUrl>
class QAction;
@@ -44,7 +44,7 @@ class OKULARCORE_EXPORT BookmarkManager : public QObject
/**
* Returns the list of bookmarks for the specified @p url.
*/
- KBookmark::List bookmarks( const KUrl& url ) const;
+ KBookmark::List bookmarks( const QUrl& url ) const;
/**
* Returns the list of bookmarks for document
@@ -92,7 +92,7 @@ class OKULARCORE_EXPORT BookmarkManager : public QObject
*
* If no @p title is specified, then \em #n will be used.
*/
- bool addBookmark( const KUrl& referurl, const Okular::DocumentViewport& vp, const QString& title = QString() );
+ bool addBookmark( const QUrl& referurl, const Okular::DocumentViewport& vp, const QString& title = QString() );
/**
* Remove a bookmark for the given @p page.
@@ -108,7 +108,7 @@ class OKULARCORE_EXPORT BookmarkManager : public QObject
/**
* Removes the bookmark @p bm for the @p referurl specified.
*/
- int removeBookmark( const KUrl& referurl, const KBookmark& bm );
+ int removeBookmark( const QUrl& referurl, const KBookmark& bm );
/**
* Removes the bookmarks in @p list for the @p referurl specified.
@@ -117,7 +117,7 @@ class OKULARCORE_EXPORT BookmarkManager : public QObject
*
* @since 0.11 (KDE 4.5)
*/
- void removeBookmarks( const KUrl& referurl, const KBookmark::List& list );
+ void removeBookmarks( const QUrl& referurl, const KBookmark::List& list );
/**
* Returns the bookmark given bookmark of the document
@@ -130,13 +130,13 @@ class OKULARCORE_EXPORT BookmarkManager : public QObject
* the @p newName specified.
* @since 0.15 (KDE 4.9)
*/
- void renameBookmark( const KUrl& referurl, const QString& newName );
+ void renameBookmark( const QUrl& referurl, const QString& newName );
/**
* Returns title for the @p referurl
* @since 0.15 (KDE 4.9)
*/
- QString titleForUrl( const KUrl& referurl ) const;
+ QString titleForUrl( const QUrl& referurl ) const;
/**
* Returns whether the given @p page is bookmarked.
@@ -167,13 +167,13 @@ class OKULARCORE_EXPORT BookmarkManager : public QObject
* @note the actions will have no parents, so you have to delete them
* yourself
*/
- QList< QAction* > actionsForUrl( const KUrl& url ) const;
+ QList< QAction* > actionsForUrl( const QUrl& url ) const;
Q_SIGNALS:
/**
* The bookmark manager is requesting to open the specified @p url.
*/
- void openUrl( const KUrl& url );
+ void openUrl( const QUrl& url );
/**
* This signal is emitted whenever bookmarks have been saved.
@@ -185,7 +185,7 @@ class OKULARCORE_EXPORT BookmarkManager : public QObject
*
* @since 0.7 (KDE 4.1)
*/
- void bookmarksChanged( const KUrl& url );
+ void bookmarksChanged( const QUrl& url );
private:
class Private;
@@ -198,7 +198,7 @@ class OKULARCORE_EXPORT BookmarkManager : public QObject
BookmarkManager( DocumentPrivate * document );
- void setUrl( const KUrl& url );
+ void setUrl( const QUrl& url );
bool setPageBookmark( int page );
bool removePageBookmark( int page );
diff --git a/core/document.cpp b/core/document.cpp
index 7bbb60d..30ad087 100644
--- a/core/document.cpp
+++ b/core/document.cpp
@@ -54,6 +54,7 @@
#include <ktoolinvocation.h>
#include <kzip.h>
+#include <KIO/Global>
// local includes
#include "action.h"
@@ -639,8 +640,6 @@ void DocumentPrivate::loadDocumentInfo( QFile &infoFile )
if ( root.tagName() != "documentInfo" )
return;
- KUrl documentUrl( root.attribute( "url" ) );
-
// Parse the DOM tree
QDomNode topLevelNode = root.firstChild();
while ( topLevelNode.isElement() )
@@ -801,7 +800,7 @@ QString DocumentPrivate::giveAbsolutePath( const QString & fileName ) const
if ( !m_url.isValid() )
return QString();
- return m_url.upUrl().url() + fileName;
+ return KIO::upUrl(m_url).path() + fileName;
}
bool DocumentPrivate::openRelativeFile( const QString & fileName )
@@ -812,7 +811,7 @@ bool DocumentPrivate::openRelativeFile( const QString & fileName )
qCDebug(OkularCoreDebug).nospace() << "openDocument: '" << absFileName << "'";
- emit m_parent->openUrl( absFileName );
+ emit m_parent->openUrl( QUrl(absFileName) );
return true;
}
@@ -1234,7 +1233,7 @@ void DocumentPrivate::saveDocumentInfo() const
QString::fromLatin1( "xml" ), QString::fromLatin1( "version=\"1.0\" encoding=\"utf-8\"" ) );
doc.appendChild( xmlPi );
QDomElement root = doc.createElement( "documentInfo" );
- root.setAttribute( "url", m_url.pathOrUrl() );
+ root.setAttribute( "url", m_url.toDisplayString(QUrl::PreferLocalFile) );
doc.appendChild( root );
// 2.1. Save page attributes (bookmark state, annotations, ... ) to DOM
@@ -2245,7 +2244,7 @@ private:
const QMimeType &_mime;
};
-QString DocumentPrivate::docDataFileName(const KUrl &url, qint64 document_size)
+QString DocumentPrivate::docDataFileName(const QUrl &url, qint64 document_size)
{
QString fn = url.fileName();
fn = QString::number( document_size ) + '.' + fn + ".xml";
@@ -2267,13 +2266,13 @@ QString DocumentPrivate::docDataFileName(const KUrl &url, qint64 document_size)
-Document::OpenResult Document::openDocument( const QString & docFile, const KUrl& url, const QMimeType &_mime, const QString & password )
+Document::OpenResult Document::openDocument(const QString & docFile, const QUrl &url, const QMimeType &_mime, const QString & password )
{
QMimeDatabase db;
QMimeType mime = _mime;
QByteArray filedata;
qint64 document_size = -1;
- bool isstdin = url.fileName( KUrl::ObeyTrailingSlash ) == QLatin1String( "-" );
+ bool isstdin = url.fileName() == QLatin1String( "-" );
bool triedMimeFromFileContent = false;
if ( !isstdin )
{
@@ -2469,7 +2468,7 @@ Document::OpenResult Document::openDocument( const QString & docFile, const KUrl
d->m_nextDocumentDestination = QString();
}
- AudioPlayer::instance()->d->m_currentDocument = isstdin ? KUrl() : d->m_url;
+ AudioPlayer::instance()->d->m_currentDocument = isstdin ? QUrl() : d->m_url;
d->m_docSize = document_size;
const QStringList docScripts = d->m_generator->metaData( "DocumentScripts", "JavaScript" ).toStringList();
@@ -2579,7 +2578,7 @@ void Document::closeDocument()
}
d->m_generator = 0;
d->m_generatorName = QString();
- d->m_url = KUrl();
+ d->m_url = QUrl();
d->m_docFileName = QString();
d->m_xmlFileName = QString();
delete d->m_tempFile;
@@ -2636,7 +2635,7 @@ void Document::closeDocument()
d->m_documentInfo = DocumentInfo();
d->m_documentInfoAskedKeys.clear();
- AudioPlayer::instance()->d->m_currentDocument = KUrl();
+ AudioPlayer::instance()->d->m_currentDocument = QUrl();
d->m_undoStack->clear();
}
@@ -2758,7 +2757,7 @@ DocumentInfo Document::documentInfo( const QSet<DocumentInfo::Key> &keys ) const
if ( missingKeys.contains( DocumentInfo::FilePath ) )
{
- info.set( DocumentInfo::FilePath, currentDocument().prettyUrl() );
+ info.set( DocumentInfo::FilePath, currentDocument().toDisplayString() );
}
if ( d->m_docSize != -1 && missingKeys.contains( DocumentInfo::DocumentSize ) )
@@ -2879,7 +2878,7 @@ uint Document::pages() const
return d->m_pagesVector.size();
}
-KUrl Document::currentDocument() const
+QUrl Document::currentDocument() const
{
return d->m_url;
}
@@ -4024,7 +4023,7 @@ void Document::processSourceReference( const SourceReference * ref )
if ( !ref )
return;
- const KUrl url( d->giveAbsolutePath( ref->fileName() ) );
+ const QUrl url( d->giveAbsolutePath( ref->fileName() ) );
if ( !url.isLocalFile() )
{
qCDebug(OkularCoreDebug) << url.url() << "is not a local file.";
@@ -4364,7 +4363,7 @@ QByteArray Document::fontData(const FontInfo &font) const
return result;
}
-Document::OpenResult Document::openDocumentArchive( const QString & docFile, const KUrl & url, const QString & password )
+Document::OpenResult Document::openDocumentArchive( const QString & docFile, const QUrl & url, const QString & password )
{
QMimeDatabase db;
const QMimeType mime = db.mimeTypeForFile( docFile, QMimeDatabase::MatchExtension );
diff --git a/core/document.h b/core/document.h
index e2dc14b..8994c85 100644
--- a/core/document.h
+++ b/core/document.h
@@ -24,7 +24,7 @@
#include <kcomponentdata.h>
#include <QMimeType>
-#include <kurl.h>
+#include <QUrl>
class QPrintDialog;
class KBookmark;
@@ -215,7 +215,7 @@ class OKULARCORE_EXPORT Document : public QObject
* Opens the document.
* @since 0.20 (KDE 4.14)
*/
- OpenResult openDocument( const QString & docFile, const KUrl & url, const QMimeType &mime, const QString &password = QString() );
+ OpenResult openDocument( const QString & docFile, const QUrl & url, const QMimeType &mime, const QString &password = QString() );
/**
* Closes the document.
@@ -321,7 +321,7 @@ class OKULARCORE_EXPORT Document : public QObject
/**
* Returns the url of the currently opened document.
*/
- KUrl currentDocument() const;
+ QUrl currentDocument() const;
/**
* Returns whether the given @p action is allowed in the document.
@@ -798,7 +798,7 @@ class OKULARCORE_EXPORT Document : public QObject
*
* @since 0.20 (KDE 4.14)
*/
- OpenResult openDocumentArchive( const QString & docFile, const KUrl & url, const QString &password = QString() );
+ OpenResult openDocumentArchive( const QString & docFile, const QUrl & url, const QString &password = QString() );
/**
* Saves a document archive.
@@ -959,7 +959,7 @@ class OKULARCORE_EXPORT Document : public QObject
* This signal is emitted whenever an action requests an
* open url operation for the given document @p url.
*/
- void openUrl( const KUrl &url );
+ void openUrl( const QUrl &url );
/**
* This signal is emitted whenever an error occurred.
diff --git a/core/document_p.h b/core/document_p.h
index 52e041c..b1cb518 100644
--- a/core/document_p.h
+++ b/core/document_p.h
@@ -21,10 +21,10 @@
#include <QtCore/QMap>
#include <QtCore/QMutex>
#include <QtCore/QPointer>
+#include <QUrl>
#include <kcomponentdata.h>
#include <kservicetypetrader.h>
-#include <kurl.h>
// local includes
#include "fontinfo.h"
@@ -139,7 +139,7 @@ class DocumentPrivate
bool canModifyExternalAnnotations() const;
bool canRemoveExternalAnnotations() const;
void warnLimitedAnnotSupport();
- OKULARCORE_EXPORT static QString docDataFileName(const KUrl &url, qint64 document_size);
+ OKULARCORE_EXPORT static QString docDataFileName(const QUrl &url, qint64 document_size);
// Methods that implement functionality needed by undo commands
void performAddPageAnnotation( int page, Annotation *annotation );
@@ -199,7 +199,7 @@ class DocumentPrivate
// needed because for remote documents docFileName is a local file and
// we want the remote url when the document refers to relativeNames
- KUrl m_url;
+ QUrl m_url;
// cached stuff
QString m_docFileName;
diff --git a/core/script/kjs_document.cpp b/core/script/kjs_document.cpp
index 5c6a6ce..c036042 100644
--- a/core/script/kjs_document.cpp
+++ b/core/script/kjs_document.cpp
@@ -80,7 +80,7 @@ static KJSObject docGetPath( KJSContext *, void *object )
{
DocumentPrivate *doc = reinterpret_cast< DocumentPrivate* >( object );
- return KJSString( doc->m_url.pathOrUrl() );
+ return KJSString( doc->m_url.toDisplayString(QUrl::PreferLocalFile) );
}
// Document.URL
@@ -88,7 +88,7 @@ static KJSObject docGetURL( KJSContext *, void *object )
{
DocumentPrivate *doc = reinterpret_cast< DocumentPrivate* >( object );
- return KJSString( doc->m_url.prettyUrl() );
+ return KJSString( doc->m_url.toDisplayString() );
}
// Document.permStatusReady
diff --git a/core/script/kjs_util.cpp b/core/script/kjs_util.cpp
index 99d329b..10e2c27 100644
--- a/core/script/kjs_util.cpp
+++ b/core/script/kjs_util.cpp
@@ -14,7 +14,7 @@
#include <kjs/kjsprototype.h>
#include <kjs/kjsarguments.h>
-#include <kurl.h>
+#include <QUrl>
using namespace Okular;
@@ -28,30 +28,30 @@ static KJSObject crackURL( KJSContext *context, void *,
return context->throwException( "Missing URL argument" );
}
QString cURL = arguments.at( 0 ).toString( context );
- KUrl url( cURL );
+ QUrl url(QUrl::fromLocalFile(cURL) );
if ( !url.isValid() )
{
return context->throwException( "Invalid URL" );
}
- if ( url.protocol() != QLatin1String( "file" )
- || url.protocol() != QLatin1String( "http" )
- || url.protocol() != QLatin1String( "https" ) )
+ if ( url.scheme() != QLatin1String( "file" )
+ || url.scheme() != QLatin1String( "http" )
+ || url.scheme() != QLatin1String( "https" ) )
{
- return context->throwException( "Protocol not valid: '" + url.protocol() + '\'' );
+ return context->throwException( "Protocol not valid: '" + url.scheme() + '\'' );
}
KJSObject obj;
- obj.setProperty( context, "cScheme", url.protocol() );
- if ( url.hasUser() )
- obj.setProperty( context, "cUser", url.user() );
- if ( url.hasPass() )
+ obj.setProperty( context, "cScheme", url.scheme() );
+ if ( !url.userName().isEmpty() )
+ obj.setProperty( context, "cUser", url.userName() );
+ if ( !url.password().isEmpty() )
obj.setProperty( context, "cPassword", url.password() );
obj.setProperty( context, "cHost", url.host() );
obj.setProperty( context, "nPort", url.port( 80 ) );
// TODO cPath (Optional) The path portion of the URL.
// TODO cParameters (Optional) The parameter string portion of the URL.
- if ( url.hasRef() )
- obj.setProperty( context, "cFragments", url.ref() );
+ if ( url.hasFragment() )
+ obj.setProperty( context, "cFragments", url.fragment(QUrl::FullyDecoded) );
return obj;
}
diff --git a/generators/chm/generator_chm.cpp b/generators/chm/generator_chm.cpp
index fec8c82..ed58c67 100644
--- a/generators/chm/generator_chm.cpp
+++ b/generators/chm/generator_chm.cpp
@@ -19,7 +19,7 @@
#include <khtml_part.h>
#include <khtmlview.h>
#include <KLocalizedString>
-#include <kurl.h>
+#include <QUrl>
#include <dom/html_misc.h>
#include <dom/dom_node.h>
#include <dom/dom_html.h>
@@ -49,15 +49,15 @@ OKULAR_EXPORT_PLUGIN( CHMGenerator, createAboutData() )
static QString absolutePath( const QString &baseUrl, const QString &path )
{
QString absPath;
- if ( path.at( 0 ) == QLatin1Char( '/' ) )
+ if ( path.startsWith(QLatin1Char( '/' )) )
{
// already absolute
absPath = path;
}
else
{
- KUrl url = QUrl::fromLocalFile( baseUrl );
- url.setFileName( path );
+ QUrl url = QUrl::fromLocalFile( baseUrl ).adjusted(QUrl::RemoveFilename);
+ url.setPath( url.path() + path );
absPath = url.toLocalFile();
}
return absPath;
@@ -178,10 +178,10 @@ bool CHMGenerator::doCloseDocument()
void CHMGenerator::preparePageForSyncOperation( int zoom , const QString & url)
{
- KUrl pAddress= QString("ms-its:" + m_fileName + "::" + url);
+ QString pAddress= QString("ms-its:" + m_fileName + "::" + url);
m_chmUrl = url;
m_syncGen->setZoomFactor(zoom);
- m_syncGen->openUrl(pAddress);
+ m_syncGen->openUrl(QUrl(pAddress));
m_syncGen->view()->layout();
QEventLoop loop;
@@ -273,13 +273,13 @@ void CHMGenerator::generatePixmap( Okular::PixmapRequest * request )
, static_cast<double>(requestHeight)/static_cast<double>(request->page()->height())
) ) * 100;
- KUrl pAddress= QString("ms-its:" + m_fileName + "::" + url);
+ QString pAddress= QString("ms-its:" + m_fileName + "::" + url);
m_chmUrl = url;
m_syncGen->setZoomFactor(zoom);
m_syncGen->view()->resize(requestWidth,requestHeight);
m_request=request;
// will emit openURL without problems
- m_syncGen->openUrl ( pAddress );
+ m_syncGen->openUrl ( QUrl(pAddress) );
}
diff --git a/generators/chm/kio-msits/msits.cpp b/generators/chm/kio-msits/msits.cpp
index 7536503..8d22c40 100644
--- a/generators/chm/kio-msits/msits.cpp
+++ b/generators/chm/kio-msits/msits.cpp
@@ -19,8 +19,8 @@
#include <sys/stat.h>
#include <kapplication.h>
-#include <QtCore/QDebug>
-#include <kurl.h>
+#include <QDebug>
+#include <QUrl>
#include <QMimeType>
#include <QMimeDatabase>
@@ -36,7 +36,7 @@ using namespace KIO;
extern "C"
{
- int KDE_EXPORT kdemain( int argc, char **argv )
+ int Q_DECL_EXPORT kdemain( int argc, char **argv )
{
kDebug() << "*** kio_msits Init";
@@ -78,7 +78,7 @@ static bool isDirectory ( const QString & filename )
}
-void ProtocolMSITS::get( const KUrl& url )
+void ProtocolMSITS::get( const QUrl& url )
{
QString htmdata, fileName;
chmUnitInfo ui;
@@ -133,7 +133,7 @@ void ProtocolMSITS::get( const KUrl& url )
}
-bool ProtocolMSITS::parseLoadAndLookup ( const KUrl& url, QString& abspath )
+bool ProtocolMSITS::parseLoadAndLookup ( const QUrl& url, QString& abspath )
{
kDebug() << "ProtocolMSITS::parseLoadAndLookup (const KUrl&) " << url.path();
@@ -220,7 +220,7 @@ static void app_file(UDSEntry& e, const QString & name, size_t size)
app_entry(e, KIO::UDSEntry::UDS_SIZE, size);
}
-void ProtocolMSITS::stat (const KUrl & url)
+void ProtocolMSITS::stat (const QUrl &url)
{
QString fileName;
chmUnitInfo ui;
@@ -258,7 +258,7 @@ static int chmlib_enumerator (struct chmFile *, struct chmUnitInfo *ui, void *co
}
-void ProtocolMSITS::listDir (const KUrl & url)
+void ProtocolMSITS::listDir (const QUrl & url)
{
QString filepath;
diff --git a/generators/chm/kio-msits/msits.h b/generators/chm/kio-msits/msits.h
index 4d147cf..f4b16e9 100644
--- a/generators/chm/kio-msits/msits.h
+++ b/generators/chm/kio-msits/msits.h
@@ -23,7 +23,7 @@
#include <kio/slavebase.h>
-#include <kurl.h>
+#include <QUrl>
#include <qbytearray.h>
#include <qstring.h>
@@ -37,16 +37,16 @@ public:
ProtocolMSITS ( const QByteArray&, const QByteArray& );
virtual ~ProtocolMSITS();
- virtual void get ( const KUrl& );
- virtual void listDir (const KUrl & url);
- virtual void stat (const KUrl & url);
+ virtual void get (const QUrl & );
+ virtual void listDir (const QUrl & url);
+ virtual void stat (const QUrl & url);
private:
// This function does next thing:
// - parses the URL to get a file name and URL inside the file;
// - loads a new CHM file, if needed;
// - returns the parsed URL inside the file;
- bool parseLoadAndLookup ( const KUrl&, QString& abspath );
+ bool parseLoadAndLookup (const QUrl &, QString& abspath );
// Resolve an object inside a CHM file
inline bool ResolveObject (const QString& fileName, chmUnitInfo *ui)
diff --git a/generators/dvi/dviRenderer.cpp b/generators/dvi/dviRenderer.cpp
index 20c3903..dfa6f4d 100644
--- a/generators/dvi/dviRenderer.cpp
+++ b/generators/dvi/dviRenderer.cpp
@@ -430,7 +430,7 @@ bool dviRenderer::isValidFile(const QString& filename) const
return true;
}
-bool dviRenderer::setFile(const QString &fname, const KUrl &base)
+bool dviRenderer::setFile(const QString &fname, const QUrl &base)
{
#ifdef DEBUG_DVIRENDERER
qCDebug(OkularDviDebug) << "dviRenderer::setFile( fname='" << fname << "' )"; //, ref='" << ref << "', sourceMarker=" << sourceMarker << " )";
diff --git a/generators/dvi/dviRenderer.h b/generators/dvi/dviRenderer.h
index 36623c2..e2e33a8 100644
--- a/generators/dvi/dviRenderer.h
+++ b/generators/dvi/dviRenderer.h
@@ -21,7 +21,7 @@
#include "prebookmark.h"
#include <QExplicitlySharedDataPointer>
-#include <kurl.h>
+#include <QUrl>
#include <QProgressDialog>
#include <QHash>
#include <QPolygon>
@@ -95,7 +95,7 @@ public:
dviRenderer(bool useFontHinting);
virtual ~dviRenderer();
- virtual bool setFile(const QString &fname, const KUrl &base);
+ virtual bool setFile(const QString &fname, const QUrl &base);
dvifile* dviFile;
@@ -185,7 +185,7 @@ private:
/** URL to the DVI file
This field is initialized by the setFile() method. See the
explanation there. */
- KUrl baseURL;
+ QUrl baseURL;
/** This method parses a color specification of type "gray 0.5", "rgb
0.5 0.7 1.0", "hsb ...", "cmyk .." or "PineGreen". See the source
diff --git a/generators/dvi/generator_dvi.cpp b/generators/dvi/generator_dvi.cpp
index 2a4e86d..fe0217e 100644
--- a/generators/dvi/generator_dvi.cpp
+++ b/generators/dvi/generator_dvi.cpp
@@ -74,7 +74,7 @@ DviGenerator::DviGenerator( QObject *parent, const QVariantList &args ) : Okular
bool DviGenerator::loadDocument( const QString & fileName, QVector< Okular::Page * > &pagesVector )
{
//qCDebug(OkularDviDebug) << "file:" << fileName;
- KUrl base( fileName );
+ QUrl base( QUrl::fromLocalFile(fileName) );
(void)userMutex();
diff --git a/generators/dvi/psgs.cpp b/generators/dvi/psgs.cpp
index 0b7d637..5081a82 100644
--- a/generators/dvi/psgs.cpp
+++ b/generators/dvi/psgs.cpp
@@ -19,7 +19,7 @@
#include <KLocalizedString>
#include <kprocess.h>
#include <qtemporaryfile.h>
-#include <kurl.h>
+#include <QUrl>
#include <QtCore/qloggingcategory.h>
#include <QDir>
@@ -332,7 +332,7 @@ void ghostscript_interface::graphics(const PageNumber& page, double dpi, long ma
}
-QString ghostscript_interface::locateEPSfile(const QString &filename, const KUrl &base)
+QString ghostscript_interface::locateEPSfile(const QString &filename, const QUrl &base)
{
// If the base URL indicates that the DVI file is local, try to find
// the graphics file in the directory where the DVI file resides
diff --git a/generators/dvi/psgs.h b/generators/dvi/psgs.h
index 63393d3..8b53a4a 100644
--- a/generators/dvi/psgs.h
+++ b/generators/dvi/psgs.h
@@ -16,7 +16,7 @@
#include <QHash>
#include <QObject>
-class KUrl;
+class QUrl;
class PageNumber;
class QPainter;
@@ -76,7 +76,7 @@ public:
returned. Otherwise, the method returns the first argument. TODO:
use the DVI file's baseURL, once this is implemented.
*/
- static QString locateEPSfile(const QString &filename, const KUrl &base);
+ static QString locateEPSfile(const QString &filename, const QUrl &base);
private:
void gs_generate_graphics_file(const PageNumber& page, const QString& filename, long magnification);
diff --git a/generators/epub/epubdocument.cpp b/generators/epub/epubdocument.cpp
index 719fcdf..3b0ef56 100644
--- a/generators/epub/epubdocument.cpp
+++ b/generators/epub/epubdocument.cpp
@@ -18,9 +18,9 @@ using namespace Epub;
namespace {
-QString resourceUrl(const KUrl &baseUrl, const QString &u)
+QString resourceUrl(const QUrl &baseUrl, const QString &u)
{
- KUrl newUrl(KUrl(baseUrl.directory(KUrl::AppendTrailingSlash)), u);
+ QUrl newUrl(baseUrl.adjusted(QUrl::RemoveFilename).path() + '/' + u);
QString newDir = newUrl.toLocalFile();
newDir.remove(0, 1);
return newDir;
diff --git a/generators/epub/epubdocument.h b/generators/epub/epubdocument.h
index 88a4d0c..1873607 100644
--- a/generators/epub/epubdocument.h
+++ b/generators/epub/epubdocument.h
@@ -14,7 +14,7 @@
#include <QUrl>
#include <QVariant>
#include <QImage>
-#include <kurl.h>
+#include <QUrl>
#include <epub.h>
#include <QtCore/qloggingcategory.h>
@@ -39,7 +39,7 @@ namespace Epub {
void checkCSS(QString &css);
struct epub *mEpub;
- KUrl mCurrentSubDocument;
+ QUrl mCurrentSubDocument;
int padding;
diff --git a/generators/kimgio/tests/kimgiotest.cpp b/generators/kimgio/tests/kimgiotest.cpp
index 826c0f6..f819724 100644
--- a/generators/kimgio/tests/kimgiotest.cpp
+++ b/generators/kimgio/tests/kimgiotest.cpp
@@ -70,7 +70,7 @@ void KIMGIOTest::testExifOrientation()
m_document->addObserver( dummyDocumentObserver );
// Load image
- m_document->openDocument( imgPath, KUrl(), mime );
+ m_document->openDocument( imgPath, QUrl(), mime );
m_document->setRotation( 0 ); // Test the default rotation
QCOMPARE( m_document->pages(), 1u );
diff --git a/generators/xps/generator_xps.cpp b/generators/xps/generator_xps.cpp
index 79220a7..2f8fe5d 100644
--- a/generators/xps/generator_xps.cpp
+++ b/generators/xps/generator_xps.cpp
@@ -27,7 +27,7 @@
#include <KAboutData>
#include <kglobal.h>
#include <KLocalizedString>
-#include <kurl.h>
+#include <QUrl>
#include <QBuffer>
#include <QImageReader>
#include <QMutex>
@@ -488,13 +488,11 @@ static QString entryPath( const KZipFileEntry* entry )
static QString absolutePath( const QString &path, const QString &location )
{
QString retPath;
- if ( location.at( 0 ) == QLatin1Char( '/' ) ) {
+ if ( location.startsWith(QLatin1Char( '/' ) )) {
// already absolute
retPath = location;
} else {
- KUrl url = QUrl::fromLocalFile( path );
- url.setFileName( location );
- retPath = url.toLocalFile();
+ retPath = QUrl::fromLocalFile(path + '/' + location).toDisplayString(QUrl::PreferLocalFile);
}
// it seems paths & file names can also be percent-encoded
// (XPS won't ever finish surprising me)
diff --git a/kdocumentviewer.h b/kdocumentviewer.h
index d5acf64..dc23cbf 100644
--- a/kdocumentviewer.h
+++ b/kdocumentviewer.h
@@ -12,7 +12,7 @@
#include <QtCore/QStringList>
-class KUrl;
+class QUrl;
/**
* @short Abstract interface for a document viewer
@@ -27,7 +27,7 @@ class KDocumentViewer
/**
* Open the document at the specified @p url at page @p page.
*/
- virtual bool openDocument( const KUrl& url, uint page ) = 0;
+ virtual bool openDocument( const QUrl& url, uint page ) = 0;
/**
* Change to @p page the currently shown page.
diff --git a/part.cpp b/part.cpp
index d68dd0e..c41d273 100644
--- a/part.cpp
+++ b/part.cpp
@@ -341,8 +341,8 @@ m_cliPresentation(false), m_cliPrint(false), m_embedMode(detectEmbedMode(parentW
connect( m_document, SIGNAL(linkGoToPage()), this, SLOT(slotGoToPage()) );
connect( m_document, SIGNAL(linkPresentation()), this, SLOT(slotShowPresentation()) );
connect( m_document, SIGNAL(linkEndPresentation()), this, SLOT(slotHidePresentation()) );
- connect( m_document, SIGNAL(openUrl(KUrl)), this, SLOT(openUrlFromDocument(KUrl)) );
- connect( m_document->bookmarkManager(), SIGNAL(openUrl(KUrl)), this, SLOT(openUrlFromBookmarks(KUrl)) );
+ connect( m_document, SIGNAL(openUrl(QUrl)), this, SLOT(openUrlFromDocument(QUrl)) );
+ connect( m_document->bookmarkManager(), SIGNAL(openUrl(QUrl)), this, SLOT(openUrlFromBookmarks(QUrl)) );
connect( m_document, SIGNAL(close()), this, SLOT(close()) );
if ( parent && parent->metaObject()->indexOfSlot( QMetaObject::normalizedSignature( "slotQuit()" ).constData() ) != -1 )
@@ -869,7 +869,7 @@ Part::~Part()
}
-bool Part::openDocument(const KUrl& url, uint page)
+bool Part::openDocument(const QUrl& url, uint page)
{
Okular::DocumentViewport vp( page - 1 );
vp.rePos.enabled = true;
@@ -894,7 +894,7 @@ QStringList Part::supportedMimeTypes() const
}
-KUrl Part::realUrl() const
+QUrl Part::realUrl() const
{
if ( !m_realUrl.isEmpty() )
return m_realUrl;
@@ -962,7 +962,7 @@ void Part::slotHandleActivatedSourceReference(const QString& absFileName, int li
}
}
-void Part::openUrlFromDocument(const KUrl &url)
+void Part::openUrlFromDocument(const QUrl &url)
{
if ( m_embedMode == PrintPreviewMode )
return;
@@ -970,20 +970,20 @@ void Part::openUrlFromDocument(const KUrl &url)
if (KIO::NetAccess::exists(url, KIO::NetAccess::SourceSide, widget()))
{
m_bExtension->openUrlNotify();
- m_bExtension->setLocationBarUrl(url.prettyUrl());
+ m_bExtension->setLocationBarUrl(url.toDisplayString());
openUrl(url);
} else {
- KMessageBox::error( widget(), i18n("Could not open '%1'. File does not exist", url.pathOrUrl() ) );
+ KMessageBox::error( widget(), i18n("Could not open '%1'. File does not exist", url.toDisplayString() ) );
}
}
-void Part::openUrlFromBookmarks(const KUrl &_url)
+void Part::openUrlFromBookmarks(const QUrl &_url)
{
- KUrl url = _url;
- Okular::DocumentViewport vp( _url.htmlRef() );
+ QUrl url = _url;
+ Okular::DocumentViewport vp( _url.fragment(QUrl::FullyDecoded) );
if ( vp.isValid() )
m_document->setNextDocumentViewport( vp );
- url.setHTMLRef( QString() );
+ url.setFragment( QString() );
if ( m_document->currentDocument() == url )
{
if ( vp.isValid() )
@@ -1022,7 +1022,7 @@ void Part::slotJobFinished(KJob *job)
{
if ( job->error() == KIO::ERR_USER_CANCELED )
{
- m_pageView->displayMessage( i18n( "The loading of %1 has been canceled.", realUrl().pathOrUrl() ) );
+ m_pageView->displayMessage( i18n( "The loading of %1 has been canceled.", realUrl().toDisplayString(QUrl::PreferLocalFile) ) );
}
}
@@ -1047,7 +1047,8 @@ void Part::setWindowTitleFromDocument()
{
// If 'DocumentTitle' should be used, check if the document has one. If
// either case is false, use the file name.
- QString title = Okular::Settings::displayDocumentNameOrPath() == Okular::Settings::EnumDisplayDocumentNameOrPath::Path ? realUrl().pathOrUrl() : realUrl().fileName();
+ QString title = Okular::Settings::displayDocumentNameOrPath() == Okular::Settings::EnumDisplayDocumentNameOrPath::Path ? realUrl().toDisplayString(QUrl::PreferLocalFile)
+ : realUrl().fileName();
if ( Okular::Settings::displayDocumentTitle() )
{
@@ -1125,7 +1126,7 @@ void Part::goToPage(uint i)
void Part::openDocument( const QString &doc )
{
- openUrl( KUrl( doc ) );
+ openUrl( QUrl::fromUserInput( doc ) );
}
@@ -1143,7 +1144,7 @@ uint Part::currentPage()
QString Part::currentDocument()
{
- return m_document->currentDocument().pathOrUrl();
+ return m_document->currentDocument().toDisplayString(QUrl::PreferLocalFile);
}
@@ -1164,7 +1165,7 @@ bool Part::slotImportPSFile()
return false;
}
- KUrl url = KFileDialog::getOpenUrl( KUrl(), "application/postscript", this->widget() );
+ QUrl url = KFileDialog::getOpenUrl( QUrl(), "application/postscript", this->widget() );
if ( url.isLocalFile() )
{
QTemporaryFile tf(QDir::tempPath() + QLatin1String("/okular_XXXXXX.pdf"));
@@ -1425,7 +1426,7 @@ bool Part::openFile()
// if can't open document, update windows so they display blank contents
m_pageView->viewport()->update();
m_thumbnailList->update();
- setUrl( KUrl() );
+ setUrl( QUrl() );
return false;
}
@@ -1477,10 +1478,10 @@ bool Part::openUrl(const QUrl &_url)
if ( !closeUrl() )
return false;
- KUrl url( _url );
- if ( url.hasHTMLRef() )
+ QUrl url( _url );
+ if ( url.hasFragment() )
{
- const QString dest = url.htmlRef();
+ const QString dest = url.fragment(QUrl::FullyDecoded);
bool ok = true;
const int page = dest.toInt( &ok );
if ( ok )
@@ -1496,7 +1497,7 @@ bool Part::openUrl(const QUrl &_url)
{
m_document->setNextDocumentDestination( dest );
}
- url.setHTMLRef( QString() );
+ url.setFragment( QString() );
}
// this calls in sequence the 'closeUrl' and 'openFile' methods
@@ -1511,7 +1512,7 @@ bool Part::openUrl(const QUrl &_url)
else
{
resetStartArguments();
- KMessageBox::error( widget(), i18n("Could not open %1", url.pathOrUrl() ) );
+ KMessageBox::error( widget(), i18n("Could not open %1", url.toDisplayString() ) );
}
return openOk;
@@ -1581,7 +1582,7 @@ bool Part::closeUrl(bool promptToSave)
if ( m_showPresentation ) m_showPresentation->setEnabled( false );
emit setWindowCaption("");
emit enablePrintAction(false);
- m_realUrl = KUrl();
+ m_realUrl = QUrl();
if ( url().isLocalFile() )
{
m_watcher->removeFile( localFilePath() );
@@ -1607,7 +1608,7 @@ bool Part::closeUrl(bool promptToSave)
m_keeper->close();
#endif
bool r = KParts::ReadWritePart::closeUrl();
- setUrl(KUrl());
+ setUrl(QUrl());
return r;
}
@@ -1759,7 +1760,7 @@ void Part::slotDoFileDirty()
if ( m_viewportDirty.pageNumber >= (int) m_document->pages() )
m_viewportDirty.pageNumber = (int) m_document->pages() - 1;
m_document->setViewport( m_viewportDirty );
- m_oldUrl = KUrl();
+ m_oldUrl = QUrl();
m_viewportDirty.pageNumber = -1;
m_document->setRotation( m_dirtyPageRotation );
if ( m_sidebar->currentIndex() != m_dirtyToolboxIndex && m_sidebar->isItemEnabled( m_dirtyToolboxIndex )
@@ -2194,7 +2195,7 @@ void Part::slotSaveFileAs()
}
}
- KUrl saveUrl = KFileDialog::getSaveUrl( url(),
+ QUrl saveUrl = KFileDialog::getSaveUrl( url(),
QString(), widget(), QString(),
KFileDialog::ConfirmOverwrite );
if ( !saveUrl.isValid() || saveUrl.isEmpty() )
@@ -2253,14 +2254,14 @@ void Part::slotSaveCopyAs()
if ( m_embedMode == PrintPreviewMode )
return;
- KUrl saveUrl = KFileDialog::getSaveUrl( KUrl("kfiledialog:///okular/" + url().fileName()),
+ QUrl saveUrl = KFileDialog::getSaveUrl( QUrl("kfiledialog:///okular/" + url().fileName()),
QString(), widget(), QString(),
KFileDialog::ConfirmOverwrite );
if ( saveUrl.isValid() && !saveUrl.isEmpty() )
{
// make use of the already downloaded (in case of remote URLs) file,
// no point in downloading that again
- KUrl srcUrl = QUrl::fromLocalFile( localFilePath() );
+ QUrl srcUrl = QUrl::fromLocalFile( localFilePath() );
QTemporaryFile * tempFile = 0;
// duh, our local file disappeared...
if ( !QFile::exists( localFilePath() ) )
@@ -2287,7 +2288,7 @@ void Part::slotSaveCopyAs()
KIO::Job *copyJob = KIO::file_copy( srcUrl, saveUrl, -1, KIO::Overwrite );
if ( !KIO::NetAccess::synchronousRun( copyJob, widget() ) )
- KMessageBox::information( widget(), i18n("File could not be saved in '%1'. Try to save it to another location.", saveUrl.prettyUrl() ) );
+ KMessageBox::information( widget(), i18n("File could not be saved in '%1'. Try to save it to another location.", saveUrl.toDisplayString() ) );
delete tempFile;
}
@@ -2730,7 +2731,7 @@ void Part::doPrint(QPrinter &printer)
void Part::restoreDocument(const KConfigGroup &group)
{
- KUrl url ( group.readPathEntry( "URL", QString() ) );
+ QUrl url ( group.readPathEntry( "URL", QString() ) );
if ( url.isValid() )
{
QString viewport = group.readEntry( "Viewport" );
@@ -2918,7 +2919,7 @@ void Part::rebuildBookmarkMenu( bool unplugActions )
qDeleteAll( m_bookmarkActions );
m_bookmarkActions.clear();
}
- KUrl u = m_document->currentDocument();
+ QUrl u = m_document->currentDocument();
if ( u.isValid() )
{
m_bookmarkActions = m_document->bookmarkManager()->actionsForUrl( u );
@@ -2945,7 +2946,7 @@ void Part::rebuildBookmarkMenu( bool unplugActions )
{
Q_ASSERT(dynamic_cast<QMenu*>(container));
disconnect(container, 0, this, 0);
- connect(container, SIGNAL(aboutToShowContextMenu(QMenu*,QAction*,QMenu*)), this, SLOT(slotAboutToShowContextMenu(QMenu*,QAction*,QMenu*)));
+ connect(container, SIGNAL(aboutToShowContextMenu(QMenu*,QAction*,QMenu*)), this, SLOT(slotAboutToShowContextMenu(QMenu*,QAction*,QMenu*))); // kf5 FIXME
containerFound = true;
}
}
diff --git a/part.h b/part.h
index 9afe219..3abdbb5 100644
--- a/part.h
+++ b/part.h
@@ -23,7 +23,7 @@
#include <qlist.h>
#include <qpointer.h>
#include <qprocess.h>
-#include <kurl.h>
+#include <QUrl>
#include <kio/job.h>
#include "core/observer.h"
#include "core/document.h"
@@ -39,7 +39,6 @@ class QWidget;
class QPrinter;
class QMenu;
-class KUrl;
class KConfigDialog;
class KConfigGroup;
class KDirWatch;
@@ -121,11 +120,11 @@ class OKULARPART_EXPORT Part : public KParts::ReadWritePart, public Okular::Docu
void notifyViewportChanged( bool smoothMove );
void notifyPageChanged( int page, int flags );
- bool openDocument(const KUrl& url, uint page);
+ bool openDocument(const QUrl &url, uint page);
void startPresentation();
QStringList supportedMimeTypes() const;
- KUrl realUrl() const;
+ QUrl realUrl() const;
void showSourceLocation(const QString& fileName, int line, int column, bool showGraphically = true);
void clearLastShownSourceLocation();
@@ -177,8 +176,8 @@ class OKULARPART_EXPORT Part : public KParts::ReadWritePart, public Okular::Docu
protected slots:
// connected to actions
- void openUrlFromDocument(const KUrl &url);
- void openUrlFromBookmarks(const KUrl &url);
+ void openUrlFromDocument(const QUrl &url);
+ void openUrlFromBookmarks(const QUrl &url);
void handleDroppedUrls( const QList<QUrl>& urls );
void slotGoToPage();
void slotHistoryBack();
@@ -282,7 +281,7 @@ class OKULARPART_EXPORT Part : public KParts::ReadWritePart, public Okular::Docu
// document watcher (and reloader) variables
KDirWatch *m_watcher;
QTimer *m_dirtyHandler;
- KUrl m_oldUrl;
+ QUrl m_oldUrl;
Okular::DocumentViewport m_viewportDirty;
bool m_wasPresentationOpen;
int m_dirtyToolboxIndex;
@@ -341,7 +340,7 @@ class OKULARPART_EXPORT Part : public KParts::ReadWritePart, public Okular::Docu
EmbedMode m_embedMode;
- KUrl m_realUrl;
+ QUrl m_realUrl;
KXMLGUIClient *m_generatorGuiClient;
FileKeeper *m_keeper;
diff --git a/shell/shell.cpp b/shell/shell.cpp
index 5473e25..7c8c164 100644
--- a/shell/shell.cpp
+++ b/shell/shell.cpp
@@ -97,8 +97,8 @@ Shell::Shell( const QString &serializedOptions )
m_tabWidget->setMovable( true );
connect( m_tabWidget, SIGNAL(currentChanged(int)), SLOT(setActiveTab(int)) );
connect( m_tabWidget, SIGNAL(tabCloseRequested(int)), SLOT(closeTab(int)) );
- connect( m_tabWidget, SIGNAL(testCanDecode(const QDragMoveEvent*,bool&)), SLOT(testTabDrop(const QDragMoveEvent*,bool&)) );
- connect( m_tabWidget, SIGNAL(receivedDropEvent(QDropEvent*)), SLOT(handleTabDrop(QDropEvent*)) );
+ connect( m_tabWidget, SIGNAL(testCanDecode(const QDragMoveEvent*,bool&)), SLOT(testTabDrop(const QDragMoveEvent*,bool&)) ); // kf5 FIXME DnD
+ connect( m_tabWidget, SIGNAL(receivedDropEvent(QDropEvent*)), SLOT(handleTabDrop(QDropEvent*)) ); // kf5 FIXME DnD
connect( m_tabWidget->tabBar(), SIGNAL(tabMoved(int,int)), SLOT(moveTabData(int,int)) );
setCentralWidget( m_tabWidget );
diff --git a/ui/bookmarklist.cpp b/ui/bookmarklist.cpp
index 0950bd5..a627e65 100644
--- a/ui/bookmarklist.cpp
+++ b/ui/bookmarklist.cpp
@@ -40,8 +40,8 @@ class BookmarkItem : public QTreeWidgetItem
{
setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable );
m_url = m_bookmark.url();
- m_viewport = Okular::DocumentViewport( m_url.htmlRef() );
- m_url.setHTMLRef( QString() );
+ m_viewport = Okular::DocumentViewport( m_url.fragment(QUrl::FullyDecoded) );
+ m_url.setFragment( QString() );
setText( 0, m_bookmark.fullText() );
if ( m_viewport.isValid() )
setData( 0, PageItemDelegate::PageRole, QString::number( m_viewport.pageNumber + 1 ) );
@@ -77,14 +77,14 @@ class BookmarkItem : public QTreeWidgetItem
return m_viewport;
}
- KUrl url() const
+ QUrl url() const
{
return m_url;
}
private:
KBookmark m_bookmark;
- KUrl m_url;
+ QUrl m_url;
Okular::DocumentViewport m_viewport;
};
@@ -92,7 +92,7 @@ class BookmarkItem : public QTreeWidgetItem
class FileItem : public QTreeWidgetItem
{
public:
- FileItem( const KUrl & url, QTreeWidget *tree, Okular::Document *document )
+ FileItem( const QUrl & url, QTreeWidget *tree, Okular::Document *document )
: QTreeWidgetItem( tree, FileItemType )
{
setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable );
@@ -156,7 +156,7 @@ BookmarkList::BookmarkList( Okular::Document *document, QWidget *parent )
m_showBoomarkOnlyAction->setCheckable( true );
connect(m_showBoomarkOnlyAction, &QAction::toggled, this, &BookmarkList::slotFilterBookmarks);
- connect( m_document->bookmarkManager(), SIGNAL(bookmarksChanged(KUrl)), this, SLOT(slotBookmarksChanged(KUrl)) );
+ connect( m_document->bookmarkManager(), SIGNAL(bookmarksChanged(QUrl)), this, SLOT(slotBookmarksChanged(QUrl)) );
rebuildTree( m_showBoomarkOnlyAction->isChecked() );
}
@@ -222,7 +222,7 @@ void BookmarkList::slotChanged( QTreeWidgetItem * item )
FileItem* fItem = dynamic_cast<FileItem*>( item );
if ( fItem )
{
- const KUrl url = fItem->data( 0, UrlRole ).value< KUrl >();
+ const QUrl url = fItem->data( 0, UrlRole ).value< QUrl >();
m_document->bookmarkManager()->renameBookmark( url, fItem->text( 0 ) );
m_document->bookmarkManager()->save();
}
@@ -266,7 +266,7 @@ void BookmarkList::contextMenuForFileItem( const QPoint& p, FileItem* fItem )
if ( !fItem )
return;
- const KUrl itemurl = fItem->data( 0, UrlRole ).value< KUrl >();
+ const QUrl itemurl = fItem->data( 0, UrlRole ).value< QUrl >();
const bool thisdoc = itemurl == m_document->currentDocument();
QMenu menu( this );
@@ -281,7 +281,7 @@ void BookmarkList::contextMenuForFileItem( const QPoint& p, FileItem* fItem )
if ( res == open )
{
- Okular::GotoAction action( itemurl.pathOrUrl(), Okular::DocumentViewport() );
+ Okular::GotoAction action( itemurl.toDisplayString(QUrl::PreferLocalFile), Okular::DocumentViewport() );
m_document->processAction( &action );
}
else if ( res == editbm )
@@ -297,7 +297,7 @@ void BookmarkList::contextMenuForFileItem( const QPoint& p, FileItem* fItem )
}
}
-void BookmarkList::slotBookmarksChanged( const KUrl& url )
+void BookmarkList::slotBookmarksChanged(const QUrl &url )
{
// special case here, as m_currentDocumentItem could represent
// the invisible root item
@@ -315,9 +315,9 @@ void BookmarkList::slotBookmarksChanged( const KUrl& url )
selectiveUrlUpdate( url, item );
}
-QList<QTreeWidgetItem*> createItems( const KUrl& baseurl, const KBookmark::List& bmlist )
+QList<QTreeWidgetItem*> createItems( const QUrl& baseurl, const KBookmark::List& bmlist )
{
- (void)baseurl;
+ Q_UNUSED(baseurl)
QList<QTreeWidgetItem*> ret;
foreach ( const KBookmark& bm, bmlist )
{
@@ -344,7 +344,7 @@ void BookmarkList::rebuildTree( bool filter )
{
if ( m_document->isOpened() )
{
- foreach ( const KUrl& url, urls )
+ foreach ( const QUrl& url, urls )
{
if ( url == m_document->currentDocument() )
{
@@ -358,7 +358,7 @@ void BookmarkList::rebuildTree( bool filter )
else
{
QTreeWidgetItem * currenturlitem = 0;
- foreach ( const KUrl& url, urls )
+ foreach ( const QUrl& url, urls )
{
QList<QTreeWidgetItem*> subitems = createItems( url, m_document->bookmarkManager()->bookmarks( url ) );
if ( !subitems.isEmpty() )
@@ -393,12 +393,12 @@ void BookmarkList::goTo( BookmarkItem * item )
}
else
{
- Okular::GotoAction action( item->url().pathOrUrl(), item->viewport() );
+ Okular::GotoAction action( item->url().toDisplayString(QUrl::PreferLocalFile), item->viewport() );
m_document->processAction( &action );
}
}
-void BookmarkList::selectiveUrlUpdate( const KUrl& url, QTreeWidgetItem*& item )
+void BookmarkList::selectiveUrlUpdate( const QUrl& url, QTreeWidgetItem*& item )
{
disconnect(m_tree, &QTreeWidget::itemChanged, this, &BookmarkList::slotChanged);
@@ -453,13 +453,13 @@ void BookmarkList::selectiveUrlUpdate( const KUrl& url, QTreeWidgetItem*& item )
connect(m_tree, &QTreeWidget::itemChanged, this, &BookmarkList::slotChanged);
}
-QTreeWidgetItem* BookmarkList::itemForUrl( const KUrl& url ) const
+QTreeWidgetItem* BookmarkList::itemForUrl( const QUrl& url ) const
{
const int count = m_tree->topLevelItemCount();
for ( int i = 0; i < count; ++i )
{
QTreeWidgetItem *item = m_tree->topLevelItem( i );
- const KUrl itemurl = item->data( 0, UrlRole ).value< KUrl >();
+ const QUrl itemurl = item->data( 0, UrlRole ).value< QUrl >();
if ( itemurl.isValid() && itemurl == url )
{
return item;
diff --git a/ui/bookmarklist.h b/ui/bookmarklist.h
index 03acd43..988fff0 100644
--- a/ui/bookmarklist.h
+++ b/ui/bookmarklist.h
@@ -18,7 +18,7 @@ class QAction;
class QTreeWidget;
class QTreeWidgetItem;
class KTreeWidgetSearchLine;
-class KUrl;
+class QUrl;
class BookmarkItem;
class FileItem;
@@ -42,13 +42,13 @@ class BookmarkList : public QWidget, public Okular::DocumentObserver
void slotExecuted( QTreeWidgetItem * item );
void slotChanged( QTreeWidgetItem * item );
void slotContextMenu( const QPoint& p );
- void slotBookmarksChanged( const KUrl& url );
+ void slotBookmarksChanged( const QUrl& url );
private:
void rebuildTree( bool filter );
void goTo( BookmarkItem * item );
- void selectiveUrlUpdate( const KUrl& url, QTreeWidgetItem*& item );
- QTreeWidgetItem* itemForUrl( const KUrl& url ) const;
+ void selectiveUrlUpdate( const QUrl& url, QTreeWidgetItem*& item );
+ QTreeWidgetItem* itemForUrl(const QUrl &url ) const;
void contextMenuForBookmarkItem( const QPoint& p, BookmarkItem* bmItem );
void contextMenuForFileItem( const QPoint& p, FileItem* fItem );
diff --git a/ui/formwidgets.cpp b/ui/formwidgets.cpp
index 911c23f..49e1e48 100644
--- a/ui/formwidgets.cpp
+++ b/ui/formwidgets.cpp
@@ -18,7 +18,7 @@
#include <KLocalizedString>
#include <kstandardaction.h>
#include <qaction.h>
-#include <kurl.h>
+#include <QUrl>
// local includes
#include "core/form.h"
@@ -624,7 +624,7 @@ FileEdit::FileEdit( Okular::FormFieldText * text, QWidget * parent )
{
setMode( KFile::File | KFile::ExistingOnly | KFile::LocalOnly );
setFilter( i18n( "*|All Files" ) );
- setUrl( KUrl( m_form->text() ) );
+ setUrl( QUrl::fromUserInput( m_form->text() ) );
lineEdit()->setAlignment( m_form->textAlignment() );
setEnabled( !m_form->isReadOnly() );
diff --git a/ui/presentationwidget.cpp b/ui/presentationwidget.cpp
index 275b0e3..350fdd7 100644
--- a/ui/presentationwidget.cpp
+++ b/ui/presentationwidget.cpp
@@ -39,7 +39,6 @@
#include <kiconloader.h>
#include <kmessagebox.h>
#include <kselectaction.h>
-#include <kurl.h>
#include <kdialog.h>
#include <Solid/PowerManagement>
diff --git a/ui/propertiesdialog.cpp b/ui/propertiesdialog.cpp
index 060500d..2c7ea77 100644
--- a/ui/propertiesdialog.cpp
+++ b/ui/propertiesdialog.cpp
@@ -29,7 +29,6 @@
#include <KLocalizedString>
#include <kmessagebox.h>
#include <ksqueezedtextlabel.h>
-#include <kurl.h>
#include <QMimeDatabase>
// local includes
diff --git a/ui/thumbnaillist.cpp b/ui/thumbnaillist.cpp
index 0dd2f2e..0552881 100644
--- a/ui/thumbnaillist.cpp
+++ b/ui/thumbnaillist.cpp
@@ -18,7 +18,6 @@
#include <qscrollbar.h>
#include <qsizepolicy.h>
#include <KLocalizedString>
-#include <kurl.h>
#include <qaction.h>
#include <kdialog.h>
#include <kiconloader.h>
diff --git a/ui/videowidget.cpp b/ui/videowidget.cpp
index dea9fb1..70cf69d 100644
--- a/ui/videowidget.cpp
+++ b/ui/videowidget.cpp
@@ -106,15 +106,15 @@ void VideoWidget::Private::load()
loaded = true;
QString url = movie->url();
- KUrl newurl;
+ QUrl newurl;
if ( QDir::isRelativePath( url ) )
{
- newurl = document->currentDocument();
- newurl.setFileName( url );
+ newurl = document->currentDocument().adjusted(QUrl::RemoveFilename);
+ newurl.setPath( newurl.path() + url );
}
else
{
- newurl = url;
+ newurl = QUrl::fromLocalFile(url);
}
if ( newurl.isLocalFile() )
player->load( newurl.toLocalFile() );
@@ -144,15 +144,15 @@ void VideoWidget::Private::setupPlayPauseAction( PlayPauseMode mode )
void VideoWidget::Private::takeSnapshot()
{
const QString url = movie->url();
- KUrl newurl;
+ QUrl newurl;
if ( QDir::isRelativePath( url ) )
{
- newurl = document->currentDocument();
- newurl.setFileName( url );
+ newurl = document->currentDocument().adjusted(QUrl::RemoveFilename);
+ newurl.setPath( newurl.path() + url );
}
else
{
- newurl = url;
+ newurl = QUrl::fromLocalFile(url);
}
SnapshotTaker *taker = 0;