File indexing completed on 2024-10-06 06:42:09

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     SPDX-FileCopyrightText: 2009 Shaun Reich <shaun.reich@kdemail.net>
0006 
0007     SPDX-License-Identifier: LGPL-2.0-only
0008 */
0009 
0010 #ifndef KWIDGETJOBTRACKER_H
0011 #define KWIDGETJOBTRACKER_H
0012 
0013 #include <kabstractwidgetjobtracker.h>
0014 #include <kjobwidgets_export.h>
0015 
0016 class KWidgetJobTrackerPrivate;
0017 
0018 /**
0019  * @class KWidgetJobTracker kwidgetjobtracker.h KWidgetJobTracker
0020  *
0021  * This class implements a job tracker with a widget suited for use as a
0022  * progress dialog.
0023  */
0024 class KJOBWIDGETS_EXPORT KWidgetJobTracker : public KAbstractWidgetJobTracker
0025 {
0026     Q_OBJECT
0027 
0028 public:
0029     /**
0030      * Creates a new KWidgetJobTracker
0031      *
0032      * @param parent the parent of this object and of the widget displaying the job progresses
0033      */
0034     explicit KWidgetJobTracker(QWidget *parent = nullptr);
0035 
0036     /**
0037      * Destroys a KWidgetJobTracker
0038      */
0039     ~KWidgetJobTracker() override;
0040 
0041     /**
0042      * The widget associated to this tracker.
0043      *
0044      * @param job the job that is assigned the widget we want to get
0045      * @return the widget displaying the job progresses
0046      */
0047     QWidget *widget(KJob *job) override;
0048 
0049     // KDE5: move this two virtual methods to be placed correctly (ereslibre)
0050 public Q_SLOTS:
0051     /**
0052      * Register a new job in this tracker.
0053      *
0054      * @param job the job to register
0055      */
0056     void registerJob(KJob *job) override;
0057 
0058     /**
0059      * Unregister a job from this tracker.
0060      *
0061      * @param job the job to unregister
0062      */
0063     void unregisterJob(KJob *job) override;
0064 
0065 public:
0066     bool keepOpen(KJob *job) const;
0067 
0068 protected Q_SLOTS:
0069     /**
0070      * The following slots are inherited from KJobTrackerInterface.
0071      */
0072     void infoMessage(KJob *job, const QString &message) override;
0073     virtual void description(KJob *job, const QString &title, const QPair<QString, QString> &field1, const QPair<QString, QString> &field2) override;
0074     void totalAmount(KJob *job, KJob::Unit unit, qulonglong amount) override;
0075     void processedAmount(KJob *job, KJob::Unit unit, qulonglong amount) override;
0076     void percent(KJob *job, unsigned long percent) override;
0077     void speed(KJob *job, unsigned long value) override;
0078     void slotClean(KJob *job) override;
0079     void suspended(KJob *job) override;
0080     void resumed(KJob *job) override;
0081 
0082     // TODO: Misses canResume()
0083 
0084 private:
0085     Q_DECLARE_PRIVATE(KWidgetJobTracker)
0086 
0087     Q_PRIVATE_SLOT(d_func(), void _k_showProgressWidget())
0088 };
0089 
0090 #endif