1 | /* |
2 | This file is part of the KDE project |
3 | SPDX-FileCopyrightText: 2007 Rafael Fernández López <ereslibre@kde.org> |
4 | SPDX-FileCopyrightText: 2007 Kevin Ottens <ervin@kde.org> |
5 | |
6 | SPDX-License-Identifier: LGPL-2.0-only |
7 | */ |
8 | |
9 | #ifndef KSTATUSBARJOBTRACKER_P_H |
10 | #define KSTATUSBARJOBTRACKER_P_H |
11 | |
12 | #include "kabstractwidgetjobtracker_p.h" |
13 | #include "kstatusbarjobtracker.h" |
14 | |
15 | #include <QBoxLayout> |
16 | #include <QMap> |
17 | #include <QStackedWidget> |
18 | #include <QWidget> |
19 | |
20 | class QPushButton; |
21 | class QCheckBox; |
22 | class QLabel; |
23 | class QProgressBar; |
24 | |
25 | class KStatusBarJobTrackerPrivate : public KAbstractWidgetJobTrackerPrivate |
26 | { |
27 | Q_DECLARE_PUBLIC(KStatusBarJobTracker) |
28 | |
29 | public: |
30 | KStatusBarJobTrackerPrivate(KStatusBarJobTracker *q, QWidget *parent, bool withStopButton) |
31 | : KAbstractWidgetJobTrackerPrivate(q) |
32 | , parent(parent) |
33 | , currentProgressWidget(nullptr) |
34 | , showStopButton(withStopButton) |
35 | { |
36 | } |
37 | |
38 | class ProgressWidget; |
39 | |
40 | QWidget *parent; |
41 | QMap<KJob *, ProgressWidget *> progressWidget; |
42 | ProgressWidget *currentProgressWidget; |
43 | bool showStopButton; |
44 | }; |
45 | |
46 | class KStatusBarJobTrackerPrivate::ProgressWidget : public QWidget |
47 | { |
48 | Q_OBJECT |
49 | |
50 | public: |
51 | ProgressWidget(KJob *job, KStatusBarJobTracker *object, QWidget *parent) |
52 | : q(object) |
53 | , job(job) |
54 | { |
55 | init(job, parent); |
56 | } |
57 | |
58 | ~ProgressWidget() override |
59 | { |
60 | beingDeleted = true; |
61 | delete widget; |
62 | |
63 | q->unregisterJob(job); |
64 | } |
65 | |
66 | KStatusBarJobTracker *const q; |
67 | KJob *const job; |
68 | |
69 | QWidget *widget = nullptr; |
70 | QProgressBar *progressBar = nullptr; |
71 | QLabel *label = nullptr; |
72 | QPushButton *button = nullptr; |
73 | QBoxLayout *box = nullptr; |
74 | QStackedWidget *stack = nullptr; |
75 | |
76 | // qlonglong totalSize = -1; |
77 | |
78 | KStatusBarJobTracker::StatusBarModes mode = KStatusBarJobTracker::NoInformation; |
79 | bool beingDeleted = false; |
80 | |
81 | void init(KJob *job, QWidget *parent); |
82 | |
83 | void setMode(KStatusBarJobTracker::StatusBarModes newMode); |
84 | |
85 | public Q_SLOTS: |
86 | virtual void description(const QString &title, const QPair<QString, QString> &field1, const QPair<QString, QString> &field2); |
87 | virtual void totalAmount(KJob::Unit unit, qulonglong amount); |
88 | virtual void percent(unsigned long percent); |
89 | virtual void speed(unsigned long value); |
90 | virtual void slotClean(); |
91 | |
92 | private Q_SLOTS: |
93 | void killJob(); |
94 | |
95 | protected: |
96 | bool eventFilter(QObject *obj, QEvent *event) override; |
97 | }; |
98 | |
99 | #endif // KSTATUSBARJOBTRACKER_P_H |
100 | |