From: David Faure Date: Tue, 25 Mar 2008 21:39:05 +0000 (+0000) Subject: Use new key in .protocol files, archiveMimetype, to know which kioslave can handle... X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/6d425dcc662dceed364dbb336522779ec16f233f?ds=inline Use new key in .protocol files, archiveMimetype, to know which kioslave can handle which type of archive in a generic way. Used that in dolphin and in konqueror (and in the filetypes config module, to show the right default value for those mimetypes). This way Urs can extend this mechanism with the p7zip kioslave in the future. CCMAIL: uwolfer@kde.org, peter.penz@gmx.at svn path=/trunk/KDE/kdebase/apps/; revision=790102 --- diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp index 237aa19f5..6fcdb7dec 100644 --- a/src/dolphinviewcontainer.cpp +++ b/src/dolphinviewcontainer.cpp @@ -18,6 +18,7 @@ ***************************************************************************/ #include "dolphinviewcontainer.h" +#include #include #include @@ -400,25 +401,16 @@ void DolphinViewContainer::slotItemTriggered(const KFileItem& item) } const GeneralSettings* settings = DolphinSettings::instance().generalSettings(); - const bool browseThroughArchives = settings->browseThroughArchives() && - item.isFile() && url.isLocalFile(); - if (browseThroughArchives) { - KMimeType::Ptr mime = item.mimeTypePtr(); - - // Don't use mime->is("application/zip"), as this would - // also browse through Open Office files: - if (mime->name() == "application/zip") { - url.setProtocol("zip"); - m_view->setUrl(url); - return; - } - - if (mime->is("application/x-tar") || - mime->is("application/x-tarz") || - mime->is("application/x-bzip-compressed-tar") || - mime->is("application/x-compressed-tar") || - mime->is("application/x-tzo")) { - url.setProtocol("tar"); + const bool browseThroughArchives = settings->browseThroughArchives(); + if (browseThroughArchives && item.isFile() && url.isLocalFile()) { + // Generic mechanism for redirecting to tar:// when clicking on a tar file, + // zip:// when clicking on a zip file, etc. + // The .protocol file specifies the mimetype that the kioslave handles. + // Note that we don't use mimetype inheritance since we don't want to + // open OpenDocument files as zip folders... + const QString protocol = KProtocolManager::protocolForArchiveMimetype(item.mimetype()); + if (!protocol.isEmpty()) { + url.setProtocol(protocol); m_view->setUrl(url); return; }