File indexing completed on 2024-04-28 04:49:22

0001 /*
0002     SPDX-FileCopyrightText: 1998-2009 Sebastian Trueg <trueg@k3b.org>
0003     SPDX-License-Identifier: GPL-2.0-or-later
0004 */
0005 #ifndef K3B_PROGRESS_INFO_EVENT_H
0006 #define K3B_PROGRESS_INFO_EVENT_H
0007 
0008 #include <QEvent>
0009 #include <QString>
0010 
0011 
0012 namespace K3b {
0013     /**
0014      * Custom event class for posting events corresponding to the
0015      * Job signals. This is useful for a threaded job since
0016      * in that case it's not possible to emit signals that directly
0017      * change the GUI (see QThread docu).
0018      */
0019     class ProgressInfoEvent : public QEvent
0020     {
0021     public:
0022         explicit ProgressInfoEvent( int type )
0023             : QEvent( QEvent::User ),
0024               m_type(type)
0025         {}
0026 
0027         ProgressInfoEvent( int type, const QString& v1, const QString& v2 = QString(),
0028                            int value1 = 0, int value2 = 0 )
0029             : QEvent( QEvent::User ),
0030               m_type( type),
0031               m_firstValue(value1),
0032               m_secondValue(value2),
0033               m_firstString(v1),
0034               m_secondString(v2)
0035         {}
0036 
0037         ProgressInfoEvent( int type, int value1, int value2 = 0 )
0038             : QEvent( QEvent::User ),
0039               m_type( type),
0040               m_firstValue(value1),
0041               m_secondValue(value2)
0042         {}
0043 
0044         int type() const { return m_type; }
0045         const QString& firstString() const { return m_firstString; }
0046         const QString& secondString() const { return m_secondString; }
0047         int firstValue() const { return m_firstValue; }
0048         int secondValue() const { return m_secondValue; }
0049 
0050         enum ProgressInfoEventType {
0051             Progress = QEvent::User + 1,
0052             SubProgress,
0053             ProcessedSize,
0054             ProcessedSubSize,
0055             InfoMessage,
0056             Started,
0057             Canceled,
0058             Finished,
0059             NewTask,
0060             NewSubTask,
0061             DebuggingOutput,
0062             BufferStatus,
0063             WriteSpeed,
0064             NextTrack
0065         };
0066 
0067     private:
0068         int m_type;
0069         int m_firstValue;
0070         int m_secondValue;
0071         QString m_firstString;
0072         QString m_secondString;
0073     };
0074 }
0075 
0076 #endif