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