34 #include "progressbar.h"
39 static const int busyTimerTickInterval = 100;
40 static const int busyTimerTickIncrement = 5;
42 Kleo::ProgressBar::ProgressBar( TQWidget * parent,
const char * name, WFlags f )
43 : TQProgressBar( 0, parent, name, f ),
46 mBusyTimer =
new TQTimer(
this );
47 connect( mBusyTimer, TQ_SIGNAL(timeout()), TQ_SLOT(slotBusyTimerTick()) );
51 void Kleo::ProgressBar::slotProgress(
const TQString &,
int cur,
int tot ) {
55 void Kleo::ProgressBar::slotProgress(
const TQString &,
int,
int cur,
int tot ) {
56 setProgress( cur, tot );
60 kdDebug() <<
"Kleo::ProgressBar::setTotalSteps( " << total <<
" )" << endl;
61 if ( total == totalSteps() )
63 TQProgressBar::setTotalSteps( 0 );
68 kdDebug() <<
"Kleo::ProgressBar::setProgress( " << p <<
" )" << endl;
78 void Kleo::ProgressBar::slotBusyTimerTick() {
80 if ( mBusyTimer->isActive() )
81 TQProgressBar::setProgress( TQProgressBar::progress() + busyTimerTickIncrement );
84 void Kleo::ProgressBar::fixup(
bool newValue ) {
85 const int cur = TQProgressBar::progress();
86 const int tot = TQProgressBar::totalSteps();
88 kdDebug() <<
"Kleo::ProgressBar::startStopBusyTimer() cur = " << cur <<
"; tot = " << tot <<
"; real = " << mRealProgress << endl;
90 if ( ( newValue && mRealProgress < 0 ) || ( !newValue && cur < 0 ) ) {
91 kdDebug() <<
"(new value) switch to reset" << endl;
94 TQProgressBar::reset();
96 }
else if ( tot == 0 ) {
97 kdDebug() <<
"(new value) switch or stay in busy" << endl;
98 if ( !mBusyTimer->isActive() ) {
99 mBusyTimer->start( busyTimerTickInterval );
101 TQProgressBar::setProgress( mRealProgress );
104 kdDebug() <<
"(new value) normal progress" << endl;
106 if ( TQProgressBar::progress() != mRealProgress )
107 TQProgressBar::setProgress( mRealProgress );
111 #include "progressbar.moc"
void setProgress(int progress)
void setTotalSteps(int total)