summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederik Gladhorn <gladhorn@kde.org>2014-09-11 13:18:05 (GMT)
committerFrederik Gladhorn <gladhorn@kde.org>2014-09-11 14:32:43 (GMT)
commite28dbc6c00243442f6278546d19d1cf1b38b4ba9 (patch)
tree34a4202a3001a9e131397afbe1417e1c82f758c7
parent33f6862a94bf224ac465c4e27fb45fba4140b74a (diff)
Port to QMime
compressedMimeFor now already does the inheritance check, so another check was removed.
-rw-r--r--active/components/documentitem.cpp2
-rw-r--r--core/chooseenginedialog.cpp4
-rw-r--r--core/chooseenginedialog_p.h5
-rw-r--r--core/document.cpp63
-rw-r--r--core/document.h5
-rw-r--r--core/generator.cpp23
-rw-r--r--core/generator.h9
-rw-r--r--core/textdocumentgenerator.cpp8
-rw-r--r--generators/chm/kio-msits/msits.cpp5
-rw-r--r--generators/comicbook/document.cpp16
-rw-r--r--generators/dvi/dviRenderer.cpp3
-rw-r--r--generators/dvi/dviRenderer_prescan.cpp10
-rw-r--r--generators/dvi/special.cpp8
-rw-r--r--generators/kimgio/generator_kimgio.cpp4
-rw-r--r--generators/kimgio/tests/kimgiotest.cpp2
-rw-r--r--generators/poppler/generator_pdf.cpp2
-rw-r--r--generators/spectre/generator_ghostview.cpp3
-rw-r--r--generators/xps/generator_xps.cpp2
-rw-r--r--part.cpp50
-rw-r--r--part.h4
-rw-r--r--shell/shell.cpp9
-rw-r--r--shell/shell.h5
-rw-r--r--tests/addremoveannotationtest.cpp3
-rw-r--r--tests/annotationstest.cpp3
-rw-r--r--tests/documenttest.cpp3
-rw-r--r--tests/editannotationcontentstest.cpp6
-rw-r--r--tests/editformstest.cpp6
-rw-r--r--tests/modifyannotationpropertiestest.cpp6
-rw-r--r--tests/searchtest.cpp3
-rw-r--r--tests/translateannotationtest.cpp6
-rw-r--r--ui/annotationwidgets.cpp7
-rw-r--r--ui/embeddedfilesdialog.cpp10
-rw-r--r--ui/pageview.cpp7
-rw-r--r--ui/propertiesdialog.cpp9
34 files changed, 175 insertions, 136 deletions
diff --git a/active/components/documentitem.cpp b/active/components/documentitem.cpp
index e1915ab..c8f7ee4 100644
--- a/active/components/documentitem.cpp
+++ b/active/components/documentitem.cpp
@@ -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());
diff --git a/core/chooseenginedialog.cpp b/core/chooseenginedialog.cpp
index 34f59b9..358b946 100644
--- a/core/chooseenginedialog.cpp
+++ b/core/chooseenginedialog.cpp
@@ -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()
diff --git a/core/chooseenginedialog_p.h b/core/chooseenginedialog_p.h
index 20ae739..1eb0356 100644
--- a/core/chooseenginedialog_p.h
+++ b/core/chooseenginedialog_p.h
@@ -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;
diff --git a/core/document.cpp b/core/document.cpp
index bbec703..4a38cf6 100644
--- a/core/document.cpp
+++ b/core/document.cpp
@@ -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 );
diff --git a/core/document.h b/core/document.h
index f891817..31bde00 100644
--- a/core/document.h
+++ b/core/document.h
@@ -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.
diff --git a/core/generator.cpp b/core/generator.cpp
index 1d0ada1..e06dc99 100644
--- a/core/generator.cpp
+++ b/core/generator.cpp
@@ -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();
diff --git a/core/generator.h b/core/generator.h
index 8bd15e1..d2e7647 100644
--- a/core/generator.h
+++ b/core/generator.h
@@ -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.
diff --git a/core/textdocumentgenerator.cpp b/core/textdocumentgenerator.cpp
index 17b65e6..fd206fa 100644
--- a/core/textdocumentgenerator.cpp
+++ b/core/textdocumentgenerator.cpp
@@ -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 );
diff --git a/generators/chm/kio-msits/msits.cpp b/generators/chm/kio-msits/msits.cpp
index 23a3fce..5e4c273 100644
--- a/generators/chm/kio-msits/msits.cpp
+++ b/generators/chm/kio-msits/msits.cpp
@@ -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() );
diff --git a/generators/comicbook/document.cpp b/generators/comicbook/document.cpp
index 93b948e..6085888 100644
--- a/generators/comicbook/document.cpp
+++ b/generators/comicbook/document.cpp
@@ -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 ) ) {
diff --git a/generators/dvi/dviRenderer.cpp b/generators/dvi/dviRenderer.cpp
index 4d098f9..3eba806 100644
--- a/generators/dvi/dviRenderer.cpp
+++ b/generators/dvi/dviRenderer.cpp
@@ -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>
diff --git a/generators/dvi/dviRenderer_prescan.cpp b/generators/dvi/dviRenderer_prescan.cpp
index bfcebb1..9fb688a 100644
--- a/generators/dvi/dviRenderer_prescan.cpp
+++ b/generators/dvi/dviRenderer_prescan.cpp
@@ -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");
diff --git a/generators/dvi/special.cpp b/generators/dvi/special.cpp
index 4d63e9d..6d21e74 100644
--- a/generators/dvi/special.cpp
+++ b/generators/dvi/special.cpp
@@ -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" ||
diff --git a/generators/kimgio/generator_kimgio.cpp b/generators/kimgio/generator_kimgio.cpp
index 5e0a314..6868877 100644
--- a/generators/kimgio/generator_kimgio.cpp
+++ b/generators/kimgio/generator_kimgio.cpp
@@ -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();
diff --git a/generators/kimgio/tests/kimgiotest.cpp b/generators/kimgio/tests/kimgiotest.cpp
index 99f3ff9..f5649e0 100644
--- a/generators/kimgio/tests/kimgiotest.cpp
+++ b/generators/kimgio/tests/kimgiotest.cpp
@@ -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 );
diff --git a/generators/poppler/generator_pdf.cpp b/generators/poppler/generator_pdf.cpp
index 112aa88..f2bd505 100644
--- a/generators/poppler/generator_pdf.cpp
+++ b/generators/poppler/generator_pdf.cpp
@@ -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;
diff --git a/generators/spectre/generator_ghostview.cpp b/generators/spectre/generator_ghostview.cpp
index b84e1e4..6672e4b 100644
--- a/generators/spectre/generator_ghostview.cpp
+++ b/generators/spectre/generator_ghostview.cpp
@@ -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>
diff --git a/generators/xps/generator_xps.cpp b/generators/xps/generator_xps.cpp
index bdc563a..ce76c22 100644
--- a/generators/xps/generator_xps.cpp
+++ b/generators/xps/generator_xps.cpp
@@ -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;
diff --git a/part.cpp b/part.cpp
index 422ddd4..5343268 100644
--- a/part.cpp
+++ b/part.cpp
@@ -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 );
@@ -1193,20 +1195,19 @@ static void addFileToWatcher( KDirWatch *watcher, const QString &filePath)
if ( fi.isSymLink() ) watcher->addFile( fi.readLink() );
}
-Document::OpenResult Part::doOpenFile( const KMimeType::Ptr &mimeA, const QString &fileNameToOpenA, bool *isCompressedFile )
+Document::OpenResult Part::doOpenFile( const QMimeType &mimeA, const QString &fileNameToOpenA, bool *isCompressedFile )
{
+ QMimeDatabase db;
Document::OpenResult openResult = Document::OpenError;
bool uncompressOk = true;
- KMimeType::Ptr mime = mimeA;
+ QMimeType mime = mimeA;
QString fileNameToOpen = fileNameToOpenA;
- QString compressedMime = compressedMimeFor( mime->name() );
- if ( compressedMime.isEmpty() )
- compressedMime = compressedMimeFor( mime->parentMimeType() );
+ QString compressedMime = compressedMimeFor( mime.name() );
if ( !compressedMime.isEmpty() )
{
*isCompressedFile = true;
uncompressOk = handleCompressed( fileNameToOpen, localFilePath(), compressedMime );
- mime = KMimeType::findByPath( fileNameToOpen );
+ mime = db.mimeTypeForFile( fileNameToOpen );
}
else
{
@@ -1216,7 +1217,7 @@ Document::OpenResult Part::doOpenFile( const KMimeType::Ptr &mimeA, const QStrin
isDocumentArchive = false;
if ( uncompressOk )
{
- if ( mime->is( "application/vnd.kde.okular-archive" ) )
+ if ( mime.inherits( "application/vnd.kde.okular-archive" ) )
{
openResult = m_document->openDocumentArchive( fileNameToOpen, url() );
isDocumentArchive = true;
@@ -1279,7 +1280,7 @@ Document::OpenResult Part::doOpenFile( const KMimeType::Ptr &mimeA, const QStrin
}
// 2. reopen the document using the password
- if ( mime->is( "application/vnd.kde.okular-archive" ) )
+ if ( mime.inherits( "application/vnd.kde.okular-archive" ) )
{
openResult = m_document->openDocumentArchive( fileNameToOpen, url(), password );
isDocumentArchive = true;
@@ -1302,25 +1303,26 @@ Document::OpenResult Part::doOpenFile( const KMimeType::Ptr &mimeA, const QStrin
bool Part::openFile()
{
- QList<KMimeType::Ptr> mimes;
+ QList<QMimeType> mimes;
QString fileNameToOpen = localFilePath();
const bool isstdin = url().isLocalFile() && url().fileName() == QLatin1String( "-" );
const QFileInfo fileInfo( fileNameToOpen );
if ( (!isstdin) && (!fileInfo.exists()) )
return false;
- KMimeType::Ptr pathMime = KMimeType::findByPath( fileNameToOpen );
+ QMimeDatabase db;
+ QMimeType pathMime = db.mimeTypeForFile( fileNameToOpen );
if ( !arguments().mimeType().isEmpty() )
{
- KMimeType::Ptr argMime = KMimeType::mimeType( arguments().mimeType() );
+ QMimeType argMime = db.mimeTypeForName( arguments().mimeType() );
// Select the "childmost" mimetype, if none of them
// inherits the other trust more what pathMime says
// but still do a second try if that one fails
- if ( argMime->is( pathMime->name() ) )
+ if ( argMime.inherits( pathMime.name() ) )
{
mimes << argMime;
}
- else if ( pathMime->is( argMime->name() ) )
+ else if ( pathMime.inherits( argMime.name() ) )
{
mimes << pathMime;
}
@@ -1329,8 +1331,8 @@ bool Part::openFile()
mimes << pathMime << argMime;
}
- if (mimes[0]->name() == "text/plain") {
- KMimeType::Ptr contentMime = KMimeType::findByFileContent( fileNameToOpen );
+ if (mimes[0].name() == "text/plain") {
+ QMimeType contentMime = db.mimeTypeForFile(fileNameToOpen, QMimeDatabase::MatchContent);
mimes.prepend( contentMime );
}
}
@@ -1339,7 +1341,7 @@ bool Part::openFile()
mimes << pathMime;
}
- KMimeType::Ptr mime;
+ QMimeType mime;
Document::OpenResult openResult = Document::OpenError;
bool isCompressedFile = false;
while ( !mimes.isEmpty() && openResult == Document::OpenError ) {
@@ -2558,7 +2560,7 @@ void Part::slotAboutBackend()
// const QString mimeTypeName = documentInfo.get(DocumentInfo::MimeType);
// if ( !mimeTypeName.isEmpty() )
// {
-// if ( KMimeType::Ptr type = KMimeType::mimeType( mimeTypeName ) )
+// if ( QMimeType type = db.mimeTypeForName( mimeTypeName ) )
// aboutData.setProgramIconName( type->iconName() );
// }
// }
@@ -2585,7 +2587,7 @@ void Part::slotExportAs(QAction * act)
filter = "application/vnd.kde.okular-archive";
break;
default:
- filter = m_exportFormats.at( id - 2 ).mimeType()->name();
+ filter = m_exportFormats.at( id - 2 ).mimeType().name();
break;
}
QString fileName = KFileDialog::getSaveFileName( url(),
diff --git a/part.h b/part.h
index 636eee8..c8cfa19 100644
--- a/part.h
+++ b/part.h
@@ -158,7 +158,7 @@ class OKULAR_PART_EXPORT Part : public KParts::ReadWritePart, public Okular::Doc
void openSourceReference(const QString& absFileName, int line, int column);
void viewerMenuStateChange(bool enabled);
void enableCloseAction(bool enable);
- void mimeTypeChanged(KMimeType::Ptr mimeType);
+ void mimeTypeChanged(QMimeType mimeType);
void urlsDropped( const QList<QUrl>& urls );
protected:
@@ -235,7 +235,7 @@ class OKULAR_PART_EXPORT Part : public KParts::ReadWritePart, public Okular::Doc
void noticeMessage( const QString &message, int duration = -1 );
private:
- Document::OpenResult doOpenFile(const KMimeType::Ptr &mime, const QString &fileNameToOpen, bool *isCompressedFile);
+ Document::OpenResult doOpenFile(const QMimeType &mime, const QString &fileNameToOpen, bool *isCompressedFile);
void setupViewerActions();
void setViewerShortcuts();
diff --git a/shell/shell.cpp b/shell/shell.cpp
index afd9564..13a42b6 100644
--- a/shell/shell.cpp
+++ b/shell/shell.cpp
@@ -28,7 +28,8 @@
#include <KFileDialog>
#include <KPluginLoader>
#include <KMessageBox>
-#include <KMimeType>
+#include <QMimeType>
+#include <QMimeDatabase>
#include <KStandardAction>
#include <KToolBar>
#include <KRecentFilesAction>
@@ -548,7 +549,7 @@ void Shell::connectPart( QObject* part )
connect( this, SIGNAL(saveDocumentRestoreInfo(KConfigGroup&)), part, SLOT(saveDocumentRestoreInfo(KConfigGroup&)));
connect( part, SIGNAL(enablePrintAction(bool)), this, SLOT(setPrintEnabled(bool)));
connect( part, SIGNAL(enableCloseAction(bool)), this, SLOT(setCloseEnabled(bool)));
- connect( part, SIGNAL(mimeTypeChanged(KMimeType::Ptr)), this, SLOT(setTabIcon(KMimeType::Ptr)));
+ connect( part, SIGNAL(mimeTypeChanged(QMimeType)), this, SLOT(setTabIcon(QMimeType)));
connect( part, SIGNAL(urlsDropped(QList<QUrl>)), this, SLOT(handleDroppedUrls(QList<QUrl>)) );
}
@@ -601,12 +602,12 @@ void Shell::activatePrevTab()
setActiveTab( prevTab );
}
-void Shell::setTabIcon( KMimeType::Ptr mimeType )
+void Shell::setTabIcon( const QMimeType& mimeType )
{
int i = findTabIndex( sender() );
if( i != -1 )
{
- m_tabWidget->setTabIcon( i, QIcon::fromTheme(mimeType->iconName()) );
+ m_tabWidget->setTabIcon( i, QIcon::fromTheme(mimeType.iconName()) );
}
}
diff --git a/shell/shell.h b/shell/shell.h
index 8c33366..83e4e2a 100644
--- a/shell/shell.h
+++ b/shell/shell.h
@@ -18,7 +18,8 @@
#include <kparts/mainwindow.h>
#include <kparts/readwritepart.h>
-#include <kmimetype.h>
+#include <QMimeType>
+#include <QMimeDatabase>
#include <kaction.h>
#include <QtDBus/QtDBus>
@@ -101,7 +102,7 @@ private slots:
void print();
void setPrintEnabled( bool enabled );
void setCloseEnabled( bool enabled );
- void setTabIcon( KMimeType::Ptr mimeType );
+ void setTabIcon(const QMimeType& mimeType );
void handleDroppedUrls( const QList<QUrl>& urls );
// Tab event handlers
diff --git a/tests/addremoveannotationtest.cpp b/tests/addremoveannotationtest.cpp
index 42e5b1b..a999e83 100644
--- a/tests/addremoveannotationtest.cpp
+++ b/tests/addremoveannotationtest.cpp
@@ -40,7 +40,8 @@ void AddRemoveAnnotationTest::initTestCase()
void AddRemoveAnnotationTest::init()
{
const QString testFile = KDESRCDIR "data/file1.pdf";
- const KMimeType::Ptr mime = KMimeType::findByPath( testFile );
+ QMimeDatabase db;
+ const QMimeType mime = db.mimeTypeForFile( testFile );
QCOMPARE( m_document->openDocument(testFile, KUrl(), mime), Okular::Document::OpenSuccess );
}
diff --git a/tests/annotationstest.cpp b/tests/annotationstest.cpp
index 830ef37..f07449a 100644
--- a/tests/annotationstest.cpp
+++ b/tests/annotationstest.cpp
@@ -41,7 +41,8 @@ void AnnotationTest::initTestCase()
Okular::SettingsCore::instance( "annotationtest" );
m_document = new Okular::Document( 0 );
const QString testFile = KDESRCDIR "data/file1.pdf";
- const KMimeType::Ptr mime = KMimeType::findByPath( testFile );
+ QMimeDatabase db;
+ const QMimeType mime = db.mimeTypeForFile( testFile );
QCOMPARE( m_document->openDocument(testFile, KUrl(), mime), Okular::Document::OpenSuccess );
}
diff --git a/tests/documenttest.cpp b/tests/documenttest.cpp
index 6b11dc7..22ae454 100644
--- a/tests/documenttest.cpp
+++ b/tests/documenttest.cpp
@@ -33,7 +33,8 @@ void DocumentTest::testCloseDuringRotationJob()
Okular::SettingsCore::instance( "documenttest" );
Okular::Document *m_document = new Okular::Document( 0 );
const QString testFile = KDESRCDIR "data/file1.pdf";
- const KMimeType::Ptr mime = KMimeType::findByPath( testFile );
+ QMimeDatabase db;
+ const QMimeType mime = db.mimeTypeForFile( testFile );
Okular::DocumentObserver *dummyDocumentObserver = new Okular::DocumentObserver();
m_document->addObserver( dummyDocumentObserver );
diff --git a/tests/editannotationcontentstest.cpp b/tests/editannotationcontentstest.cpp
index fba1c45..a89d55a 100644
--- a/tests/editannotationcontentstest.cpp
+++ b/tests/editannotationcontentstest.cpp
@@ -9,7 +9,8 @@
#include <QtTest>
-#include <kmimetype.h>
+#include <QMimeType>
+#include <QMimeDatabase>
#include "../settings_core.h"
#include "core/annotations.h"
#include "core/document.h"
@@ -105,7 +106,8 @@ void EditAnnotationContentsTest::cleanupTestCase()
void EditAnnotationContentsTest::init()
{
const QString testFile = KDESRCDIR "data/file1.pdf";
- const KMimeType::Ptr mime = KMimeType::findByPath( testFile );
+ QMimeDatabase db;
+ const QMimeType mime = db.mimeTypeForFile( testFile );
QCOMPARE( m_document->openDocument(testFile, KUrl(), mime), Okular::Document::OpenSuccess );
// Undo and Redo should be unavailable when docuemnt is first opened.
diff --git a/tests/editformstest.cpp b/tests/editformstest.cpp
index 5c9f537..9896e71 100644
--- a/tests/editformstest.cpp
+++ b/tests/editformstest.cpp
@@ -9,7 +9,8 @@
#include <QtTest>
-#include <kmimetype.h>
+#include <QMimeType>
+#include <QMimeDatabase>
#include "../settings_core.h"
#include "core/document.h"
#include <core/page.h>
@@ -65,7 +66,8 @@ void EditFormsTest::cleanupTestCase()
void EditFormsTest::init()
{
const QString testFile = KDESRCDIR "data/formSamples.pdf";
- const KMimeType::Ptr mime = KMimeType::findByPath( testFile );
+ QMimeDatabase db;
+ const QMimeType mime = db.mimeTypeForFile( testFile );
QCOMPARE( m_document->openDocument(testFile, KUrl(), mime), Okular::Document::OpenSuccess );
// Undo and Redo should be unavailable when docuemnt is first opened.
diff --git a/tests/modifyannotationpropertiestest.cpp b/tests/modifyannotationpropertiestest.cpp
index 802d181..322732b 100644
--- a/tests/modifyannotationpropertiestest.cpp
+++ b/tests/modifyannotationpropertiestest.cpp
@@ -9,7 +9,8 @@
#include <QtTest>
-#include <kmimetype.h>
+#include <QMimeType>
+#include <QMimeDatabase>
#include "../settings_core.h"
#include <core/area.h>
#include <core/annotations.h>
@@ -51,7 +52,8 @@ void ModifyAnnotationPropertiesTest::cleanupTestCase()
void ModifyAnnotationPropertiesTest::init()
{
const QString testFile = KDESRCDIR "data/file1.pdf";
- const KMimeType::Ptr mime = KMimeType::findByPath( testFile );
+ QMimeDatabase db;
+ const QMimeType mime = db.mimeTypeForFile( testFile );
QCOMPARE( m_document->openDocument(testFile, KUrl(), mime), Okular::Document::OpenSuccess );
// Undo and Redo should be unavailable when docuemnt is first opened.
diff --git a/tests/searchtest.cpp b/tests/searchtest.cpp
index ab459af..944a116 100644
--- a/tests/searchtest.cpp
+++ b/tests/searchtest.cpp
@@ -173,7 +173,8 @@ void SearchTest::test311232()
QObject::connect(&d, SIGNAL(searchFinished(int,Okular::Document::SearchStatus)), &receiver, SLOT(searchFinished(int,Okular::Document::SearchStatus)));
const QString testFile = KDESRCDIR "data/file1.pdf";
- const KMimeType::Ptr mime = KMimeType::findByPath( testFile );
+ QMimeDatabase db;
+ const QMimeType mime = db.mimeTypeForFile( testFile );
d.openDocument(testFile, KUrl(), mime);
const int searchId = 0;
diff --git a/tests/translateannotationtest.cpp b/tests/translateannotationtest.cpp
index 7d53a9d..1a897f3 100644
--- a/tests/translateannotationtest.cpp
+++ b/tests/translateannotationtest.cpp
@@ -9,7 +9,8 @@
#include <QtTest>
-#include <kmimetype.h>
+#include <QMimeType>
+#include <QMimeDatabase>
#include "../settings_core.h"
#include "core/annotations.h"
#include "core/document.h"
@@ -107,7 +108,8 @@ void TranslateAnnotationTest::cleanupTestCase()
void TranslateAnnotationTest::init()
{
const QString testFile = KDESRCDIR "data/file1.pdf";
- const KMimeType::Ptr mime = KMimeType::findByPath( testFile );
+ QMimeDatabase db;
+ const QMimeType mime = db.mimeTypeForFile( testFile );
QCOMPARE( m_document->openDocument(testFile, KUrl(), mime), Okular::Document::OpenSuccess );
// Undo and Redo should be unavailable when docuemnt is first opened.
diff --git a/ui/annotationwidgets.cpp b/ui/annotationwidgets.cpp
index c823bf1..50586ab 100644
--- a/ui/annotationwidgets.cpp
+++ b/ui/annotationwidgets.cpp
@@ -681,11 +681,12 @@ QWidget * FileAttachmentAnnotationWidget::createExtraWidget()
tmplabel->setTextInteractionFlags( Qt::TextSelectableByMouse );
lay->addWidget( tmplabel, 3, 0, 1, 2 );
- KMimeType::Ptr mime = KMimeType::findByPath( ef->name(), 0, true );
- if ( mime )
+ QMimeDatabase db;
+ QMimeType mime = db.mimeTypeForFile( ef->name(), QMimeDatabase::MatchExtension);
+ if ( mime.isValid() )
{
tmplabel = new QLabel( widget );
- tmplabel->setPixmap( QIcon::fromTheme( mime->iconName() ).pixmap( FILEATTACH_ICONSIZE, FILEATTACH_ICONSIZE ) );
+ tmplabel->setPixmap( QIcon::fromTheme( mime.iconName() ).pixmap( FILEATTACH_ICONSIZE, FILEATTACH_ICONSIZE ) );
tmplabel->setFixedSize( FILEATTACH_ICONSIZE, FILEATTACH_ICONSIZE );
lay->addWidget( tmplabel, 0, 1, 3, 1, Qt::AlignTop );
}
diff --git a/ui/embeddedfilesdialog.cpp b/ui/embeddedfilesdialog.cpp
index 1a85ec7..627e80e 100644
--- a/ui/embeddedfilesdialog.cpp
+++ b/ui/embeddedfilesdialog.cpp
@@ -18,7 +18,8 @@
#include <kglobal.h>
#include <kicon.h>
#include <klocale.h>
-#include <kmimetype.h>
+#include <QMimeType>
+#include <QMimeDatabase>
#include <kstandardguiitem.h>
#include "core/document.h"
@@ -60,10 +61,11 @@ EmbeddedFilesDialog::EmbeddedFilesDialog(QWidget *parent, const Okular::Document
{
QTreeWidgetItem *twi = new QTreeWidgetItem();
twi->setText(0, ef->name());
- KMimeType::Ptr mime = KMimeType::findByPath( ef->name(), 0, true );
- if (mime)
+ QMimeDatabase db;
+ QMimeType mime = db.mimeTypeForFile( ef->name(), QMimeDatabase::MatchExtension);
+ if (mime.isValid())
{
- twi->setIcon(0, QIcon::fromTheme(mime->iconName()));
+ twi->setIcon(0, QIcon::fromTheme(mime.iconName()));
}
twi->setText(1, ef->description());
twi->setText(2, ef->size() <= 0 ? i18nc("Not available size", "N/A") : KGlobal::locale()->formatByteSize(ef->size()));
diff --git a/ui/pageview.cpp b/ui/pageview.cpp
index 70f5c76..4184d00 100644
--- a/ui/pageview.cpp
+++ b/ui/pageview.cpp
@@ -2628,12 +2628,13 @@ void PageView::mouseReleaseEvent( QMouseEvent * e )
d->messageWindow->display( i18n( "File not saved." ), QString(), PageViewMessage::Warning );
else
{
- KMimeType::Ptr mime = KMimeType::findByUrl( QUrl::fromLocalFile(fileName) );
+ QMimeDatabase db;
+ QMimeType mime = db.mimeTypeForUrl( QUrl::fromLocalFile(fileName) );
QString type;
- if ( !mime || mime == KMimeType::defaultMimeTypePtr() )
+ if ( !mime.isDefault() )
type = "PNG";
else
- type = mime->name().section( '/', -1 ).toUpper();
+ type = mime.name().section( '/', -1 ).toUpper();
copyPix.save( fileName, qPrintable( type ) );
d->messageWindow->display( i18n( "Image [%1x%2] saved to %3 file.", copyPix.width(), copyPix.height(), type ) );
}
diff --git a/ui/propertiesdialog.cpp b/ui/propertiesdialog.cpp
index 0305fc3..ac517f4 100644
--- a/ui/propertiesdialog.cpp
+++ b/ui/propertiesdialog.cpp
@@ -97,15 +97,16 @@ PropertiesDialog::PropertiesDialog(QWidget *parent, Okular::Document *doc)
QHBoxLayout *hboxLayout = new QHBoxLayout( value );
hboxLayout->setMargin( 0 );
/// retrieve icon and place it in a QLabel
- KMimeType::Ptr mimeType = KMimeType::mimeType( valueString );
+ QMimeDatabase db;
+ QMimeType mimeType = db.mimeTypeForName( valueString );
KSqueezedTextLabel *squeezed;
- if (!mimeType.isNull()) {
+ if (mimeType.isValid()) {
/// retrieve icon and place it in a QLabel
QLabel *pixmapLabel = new QLabel( value );
hboxLayout->addWidget( pixmapLabel, 0 );
- pixmapLabel->setPixmap( KIconLoader::global()->loadMimeTypeIcon( mimeType->iconName(), KIconLoader::Small ) );
+ pixmapLabel->setPixmap( KIconLoader::global()->loadMimeTypeIcon( mimeType.iconName(), KIconLoader::Small ) );
/// mime type's name and label
- squeezed = new KSqueezedTextLabel( i18nc( "mimetype information, example: \"PDF Document (application/pdf)\"", "%1 (%2)", mimeType->comment(), valueString ), value );
+ squeezed = new KSqueezedTextLabel( i18nc( "mimetype information, example: \"PDF Document (application/pdf)\"", "%1 (%2)", mimeType.comment(), valueString ), value );
} else {
/// only mime type name
squeezed = new KSqueezedTextLabel( valueString, value );