Bug 145451

Summary: Patch for replacing "0 Kb/s" with empty string
Product: [Applications] ktorrent Reporter: twisted_fall <twisted.fall>
Component: generalAssignee: Joris Guisson <joris.guisson>
Status: RESOLVED FIXED    
Severity: wishlist    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: empty_string_when_zero_speed.patch

Description twisted_fall 2007-05-15 11:55:46 UTC
Version:           2.1.4 (using KDE KDE 3.5.6)
Installed from:    Gentoo Packages
OS:                Linux

It is quite uninformative for me to see all those 0 Kb/s in speed columns. Both BitComet and uTorrent do hide such values which results in cleaner view of torrent activity IMHO. I have made a patch that replaces all speed values that are less than 103 bytes/sec with an empty string. Patched are main ktorrent view and peer tab of info widget plugin.
Comment 1 twisted_fall 2007-05-15 11:56:34 UTC
Created attachment 20573 [details]
empty_string_when_zero_speed.patch
Comment 2 Joris Guisson 2007-05-15 20:13:57 UTC
SVN commit 665062 by guisson:

Added patch from twisted_fall, which doesn't show anything in speed columns if the speed is very low or 0

BUG: 145451


 M  +16 -6     apps/ktorrent/ktorrentviewitem.cpp  
 M  +1 -0      apps/ktorrent/main.cpp  
 M  +9 -3      plugins/infowidget/peerview.cpp  


--- trunk/extragear/network/ktorrent/apps/ktorrent/ktorrentviewitem.cpp #665061:665062
@@ -191,15 +191,25 @@
 	
 	if(m_parent->columnVisible(5))
 	{
-		if (s.bytes_left_to_download == 0)
-			setText(5,KBytesPerSecToString(0));
+		if (s.download_rate >= 103) // lowest "visible" speed, all below will be 0,0 Kb/s
+		{
+			if (s.bytes_left_to_download == 0)
+				setText(5,KBytesPerSecToString(0));
+			else
+				setText(5,KBytesPerSecToString(s.download_rate / 1024.0));
+		}
 		else
-			setText(5,KBytesPerSecToString(s.download_rate / 1024.0));
+			setText(5, "");
 	}
-	
+
 	if(m_parent->columnVisible(6))
-		setText(6,KBytesPerSecToString(s.upload_rate / 1024.0));
-  
+	{
+		if (s.upload_rate >= 103) // lowest "visible" speed, all below will be 0,0 Kb/s
+			setText(6,KBytesPerSecToString(s.upload_rate / 1024.0));
+		else
+			setText(6, "");
+	}
+
 	if(m_parent->columnVisible(7))
 	{
 		if (s.bytes_left_to_download == 0)
--- trunk/extragear/network/ktorrent/apps/ktorrent/main.cpp #665061:665062
@@ -150,6 +150,7 @@
 	about.addCredit("Goten Xiao",I18N_NOOP("Patch to load silently with a save location"),0);
 	about.addCredit("Rapsys",I18N_NOOP("Fixes in PHP code of webinterface"),0);
 	about.addCredit("Athantor",I18N_NOOP("XFS specific disk preallocation"),0);
+	about.addCredit("twisted_fall",I18N_NOOP("Patch to not show very low speeds"),"twisted.fall@gmail.com");
 
 	KCmdLineArgs::init(argc, argv, &about);
 	KCmdLineArgs::addCmdLineOptions(options);
--- trunk/extragear/network/ktorrent/plugins/infowidget/peerview.cpp #665061:665062
@@ -120,9 +120,15 @@
 	{
 		KLocale* loc = KGlobal::locale();
 		const PeerInterface::Stats & s = peer->getStats();
-		
-		setText(3,KBytesPerSecToString(s.download_rate / 1024.0));
-		setText(4,KBytesPerSecToString(s.upload_rate / 1024.0));
+
+		if (s.download_rate >= 103) // lowest "visible" speed, all below will be 0,0 Kb/s
+			setText(3,KBytesPerSecToString(s.download_rate / 1024.0));
+		else
+			setText(3, "");
+		if (s.upload_rate >= 103) // lowest "visible" speed, all below will be 0,0 Kb/s
+			setText(4,KBytesPerSecToString(s.upload_rate / 1024.0));
+		else
+			setText(4, "");
 		//setPixmap(5,!s.choked ? yes_pix : no_pix);
 		setText(5,s.choked ? i18n("Yes") : i18n("No"));
 		//setPixmap(6,!s.snubbed ? yes_pix : no_pix);