1 | /* This file is part of the KDE project |
2 | Copyright (C) 2000 Matej Koss <koss@miesto.sk> |
3 | Copyright (C) 2007 Kevin Ottens <ervin@kde.org> |
4 | |
5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public |
7 | License version 2 as published by the Free Software Foundation. |
8 | |
9 | This library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Library General Public License for more details. |
13 | |
14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to |
16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 | Boston, MA 02110-1301, USA. |
18 | |
19 | */ |
20 | |
21 | #ifndef KSTATUSBARJOBTRACKER_H |
22 | #define KSTATUSBARJOBTRACKER_H |
23 | |
24 | #include <kabstractwidgetjobtracker.h> |
25 | |
26 | /** |
27 | * This class implements a job tracker with a widget suited for embedding in a |
28 | * status bar. |
29 | */ |
30 | class KDEUI_EXPORT KStatusBarJobTracker : public KAbstractWidgetJobTracker |
31 | { |
32 | Q_OBJECT |
33 | |
34 | public: |
35 | enum StatusBarMode |
36 | { |
37 | NoInformation = 0x0000, ///< Does not show any information |
38 | LabelOnly = 0x0001, ///< Shows an informative label for job progress |
39 | ProgressOnly = 0x0002 ///< Shows a progress bar with the job completion |
40 | }; |
41 | |
42 | Q_DECLARE_FLAGS(StatusBarModes, StatusBarMode) |
43 | |
44 | /** |
45 | * Creates a new KStatusBarJobTracker |
46 | * |
47 | * @param parent the parent of this object and of the widget displaying the job progresses |
48 | * @param button true to display a stop button allowing to kill the job, false otherwise |
49 | */ |
50 | explicit KStatusBarJobTracker(QWidget *parent = 0, bool button = true); |
51 | |
52 | /** |
53 | * Destroys a KStatusBarJobTracker |
54 | */ |
55 | virtual ~KStatusBarJobTracker(); |
56 | |
57 | /** |
58 | * Register a new job in this tracker. |
59 | * |
60 | * @param job the job to register |
61 | */ |
62 | virtual void registerJob(KJob *job); |
63 | |
64 | /** |
65 | * Unregister a job from this tracker. |
66 | * |
67 | * @param job the job to unregister |
68 | */ |
69 | virtual void unregisterJob(KJob *job); |
70 | |
71 | /** |
72 | * The widget associated to this tracker. |
73 | * |
74 | * @return the widget displaying the job progresses |
75 | */ |
76 | virtual QWidget *widget(KJob *job); |
77 | |
78 | /** |
79 | * Sets the mode of the status bar. |
80 | * |
81 | * @param statusBarMode what information the status bar will show (see StatusBarMode). |
82 | * LabelOnly by default |
83 | */ |
84 | void setStatusBarMode(StatusBarModes statusBarMode); |
85 | |
86 | public Q_SLOTS: |
87 | /** |
88 | * The following slots are inherited from KJobTrackerInterface. |
89 | */ |
90 | virtual void description(KJob *job, const QString &title, |
91 | const QPair<QString, QString> &field1, |
92 | const QPair<QString, QString> &field2); |
93 | virtual void totalAmount(KJob *job, KJob::Unit unit, qulonglong amount); |
94 | virtual void percent(KJob *job, unsigned long percent); |
95 | virtual void speed(KJob *job, unsigned long value); |
96 | virtual void slotClean(KJob *job); |
97 | |
98 | private: |
99 | class Private; |
100 | Private *const d; |
101 | }; |
102 | |
103 | Q_DECLARE_OPERATORS_FOR_FLAGS(KStatusBarJobTracker::StatusBarModes) |
104 | |
105 | #endif |
106 | |