File: progressframe.h

package info (click to toggle)
esperanza 0.2.1-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 600 kB
  • ctags: 536
  • sloc: cpp: 4,533; sh: 63; makefile: 4
file content (117 lines) | stat: -rw-r--r-- 4,028 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/***************************************************************************
 *   Copyright (C) 2005 - 2006 by                                          *
 *      Christian Muehlhaeuser, Last.fm Ltd <chris@last.fm>                *
 *      Erik Jaelevik, Last.fm Ltd <erik@last.fm>                          *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Steet, Fifth Floor, Boston, MA  02111-1307, USA.          *
 ***************************************************************************/

#ifndef PROGRESSFRAME_H
#define PROGRESSFRAME_H

#include <QtGui>

class ProgressFrame : public QFrame
{
    Q_OBJECT

    public:
        ProgressFrame( QWidget *parent = 0 );

        void clear() { stop(); setText( "" ); m_timerText = ""; }

        int maximum() { return m_maxValue; }
        void setMaximum( int value ) { m_maxValue = value; }
        int value() { return m_value; }

        QString text() { return m_text; }
        void setText( const QString& text );

        // Temporary message that should only be displayed for a few seconds
        void pushText( const QString& text );
    
        QPixmap icon() { return m_pixmap; }
        void setIcon( QPixmap pixmap ) { m_pixmap = pixmap; }

        void start() { setValue( 0 ); m_timer->start(); }
        void stop() { setMaximum( 0 ); setValue( 0 ); m_timer->stop(); }
        void resume() { m_timer->start(); }
        void pause() { m_timer->stop(); }
        bool isActive() { return m_timer->isActive(); }

        void useInternalTimer();
        void setTimerText( QString text );

        void setBackgroundEnabled( bool drawBackground ) { m_drawBackground = drawBackground; }
        void setReverse( bool reverse ) { m_reverse = reverse; }
        void setEnabled( bool enabled );

        QHash<QString, QString> itemData() { return m_itemData; }
        void setItemData( QHash<QString, QString> data ) { m_itemData = data; }

        int itemType() { return m_itemType; }
        void setItemType( int type ) { m_itemType = type; }

        void setGreen( bool green ) { m_green = green; }

		void mouseMoveEvent (QMouseEvent *);
		void mousePressEvent (QMouseEvent *);

		void setMove (bool b) {
			m_move = b;
		};

    public slots:
        void setValue( int value );

    private:
        void paintEvent( QPaintEvent* event );

        void disableInternalTimer();
        void disconnectWatch();

        QPixmap m_pixmap;

        QString m_baseText;
        QString m_text;
        QString m_timerText; 
        
        int m_maxValue;
        int m_value;

        int m_itemType;
        QHash<QString, QString> m_itemData;

        bool m_drawBackground;
        bool m_drawTime;
        bool m_reverse;
        bool m_green;

        QTimer* m_timer;
        bool m_timerEnabled;
        
        QTimer pushTimer;

		bool m_move;
		uint32_t m_diffx;
		uint32_t m_diffy;

    private slots:
        void updateTimer() { setValue( value() + 1 ); }
        void popText();
};

#endif