[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/stable/extragear/network/ktorrent
From:       Joris Guisson <joris.guisson () gmail ! com>
Date:       2005-10-08 8:53:25
Message-ID: 1128761605.928567.24537.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 468469 by guisson:

Added better estimation of download time (Ivan)

 M  +15 -15    ktorrent.kdevelop  
 M  +23 -9     src/ktorrentviewitem.cpp  


--- branches/stable/extragear/network/ktorrent/ktorrent.kdevelop #468468:468469
@@ -14,7 +14,7 @@
     </keywords>
     <projectdirectory>.</projectdirectory>
     <absoluteprojectpath>false</absoluteprojectpath>
-    <description/>
+    <description></description>
     <ignoreparts/>
     <versioncontrol>kdevsubversion</versioncontrol>
   </general>
@@ -59,21 +59,21 @@
         <cxxflags>-O2 -g0</cxxflags>
       </optimized>
       <debug>
-        <configargs>--enable-debug=full --enable-profile</configargs>
+        <configargs>--enable-debug=full</configargs>
         <builddir>debug</builddir>
         <ccompiler>kdevgccoptions</ccompiler>
         <cxxcompiler>kdevgppoptions</cxxcompiler>
         <f77compiler>kdevg77options</f77compiler>
         <cxxflags>-O0 -g3</cxxflags>
         <envvars/>
-        <topsourcedir/>
-        <cppflags/>
-        <ldflags/>
-        <ccompilerbinary/>
-        <cxxcompilerbinary/>
-        <f77compilerbinary/>
-        <cflags/>
-        <f77flags/>
+        <topsourcedir></topsourcedir>
+        <cppflags></cppflags>
+        <ldflags></ldflags>
+        <ccompilerbinary></ccompilerbinary>
+        <cxxcompilerbinary></cxxcompilerbinary>
+        <f77compilerbinary></f77compilerbinary>
+        <cflags></cflags>
+        <f77flags></f77flags>
       </debug>
     </configurations>
     <subclassing>
@@ -139,14 +139,14 @@
     <general>
       <dbgshell>libtool</dbgshell>
       <programargs>--nofork --debug</programargs>
-      <gdbpath/>
+      <gdbpath></gdbpath>
       <breakonloadinglibs>true</breakonloadinglibs>
       <separatetty>false</separatetty>
       <floatingtoolbar>false</floatingtoolbar>
       <runappinappdirectory>true</runappinappdirectory>
-      <configGdbScript/>
-      <runShellScript/>
-      <runGdbScript/>
+      <configGdbScript></configGdbScript>
+      <runShellScript></runShellScript>
+      <runGdbScript></runGdbScript>
     </general>
     <display>
       <staticmembers>false</staticmembers>
@@ -224,7 +224,7 @@
       <headerCompletionDelay>250</headerCompletionDelay>
     </codecompletion>
     <creategettersetter>
-      <prefixGet/>
+      <prefixGet></prefixGet>
       <prefixSet>set</prefixSet>
       <prefixVariable>m_,_</prefixVariable>
       <parameterName>theValue</parameterName>
--- branches/stable/extragear/network/ktorrent/src/ktorrentviewitem.cpp #468468:468469
@@ -118,17 +118,31 @@
 	{
 		setText(7,i18n("finished"));
 	}
-	else if (tc->getDownloadRate() != 0)
+	else 
 	{
-		Uint32 secs = (int)floor((float)tc->getBytesLeft() / (float)tc->getDownloadRate());
-		QTime t;
-		t = t.addSecs(secs);
-		setText(7,loc->formatTime(t,true,true));
+		float bytes_downloaded = (float)tc->getBytesDownloaded();
+		if( bytes_downloaded < 1 ) //if we just started download use old algorithm
+		{
+			if (tc->getDownloadRate() == 0)
+				setText(7,i18n("infinity"));
+			else
+			{
+				Uint32 secs = (int)floor( (float)tc->getBytesLeft() / (float)tc->getDownloadRate() );
+				QTime t;
+				t = t.addSecs(secs);
+				setText(7,loc->formatTime(t,true,true));
+			}
+		}
+		else 
+		{
+			double avg_speed = (double)bytes_downloaded / (double)tc->getRunningTimeDL();
+			double eta = tc->getBytesLeft() / avg_speed;
+			QTime t;
+			t = t.addSecs((int)floor(eta));
+			setText(7,loc->formatTime(t,true,true));
+		}
 	}
-	else
-	{
-		setText(7,i18n("infinity"));
-	}
+	
 	setText(8,QString::number(tc->getNumPeers()));
 
 	double perc = 0;
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic