File indexing completed on 2024-10-06 03:40:32
0001 /* 0002 SPDX-FileCopyrightText: 2021 Kai Uwe Broulik <kde@broulik.de> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef KJOBCREATOR_H 0008 #define KJOBCREATOR_H 0009 0010 #include <QDialog> 0011 #include <QPointer> 0012 #include <QScopedPointer> 0013 0014 #include <KJob> 0015 0016 #include "ui_kjobcreator.h" 0017 0018 class KWidgetJobTracker; 0019 class KUiServerJobTracker; 0020 class KUiServerV2JobTracker; 0021 0022 class TestJob : public KJob 0023 { 0024 Q_OBJECT 0025 0026 public: 0027 TestJob(QObject *parent = nullptr); 0028 0029 void start() override; 0030 bool started() const; 0031 0032 void finish(); 0033 0034 void setPercentage(int percent); 0035 0036 void setProcessedMiB(double bytes); 0037 void setTotalMiB(double bytes); 0038 void setProcessedFiles(int files); 0039 void setTotalFiles(int files); 0040 void setProcessedDirectories(int directories); 0041 void setTotalDirectories(int directories); 0042 void setProcessedItems(int items); 0043 void setTotalItems(int items); 0044 0045 void setSpeedMiB(double speed); 0046 0047 void setErrorState(int errorCode, const QString &errorText); 0048 0049 void setKillable(bool killable); 0050 void setSuspendable(bool suspendable); 0051 0052 protected: 0053 bool doKill() override; 0054 bool doSuspend() override; 0055 bool doResume() override; 0056 0057 private: 0058 bool m_started = false; 0059 }; 0060 0061 class TestDialog : public QDialog 0062 { 0063 Q_OBJECT 0064 0065 public: 0066 TestDialog(QWidget *parent = nullptr); 0067 ~TestDialog() override; 0068 0069 protected: 0070 void closeEvent(QCloseEvent *event) override; 0071 0072 private: 0073 void updateUiState(); 0074 void updateJob(); 0075 0076 Ui_KJobCreator m_ui; 0077 0078 QPointer<TestJob> m_job; 0079 0080 QScopedPointer<KWidgetJobTracker> m_widgetTracker; 0081 bool m_registeredWithWidgetTracker = false; 0082 QScopedPointer<KUiServerJobTracker> m_uiServerTracker; 0083 bool m_registeredWithUiServerTracker = false; 0084 QScopedPointer<KUiServerV2JobTracker> m_uiServerV2Tracker; 0085 bool m_registeredWithUiServerV2Tracker = false; 0086 }; 0087 0088 #endif // KJOBCREATOR_H