File indexing completed on 2024-05-12 16:02:31
0001 /* This file is part of the KDE project 0002 * SPDX-FileCopyrightText: 2006-2007 Thomas Zander <zander@kde.org> 0003 * SPDX-FileCopyrightText: 2009 Boudewijn Rempt <boud@valdyas.org> 0004 * 0005 * SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #ifndef KO_UPDATERPRIVATE__P_H 0009 #define KO_UPDATERPRIVATE__P_H 0010 0011 #include "KoProgressUpdater.h" 0012 0013 #include <QTime> 0014 #include <QVector> 0015 0016 /** 0017 * KoUpdaterPrivate is the gui-thread side of KoUpdater. Communication 0018 * between KoUpdater and KoUpdaterPrivate is handled through queued 0019 * connections -- this is the main app thread part of the 0020 * KoUpdater-KoUpdaterPrivate bridge. 0021 * 0022 * The gui thread can iterate over its list of KoUpdaterPrivate 0023 * instances for the total progress computation: the queued signals 0024 * from the threads will only arrive when the eventloop in the gui 0025 * thread has a chance to deliver them. 0026 */ 0027 class KoUpdaterPrivate : public QObject 0028 { 0029 0030 Q_OBJECT 0031 0032 public: 0033 0034 KoUpdaterPrivate(KoProgressUpdater *parent, int weight, const QString& name, bool isPersistent = false); 0035 0036 /// when deleting an updater, make sure the accompanying thread is 0037 /// interrupted, too. 0038 ~KoUpdaterPrivate() override; 0039 0040 bool interrupted() const { return m_interrupted; } 0041 0042 int progress() const { return m_progress; } 0043 0044 int weight() const { return m_weight; } 0045 0046 QString autoNestedName() const; 0047 QString subTaskName() const; 0048 QString mergedSubTaskName() const; 0049 0050 bool hasValidRange() const; 0051 bool isPersistent() const; 0052 bool isCompleted() const; 0053 0054 QPointer<KoUpdater> connectedUpdater() const; 0055 0056 public Q_SLOTS: 0057 0058 /// Cancel comes from KoUpdater 0059 void cancel(); 0060 0061 void setInterrupted(bool value = true); 0062 0063 /// progress comes from KoUpdater 0064 void setProgress( int percent ); 0065 0066 void setAutoNestedName(const QString &name); 0067 void setHasValidRange(bool value); 0068 0069 0070 Q_SIGNALS: 0071 0072 /// Emitted whenever the progress changed 0073 void sigUpdated(); 0074 0075 /// Emitted whenever the parent KoProgressUpdater is interrupted, 0076 /// for instance through a press on a cancel button 0077 void sigInterrupted(bool value); 0078 0079 private: 0080 int m_progress; // always in percent 0081 int m_weight; 0082 bool m_interrupted; 0083 QString m_autoNestedName; 0084 QString m_subTaskName; 0085 bool m_hasValidRange; 0086 bool m_isPersistent; 0087 KoProgressUpdater *m_parent; 0088 QPointer<KoUpdater> m_connectedUpdater; 0089 }; 0090 0091 #endif