@ -51,6 +51,14 @@
# endif
# endif
# include <limits.h>
# include <limits.h>
class TQProgressBarPrivate
{
public :
TQProgressBarPrivate ( ) : last_painted_progress ( 0 ) { }
int last_painted_progress ;
} ;
/*!
/*!
\ class TQProgressBar ntqprogressbar . h
\ class TQProgressBar ntqprogressbar . h
\ brief The TQProgressBar widget provides a horizontal progress bar .
\ brief The TQProgressBar widget provides a horizontal progress bar .
@ -103,7 +111,7 @@ TQProgressBar::TQProgressBar( TQWidget *parent, const char *name, WFlags f )
center_indicator ( TRUE ) ,
center_indicator ( TRUE ) ,
auto_indicator ( TRUE ) ,
auto_indicator ( TRUE ) ,
percentage_visible ( TRUE ) ,
percentage_visible ( TRUE ) ,
d ( 0 ) ,
d ( new TQProgressBarPrivate ) ,
m_orientation ( Horizontal )
m_orientation ( Horizontal )
{
{
setSizePolicy ( TQSizePolicy ( TQSizePolicy : : Expanding , TQSizePolicy : : Fixed ) ) ;
setSizePolicy ( TQSizePolicy ( TQSizePolicy : : Expanding , TQSizePolicy : : Fixed ) ) ;
@ -135,7 +143,7 @@ TQProgressBar::TQProgressBar( int totalSteps,
center_indicator ( TRUE ) ,
center_indicator ( TRUE ) ,
auto_indicator ( TRUE ) ,
auto_indicator ( TRUE ) ,
percentage_visible ( TRUE ) ,
percentage_visible ( TRUE ) ,
d ( 0 ) ,
d ( new TQProgressBarPrivate ) ,
m_orientation ( Horizontal )
m_orientation ( Horizontal )
{
{
setSizePolicy ( TQSizePolicy ( TQSizePolicy : : Expanding , TQSizePolicy : : Fixed ) ) ;
setSizePolicy ( TQSizePolicy ( TQSizePolicy : : Expanding , TQSizePolicy : : Fixed ) ) ;
@ -143,6 +151,16 @@ TQProgressBar::TQProgressBar( int totalSteps,
}
}
/*!
Destroys the object and frees any allocated ressources .
*/
TQProgressBar : : ~ TQProgressBar ( )
{
delete d ;
}
/*!
/*!
Reset the progress bar . The progress bar " rewinds " and shows no
Reset the progress bar . The progress bar " rewinds " and shows no
progress .
progress .
@ -194,11 +212,16 @@ void TQProgressBar::setProgress( int progress )
progress < 0 | | ( ( progress > total_steps ) & & total_steps ) )
progress < 0 | | ( ( progress > total_steps ) & & total_steps ) )
return ;
return ;
const bool needRepaint = isVisible ( ) & & requireRepaint ( progress ) ;
progress_val = progress ;
progress_val = progress ;
setIndicator ( progress_str , progress_val , total_steps ) ;
setIndicator ( progress_str , progress_val , total_steps ) ;
repaint ( FALSE ) ;
if ( needRepaint ) {
repaint ( FALSE ) ;
d - > last_painted_progress = progress ;
}
# if defined(QT_ACCESSIBILITY_SUPPORT)
# if defined(QT_ACCESSIBILITY_SUPPORT)
TQAccessible : : updateAccessibility ( this , 0 , TQAccessible : : ValueChanged ) ;
TQAccessible : : updateAccessibility ( this , 0 , TQAccessible : : ValueChanged ) ;
@ -330,6 +353,32 @@ void TQProgressBar::styleChange( TQStyle& old )
TQFrame : : styleChange ( old ) ;
TQFrame : : styleChange ( old ) ;
}
}
/*!
This method returns whether changing the progress to the \ a newValue
would require a repaint of the progress bar . This allows efficient
repainting .
*/
bool TQProgressBar : : requireRepaint ( int newProgress ) const
{
if ( newProgress = = progress_val | |
newProgress = = d - > last_painted_progress ) {
return false ;
}
const int width = contentsRect ( ) . width ( ) ;
if ( width = = 0 ) {
return false ;
}
float progressPerPixel = 1.0 ;
if ( total_steps > width ) {
progressPerPixel = float ( total_steps ) / float ( width ) ;
}
const int delta = d - > last_painted_progress - newProgress ;
return TQABS ( delta ) > = progressPerPixel ;
}
TQt : : Orientation TQProgressBar : : orientation ( ) const
TQt : : Orientation TQProgressBar : : orientation ( ) const
{
{
return m_orientation ;
return m_orientation ;