Bug 140040

Summary: open file from 'Files' tab
Product: [Applications] ktorrent Reporter: Becheru Petru-Ioan <becheru.petru.ioan>
Component: generalAssignee: Joris Guisson <joris.guisson>
Status: RESOLVED FIXED    
Severity: wishlist    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: unspecified   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Becheru Petru-Ioan 2007-01-14 00:53:45 UTC
Version:           2.1beta1 (using KDE 3.5.5, Debian Package 4:3.5.5a.dfsg.1-5 (4.0))
Compiler:          Target: i486-linux-gnu
OS:                Linux (i686) release 2.6.18-3-k7

I would like to be able to open a file (even partially downloaded ones) from the 'Files' tab by double clicking them. It exists a similar function that allows to (pre)view a video file.
Comment 1 Joris Guisson 2007-06-30 12:21:36 UTC
SVN commit 681804 by guisson:

Double clicking on files in file tab, opens them.

BUG: 140040



 M  +5 -2      ChangeLog  
 M  +33 -0     plugins/infowidget/fileview.cpp  
 M  +1 -0      plugins/infowidget/fileview.h  


--- branches/extragear/kde3/network/ktorrent/ChangeLog #681803:681804
@@ -1,10 +1,13 @@
-Changes in 2.2dev
+Changes in 2.2 :
+- Allow user to create torrents without tracker 
+- Double clicking on files in files tab opens them
+
+Changes in 2.2rc1
 - Revamped plugin settings page, looks much nicer now.
 - Scan dialog now has only one button cancel, which becomes close when the
 scan is finished
 - Add max seed time feature
 - Add download and seed time columns in view
-- Allow user to create torrents without tracker 
 
 Changes in 2.2beta1
 - Ditch KMDI in favor of KDevelop IDEA code
--- branches/extragear/kde3/network/ktorrent/plugins/infowidget/fileview.cpp #681803:681804
@@ -29,6 +29,7 @@
 #include <interfaces/functions.h>
 #include <interfaces/torrentinterface.h>
 #include <interfaces/torrentfileinterface.h>
+#include <qfileinfo.h>
 #include "functions.h"
 #include "iwfiletreeitem.h"
 #include "iwfiletreediritem.h"
@@ -72,6 +73,8 @@
 		connect(this,SIGNAL(contextMenu(KListView*, QListViewItem*, const QPoint& )),
 				this,SLOT(showContextMenu(KListView*, QListViewItem*, const QPoint& )));
 		connect(context_menu, SIGNAL ( activated ( int ) ), this, SLOT ( contextItem ( int ) ) );
+		connect(this,SIGNAL(doubleClicked( QListViewItem*, const QPoint&, int )),
+				this,SLOT(onDoubleClicked(QListViewItem*, const QPoint&, int)));
 		
 		setEnabled(false);
 		
@@ -388,6 +391,36 @@
 		if (multi_root)
 			multi_root->updateDNDInformation();
 	}
+	
+	void FileView::onDoubleClicked(QListViewItem* item,const QPoint & ,int )
+	{
+		if (!curr_tc)
+			return;
+		
+		const TorrentStats & s = curr_tc->getStats();
+		
+		if (s.multi_file_torrent)
+		{
+			if (item->childCount() == 0)
+			{
+				// file
+				FileTreeItem* file = (FileTreeItem*)item;
+				QString path = "cache" + bt::DirSeparator() + file->getTorrentFile().getPath();
+				new KRun(KURL::fromPathOrURL(curr_tc->getTorDir() + path), 0, true, true);
+			}
+			else
+			{
+				// directory
+				FileTreeDirItem* dir = ((FileTreeDirItem*)item);
+				new KRun(KURL::fromPathOrURL(curr_tc->getTorDir() + "cache" + dir->getPath()), 0, true, true);
+			}
+		}
+		else
+		{
+			QFileInfo fi(curr_tc->getTorDir()+"cache");
+			new KRun(KURL::fromPathOrURL(fi.readLink()), 0, true, true);
+		}
+	}
 }
 
 #include "fileview.moc"
--- branches/extragear/kde3/network/ktorrent/plugins/infowidget/fileview.h #681803:681804
@@ -44,6 +44,7 @@
 		void contextItem(int id);
 		void showContextMenu(KListView* ,QListViewItem* item,const QPoint & p);
 		void refreshFileTree(kt::TorrentInterface* tc);
+		void onDoubleClicked(QListViewItem* item,const QPoint & ,int );
 		
 	private:
 		void fillFileTree();