void DolphinView::updateURL() { KFileView* fileView = (m_iconsView != 0) ? static_cast<KFileView*>(m_iconsView) : static_cast<KFileView*>(m_detailsView); KFileItem* fileItem = fileView->currentFileItem(); if (fileItem == 0) { return; } if (fileItem->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(fileItem->localPath()); if (localPath.isEmpty()) { setURL(fileItem->url()); } else { setURL(KURL(localPath)); } } else if (fileItem->isFile()) { // allow to browse through ZIP and tar files KMimeType::Ptr mime = fileItem->mimeTypePtr(); if (mime->is("application/x-zip")) { KURL url = fileItem->url(); 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")) { KURL url = fileItem->url(); url.setProtocol("tar"); setURL(url); } else { fileItem->run(); } } else { fileItem->run(); } }
KFileItem * KCombiView::currentFileItem() const { // we can actually have two current items, one in each view. So we simply // prefer the fileview's item over the directory's. // Smarter: if the right view has focus, prefer that over the left. if ( !right ) return left->currentFileItem(); KFileView *preferredView = focusView( right ); KFileItem *item = preferredView->currentFileItem(); if ( !item && preferredView != left ) item = left->currentFileItem(); return item; }