summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2014-09-16 20:10:51 +0200
committerSlávek Banko <slavek.banko@axis.cz>2014-09-16 20:10:51 +0200
commit5b34ad0d8e489369a0cd8bd1e1b3ccebc4c9acb7 (patch)
tree4d5c979e74e1148c4a04d58de5894491fca91870 /src
parentfbc4cf8e7f2170744c12fd0d435639516c733db9 (diff)
downloadqt3-5b34ad0d8e489369a0cd8bd1e1b3ccebc4c9acb7.tar.gz
qt3-5b34ad0d8e489369a0cd8bd1e1b3ccebc4c9acb7.zip
Improve TQProgressBar repaint optimization
Diffstat (limited to 'src')
-rw-r--r--src/widgets/qprogressbar.cpp11
-rw-r--r--src/widgets/qprogressbar.h2
2 files changed, 5 insertions, 8 deletions
diff --git a/src/widgets/qprogressbar.cpp b/src/widgets/qprogressbar.cpp
index 1219419..98d35a8 100644
--- a/src/widgets/qprogressbar.cpp
+++ b/src/widgets/qprogressbar.cpp
@@ -212,13 +212,11 @@ void QProgressBar::setProgress( int progress )
progress < 0 || ( ( progress > total_steps ) && total_steps ) )
return;
- const bool needRepaint = isVisible() && requireRepaint( progress );
-
progress_val = progress;
setIndicator( progress_str, progress_val, total_steps );
- if ( needRepaint ) {
+ if ( isVisible() && repaintRequired() ) {
repaint( FALSE );
d->last_painted_progress = progress;
}
@@ -358,10 +356,9 @@ void QProgressBar::styleChange( QStyle& old )
would require a repaint of the progress bar. This allows efficient
repainting.
*/
-bool QProgressBar::requireRepaint( int newProgress ) const
+bool QProgressBar::repaintRequired() const
{
- if ( newProgress == progress_val ||
- newProgress == d->last_painted_progress ) {
+ if ( progress_val == d->last_painted_progress ) {
return false;
}
@@ -375,7 +372,7 @@ bool QProgressBar::requireRepaint( int newProgress ) const
progressPerPixel = float( total_steps ) / float( width );
}
- const int delta = d->last_painted_progress - newProgress;
+ const int delta = d->last_painted_progress - progress_val;
return QABS( delta ) >= progressPerPixel;
}
diff --git a/src/widgets/qprogressbar.h b/src/widgets/qprogressbar.h
index 3ba2388..336ade5 100644
--- a/src/widgets/qprogressbar.h
+++ b/src/widgets/qprogressbar.h
@@ -96,7 +96,7 @@ protected:
virtual bool setIndicator( QString & progress_str, int progress,
int totalSteps );
void styleChange( QStyle& );
- bool requireRepaint( int newProgress ) const;
+ bool repaintRequired() const;
private:
int total_steps;