File indexing completed on 2024-04-14 03:54:03

0001 /*
0002     This file is part of the KDE project
0003     SPDX-FileCopyrightText: 2000 Matej Koss <koss@miesto.sk>
0004     SPDX-FileCopyrightText: 2007 Kevin Ottens <ervin@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.0-only
0007 */
0008 
0009 #ifndef KSTATUSBARJOBTRACKER_H
0010 #define KSTATUSBARJOBTRACKER_H
0011 
0012 #include <kabstractwidgetjobtracker.h>
0013 
0014 class KStatusBarJobTrackerPrivate;
0015 
0016 /**
0017  * @class KStatusBarJobTracker kstatusbarjobtracker.h KStatusBarJobTracker
0018  *
0019  * This class implements a job tracker with a widget suited for embedding in a
0020  * status bar.
0021  */
0022 class KJOBWIDGETS_EXPORT KStatusBarJobTracker : public KAbstractWidgetJobTracker
0023 {
0024     Q_OBJECT
0025 
0026 public:
0027     /**
0028      * @see StatusBarModes
0029      */
0030     enum StatusBarMode {
0031         NoInformation = 0x0000, ///< Does not show any information
0032         LabelOnly = 0x0001, ///< Shows an informative label for job progress
0033         ProgressOnly = 0x0002, ///< Shows a progress bar with the job completion
0034     };
0035 
0036     /**
0037      * Stores a combination of #StatusBarMode values.
0038      */
0039     Q_DECLARE_FLAGS(StatusBarModes, StatusBarMode)
0040 
0041     /**
0042      * Creates a new KStatusBarJobTracker
0043      *
0044      * @param parent the parent of this object and of the widget displaying the job progresses
0045      * @param button true to display a stop button allowing to kill the job, false otherwise
0046      */
0047     explicit KStatusBarJobTracker(QWidget *parent = nullptr, bool button = true);
0048 
0049     /**
0050      * Destroys a KStatusBarJobTracker
0051      */
0052     ~KStatusBarJobTracker() override;
0053 
0054     /**
0055      * Register a new job in this tracker.
0056      *
0057      * @param job the job to register
0058      */
0059     void registerJob(KJob *job) override;
0060 
0061     /**
0062      * Unregister a job from this tracker.
0063      *
0064      * @param job the job to unregister
0065      */
0066     void unregisterJob(KJob *job) override;
0067 
0068     /**
0069      * The widget associated to this tracker.
0070      *
0071      * @return the widget displaying the job progresses
0072      */
0073     QWidget *widget(KJob *job) override;
0074 
0075     /**
0076      * Sets the mode of the status bar.
0077      *
0078      * @param statusBarMode what information the status bar will show (see StatusBarMode).
0079      *                      LabelOnly by default
0080      */
0081     void setStatusBarMode(StatusBarModes statusBarMode);
0082 
0083 public Q_SLOTS:
0084     /**
0085      * The following slots are inherited from KJobTrackerInterface.
0086      */
0087     virtual void description(KJob *job, const QString &title, const QPair<QString, QString> &field1, const QPair<QString, QString> &field2) override;
0088     void totalAmount(KJob *job, KJob::Unit unit, qulonglong amount) override;
0089     void percent(KJob *job, unsigned long percent) override;
0090     void speed(KJob *job, unsigned long value) override;
0091     void slotClean(KJob *job) override;
0092 
0093 private:
0094     Q_DECLARE_PRIVATE(KStatusBarJobTracker)
0095 };
0096 
0097 Q_DECLARE_OPERATORS_FOR_FLAGS(KStatusBarJobTracker::StatusBarModes)
0098 
0099 #endif