1 /* This file is part of the KDE project
2 Copyright 2002 John Firebaugh <jfirebaugh@kde.org>
3 Copyright 2007 Andreas Pakulat <apaku@gmx.de>
4 Copyright 2007 Oswald Buddenhagen <ossi@kde.org>
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
22 #ifndef _PROCESSLINEMAKER_H_
23 #define _PROCESSLINEMAKER_H_
25 #include <QtCore/QObject>
26 #include "utilexport.h"
29 @file processlinemaker.h
30 Utility objects for process output views.
38 Convenience class to catch output of QProcess.
44 class KDEVPLATFORMUTIL_EXPORT ProcessLineMaker
: public QObject
49 ProcessLineMaker( QObject
* parent
= 0 );
50 ProcessLineMaker( QProcess
* process
, QObject
* parent
= 0 );
55 * clears out the internal buffers, this drops any data without
56 * emitting the related signal
58 void discardBuffers();
61 * Flush the data from the buffers and then clear them.
62 * This should be called once when the process has
63 * exited to make sure all data that was received from the
64 * process is properly converted and emitted.
66 * Note: Connecting this class to the process finished signal
67 * is not going to work, as the user of this class will do
68 * that itself too and possibly delete the process, making
69 * it impossible to fetch the last output.
75 * This should be used (instead of hand-crafted code) when
76 * you need to do custom things with the process output
77 * before feeding it to the linemaker and have it convert
78 * it to QString lines.
79 * @param buffer the output from the process
81 void slotReceivedStdout( const QByteArray
& buffer
);
84 * This should be used (instead of hand-crafted code) when
85 * you need to do custom things with the process error output
86 * before feeding it to the linemaker and have it convert
87 * it to QString lines.
88 * @param buffer the output from the process
90 void slotReceivedStderr( const QByteArray
& buffer
);
94 * Emitted whenever the process prints something
95 * to its standard output. The output is converted
96 * to a QString using fromLocal8Bit() and will
98 * @param lines the lines that the process printed
100 void receivedStdoutLines( const QStringList
& lines
);
103 * Emitted whenever the process prints something
104 * to its error output. The output is converted
105 * to a QString using fromLocal8Bit() and will
107 * @param lines the lines that the process printed
109 void receivedStderrLines( const QStringList
& lines
);
112 Q_PRIVATE_SLOT(d
, void slotReadyReadStdout( ) )
113 Q_PRIVATE_SLOT(d
, void slotReadyReadStderr( ) )
114 class ProcessLineMakerPrivate
* const d
;
115 friend class ProcessLineMakerPrivate
;