]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinview.cpp
Update of the patch from Filip Brcic for browsing through ZIP and TAR files. One...
[dolphin.git] / src / dolphinview.cpp
index 47c98f03fa95e5517ee4e4b54d18fb5fb776703f..3927d9c6d10749177b8e6a281889ed669b1265fd 100644 (file)
@@ -638,18 +638,40 @@ void DolphinView::triggerItem(const QModelIndex& index)
         return;
     }
 
+    // Prefer the local path over the URL. This assures that the
+    // volume space information is correct. Assuming that the URL is media:/sda1,
+    // and the local path is /windows/C: For the URL the space info is related
+    // to the root partition (and hence wrong) and for the local path the space
+    // info is related to the windows partition (-> correct).
+    const QString localPath(item->localPath());
+    KUrl url;
+    if (localPath.isEmpty()) {
+        url = item->url();
+    }
+    else {
+        url = localPath;
+    }
+
     if (item->isDir()) {
-        // Prefer the local path over the URL. This assures that the
-        // volume space information is correct. Assuming that the URL is media:/sda1,
-        // and the local path is /windows/C: For the URL the space info is related
-        // to the root partition (and hence wrong) and for the local path the space
-        // info is related to the windows partition (-> correct).
-        const QString localPath(item->localPath());
-        if (localPath.isEmpty()) {
-            setUrl(item->url());
+        setUrl(url);
+    }
+    else if (item->isFile()) {
+        // allow to browse through ZIP and tar files
+        KMimeType::Ptr mime = item->mimeTypePtr();
+        if (mime->is("application/x-zip")) {
+            url.setProtocol("zip");
+            setUrl(url);
+        }
+        else if (mime->is("application/x-tar") ||
+                 mime->is("application/x-tarz") ||
+                 mime->is("application/x-tbz") ||
+                 mime->is("application/x-tgz") ||
+                 mime->is("application/x-tzo")) {
+            url.setProtocol("tar");
+            setUrl(url);
         }
         else {
-            setUrl(KUrl(localPath));
+            item->run();
         }
     }
     else {