Commit be0023b0 authored by Pino Toscano's avatar Pino Toscano

recognize correctly the compressed mimetypes for pdf, ps and dvi

svn path=/trunk/KDE/kdegraphics/okular/; revision=692295
parent ec4827fc
...@@ -764,6 +764,28 @@ bool Part::openFile() ...@@ -764,6 +764,28 @@ bool Part::openFile()
return true; return true;
} }
static QString compressedMimeFor( const QString& mime_to_check )
{
static QHash< QString, QString > compressedMimeMap;
if ( compressedMimeMap.isEmpty() )
{
compressedMimeMap[ QString::fromLatin1( "application/x-gzip" ) ] =
QString::fromLatin1( "application/x-gzip" );
compressedMimeMap[ QString::fromLatin1( "application/x-bzip" ) ] =
QString::fromLatin1( "application/x-bzip" );
compressedMimeMap[ QString::fromLatin1( "application/x-bzpdf" ) ] =
QString::fromLatin1( "application/x-bzip" );
compressedMimeMap[ QString::fromLatin1( "application/x-bzpostscript" ) ] =
QString::fromLatin1( "application/x-bzip" );
compressedMimeMap[ QString::fromLatin1( "application/x-bzdvi" ) ] =
QString::fromLatin1( "application/x-bzip" );
}
QHash< QString, QString >::const_iterator it = compressedMimeMap.find( mime_to_check );
if ( it != compressedMimeMap.end() )
return it.value();
return QString();
}
bool Part::openUrl(const KUrl &url) bool Part::openUrl(const KUrl &url)
{ {
...@@ -776,11 +798,10 @@ bool Part::openUrl(const KUrl &url) ...@@ -776,11 +798,10 @@ bool Part::openUrl(const KUrl &url)
const KMimeType::Ptr mimetype = KMimeType::findByPath( path ); const KMimeType::Ptr mimetype = KMimeType::findByPath( path );
bool isCompressedFile = false; bool isCompressedFile = false;
KUrl tempUrl; KUrl tempUrl;
if (( mimetype->name() == "application/x-gzip" ) QString compressedMime = compressedMimeFor( mimetype->name() );
|| ( mimetype->name() == "application/x-bzip" ) if ( compressedMime.isEmpty() )
|| ( mimetype->parentMimeType() == "application/x-gzip" ) compressedMime = compressedMimeFor( mimetype->parentMimeType() );
|| ( mimetype->parentMimeType() == "application/x-bzip" ) if ( !compressedMime.isEmpty() )
)
{ {
isCompressedFile=handleCompressed(tempUrl,path,mimetype); isCompressedFile=handleCompressed(tempUrl,path,mimetype);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment