Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Graphics
Okular
Commits
c8e3c0eb
Commit
c8e3c0eb
authored
Jul 11, 2016
by
Martin Tobias Holmedahl Sandsmark
Browse files
Port part away from deprecated KArchive methods
parent
b51d4959
Changes
2
Hide whitespace changes
Inline
Side-by-side
part.cpp
View file @
c8e3c0eb
...
...
@@ -170,12 +170,12 @@ static QAction* actionForExportFormat( const Okular::ExportFormat& format, QObje
return
act
;
}
static
QString
compress
edMim
eFor
(
const
QString
&
mime_to_check
)
static
KFilterDev
::
CompressionType
compress
ionTyp
eFor
(
const
QString
&
mime_to_check
)
{
// The compressedMimeMap is here in case you have a very old shared mime database
// that doesn't have inheritance info for things like gzeps, etc
// Otherwise the "is()" calls below are just good enough
static
QHash
<
QString
,
QString
>
compressedMimeMap
;
static
QHash
<
QString
,
KFilterDev
::
CompressionType
>
compressedMimeMap
;
static
bool
supportBzip
=
false
;
static
bool
supportXz
=
false
;
const
QString
app_gzip
(
QStringLiteral
(
"application/x-gzip"
)
);
...
...
@@ -184,16 +184,16 @@ static QString compressedMimeFor( const QString& mime_to_check )
if
(
compressedMimeMap
.
isEmpty
()
)
{
std
::
unique_ptr
<
KFilterBase
>
f
;
compressedMimeMap
[
QLatin1String
(
"image/x-gzeps"
)
]
=
app_gz
ip
;
compressedMimeMap
[
QLatin1String
(
"image/x-gzeps"
)
]
=
KFilterDev
::
GZ
ip
;
// check we can read bzip2-compressed files
f
.
reset
(
KCompressionDevice
::
filterForCompressionType
(
KCompressionDevice
::
BZip2
)
);
if
(
f
.
get
()
)
{
supportBzip
=
true
;
compressedMimeMap
[
QLatin1String
(
"application/x-bzpdf"
)
]
=
app_bz
ip
;
compressedMimeMap
[
QLatin1String
(
"application/x-bzpostscript"
)
]
=
app_bz
ip
;
compressedMimeMap
[
QLatin1String
(
"application/x-bzdvi"
)
]
=
app_bz
ip
;
compressedMimeMap
[
QLatin1String
(
"image/x-bzeps"
)
]
=
app_bz
ip
;
compressedMimeMap
[
QLatin1String
(
"application/x-bzpdf"
)
]
=
KFilterDev
::
BZ
ip
2
;
compressedMimeMap
[
QLatin1String
(
"application/x-bzpostscript"
)
]
=
KFilterDev
::
BZ
ip
2
;
compressedMimeMap
[
QLatin1String
(
"application/x-bzdvi"
)
]
=
KFilterDev
::
BZ
ip
2
;
compressedMimeMap
[
QLatin1String
(
"image/x-bzeps"
)
]
=
KFilterDev
::
BZ
ip
2
;
}
// check if we can read XZ-compressed files
f
.
reset
(
KCompressionDevice
::
filterForCompressionType
(
KCompressionDevice
::
Xz
)
);
...
...
@@ -202,7 +202,7 @@ static QString compressedMimeFor( const QString& mime_to_check )
supportXz
=
true
;
}
}
QHash
<
QString
,
QString
>::
const_iterator
it
=
compressedMimeMap
.
constFind
(
mime_to_check
);
QHash
<
QString
,
KFilterDev
::
CompressionType
>::
const_iterator
it
=
compressedMimeMap
.
constFind
(
mime_to_check
);
if
(
it
!=
compressedMimeMap
.
constEnd
()
)
return
it
.
value
();
...
...
@@ -211,14 +211,14 @@ static QString compressedMimeFor( const QString& mime_to_check )
if
(
mime
.
isValid
()
)
{
if
(
mime
.
inherits
(
app_gzip
)
)
return
app_gz
ip
;
return
KFilterDev
::
GZ
ip
;
else
if
(
supportBzip
&&
mime
.
inherits
(
app_bzip
)
)
return
app_bz
ip
;
return
KFilterDev
::
BZ
ip
2
;
else
if
(
supportXz
&&
mime
.
inherits
(
app_xz
)
)
return
app_x
z
;
return
KFilterDev
::
X
z
;
}
return
QString
()
;
return
KFilterDev
::
None
;
}
static
Okular
::
EmbedMode
detectEmbedMode
(
QWidget
*
parentWidget
,
QObject
*
parent
,
const
QVariantList
&
args
)
...
...
@@ -1227,11 +1227,11 @@ Document::OpenResult Part::doOpenFile( const QMimeType &mimeA, const QString &fi
bool
uncompressOk
=
true
;
QMimeType
mime
=
mimeA
;
QString
fileNameToOpen
=
fileNameToOpenA
;
QString
compress
edMim
e
=
compress
edMim
eFor
(
mime
.
name
()
);
if
(
!
compress
edMime
.
isEmpty
()
)
KFilterDev
::
CompressionType
compress
ionTyp
e
=
compress
ionTyp
eFor
(
mime
.
name
()
);
if
(
compress
ionType
!=
KFilterDev
::
None
)
{
*
isCompressedFile
=
true
;
uncompressOk
=
handleCompressed
(
fileNameToOpen
,
localFilePath
(),
compress
edMim
e
);
uncompressOk
=
handleCompressed
(
fileNameToOpen
,
localFilePath
(),
compress
ionTyp
e
);
mime
=
db
.
mimeTypeForFile
(
fileNameToOpen
);
}
else
...
...
@@ -2864,7 +2864,7 @@ void Part::unsetDummyMode()
}
bool
Part
::
handleCompressed
(
QString
&
destpath
,
const
QString
&
path
,
const
QString
&
compress
edMimet
ype
)
bool
Part
::
handleCompressed
(
QString
&
destpath
,
const
QString
&
path
,
KFilterDev
::
CompressionType
compress
ionT
ype
)
{
m_tempfile
=
0
;
...
...
@@ -2884,14 +2884,9 @@ bool Part::handleCompressed( QString &destpath, const QString &path, const QStri
}
// decompression filer
QIODevice
*
filterDev
=
KFilterDev
::
deviceForFile
(
path
,
compressedMimetype
);
if
(
!
filterDev
)
{
delete
newtempfile
;
return
false
;
}
KCompressionDevice
dev
(
path
,
compressionType
);
if
(
!
filterDev
->
open
(
QIODevice
::
ReadOnly
)
)
if
(
!
dev
.
open
(
QIODevice
::
ReadOnly
)
)
{
KMessageBox
::
detailedError
(
widget
(),
i18n
(
"<qt><strong>File Error!</strong> Could not open the file "
...
...
@@ -2903,7 +2898,6 @@ bool Part::handleCompressed( QString &destpath, const QString &path, const QStri
"right-click on the file in the Dolphin "
"file manager and then choose the 'Properties' tab.</qt>"
));
delete
filterDev
;
delete
newtempfile
;
return
false
;
}
...
...
@@ -2911,13 +2905,12 @@ bool Part::handleCompressed( QString &destpath, const QString &path, const QStri
char
buf
[
65536
];
int
read
=
0
,
wrtn
=
0
;
while
((
read
=
filterDev
->
read
(
buf
,
sizeof
(
buf
)))
>
0
)
while
((
read
=
dev
.
read
(
buf
,
sizeof
(
buf
)))
>
0
)
{
wrtn
=
newtempfile
->
write
(
buf
,
read
);
if
(
read
!=
wrtn
)
break
;
}
delete
filterDev
;
if
((
read
!=
0
)
||
(
newtempfile
->
size
()
==
0
))
{
KMessageBox
::
detailedError
(
widget
(),
...
...
part.h
View file @
c8e3c0eb
...
...
@@ -19,6 +19,7 @@
#include
<kparts/readwritepart.h>
#include
<kpluginfactory.h>
#include
<kmessagewidget.h>
#include
<KCompressionDevice>
#include
<qicon.h>
#include
<qlist.h>
#include
<qpointer.h>
...
...
@@ -246,7 +247,7 @@ class OKULARPART_EXPORT Part : public KParts::ReadWritePart, public Okular::Docu
void
setupPrint
(
QPrinter
&
printer
);
void
doPrint
(
QPrinter
&
printer
);
bool
handleCompressed
(
QString
&
destpath
,
const
QString
&
path
,
const
QString
&
compress
edMimet
ype
);
bool
handleCompressed
(
QString
&
destpath
,
const
QString
&
path
,
KCompressionDevice
::
CompressionType
compress
ionT
ype
);
void
rebuildBookmarkMenu
(
bool
unplugActions
=
true
);
void
updateAboutBackendAction
();
void
unsetDummyMode
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment