1 /****************************************************************************
2 ** $Id: qt/qprogressbar.h   3.3.8   edited Jan 11 14:38 $
3 **
4 ** Definition of QProgressBar class
5 **
6 ** Created : 970520
7 **
8 ** Copyright (C) 1992-2007 Trolltech ASA.  All rights reserved.
9 **
10 ** This file is part of the widgets module of the Qt GUI Toolkit.
11 **
12 ** This file may be distributed under the terms of the Q Public License
13 ** as defined by Trolltech ASA of Norway and appearing in the file
14 ** LICENSE.QPL included in the packaging of this file.
15 **
16 ** This file may be distributed and/or modified under the terms of the
17 ** GNU General Public License version 2 as published by the Free Software
18 ** Foundation and appearing in the file LICENSE.GPL included in the
19 ** packaging of this file.
20 **
21 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22 ** licenses may use this file in accordance with the Qt Commercial License
23 ** Agreement provided with the Software.
24 **
25 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27 **
28 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29 **   information about Qt Commercial License Agreements.
30 ** See http://www.trolltech.com/qpl/ for QPL licensing information.
31 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
32 **
33 ** Contact info@trolltech.com if any conditions of this licensing are
34 ** not clear to you.
35 **
36 **********************************************************************/
37 
38 #ifndef QPROGRESSBAR_H
39 #define QPROGRESSBAR_H
40 
41 #ifndef QT_H
42 #include "qframe.h"
43 #endif // QT_H
44 
45 #ifndef QT_NO_PROGRESSBAR
46 
47 
48 class QProgressBarPrivate;
49 
50 
51 class Q_EXPORT QProgressBar : public QFrame
52 {
53     Q_OBJECT
54     Q_PROPERTY( int totalSteps READ totalSteps WRITE setTotalSteps )
55     Q_PROPERTY( int progress READ progress WRITE setProgress )
56     Q_PROPERTY( QString progressString READ progressString )
57     Q_PROPERTY( bool centerIndicator READ centerIndicator WRITE setCenterIndicator )
58     Q_PROPERTY( bool indicatorFollowsStyle READ indicatorFollowsStyle WRITE setIndicatorFollowsStyle )
59     Q_PROPERTY( bool percentageVisible READ percentageVisible WRITE setPercentageVisible )
60 
61 public:
62     QProgressBar( QWidget* parent=0, const char* name=0, WFlags f=0 );
63     QProgressBar( int totalSteps, QWidget* parent=0, const char* name=0, WFlags f=0 );
64 
65     int		totalSteps() const;
66     int		progress()   const;
67     const QString &progressString() const;
68 
69     QSize	sizeHint() const;
70     QSize	minimumSizeHint() const;
71 
72     void	setCenterIndicator( bool on );
73     bool	centerIndicator() const;
74 
75     void        setIndicatorFollowsStyle( bool );
76     bool	indicatorFollowsStyle() const;
77 
78     bool	percentageVisible() const;
79     void	setPercentageVisible( bool );
80 
81     void	show();
82 
83 public slots:
84     void	reset();
85     virtual void setTotalSteps( int totalSteps );
86     virtual void setProgress( int progress );
87     void	setProgress( int progress, int totalSteps );
88 
89 protected:
90     void	drawContents( QPainter * );
91     virtual bool setIndicator( QString & progress_str, int progress,
92 			       int totalSteps );
93     void styleChange( QStyle& );
94 
95 private:
96     int		total_steps;
97     int		progress_val;
98     int		percentage;
99     QString	progress_str;
100     bool        center_indicator    : 1;
101     bool        auto_indicator	    : 1;
102     bool	percentage_visible  : 1;
103     QProgressBarPrivate * d;
104     void         initFrame();
105 
106 private:	// Disabled copy constructor and operator=
107 #if defined(Q_DISABLE_COPY)
108     QProgressBar( const QProgressBar & );
109     QProgressBar &operator=( const QProgressBar & );
110 #endif
111 };
112 
113 
totalSteps()114 inline int QProgressBar::totalSteps() const
115 {
116     return total_steps;
117 }
118 
progress()119 inline int QProgressBar::progress() const
120 {
121     return progress_val;
122 }
123 
progressString()124 inline const QString &QProgressBar::progressString() const
125 {
126     return progress_str;
127 }
128 
centerIndicator()129 inline bool QProgressBar::centerIndicator() const
130 {
131     return center_indicator;
132 }
133 
indicatorFollowsStyle()134 inline bool QProgressBar::indicatorFollowsStyle() const
135 {
136     return auto_indicator;
137 }
138 
percentageVisible()139 inline bool QProgressBar::percentageVisible() const
140 {
141     return percentage_visible;
142 }
143 
144 #endif // QT_NO_PROGRESSBAR
145 
146 #endif // QPROGRESSBAR_H
147