summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleix Pol <aleixpol@kde.org>2016-01-30 19:00:25 (GMT)
committerAleix Pol <aleixpol@kde.org>2016-01-30 19:00:25 (GMT)
commita704fbce94b6949c3a583ca8f28c63cb86638966 (patch)
treedcb6b0a8c942664f929d3b35cedebe8103a08ac7
parentcbf47d1bb8540a3e2007ff2dacdb04bd91c97714 (diff)
Fix porting QUrl issues
Reviewed by Albert Astals
-rw-r--r--core/document.cpp39
-rw-r--r--core/document_p.h2
-rw-r--r--shell/shell.cpp8
3 files changed, 24 insertions, 25 deletions
diff --git a/core/document.cpp b/core/document.cpp
index 4010f17..0bb8775 100644
--- a/core/document.cpp
+++ b/core/document.cpp
@@ -791,26 +791,26 @@ void DocumentPrivate::saveViewsInfo( View *view, QDomElement &e ) const
}
}
-QString DocumentPrivate::giveAbsolutePath( const QString & fileName ) const
+QUrl DocumentPrivate::giveAbsoluteUrl( const QString & fileName ) const
{
if ( !QDir::isRelativePath( fileName ) )
- return fileName;
+ return QUrl::fromLocalFile(fileName);
if ( !m_url.isValid() )
- return QString();
+ return QUrl();
- return KIO::upUrl(m_url).path() + fileName;
+ return QUrl(KIO::upUrl(m_url).toString() + fileName);
}
bool DocumentPrivate::openRelativeFile( const QString & fileName )
{
- QString absFileName = giveAbsolutePath( fileName );
- if ( absFileName.isEmpty() )
+ QUrl url = giveAbsoluteUrl( fileName );
+ if ( url.isEmpty() )
return false;
- qCDebug(OkularCoreDebug).nospace() << "openDocument: '" << absFileName << "'";
+ qCDebug(OkularCoreDebug).nospace() << "openRelativeFile: '" << url << "'";
- emit m_parent->openUrl( QUrl(absFileName) );
+ emit m_parent->openUrl( url );
return true;
}
@@ -3882,8 +3882,8 @@ void Document::processAction( const Action * action )
case Action::Execute: {
const ExecuteAction * exe = static_cast< const ExecuteAction * >( action );
- QString fileName = exe->fileName();
- if ( fileName.endsWith( QLatin1String(".pdf") ) || fileName.endsWith( QLatin1String(".PDF") ) )
+ const QString fileName = exe->fileName();
+ if ( fileName.endsWith( QLatin1String(".pdf"), Qt::CaseInsensitive ) )
{
d->openRelativeFile( fileName );
return;
@@ -3891,20 +3891,19 @@ void Document::processAction( const Action * action )
// Albert: the only pdf i have that has that kind of link don't define
// an application and use the fileName as the file to open
- fileName = d->giveAbsolutePath( fileName );
+ QUrl url = d->giveAbsoluteUrl( fileName );
QMimeDatabase db;
- QMimeType mime = db.mimeTypeForFile( fileName );
+ QMimeType mime = db.mimeTypeForUrl( url );
// Check executables
-#pragma message("KF5 check if QUrl::fromUserInput is right here")
- if ( KRun::isExecutableFile( QUrl::fromUserInput(fileName), mime.name() ) )
+ if ( KRun::isExecutableFile( url, mime.name() ) )
{
// Don't have any pdf that uses this code path, just a guess on how it should work
if ( !exe->parameters().isEmpty() )
{
- fileName = d->giveAbsolutePath( exe->parameters() );
- mime = db.mimeTypeForFile( fileName );
- #pragma message("KF5 check QUrl usage")
- if ( KRun::isExecutableFile( QUrl(fileName), mime.name() ) )
+ url = d->giveAbsoluteUrl( exe->parameters() );
+ mime = db.mimeTypeForUrl( url );
+
+ if ( KRun::isExecutableFile( url, mime.name() ) )
{
// this case is a link pointing to an executable with a parameter
// that also is an executable, possibly a hand-crafted pdf
@@ -3925,7 +3924,7 @@ void Document::processAction( const Action * action )
if ( ptr )
{
QList<QUrl> lst;
- lst.append( QUrl::fromLocalFile(fileName) );
+ lst.append( url );
KRun::runService( *ptr, lst, 0 );
}
else
@@ -4047,7 +4046,7 @@ void Document::processSourceReference( const SourceReference * ref )
if ( !ref )
return;
- const QUrl url = QUrl::fromLocalFile( d->giveAbsolutePath( ref->fileName() ) );
+ const QUrl url = d->giveAbsoluteUrl( ref->fileName() );
if ( !url.isLocalFile() )
{
qCDebug(OkularCoreDebug) << url.url() << "is not a local file.";
diff --git a/core/document_p.h b/core/document_p.h
index 36e030b..ef4dda6 100644
--- a/core/document_p.h
+++ b/core/document_p.h
@@ -119,7 +119,7 @@ class DocumentPrivate
void loadDocumentInfo( QFile &infoFile );
void loadViewsInfo( View *view, const QDomElement &e );
void saveViewsInfo( View *view, QDomElement &e ) const;
- QString giveAbsolutePath( const QString & fileName ) const;
+ QUrl giveAbsoluteUrl( const QString & fileName ) const;
bool openRelativeFile( const QString & fileName );
Generator * loadGeneratorLibrary( const KPluginMetaData& service );
void loadAllGeneratorLibraries();
diff --git a/shell/shell.cpp b/shell/shell.cpp
index e75a32e..c97054a 100644
--- a/shell/shell.cpp
+++ b/shell/shell.cpp
@@ -412,12 +412,12 @@ void Shell::fileOpen()
m_fileformatsscanned = true;
}
- QString startDir;
+ QUrl startDir;
const KParts::ReadWritePart* const curPart = m_tabs[activeTab].part;
if ( curPart->url().isLocalFile() )
- startDir = curPart->url().toLocalFile();
-#pragma message("KF5 check QUrl usage")
- KFileDialog dlg( QUrl(startDir), QString(), this );
+ startDir = curPart->url();
+
+ KFileDialog dlg( startDir, QString(), this );
dlg.setOperationMode( KFileDialog::Opening );
// A directory may be a document. E.g. comicbook generator.