mirror of
https://invent.kde.org/graphics/okular
synced 2024-07-05 00:58:46 +00:00
Port to QMime
compressedMimeFor now already does the inheritance check, so another check was removed.
This commit is contained in:
parent
33f6862a94
commit
e28dbc6c00
|
@ -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;
|
||||
|
|
50
part.cpp
50
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(),
|
||||
|
|
4
part.h
4
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();
|
||||
|
|
|
@ -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()) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
|
|
@ -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()));
|
||||
|
|
|
@ -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 ) );
|
||||
}
|
||||
|
|
|
@ -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 );
|
||||
|
|
Loading…
Reference in New Issue
Block a user