Commit fd6a3548 authored by Lukáš Tinkl's avatar Lukáš Tinkl

port KUrl -> QUrl

parent ec8c2900
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 )
......
......@@ -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)
......
......@@ -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);
......
......@@ -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()
......
......@@ -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()
......
......@@ -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
......
......@@ -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() );
......
......@@ -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() );
......
......@@ -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());
......
......@@ -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() );
......
......@@ -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 */
......
......@@ -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());
......
......@@ -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 );
}
......
......@@ -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() );
......
......@@ -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 );
......
......@@ -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;
};
......
This diff is collapsed.
......@@ -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 );
......
......@@ -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 );
......
......@@ -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.
......
......@@ -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;
......
......@@ -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
......
......@@ -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;
}
......
......@@ -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 ).adjuste