Commit 7049feb8 authored by Pino Toscano's avatar Pino Toscano
Browse files

port to the new kdelibs api; mainly ktrader usage and URL -> Url

svn path=/branches/work/kde4/playground/graphics/okular/; revision=543576
parent 64867d5b
......@@ -23,12 +23,11 @@
#include <klocale.h>
#include <kfinddialog.h>
#include <kmessagebox.h>
#include <kmimetypetrader.h>
#include <ktoolinvocation.h>
#include <kuserprofile.h>
#include <krun.h>
#include <kstandarddirs.h>
#include <klibloader.h>
#include <ktrader.h>
#include <qcombobox.h>
#include <qlabel.h>
......@@ -155,8 +154,7 @@ bool KPDFDocument::openDocument( const QString & docFile, const KUrl& url, const
// 0. load Generator
// request only valid non-disabled plugins suitable for the mimetype
QString constraint("([X-KDE-Priority] > 0) and (exist Library)") ;
KTrader::OfferList offers=KTrader::self()->query(mime->name(),"oKular/Generator",constraint, "[X-KDE-Priority]");
KService::List offers = KMimeTypeTrader::self()->query(mime->name(),"oKular/Generator",constraint);
if (offers.isEmpty())
{
kWarning() << "No plugin for '" << mime->name() << "' mimetype." << endl;
......@@ -1130,12 +1128,12 @@ void KPDFDocument::processLink( const KPDFLink * link )
}
}
KService::Ptr ptr = KServiceTypeProfile::preferredService( mime->name(), "Application" );
KService::Ptr ptr = KMimeTypeTrader::self()->preferredService( mime->name(), "Application" );
if ( ptr )
{
KUrl::List lst;
lst.append( fileName );
KRun::run( *ptr, lst );
KRun::run( *ptr, lst, 0 );
}
else
KMessageBox::information( 0, i18n( "No application found for opening file of mimetype %1.", mime->name() ) );
......@@ -1202,11 +1200,11 @@ void KPDFDocument::processLink( const KPDFLink * link )
return;
}
// get service for web browsing
KService::Ptr ptr = KServiceTypeProfile::preferredService("text/html", "Application");
KService::Ptr ptr = KMimeTypeTrader::self()->preferredService("text/html", "Application");
KUrl::List lst;
// append 'url' parameter to the service and run it
lst.append( url );
KRun::run( *ptr, lst );
KRun::run( *ptr, lst, 0 );
}
} break;
......@@ -1521,7 +1519,7 @@ QString KPDFDocument::giveAbsolutePath( const QString & fileName )
if ( !d->url.isValid() )
return QString::null;
return d->url.upURL().url() + fileName;
return d->url.upUrl().url() + fileName;
}
bool KPDFDocument::openRelativeFile( const QString & fileName )
......
......@@ -91,14 +91,14 @@ void ProtocolMSITS::get( const KUrl& url )
if ( isDirectory (fileName) )
{
error( KIO::ERR_IS_DIRECTORY, url.prettyURL() );
error( KIO::ERR_IS_DIRECTORY, url.prettyUrl() );
return;
}
if ( !ResolveObject ( fileName, &ui) )
{
kDebug() << "kio_msits::get: could not resolve filename " << fileName << endl;
error( KIO::ERR_DOES_NOT_EXIST, url.prettyURL() );
error( KIO::ERR_DOES_NOT_EXIST, url.prettyUrl() );
return;
}
......@@ -107,7 +107,7 @@ void ProtocolMSITS::get( const KUrl& url )
if ( RetrieveObject (&ui, (unsigned char*) buf.data(), 0, ui.length) == 0 )
{
kDebug() << "kio_msits::get: could not retrieve filename " << fileName << endl;
error( KIO::ERR_NO_CONTENT, url.prettyURL() );
error( KIO::ERR_NO_CONTENT, url.prettyUrl() );
return;
}
......@@ -131,7 +131,7 @@ bool ProtocolMSITS::parseLoadAndLookup ( const KUrl& url, QString& abspath )
if ( pos == -1 )
{
error( KIO::ERR_MALFORMED_URL, url.prettyURL() );
error( KIO::ERR_MALFORMED_URL, url.prettyUrl() );
return false;
}
......@@ -142,7 +142,7 @@ bool ProtocolMSITS::parseLoadAndLookup ( const KUrl& url, QString& abspath )
if ( filename.isEmpty() )
{
error( KIO::ERR_MALFORMED_URL, url.prettyURL() );
error( KIO::ERR_MALFORMED_URL, url.prettyUrl() );
return false;
}
......@@ -157,7 +157,7 @@ bool ProtocolMSITS::parseLoadAndLookup ( const KUrl& url, QString& abspath )
if ( (tmpchm = chm_open ( QFile::encodeName (filename))) == 0 )
{
error( KIO::ERR_COULD_NOT_READ, url.prettyURL() );
error( KIO::ERR_COULD_NOT_READ, url.prettyUrl() );
return false;
}
......@@ -218,7 +218,7 @@ void ProtocolMSITS::stat (const KUrl & url)
if ( !ResolveObject ( fileName, &ui ) )
{
error( KIO::ERR_DOES_NOT_EXIST, url.prettyURL() );
error( KIO::ERR_DOES_NOT_EXIST, url.prettyUrl() );
return;
}
......
......@@ -42,6 +42,7 @@
#include <kfiledialog.h>
#include <kfind.h>
#include <kmessagebox.h>
#include <kmimetypetrader.h>
#include <kfinddialog.h>
#include <knuminput.h>
#include <kiconloader.h>
......@@ -49,8 +50,8 @@
#include <kmenu.h>
#include <kxmlguiclient.h>
#include <kxmlguifactory.h>
#include <ktrader.h>
#include <kprocess.h>
#include <kservicetypetrader.h>
#include <kstandarddirs.h>
#include <ktempfile.h>
#include <ktoggleaction.h>
......@@ -249,7 +250,7 @@ Part::Part(QWidget *parentWidget,
prefs->setText( i18n( "Configure oKular..." ) ); // TODO: use "Configure PDF Viewer..." when used as part (like in konq
QString constraint("([X-KDE-Priority] > 0) and (exist Library) and ([X-KDE-oKularHasInternalSettings])") ;
KTrader::OfferList gens=KTrader::self()->query("oKular/Generator",constraint);
KService::List gens = KServiceTypeTrader::self()->query("oKular/Generator",constraint);
if (gens.count() > 0)
{
KAction * genPrefs = KStdAction::preferences( this, SLOT( slotGeneratorPreferences() ), ac, "generator_prefs" );
......@@ -307,7 +308,7 @@ Part::Part(QWidget *parentWidget,
slotNewConfig();
// [SPEECH] check for KTTSD presence and usability
KTrader::OfferList offers = KTrader::self()->query("DCOP/Text-to-Speech", "Name == 'KTTSD'");
KService::List offers = KServiceTypeTrader::self()->query("DCOP/Text-to-Speech", "Name == 'KTTSD'");
KpdfSettings::setUseKTTSD( (offers.count() > 0) );
KpdfSettings::writeConfig();
......@@ -330,7 +331,7 @@ Part::~Part()
void Part::openURLFromDocument(const KUrl &url)
{
m_bExtension->openURLNotify();
m_bExtension->setLocationBarURL(url.prettyURL());
m_bExtension->setLocationBarURL(url.prettyUrl());
openURL(url);
}
......@@ -338,9 +339,9 @@ void Part::supportedMimetypes()
{
m_supportedMimeTypes.clear();
QString constraint("([X-KDE-Priority] > 0) and (exist Library) ") ;
KTrader::OfferList offers=KTrader::self()->query("oKular/Generator",QString::null,constraint, QString::null);
KTrader::OfferList::ConstIterator iterator = offers.begin();
KTrader::OfferList::ConstIterator end = offers.end();
KService::List offers = KServiceTypeTrader::self()->query("oKular/Generator",constraint);
KService::List::ConstIterator iterator = offers.begin();
KService::List::ConstIterator end = offers.end();
QStringList::Iterator mimeType;
for (; iterator != end; ++iterator)
......@@ -366,7 +367,7 @@ void Part::setMimeTypes(KIO::Job *job)
void Part::fillGenerators()
{
QString constraint("([X-KDE-Priority] > 0) and (exist Library) and ([X-KDE-oKularHasInternalSettings])") ;
KTrader::OfferList offers=KTrader::self()->query("oKular/Generator",constraint);
KService::List offers = KServiceTypeTrader::self()->query("oKular/Generator", constraint);
QString propName;
int count=offers.count();
if (count > 0)
......@@ -566,7 +567,7 @@ bool Part::openURL(const KUrl &url)
if ( openOk )
m_viewportDirty = 0;
else
KMessageBox::error( widget(), i18n( "Could not open %1", url.prettyURL() ) );
KMessageBox::error( widget(), i18n( "Could not open %1", url.prettyUrl() ) );
emit enablePrintAction(openOk);
return openOk;
}
......@@ -824,7 +825,7 @@ void Part::slotSaveFileAs()
}
if ( !KIO::NetAccess::file_copy( url(), saveURL, -1, true ) )
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.prettyUrl() ) );
}
}
......
......@@ -36,9 +36,9 @@
#include <kio/netaccess.h>
#include <kmainwindowiface.h>
#include <krecentfilesaction.h>
#include <kservicetypetrader.h>
#include <ktoggleaction.h>
#include <ktogglefullscreenaction.h>
#include <ktrader.h>
#include <ktempfile.h>
#include <kfilterbase.h>
#include <kfilterdev.h>
......@@ -199,7 +199,7 @@ void Shell::readProperties(KConfig* config)
QStringList* Shell::fileFormats()
{
QString constraint("([X-KDE-Priority] > 0) and (exist Library) ") ;
KTrader::OfferList offers=KTrader::self()->query("oKular/Generator",QString::null,constraint, QString::null);
KService::List offers = KServiceTypeTrader::self()->query("oKular/Generator",constraint);
QStringList supportedMimeTypes;
QStringList * supportedPattern;
......@@ -210,8 +210,8 @@ QStringList* Shell::fileFormats()
bool bzip2Available = (KFilterBase::findFilterByMimeType( "application/x-bzip2" ) != 0L);
supportedPattern = new QStringList;
KTrader::OfferList::ConstIterator iterator = offers.begin();
KTrader::OfferList::ConstIterator end = offers.end();
KService::List::ConstIterator iterator = offers.begin();
KService::List::ConstIterator end = offers.end();
QStringList::Iterator mimeType;
QString tmp;
QStringList mimeTypes,pattern,extensions;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment