]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinstatusbar.h
Byebye Q3H(V)Box
[dolphin.git] / src / dolphinstatusbar.h
1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz *
3 * peter.penz@gmx.at *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20
21 #ifndef DOLPHINSTATUSBAR_H
22 #define DOLPHINSTATUSBAR_H
23
24
25 //Added by qt3to4:
26 #include <QLabel>
27 #include <khbox.h>
28 class QProgressBar;
29 class QLabel;
30 class QTimer;
31 class StatusBarMessageLabel;
32 class StatusBarSpaceInfo;
33 class DolphinView;
34 class KUrl;
35
36 /**
37 * @brief Represents the statusbar of a Dolphin view.
38 *
39 * The statusbar allows to show messages and progress
40 * information.
41 *
42 * @author Peter Penz
43 */
44 class DolphinStatusBar : public KHBox {
45 Q_OBJECT
46
47 public:
48 /**
49 * Describes the type of the message text. Dependent
50 * from the type a corresponding icon and color is
51 * used for the message text.
52 */
53 enum Type {
54 Default,
55 OperationCompleted,
56 Information,
57 Error
58 };
59
60 DolphinStatusBar(DolphinView* parent = 0);
61 virtual ~DolphinStatusBar();
62
63 /**
64 * Sets the message text to \a msg. Dependant
65 * from the given type \a type an icon is shown and
66 * the color of the text is adjusted. The height of
67 * the statusbar is automatically adjusted in a way,
68 * that the full text fits into the available width.
69 *
70 * If a progress is ongoing and a message
71 * with the type Type::Error is set, the progress
72 * is cleared automatically.
73 */
74 void setMessage(const QString& msg, Type type);
75
76 QString message() const;
77 Type type() const;
78
79 /**
80 * Sets the text for the progress information.
81 * The text is shown with a delay of 300 milliseconds:
82 * if the progress set by DolphinStatusBar::setProgress()
83 * does reach 100 % within 300 milliseconds,
84 * the progress text is not shown at all. This assures that
85 * no flickering occurs for showing a progress of fast
86 * operations.
87 */
88 void setProgressText(const QString& text);
89 QString progressText() const;
90
91 /**
92 * Sets the progress in percent (0 - 100). The
93 * progress is shown with a delay of 300 milliseconds:
94 * if the progress does reach 100 % within 300 milliseconds,
95 * the progress is not shown at all. This assures that
96 * no flickering occurs for showing a progress of fast
97 * operations.
98 */
99 void setProgress(int percent);
100 int progress() const { return m_progress; }
101
102 /**
103 * Clears the message text of the status bar by replacing
104 * the message with the default text, which can be set
105 * by DolphinStatusBar::setDefaultText(). The progress
106 * information is not cleared.
107 */
108 void clear();
109
110 /**
111 * Sets the default text, which is shown if the status bar
112 * is cleared by DolphinStatusBar::clear().
113 */
114 void setDefaultText(const QString& text);
115 const QString& defaultText() const { return m_defaultText; }
116
117 private slots:
118 void slotProgressTimer();
119
120 /**
121 * Is invoked, when the Url of the DolphinView, where the
122 * statusbar belongs too, has been changed.
123 */
124 void slotUrlChanged(const KUrl& url);
125
126 private:
127 StatusBarMessageLabel* m_messageLabel;
128 StatusBarSpaceInfo* m_spaceInfo;
129 QLabel* m_progressText;
130 QProgressBar* m_progressBar;
131 QTimer* m_progressTimer;
132 int m_progress;
133 QString m_defaultText;
134 };
135
136 #endif