+
+
+ConOut::ConOut(QProcess * proc) : proc_(proc), outindex_(0), errindex_(0),
+ showout_(false), showerr_(false)
+{
+ connect(proc, SIGNAL(readyReadStandardOutput()), SLOT(stdOut()));
+ connect(proc, SIGNAL(readyReadStandardError()), SLOT(stdErr()));
+}
+
+
+ConOut::~ConOut()
+{
+ cout.flush();
+ cerr.flush();
+}
+
+
+void ConOut::stdOut()
+{
+ if (showout_) {
+ char c;
+ proc_->setReadChannel(QProcess::StandardOutput);
+ while (proc_->getChar(&c)) {
+ outdata_[outindex_++] = c;
+ if (c == '\n' || outindex_ + 1 == bufsize_) {
+ outdata_[outindex_] = '\0';
+ outindex_ = 0;
+ cout << outdata_;
+ }
+ }
+ }
+}
+
+
+void ConOut::stdErr()
+{
+ if (showerr_) {
+ char c;
+ proc_->setReadChannel(QProcess::StandardError);
+ while (proc_->getChar(&c)) {
+ errdata_[errindex_++] = c;
+ if (c == '\n' || errindex_ + 1 == bufsize_) {
+ errdata_[errindex_] = '\0';
+ errindex_ = 0;
+ cerr << errdata_;
+ }
+ }
+ }
+}
+
+#include "moc_Systemcall.cpp"