Add support for lzipped archives
ClosedPublic

Authored by rthomsen on Mar 9 2016, 8:50 PM.

Details

Summary

This diff enables readwrite support for lzipped archives in the libarchive plugin. Lzip is a file compressor and is usually used in combination with tar.

One issue:
lzip does not have a "tar.lz"-mimetype but only a "lz" mimetype (application/x-lzip). This means that when creating a new archive, the dropdown menu only shows the extention .lz, but libarchive actually creates a tar.lz archive. Do we want to add an exception and force a tar.lz filter in CreateDialog?

LZip website

Bug 209418

Diff Detail

Repository
R36 Ark
Lint
Lint Skipped
Unit
Unit Tests Skipped
rthomsen updated this revision to Diff 2651.Mar 9 2016, 8:50 PM
rthomsen retitled this revision from to Add support for lzipped archives.
rthomsen updated this object.
rthomsen edited the test plan for this revision. (Show Details)
rthomsen added a reviewer: elvisangelaccio.
rthomsen set the repository for this revision to R36 Ark.
rthomsen added a project: Ark.
Restricted Application added a subscriber: kde-utils-devel. · View Herald TranscriptMar 9 2016, 8:50 PM
rthomsen updated this object.Mar 9 2016, 9:02 PM
rthomsen updated this object.Mar 9 2016, 9:09 PM
elvisangelaccio accepted this revision.Mar 9 2016, 9:21 PM
elvisangelaccio edited edge metadata.

Let's go with the exception in CreateDialog!

This revision is now accepted and ready to land.Mar 9 2016, 9:21 PM
rthomsen updated this revision to Diff 2677.Mar 10 2016, 8:13 PM
rthomsen edited edge metadata.

Changed CreateDialog to be able to modify the comment and glob pattern for lzip archives. We now use KFileWidget::setFilter() instead of KFileWidget::setMimeFilter() to populate the filterlist. This allows more flexibility in adding archive types to the list.

It is now possible to modify the filterlist, so we can support archives with no mimetype in shared-mime-info. Also, now the primary glob pattern is visible in the dropdown menu of CreateDialog.

elvisangelaccio requested changes to this revision.Mar 10 2016, 9:04 PM
elvisangelaccio edited edge metadata.
elvisangelaccio added inline comments.
autotests/kerfuffle/archivetest.cpp
286

QString() instead of QStringLiteral(""), same for the other occurrences below.

kerfuffle/createdialog.cpp
254

Opening brace after the new line, same for CreateDialog::currentFilterMimeType()

kerfuffle/createdialog.h
53

Since these are public, better not use the m_ prefix scheme.

81

Missing const.

82

If this function accepted a QString with the name() of the mimetype, the patch would be a bit simpler:

  • The mimetype is already saved as string in arkrc
  • No need to use the QMimeDatabase in the tests or in other places
This revision now requires changes to proceed.Mar 10 2016, 9:04 PM
rthomsen updated this revision to Diff 2684.Mar 10 2016, 9:30 PM
rthomsen edited edge metadata.

Implement Elvis' suggestions.

Fix filtermenu being editable by user.

rthomsen marked 5 inline comments as done.Mar 10 2016, 9:31 PM
elvisangelaccio requested changes to this revision.Mar 10 2016, 9:46 PM
elvisangelaccio edited edge metadata.

Sorry, didn't notice this earlier. We're almost done :)

autotests/kerfuffle/createdialogtest.cpp
71 ↗(On Diff #2684)

This slot is now basically useless outside of CreateDialog. It makes more sense to have it called from setCurrentFilterFromMimeType() instead.
This way you can remove all the calls to slotFilterChanged(QStringLiteral("")) in the test.

This revision now requires changes to proceed.Mar 10 2016, 9:46 PM
rthomsen added inline comments.Mar 10 2016, 9:58 PM
autotests/kerfuffle/createdialogtest.cpp
71 ↗(On Diff #2684)

Yeah, there is something strange about this. When I run Ark normally and open the CreateDialog, calling setCurrentFilterFromMimeType() will emit the filterChanged() signal and hence call slotFilterChanged(). This does not happen when calling setCurrentFilterFromMimeType() from the tests and therefore I added the direct calls to slotFilterChanged() in the tests.

So making setCurrentFilterFromMimeType() call slotFilterChanged() will result in slotFilterChanged() being called twice normally.

autotests/kerfuffle/createdialogtest.cpp
71 ↗(On Diff #2684)

I think we should try to connect to the currentIndexChanged signal instead. That's the one emitted when setting the index within setCurrentFilterFromMimeType().

kerfuffle/createdialog.cpp
311 ↗(On Diff #2684)

Would be better to use QStringLiteral("%1 (%2)\n").arg(...) here.

rthomsen updated this revision to Diff 2694.EditedMar 11 2016, 7:13 AM
rthomsen edited edge metadata.

Implement Elvis' suggestions.

We now connect the KFileFilterCombo::currentIndexChanged() signal instead of KFileWidget::currentFilterChanged(). The currentIndexChanged() signal is overloaded and can send both an int and QString, so the conect syntax is slightly more complex. OTOH we can get rid of the direct slotCurrentFilterChanged() calls in the CreateDialogTest and also we pass an int now with the signal so we can actually use it and save a currentFilterMimeType() call in slotFilterChanged(). slotFilterChanged() was changed from public to protected.

Also renamed updateDefaultMimeType() to slotUdateDefaultMimeType() to be consistent.

rthomsen marked 2 inline comments as done.Mar 11 2016, 7:35 AM
elvisangelaccio accepted this revision.Mar 11 2016, 9:41 AM
elvisangelaccio edited edge metadata.

Thanks! Now is really good to go :)

kerfuffle/createdialog.cpp
309

Is the | character a typo? (btw it does not show up in the UI...)

This revision is now accepted and ready to land.Mar 11 2016, 9:41 AM
rthomsen marked an inline comment as done.Mar 11 2016, 12:16 PM
rthomsen added inline comments.
kerfuffle/createdialog.cpp
309

No, the combined filterstring needs to be constructed like this:
"*.tar.gz *.tgz|Tar archive (gzip-compressed) (*.tar.gz)"
for each line. So the glob patterns before the "|" are the ones the KFileWidget uses to filter the files, while whatever comes after the "|" is displayed in the dropdown menu.

This revision was automatically updated to reflect the committed changes.
rthomsen marked an inline comment as done.