File indexing completed on 2024-05-12 16:02:31
0001 /* This file is part of the KDE project 0002 * 0003 * SPDX-FileCopyrightText: 2006-2007 Thomas Zander <zander@kde.org> 0004 * SPDX-FileCopyrightText: 2009 Boudewijn Rempt <boud@valdyas.org> 0005 * 0006 * SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 #include "KoUpdaterPrivate_p.h" 0009 #include <KoUpdater.h> 0010 0011 KoUpdaterPrivate::KoUpdaterPrivate(KoProgressUpdater *parent, int weight, const QString &name, bool isPersistent) 0012 : QObject(0) 0013 , m_progress(0) 0014 , m_weight(weight) 0015 , m_interrupted(false) 0016 , m_autoNestedName() 0017 , m_subTaskName(name) 0018 , m_hasValidRange(true) 0019 , m_isPersistent(isPersistent) 0020 , m_parent(parent) 0021 , m_connectedUpdater(new KoUpdater(this)) 0022 { 0023 } 0024 0025 KoUpdaterPrivate::~KoUpdaterPrivate() 0026 { 0027 setInterrupted(true); 0028 m_connectedUpdater->deleteLater(); 0029 } 0030 0031 QString KoUpdaterPrivate::autoNestedName() const 0032 { 0033 return m_autoNestedName; 0034 } 0035 0036 QString KoUpdaterPrivate::subTaskName() const 0037 { 0038 return m_subTaskName; 0039 } 0040 0041 QString KoUpdaterPrivate::mergedSubTaskName() const 0042 { 0043 QString result = m_subTaskName; 0044 0045 if (!m_autoNestedName.isEmpty()) { 0046 if (result.isEmpty()) { 0047 result = m_autoNestedName; 0048 } else { 0049 result = QString("%1: %2").arg(result).arg(m_autoNestedName); 0050 } 0051 } 0052 0053 return result; 0054 } 0055 0056 bool KoUpdaterPrivate::hasValidRange() const 0057 { 0058 return m_hasValidRange; 0059 } 0060 0061 bool KoUpdaterPrivate::isPersistent() const 0062 { 0063 return m_isPersistent; 0064 } 0065 0066 bool KoUpdaterPrivate::isCompleted() const 0067 { 0068 return m_progress >= 100; 0069 } 0070 0071 void KoUpdaterPrivate::cancel() 0072 { 0073 m_parent->cancel(); 0074 } 0075 0076 void KoUpdaterPrivate::setInterrupted(bool value) 0077 { 0078 m_interrupted = value; 0079 emit sigInterrupted(m_interrupted); 0080 } 0081 0082 void KoUpdaterPrivate::setProgress(int percent) 0083 { 0084 m_progress = percent; 0085 emit sigUpdated(); 0086 } 0087 0088 void KoUpdaterPrivate::setAutoNestedName(const QString &name) 0089 { 0090 m_autoNestedName = name; 0091 emit sigUpdated(); 0092 } 0093 0094 void KoUpdaterPrivate::setHasValidRange(bool value) 0095 { 0096 m_hasValidRange = value; 0097 emit sigUpdated(); 0098 } 0099 0100 QPointer<KoUpdater> KoUpdaterPrivate::connectedUpdater() const 0101 { 0102 return m_connectedUpdater; 0103 }