~ubuntu-branches/ubuntu/raring/okular/raring-proposed

« back to all changes in this revision

Viewing changes to part.cpp

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac
  • Date: 2013-06-20 04:37:41 UTC
  • mfrom: (1.1.27)
  • Revision ID: package-import@ubuntu.com-20130620043741-2pbu2sdus67ejy5n
Tags: 4:4.10.4-0ubuntu0.1
New upstream bugfix release (LP: #1187574)

Show diffs side-by-side

added added

removed removed

Lines of Context:
184
184
 
185
185
static QString compressedMimeFor( const QString& mime_to_check )
186
186
{
 
187
    // The compressedMimeMap is here in case you have a very old shared mime database
 
188
    // that doesn't have inheritance info for things like gzeps, etc
 
189
    // Otherwise the "is()" calls below are just good enough
187
190
    static QHash< QString, QString > compressedMimeMap;
 
191
    static bool supportBzip = false;
 
192
    static bool supportXz = false;
 
193
    const QString app_gzip( QString::fromLatin1( "application/x-gzip" ) );
 
194
    const QString app_bzip( QString::fromLatin1( "application/x-bzip" ) );
 
195
    const QString app_xz( QString::fromLatin1( "application/x-xz" ) );
188
196
    if ( compressedMimeMap.isEmpty() )
189
197
    {
190
198
        std::auto_ptr< KFilterBase > f;
191
 
        compressedMimeMap[ QString::fromLatin1( "application/x-gzip" ) ] =
192
 
            QString::fromLatin1( "application/x-gzip" );
193
 
        compressedMimeMap[ QString::fromLatin1( "image/x-gzeps" ) ] =
194
 
            QString::fromLatin1( "application/x-gzip" );
 
199
        compressedMimeMap[ QString::fromLatin1( "image/x-gzeps" ) ] = app_gzip;
195
200
        // check we can read bzip2-compressed files
196
 
        f.reset( KFilterBase::findFilterByMimeType( QString::fromLatin1( "application/x-bzip" ) ) );
 
201
        f.reset( KFilterBase::findFilterByMimeType( app_bzip ) );
197
202
        if ( f.get() )
198
203
        {
199
 
            const QString app_bzip( QString::fromLatin1( "application/x-bzip" ) );
200
 
            compressedMimeMap[ app_bzip ] = app_bzip;
 
204
            supportBzip = true;
201
205
            compressedMimeMap[ QString::fromLatin1( "application/x-bzpdf" ) ] = app_bzip;
202
206
            compressedMimeMap[ QString::fromLatin1( "application/x-bzpostscript" ) ] = app_bzip;
203
207
            compressedMimeMap[ QString::fromLatin1( "application/x-bzdvi" ) ] = app_bzip;
204
208
            compressedMimeMap[ QString::fromLatin1( "image/x-bzeps" ) ] = app_bzip;
205
209
        }
206
210
        // check we can read XZ-compressed files
207
 
        f.reset( KFilterBase::findFilterByMimeType( QString::fromLatin1( "application/x-xz" ) ) );
 
211
        f.reset( KFilterBase::findFilterByMimeType( app_xz ) );
208
212
        if ( f.get() )
209
213
        {
210
 
            const QString app_xz( QString::fromLatin1( "application/x-xz" ) );
211
 
            compressedMimeMap[ app_xz ] = app_xz;
 
214
            supportXz = true;
212
215
        }
213
216
    }
214
217
    QHash< QString, QString >::const_iterator it = compressedMimeMap.constFind( mime_to_check );
215
218
    if ( it != compressedMimeMap.constEnd() )
216
219
        return it.value();
217
220
 
 
221
    KMimeType::Ptr mime = KMimeType::mimeType( mime_to_check );
 
222
    if ( mime->is( app_gzip ) )
 
223
        return app_gzip;
 
224
    else if ( supportBzip && mime->is( app_bzip ) )
 
225
        return app_bzip;
 
226
    else if ( supportXz && mime->is( app_xz ) )
 
227
        return app_xz;
 
228
 
218
229
    return QString();
219
230
}
220
231