~ubuntu-branches/ubuntu/maverick/asc/maverick

« back to all changes in this revision

Viewing changes to source/widgets/autoprogressbar.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Barry deFreese, Eddy Petrișor, Gonéri Le Bouder, Cyril Brulebois, Barry deFreese
  • Date: 2008-01-08 19:54:18 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20080108195418-n19fc4eobhhqxcy5
Tags: 2.0.1.0-1
[ Eddy Petrișor ]
* fixed Homepage semifield

[ Gonéri Le Bouder ]
* add a watchfile
* move homepage from the description to the new Homepage field

[ Cyril Brulebois ]
* Added Vcs-Svn and Vcs-Browser fields in the control file.

[ Barry deFreese ]
* Fix make-clean lintian warning
* New upstream release
* Bump debhelper build-dep to match compat
* Add desktop file
* Update watch file for new upstream naming
* Remove nostrip check from rules
* Bump Standards Version to 3.7.3
* Add myself to uploaders

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/***************************************************************************
 
3
 *                                                                         *
 
4
 *   This program is free software; you can redistribute it and/or modify  *
 
5
 *   it under the terms of the GNU General Public License as published by  *
 
6
 *   the Free Software Foundation; either version 2 of the License, or     *
 
7
 *   (at your option) any later version.                                   *
 
8
 *                                                                         *
 
9
 ***************************************************************************/
 
10
 
 
11
#include "autoprogressbar.h"
 
12
 
 
13
#include <pgapplication.h>
 
14
#include "../events.h"
 
15
 
 
16
#include "../basestrm.h"
 
17
 
 
18
void AutoProgressBar :: tick()
 
19
{
 
20
 
 
21
   newTickTimes.push_back ( ticker - starttime );
 
22
 
 
23
   // limit to 25 Hz to reduce graphic updates
 
24
   if ( lastdisplaytime + 4 < ticker ) {
 
25
      double p;
 
26
      // double p = double(ticker - starttime) * 100  / time;
 
27
      if ( counter < prevTickTimes.size() && time ) {
 
28
         int a = prevTickTimes[counter];
 
29
         p = 100 * a / time;
 
30
      } else
 
31
         p = counter / 100;
 
32
 
 
33
         if ( p > 99 )
 
34
            p = 99;
 
35
 
 
36
         SetProgress( p );
 
37
         lastdisplaytime = ticker;
 
38
   }
 
39
 
 
40
   ++counter;
 
41
 
 
42
 
 
43
   lastticktime = ticker;
 
44
};
 
45
 
 
46
AutoProgressBar :: AutoProgressBar( SigC::Signal0<void>& tickSignal, PG_Widget *parent, const PG_Rect &r, const std::string &style ) : PG_ProgressBar( parent, r, style ), lastticktime(-1), counter(0)
 
47
{
 
48
   lastdisplaytime = starttime = ticker;
 
49
 
 
50
   tickSignal.connect( SigC::slot( *this, &AutoProgressBar::tick ));
 
51
 
 
52
   try {
 
53
      tnfilestream stream ( "progress.dat", tnstream::reading  );
 
54
      stream.readInt(); // version
 
55
      time = stream.readInt( );
 
56
      readClassContainer( prevTickTimes, stream );
 
57
   }
 
58
   catch ( ... ) {
 
59
      time = 200;
 
60
   };
 
61
};
 
62
 
 
63
void AutoProgressBar :: close( )
 
64
{
 
65
   try {
 
66
      tnfilestream stream ( "progress.dat", tnstream::writing  );
 
67
      stream.writeInt( 1 );
 
68
      stream.writeInt( lastticktime - starttime );
 
69
      writeClassContainer( newTickTimes, stream );
 
70
   }
 
71
   catch ( ... ) {
 
72
   }
 
73
}
 
74