Warning, file /office/calligra/libs/widgetutils/KoUpdaterPrivate_p.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* This file is part of the KDE project 0002 * Copyright (C) 2006-2007 Thomas Zander <zander@kde.org> 0003 * Copyright (C) 2009 Boudewijn Rempt <boud@valdyas.org> 0004 * 0005 * This library is free software; you can redistribute it and/or 0006 * modify it under the terms of the GNU Library General Public 0007 * License as published by the Free Software Foundation; either 0008 * version 2 of the License, or (at your option) any later version. 0009 * 0010 * This library is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0013 * Library General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU Library General Public License 0016 * along with this library; see the file COPYING.LIB. If not, write to 0017 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0018 * Boston, MA 02110-1301, USA. 0019 */ 0020 0021 #ifndef KO_UPDATERPRIVATE__P_H 0022 #define KO_UPDATERPRIVATE__P_H 0023 0024 #include "KoProgressUpdater.h" 0025 0026 #include <QTime> 0027 #include <QVector> 0028 0029 /** 0030 * KoUpdaterPrivate is the gui-thread side of KoUpdater. Communication 0031 * between KoUpdater and KoUpdaterPrivate is handled through queued 0032 * connections -- this is the main app thread part of the 0033 * KoUpdater-KoUpdaterPrivate bridge. 0034 * 0035 * The gui thread can iterate over its list of KoUpdaterPrivate 0036 * instances for the total progress computation: the queued signals 0037 * from the threads will only arrive when the eventloop in the gui 0038 * thread has a chance to deliver them. 0039 */ 0040 class KoUpdaterPrivate : public QObject 0041 { 0042 0043 Q_OBJECT 0044 0045 public: 0046 0047 KoUpdaterPrivate(KoProgressUpdater *parent, int weight, const QString& name) 0048 : QObject(0) 0049 , m_progress(0) 0050 , m_weight(weight) 0051 , m_interrupted(false) 0052 , m_hasOutput(parent->hasOutput()) 0053 , m_parent(parent) 0054 { 0055 setObjectName(name); 0056 } 0057 0058 /// when deleting an updater, make sure the accompanying thread is 0059 /// interrupted, too. 0060 ~KoUpdaterPrivate() override; 0061 0062 bool interrupted() const { return m_interrupted; } 0063 0064 int progress() const { return m_progress; } 0065 0066 int weight() const { return m_weight; } 0067 0068 class TimePoint { 0069 public: 0070 QTime time; 0071 int value; 0072 0073 explicit TimePoint(int value_) :time(QTime::currentTime()), value(value_) {} 0074 TimePoint() {} 0075 }; 0076 0077 void addPoint(int value) { 0078 if (m_hasOutput) { 0079 m_points.append(TimePoint(value)); 0080 } 0081 } 0082 0083 const QVector<TimePoint> & getPoints() const { 0084 return m_points; 0085 } 0086 0087 public Q_SLOTS: 0088 0089 /// Cancel comes from KoUpdater 0090 void cancel(); 0091 0092 /// Interrupt comes from the gui, through KoProgressUpdater, goes 0093 /// to KoUpdater to signal running tasks they might as well quit. 0094 void interrupt(); 0095 0096 /// progress comes from KoUpdater 0097 void setProgress( int percent ); 0098 0099 Q_SIGNALS: 0100 0101 /// Emitted whenever the progress changed 0102 void sigUpdated(); 0103 0104 /// Emitted whenever the parent KoProgressUpdater is interrupted, 0105 /// for instance through a press on a cancel button 0106 void sigInterrupted(); 0107 0108 private: 0109 int m_progress; // always in percent 0110 int m_weight; 0111 bool m_interrupted; 0112 bool m_hasOutput; 0113 0114 KoProgressUpdater *m_parent; 0115 QVector<TimePoint> m_points; 0116 }; 0117 0118 Q_DECLARE_TYPEINFO(KoUpdaterPrivate::TimePoint, Q_MOVABLE_TYPE); 0119 0120 #endif