File indexing completed on 2024-05-12 15:58:29

0001 /*
0002  *  SPDX-FileCopyrightText: 2008 Cyrille Berger <cberger@cberger.net>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #ifndef _KIS_NODE_PROGRESS_PROXY_H_
0008 #define _KIS_NODE_PROGRESS_PROXY_H_
0009 
0010 #include <KoProgressProxy.h>
0011 #include <QObject>
0012 
0013 #include <kis_types.h>
0014 
0015 #include "kritaimage_export.h"
0016 
0017 /**
0018  * This class implements \ref KoProgressProxy and allows node to report progress.
0019  */
0020 class KRITAIMAGE_EXPORT KisNodeProgressProxy : public QObject, public KoProgressProxy
0021 {
0022     Q_OBJECT
0023     friend class KisNode;
0024     /**
0025      * Create a proxy to report progress when processing, this proxy is associated
0026      * with a node, it will report progress in the node progress bar. This proxy
0027      * will be deleted when @p _node is deleted.
0028      */
0029     explicit KisNodeProgressProxy(KisNode* _node);
0030     ~KisNodeProgressProxy() override;
0031 
0032 public:
0033     int maximum() const override;
0034     void setValue(int value) override;
0035     void setRange(int minimum, int maximum) override;
0036     void setFormat(const QString & format) override;
0037     /**
0038      * @return the current percentage (return -1 if no progress)
0039      */
0040     int percentage() const;
0041 Q_SIGNALS:
0042     /**
0043      * Emitted when the percentage of the proxy is changed.
0044      * @param _percentage is the progress value in percent
0045      * @param _node is the node that own this \ref KisNodeProgressProxy
0046      */
0047     void percentageChanged(int _percentage, const KisNodeSP& _node);
0048 
0049 private:
0050     /**
0051      * To be called when the node is and will be no longer available
0052      * and this object is going to be deleted as well.
0053      */
0054     void prepareDestroying();
0055 
0056 private:
0057     struct Private;
0058     Private* const d;
0059 };
0060 
0061 #endif