]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Use new key in .protocol files, archiveMimetype, to know which kioslave can handle...
authorDavid Faure <faure@kde.org>
Tue, 25 Mar 2008 21:39:05 +0000 (21:39 +0000)
committerDavid Faure <faure@kde.org>
Tue, 25 Mar 2008 21:39:05 +0000 (21:39 +0000)
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

src/dolphinviewcontainer.cpp

index 237aa19f50e621caaeb19f0439939f22a7f59359..6fcdb7deca075ec2956301e83cfedca465118d3a 100644 (file)
@@ -18,6 +18,7 @@
  ***************************************************************************/
 
 #include "dolphinviewcontainer.h"
+#include <kprotocolmanager.h>
 
 #include <QtGui/QApplication>
 #include <QtGui/QClipboard>
@@ -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:/<path>/ when clicking on a tar file,
+        // zip:/<path>/ 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;
         }