PageRenderTime 16ms CodeModel.GetById 13ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/safeFatPrinter/trunk/src/proc_thread.h

http://cupsfilter.googlecode.com/
C++ Header | 71 lines | 26 code | 11 blank | 34 comment | 0 complexity | 7d422665e50dd1d6482adfd0ccb9345e MD5 | raw file
 1#ifndef PROC_THREAD_H
 2#define PROC_THREAD_H
 3
 4#include <QObject>
 5#include <QThread>
 6#include <QVector>
 7#include <QString>
 8#include <QStringList>
 9#include <QProcess>
10#include <QtDebug> 
11
12
13/**
14* 
15* 
16* @short Class which can execute a command as a seperate thread.
17* 
18*/
19
20class ProcessT : public QThread {
21
22	Q_OBJECT
23
24	public:
25		/**
26		 * Constructor. Creats a new ProcessT object.
27		 * @param parent The QObject parent of this object.
28		 */
29		ProcessT( QObject *parent = 0 );
30		/**
31		 * Destructor.
32		 */
33		virtual ~ProcessT();
34		/**
35		 * Reimplementation of QThread::run().
36		 * Executes the command which was set using setCommand(). 
37		 * If no command was set, this function does nothing.
38		 */
39		void run();
40		/**
41		 * Set the given command to be executed when run() is called.
42		 * @param name The name of the program.
43		 * @param args The command line arguments.
44		 * @param mode The process channel modes of the command which will be executed.
45		 */
46		void setCommand( const QString &name, const QStringList &args, const QProcess::ProcessChannelMode &mode = QProcess::SeparateChannels );
47		/**
48		 * Execute the given command. Calls setCommand() first and then just starts the thread if it's not running.
49		 * @param name The name of the program.
50		 * @param args The command line arguments.
51		 * @param mode The process channel modes of the command which will be executed.
52		 */
53		void execute( const QString &name, const QStringList &args, const QProcess::ProcessChannelMode &mode = QProcess::SeparateChannels );
54
55	signals:
56		/**
57		 * Emitted when a command has finished running. 
58		 * @param output The output of the command which was executed.
59		 */
60		void commandOutput(int Code,QString output);
61
62	private:
63		QString m_Command;
64		QStringList m_Args;
65		QProcess::ProcessChannelMode m_ChanMode;
66		QString m_Output;
67
68
69};
70
71#endif //PROC_THREAD_H