Commit e28dbc6c authored by Frederik Gladhorn's avatar Frederik Gladhorn

Port to QMime

compressedMimeFor now already does the inheritance check, so another
check was removed.
parent 33f6862a
......@@ -56,7 +56,7 @@ void DocumentItem::setPath(const QString &path)
{
//TODO: remote urls
//TODO: password
m_document->openDocument(path, KUrl(path), KMimeType::findByUrl(KUrl(path)));
m_document->openDocument(path, KUrl(path), db.mimeTypeForUrl(KUrl(path)));
m_tocModel->fill(m_document->documentSynopsis());
m_tocModel->setCurrentViewport(m_document->viewport());
......
......@@ -16,7 +16,7 @@
#include "ui_chooseenginewidget.h"
ChooseEngineDialog::ChooseEngineDialog( const QStringList &generators, const KMimeType::Ptr &mime, QWidget * parent )
ChooseEngineDialog::ChooseEngineDialog( const QStringList &generators, const QMimeType &mime, QWidget * parent )
: KDialog( parent )
{
setCaption( i18n( "Backend Selection" ) );
......@@ -32,7 +32,7 @@ ChooseEngineDialog::ChooseEngineDialog( const QStringList &generators, const KMi
m_widget->description->setText(
i18n( "<qt>More than one backend found for the MIME type:<br />"
"<b>%1</b> (%2).<br /><br />"
"Please select which one to use:</qt>", mime->comment(), mime->name() ) );
"Please select which one to use:</qt>", mime.comment(), mime.name() ) );
}
ChooseEngineDialog::~ChooseEngineDialog()
......
......@@ -13,14 +13,15 @@
#include <QtCore/QStringList>
#include <kdialog.h>
#include <kmimetype.h>
#include <QMimeType>
#include <QMimeDatabase>
class Ui_ChooseEngineWidget;
class ChooseEngineDialog : public KDialog
{
public:
ChooseEngineDialog( const QStringList &generators, const KMimeType::Ptr &mime, QWidget * parent = 0 );
ChooseEngineDialog( const QStringList &generators, const QMimeType &mime, QWidget * parent = 0 );
~ChooseEngineDialog();
int selectedGenerator() const;
......
......@@ -883,7 +883,7 @@ void DocumentPrivate::cacheExportFormats()
const ExportFormat::List formats = m_generator->exportFormats();
for ( int i = 0; i < formats.count(); ++i )
{
if ( formats.at( i ).mimeType()->name() == QLatin1String( "text/plain" ) )
if ( formats.at( i ).mimeType().name() == QLatin1String( "text/plain" ) )
m_exportToText = formats.at( i );
else
m_exportFormats.append( formats.at( i ) );
......@@ -2100,10 +2100,10 @@ Document::~Document()
class kMimeTypeMoreThan {
public:
kMimeTypeMoreThan( const KMimeType::Ptr &mime ) : _mime( mime ) {}
kMimeTypeMoreThan( const QMimeType &mime ) : _mime( mime ) {}
bool operator()( const KService::Ptr &s1, const KService::Ptr &s2 )
{
const QString mimeName = _mime->name();
const QString mimeName = _mime.name();
if (s1->mimeTypes().contains( mimeName ) && !s2->mimeTypes().contains( mimeName ))
return true;
else if (s2->mimeTypes().contains( mimeName ) && !s1->mimeTypes().contains( mimeName ))
......@@ -2112,7 +2112,7 @@ public:
}
private:
const KMimeType::Ptr &_mime;
const QMimeType &_mime;
};
QString DocumentPrivate::docDataFileName(const KUrl &url, qint64 document_size)
......@@ -2135,16 +2135,19 @@ QString DocumentPrivate::docDataFileName(const KUrl &url, qint64 document_size)
return newokularfile;
}
Document::OpenResult Document::openDocument( const QString & docFile, const KUrl& url, const KMimeType::Ptr &_mime, const QString & password )
Document::OpenResult Document::openDocument( const QString & docFile, const KUrl& url, const QMimeType &_mime, const QString & password )
{
KMimeType::Ptr mime = _mime;
QMimeDatabase db;
QMimeType mime = _mime;
QByteArray filedata;
qint64 document_size = -1;
bool isstdin = url.fileName( KUrl::ObeyTrailingSlash ) == QLatin1String( "-" );
bool triedMimeFromFileContent = false;
if ( !isstdin )
{
if ( mime->allMimeTypes().count() <= 0 )
if ( !mime.isValid() )
return OpenError;
// docFile is always local so we can use QFileInfo on it
......@@ -2168,8 +2171,8 @@ Document::OpenResult Document::openDocument( const QString & docFile, const KUrl
QFile qstdin;
qstdin.open( stdin, QIODevice::ReadOnly );
filedata = qstdin.readAll();
mime = KMimeType::findByContent( filedata );
if ( !mime || mime->name() == QLatin1String( "application/octet-stream" ) )
mime = db.mimeTypeForData( filedata );
if ( !mime.isValid() || mime.isDefault() )
return OpenError;
document_size = filedata.size();
triedMimeFromFileContent = true;
......@@ -2178,15 +2181,15 @@ Document::OpenResult Document::openDocument( const QString & docFile, const KUrl
// 0. load Generator
// request only valid non-disabled plugins suitable for the mimetype
QString constraint("([X-KDE-Priority] > 0) and (exist Library)") ;
KService::List offers = KMimeTypeTrader::self()->query(mime->name(),"okular/Generator",constraint);
KService::List offers = KMimeTypeTrader::self()->query(mime.name(),"okular/Generator",constraint);
if ( offers.isEmpty() && !triedMimeFromFileContent )
{
KMimeType::Ptr newmime = KMimeType::findByFileContent( docFile );
QMimeType newmime = db.mimeTypeForFile(docFile, QMimeDatabase::MatchExtension);
triedMimeFromFileContent = true;
if ( newmime->name() != mime->name() )
if ( newmime.name() != mime.name() )
{
mime = newmime;
offers = KMimeTypeTrader::self()->query( mime->name(), "okular/Generator", constraint );
offers = KMimeTypeTrader::self()->query( mime.name(), "okular/Generator", constraint );
}
if ( offers.isEmpty() )
{
......@@ -2195,18 +2198,18 @@ Document::OpenResult Document::openDocument( const QString & docFile, const KUrl
// use is the one fed by the server, that may be wrong
#pragma message("Fix generator loading")
// newmime = KMimeType::findByUrl( docFile );
if ( newmime->name() != mime->name() )
// newmime = db.mimeTypeForUrl( docFile );
if ( newmime.name() != mime.name() )
{
mime = newmime;
offers = KMimeTypeTrader::self()->query( mime->name(), "okular/Generator", constraint );
offers = KMimeTypeTrader::self()->query( mime.name(), "okular/Generator", constraint );
}
}
}
if (offers.isEmpty())
{
emit error( i18n( "Can not find a plugin which is able to handle the document being passed." ), -1 );
kWarning(OkularDebug).nospace() << "No plugin for mimetype '" << mime->name() << "'.";
kWarning(OkularDebug).nospace() << "No plugin for mimetype '" << mime.name() << "'.";
return OpenError;
}
int hRank=0;
......@@ -2239,12 +2242,12 @@ Document::OpenResult Document::openDocument( const QString & docFile, const KUrl
OpenResult openResult = d->openDocumentInternal( offer, isstdin, docFile, filedata, password );
if ( openResult == OpenError && !triedMimeFromFileContent )
{
KMimeType::Ptr newmime = KMimeType::findByFileContent( docFile );
QMimeType newmime = db.mimeTypeForFile(docFile, QMimeDatabase::MatchExtension);
triedMimeFromFileContent = true;
if ( newmime->name() != mime->name() )
if ( newmime.name() != mime.name() )
{
mime = newmime;
offers = KMimeTypeTrader::self()->query( mime->name(), "okular/Generator", constraint );
offers = KMimeTypeTrader::self()->query( mime.name(), "okular/Generator", constraint );
if ( !offers.isEmpty() )
{
offer = offers.first();
......@@ -3657,18 +3660,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 );
KMimeType::Ptr mime = KMimeType::findByPath( fileName );
QMimeDatabase db;
QMimeType mime = db.mimeTypeForFile( fileName );
// Check executables
#pragma message("KF5 check if QUrl::fromUserInput is right here")
if ( KRun::isExecutableFile( QUrl::fromUserInput(fileName), mime->name() ) )
if ( KRun::isExecutableFile( QUrl::fromUserInput(fileName), 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 = KMimeType::findByPath( fileName );
mime = db.mimeTypeForFile( fileName );
#pragma message("KF5 check QUrl usage")
if ( KRun::isExecutableFile( QUrl(fileName), mime->name() ) )
if ( KRun::isExecutableFile( QUrl(fileName), mime.name() ) )
{
// this case is a link pointing to an executable with a parameter
// that also is an executable, possibly a hand-crafted pdf
......@@ -3685,7 +3689,7 @@ void Document::processAction( const Action * action )
}
}
KService::Ptr ptr = KMimeTypeTrader::self()->preferredService( mime->name(), "Application" );
KService::Ptr ptr = KMimeTypeTrader::self()->preferredService( mime.name(), "Application" );
if ( ptr )
{
QList<QUrl> lst;
......@@ -3693,7 +3697,7 @@ void Document::processAction( const Action * action )
KRun::run( *ptr, lst, 0 );
}
else
KMessageBox::information( d->m_widget, i18n( "No application found for opening file of mimetype %1.", mime->name() ) );
KMessageBox::information( d->m_widget, i18n( "No application found for opening file of mimetype %1.", mime.name() ) );
} break;
case Action::DocAction: {
......@@ -4135,8 +4139,9 @@ QByteArray Document::fontData(const FontInfo &font) const
Document::OpenResult Document::openDocumentArchive( const QString & docFile, const KUrl & url, const QString & password )
{
const KMimeType::Ptr mime = KMimeType::findByPath( docFile, 0, false /* content too */ );
if ( !mime->is( "application/vnd.kde.okular-archive" ) )
QMimeDatabase db;
const QMimeType mime = db.mimeTypeForFile( docFile, QMimeDatabase::MatchExtension );
if ( !mime.inherits( "application/vnd.kde.okular-archive" ) )
return OpenError;
KZip okularArchive( docFile );
......@@ -4208,7 +4213,7 @@ Document::OpenResult Document::openDocumentArchive( const QString & docFile, con
}
}
const KMimeType::Ptr docMime = KMimeType::findByPath( tempFileName, 0, true /* local file */ );
const QMimeType docMime = db.mimeTypeForFile( tempFileName, QMimeDatabase::MatchContent );
d->m_archiveData = archiveData.get();
d->m_archivedFileName = documentFileName;
const OpenResult ret = openDocument( tempFileName, url, docMime, password );
......
......@@ -23,7 +23,8 @@
#include <QtXml/QDomDocument>
#include <kcomponentdata.h>
#include <kmimetype.h>
#include <QMimeType>
#include <QMimeDatabase>
#include <kurl.h>
class QPrintDialog;
......@@ -215,7 +216,7 @@ class OKULAR_EXPORT Document : public QObject
* Opens the document.
* @since 0.20 (KDE 4.14)
*/
OpenResult openDocument( const QString & docFile, const KUrl & url, const KMimeType::Ptr &mime, const QString &password = QString() );
OpenResult openDocument( const QString & docFile, const KUrl & url, const QMimeType &mime, const QString &password = QString() );
/**
* Closes the document.
......
......@@ -553,7 +553,7 @@ void PixmapRequestPrivate::swap()
class Okular::ExportFormatPrivate : public QSharedData
{
public:
ExportFormatPrivate( const QString &description, const KMimeType::Ptr &mimeType, const QIcon &icon = QIcon() )
ExportFormatPrivate( const QString &description, const QMimeType &mimeType, const QIcon &icon = QIcon() )
: QSharedData(), mDescription( description ), mMimeType( mimeType ), mIcon( icon )
{
}
......@@ -562,21 +562,21 @@ class Okular::ExportFormatPrivate : public QSharedData
}
QString mDescription;
KMimeType::Ptr mMimeType;
QMimeType mMimeType;
QIcon mIcon;
};
ExportFormat::ExportFormat()
: d( new ExportFormatPrivate( QString(), KMimeType::Ptr() ) )
: d( new ExportFormatPrivate( QString(), QMimeType() ) )
{
}
ExportFormat::ExportFormat( const QString &description, const KMimeType::Ptr &mimeType )
ExportFormat::ExportFormat( const QString &description, const QMimeType &mimeType )
: d( new ExportFormatPrivate( description, mimeType ) )
{
}
ExportFormat::ExportFormat( const QIcon &icon, const QString &description, const KMimeType::Ptr &mimeType )
ExportFormat::ExportFormat( const QIcon &icon, const QString &description, const QMimeType &mimeType )
: d( new ExportFormatPrivate( description, mimeType, icon ) )
{
}
......@@ -605,7 +605,7 @@ QString ExportFormat::description() const
return d->mDescription;
}
KMimeType::Ptr ExportFormat::mimeType() const
QMimeType ExportFormat::mimeType() const
{
return d->mMimeType;
}
......@@ -617,27 +617,28 @@ QIcon ExportFormat::icon() const
bool ExportFormat::isNull() const
{
return d->mMimeType.isNull() || d->mDescription.isNull();
return !d->mMimeType.isValid() || d->mDescription.isNull();
}
ExportFormat ExportFormat::standardFormat( StandardExportFormat type )
{
QMimeDatabase db;
switch ( type )
{
case PlainText:
return ExportFormat( QIcon::fromTheme( "text-x-generic" ), i18n( "Plain &Text..." ), KMimeType::mimeType( "text/plain" ) );
return ExportFormat( QIcon::fromTheme( "text-x-generic" ), i18n( "Plain &Text..." ), db.mimeTypeForName( "text/plain" ) );
break;
case PDF:
return ExportFormat( QIcon::fromTheme( "application-pdf" ), i18n( "PDF" ), KMimeType::mimeType( "application/pdf" ) );
return ExportFormat( QIcon::fromTheme( "application-pdf" ), i18n( "PDF" ), db.mimeTypeForName( "application/pdf" ) );
break;
case OpenDocumentText:
return ExportFormat(
QIcon::fromTheme( "application-vnd.oasis.opendocument.text" ),
i18nc( "This is the document format", "OpenDocument Text" ),
KMimeType::mimeType( "application/vnd.oasis.opendocument.text" ) );
db.mimeTypeForName( "application/vnd.oasis.opendocument.text" ) );
break;
case HTML:
return ExportFormat( QIcon::fromTheme( "text-html" ), i18nc( "This is the document format", "HTML" ), KMimeType::mimeType( "text/html" ) );
return ExportFormat( QIcon::fromTheme( "text-html" ), i18nc( "This is the document format", "HTML" ), db.mimeTypeForName( "text/html" ) );
break;
}
return ExportFormat();
......
......@@ -26,7 +26,8 @@
#include <QtCore/QVariant>
#include <QtCore/QVector>
#include <kmimetype.h>
#include <QMimeType>
#include <QMimeDatabase>
#include <kpluginfactory.h>
#define OKULAR_EXPORT_PLUGIN( classname, aboutdata ) \
......@@ -91,7 +92,7 @@ class OKULAR_EXPORT ExportFormat
* @param description The i18n'ed description of the format.
* @param mimeType The supported mime type of the format.
*/
ExportFormat( const QString &description, const KMimeType::Ptr &mimeType );
ExportFormat( const QString &description, const QMimeType &mimeType );
/**
* Creates a new export format.
......@@ -100,7 +101,7 @@ class OKULAR_EXPORT ExportFormat
* @param description The i18n'ed description of the format.
* @param mimeType The supported mime type of the format.
*/
ExportFormat( const QIcon &icon, const QString &description, const KMimeType::Ptr &mimeType );
ExportFormat( const QIcon &icon, const QString &description, const QMimeType &mimeType );
/**
* Destroys the export format.
......@@ -125,7 +126,7 @@ class OKULAR_EXPORT ExportFormat
/**
* Returns the mime type of the format.
*/
KMimeType::Ptr mimeType() const;
QMimeType mimeType() const;
/**
* Returns the icon for GUI representations of the format.
......
......@@ -495,7 +495,7 @@ bool TextDocumentGenerator::exportTo( const QString &fileName, const Okular::Exp
if ( !d->mDocument )
return false;
if ( format.mimeType()->name() == QLatin1String( "application/pdf" ) ) {
if ( format.mimeType().name() == QLatin1String( "application/pdf" ) ) {
QFile file( fileName );
if ( !file.open( QIODevice::WriteOnly ) )
return false;
......@@ -506,7 +506,7 @@ bool TextDocumentGenerator::exportTo( const QString &fileName, const Okular::Exp
d->mDocument->print( &printer );
return true;
} else if ( format.mimeType()->name() == QLatin1String( "text/plain" ) ) {
} else if ( format.mimeType().name() == QLatin1String( "text/plain" ) ) {
QFile file( fileName );
if ( !file.open( QIODevice::WriteOnly ) )
return false;
......@@ -516,11 +516,11 @@ bool TextDocumentGenerator::exportTo( const QString &fileName, const Okular::Exp
return true;
#if QT_VERSION >= 0x040500
} else if ( format.mimeType()->name() == QLatin1String( "application/vnd.oasis.opendocument.text" ) ) {
} else if ( format.mimeType().name() == QLatin1String( "application/vnd.oasis.opendocument.text" ) ) {
QTextDocumentWriter odfWriter( fileName, "odf" );
return odfWriter.write( d->mDocument );
} else if ( format.mimeType()->name() == QLatin1String( "text/html" ) ) {
} else if ( format.mimeType().name() == QLatin1String( "text/html" ) ) {
QTextDocumentWriter odfWriter( fileName, "html" );
return odfWriter.write( d->mDocument );
......
......@@ -21,7 +21,8 @@
#include <kapplication.h>
#include <kdebug.h>
#include <kurl.h>
#include <kmimetype.h>
#include <QMimeType>
#include <QMimeDatabase>
#include <qfile.h>
#include <qdir.h>
......@@ -121,7 +122,7 @@ void ProtocolMSITS::get( const KUrl& url )
}
totalSize( buf.size() );
KMimeType::Ptr result = KMimeType::findByNameAndContent( fileName, buf );
QMimeType result = db.mimeTypeForNameAndData( fileName, buf );
kDebug() << "Emitting mimetype " << result->name();
mimeType( result->name() );
......
......@@ -14,7 +14,8 @@
#include <QtGui/QImageReader>
#include <klocale.h>
#include <kmimetype.h>
#include <QMimeType>
#include <QMimeDatabase>
#include <kzip.h>
#include <ktar.h>
......@@ -54,12 +55,13 @@ bool Document::open( const QString &fileName )
{
close();
const KMimeType::Ptr mime = KMimeType::findByFileContent( fileName );
QMimeDatabase db;
const QMimeType mime = db.mimeTypeForFile(fileName, QMimeDatabase::MatchContent);
/**
* We have a zip archive
*/
if ( mime->is( "application/x-cbz" ) || mime->name() == "application/zip" ) {
if ( mime.inherits("application/x-cbz" ) || mime.inherits( "application/zip" ) ) {
mArchive = new KZip( fileName );
if ( !processArchive() ) {
......@@ -68,14 +70,14 @@ bool Document::open( const QString &fileName )
/**
* We have a TAR archive
*/
} else if ( mime->is( "application/x-cbt" ) || mime->name() == "application/x-gzip" ||
mime->name() == "application/x-tar" || mime->name() == "application/x-bzip" ) {
} else if ( mime.inherits( "application/x-cbt" ) || mime.inherits( "application/x-gzip" ) ||
mime.inherits( "application/x-tar" ) || mime.inherits( "application/x-bzip" ) ) {
mArchive = new KTar( fileName );
if ( !processArchive() ) {
return false;
}
} else if ( mime->is( "application/x-cbr" ) || mime->name() == "application/x-rar" ) {
} else if ( mime.inherits( "application/x-cbr" ) || mime.inherits( "application/x-rar" ) ) {
if ( !Unrar::isAvailable() ) {
mLastErrorString = i18n( "Cannot open document, unrar was not found." );
return false;
......@@ -99,7 +101,7 @@ bool Document::open( const QString &fileName )
}
mEntries = mUnrar->list();
} else if ( mime->is( "inode/directory" ) ) {
} else if ( mime.inherits( "inode/directory" ) ) {
mDirectory = new Directory();
if ( !mDirectory->open( fileName ) ) {
......
......@@ -26,7 +26,8 @@
#include <kconfig.h>
#include <kglobal.h>
#include <klocale.h>
#include <kmimetype.h>
#include <QMimeType>
#include <QMimeDatabase>
#include <kstandarddirs.h>
#include <kvbox.h>
......
......@@ -17,7 +17,8 @@
#include "TeXFont.h"
#include <klocale.h>
#include <kmimetype.h>
#include <QMimeType>
#include <QMimeDatabase>
#include <kprocess.h>
#include <QApplication>
......@@ -70,9 +71,10 @@ void dviRenderer::prescan_embedPS(char *cp, quint8 *beginningOfSpecialCommand)
// If the file is neither a PostScript not a PDF file, we exit here.
// The graphic file is later read when the page is rendered.
KMimeType::Ptr const mime_type =
KMimeType::findByFileContent(EPSfilename);
QString const & mime_type_name = mime_type?mime_type->name():"";
QMimeDatabase db;
QMimeType const mime_type =
db.mimeTypeForFile(EPSfilename, QMimeDatabase::MatchContent);
QString const & mime_type_name = mime_type.isValid() ? mime_type.name() : QString();
bool const is_ps_file = (mime_type_name == "application/postscript" ||
mime_type_name == "image/x-eps");
......
......@@ -17,7 +17,8 @@
//#include "renderedDocumentPage.h"
#include <klocale.h>
#include <kmimetype.h>
#include <QMimeType>
#include <QMimeDatabase>
#include <QFile>
#include <QImage>
......@@ -352,8 +353,9 @@ void dviRenderer::epsf_special(const QString& cp)
parse_special_argument(include_command, "angle=", &angle);
// If we have a png, gif, jpeg or mng file, we need to draw it here.
KMimeType::Ptr const mime_type = KMimeType::findByFileContent(EPSfilename);
QString const & mime_type_name = mime_type?mime_type->name():"";
QMimeDatabase db;
QMimeType const mime_type = db.mimeTypeForFile(EPSfilename, QMimeDatabase::MatchContent);
QString const & mime_type_name = mime_type.isValid() ? mime_type.name() : QString();
bool const isGFX = (mime_type_name == "image/png" ||
mime_type_name == "image/gif" ||
mime_type_name == "image/jpeg" ||
......
......@@ -64,7 +64,7 @@ KIMGIOGenerator::~KIMGIOGenerator()
bool KIMGIOGenerator::loadDocument( const QString & fileName, QVector<Okular::Page*> & pagesVector )
{
const QString mime = KMimeType::findByFileContent(fileName)->name();
const QString mime = db.mimeTypeForFile(fileName, QMimeDatabase::MatchContent).name();
const QStringList types = KImageIO::typeForMime(mime);
const QByteArray type = !types.isEmpty() ? types[0].toAscii() : QByteArray();
QImageReader reader( fileName, type );
......@@ -90,7 +90,7 @@ bool KIMGIOGenerator::loadDocument( const QString & fileName, QVector<Okular::Pa
bool KIMGIOGenerator::loadDocumentFromData( const QByteArray & fileData, QVector<Okular::Page*> & pagesVector )
{
const QString mime = KMimeType::findByContent(fileData)->name();
const QString mime = db.mimeTypeForData(fileData).name();
const QStringList types = KImageIO::typeForMime(mime);
const QByteArray type = !types.isEmpty() ? types[0].toAscii() : QByteArray();
......
......@@ -63,7 +63,7 @@ void KIMGIOTest::testExifOrientation()
Okular::SettingsCore::instance( "kimgiotest" );
Okular::Document *m_document = new Okular::Document( 0 );
const KMimeType::Ptr mime = KMimeType::findByPath( imgPath );
const QMimeType mime = db.mimeTypeForFile( imgPath );
Okular::DocumentObserver *dummyDocumentObserver = new Okular::DocumentObserver();
m_document->addObserver( dummyDocumentObserver );
......
......@@ -1239,7 +1239,7 @@ Okular::ExportFormat::List PDFGenerator::exportFormats() const
bool PDFGenerator::exportTo( const QString &fileName, const Okular::ExportFormat &format )
{
if ( format.mimeType()->name() == QLatin1String( "text/plain" ) ) {
if ( format.mimeType().inherits( QLatin1String( "text/plain" ) ) ) {
QFile f( fileName );
if ( !f.open( QIODevice::WriteOnly ) )
return false;
......
......@@ -20,7 +20,8 @@
#include <kaboutdata.h>
#include <kconfigdialog.h>
#include <kdebug.h>
#include <kmimetype.h>
#include <QMimeType>
#include <QMimeDatabase>
#include <ktemporaryfile.h>
#include <core/document.h>
......
......@@ -2181,7 +2181,7 @@ Okular::ExportFormat::List XpsGenerator::exportFormats() const
bool XpsGenerator::exportTo( const QString &fileName, const Okular::ExportFormat &format )
{
if ( format.mimeType()->name() == QLatin1String( "text/plain" ) ) {
if ( format.mimeType().inherits( QLatin1String( "text/plain" ) ) ) {
QFile f( fileName );
if ( !f.open( QIODevice::WriteOnly ) )
return false;
......
......@@ -204,14 +204,15 @@ static QString compressedMimeFor( const QString& mime_to_check )
if ( it != compressedMimeMap.constEnd() )
return it.value();
KMimeType::Ptr mime = KMimeType::mimeType( mime_to_check );
if ( mime )
QMimeDatabase db;
QMimeType mime = db.mimeTypeForName( mime_to_check );
if ( mime.isValid() )
{
if ( mime->is( app_gzip ) )
if ( mime.inherits( app_gzip ) )
return app_gzip;
else if ( supportBzip && mime->is( app_bzip ) )
else if ( supportBzip && mime.inherits( app_bzip ) )
return app_bzip;
else if ( supportXz && mime->is( app_xz ) )
else if ( supportXz && mime.inherits( app_xz ) )
return app_xz;
}
......@@ -732,6 +733,7 @@ void Part::setViewerShortcuts()
void Part::setupActions()
{
KActionCollection * ac = actionCollection();
QMimeDatabase db;
m_copy = KStandardAction::create( KStandardAction::Copy, m_pageView, SLOT(copyTextSelection()), ac );
......@@ -778,7 +780,7 @@ void Part::setupActions()
m_exportAsText->setEnabled( false );
m_exportAsDocArchive = actionForExportFormat( Okular::ExportFormat(
i18nc( "A document format, Okular-specific", "Document Archive" ),
KMimeType::mimeType( "application/vnd.kde.okular-archive" ) ), m_exportAsMenu );
db.mimeTypeForName( "application/vnd.kde.okular-archive" ) ), m_exportAsMenu );
m_exportAsMenu->addAction( m_exportAsDocArchive );
m_exportAsDocArchive->setEnabled( false );