Esempio n. 1
0
void MyProcess::error(QProcess::ProcessError error) {
    QString l_error= QString("QProcess Crashed");

	switch (error) {
	case QProcess::FailedToStart:
                trace((char *)"\nQProcess::FailedToStart\n");
		break;
	case QProcess::Crashed:
                emit lineAvailable(l_error);
                trace((char *)"\n QProcess::Crashed \n");

		break;
	case QProcess::Timedout:
                trace((char *)"\n QProcess::Timedout \n");

		break;
	case QProcess::WriteError:
                emit lineAvailable(l_error);
                trace((char *)"\n QProcess::WriteError \n");

		break;
	case QProcess::ReadError:
                trace((char *)"\n QProcess::ReadError \n");

		break;
	case QProcess::UnknownError:
                trace((char *)"\n QProcess::UnknownError \n");

		break;
	default:
                trace((char *)"\n Unknown QProcess::ProcessError \n");

	}
}
Esempio n. 2
0
void MyProcess::genericRead(QByteArray buffer) {
	QByteArray ba = remaining_output + buffer;
	int start = 0;
	int from_pos = 0;
	int pos = canReadLine(ba, from_pos);

	//qDebug("MyProcess::read: pos: %d", pos);
	while ( pos > -1 ) {
		// Readline
		//QByteArray line = ba.left(pos);
		QByteArray line = ba.mid(start, pos-start);
		//ba = ba.mid(pos+1);
		from_pos = pos + 1;
#ifdef Q_OS_WIN
		if ((from_pos < ba.size()) && (ba.at(from_pos)=='\n')) from_pos++;
#endif
		start = from_pos;

		emit lineAvailable(line);

		pos = canReadLine(ba, from_pos);
	}

	remaining_output = ba.mid(from_pos);
}
Esempio n. 3
0
void MyProcess::genericRead(const QByteArray & output) {
	QByteArray totalOutput = _remainingOutput + output;
	int start = 0;
	int from = 0;
        int pos = canReadLine(totalOutput, from);

	while (pos > -1) {
		//Readline
		//QString line = totalOutput.mid(start, pos - start);
		//cp1252
		//Windows-1252
		//QTextCodec::setCodecForCStrings(QTextCodec::codecForName("Windows-1252"));
		QString line = QString::fromLocal8Bit(totalOutput.mid(start, pos - start));
		from = pos + 1;


		start = from;

		//QString::trimmed() is used for removing leading and trailing whitespaces
		//Some .mp3 files contain tags with starting and ending whitespaces
		//Unfortunately MPlayer gives us leading and trailing whitespaces,
		//Winamp for example doesn't show them
		line = line.trimmed();
		if (!line.isEmpty()) {
			emit lineAvailable(line);
		}

                pos = canReadLine(totalOutput, from);
	}

	_remainingOutput = totalOutput.mid(from);
}
Esempio n. 4
0
ripDialog::ripDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ripDialog)
{
    ui->setupUi(this);

    ripProcess=new MyProcess();
    ripProcess->addArgument(qApp->applicationDirPath()+"/cdda2wav.exe");
    ripProcess->start();
    QObject::connect(ripProcess,SIGNAL(lineAvailable(QByteArray)),this,SLOT(consoleLine(QByteArray)));
   // QObject::connect(ripProcess,SIGNAL(),this,SLOT());

    ui->tab->setColumnCount(3);
     //ui->tab->setAcceptDrops(true);
    QStringList headerLabels;
    headerLabels << "Title" << "Duration"<<"";
     ui->tab->setHorizontalHeaderLabels(headerLabels);
     ui->tab->setSelectionBehavior(QAbstractItemView::SelectRows);
     ui->tab->setColumnWidth(0,170);
    //tab->setDragEnabled(true);
     //ui->tab->setDropIndicatorShown(true);
    //tab->viewport()->setAcceptDrops(true);
     ui->tab->setEditTriggers(QAbstractItemView::NoEditTriggers);


}
Esempio n. 5
0
void Process::onFinished() {

    if( _state!=RUNNING ) return;

    if( sender()==_procwaiter ) {
        _state=FINISHED;
        emit finished();
        return;
    }

    for( int channel=0; channel<2; ++channel ) {
        if( sender()==_linereaders[channel] ) {
            if( _linereaders[channel]->isLineAvailable() ) {
                emit lineAvailable( channel );
            }
            return;
        }
    }
}
Esempio n. 6
0
void MyProcess::genericRead(QByteArray buffer) {
	QByteArray ba = remaining_output + buffer;
	int start = 0;
	int from_pos = 0;
	int pos = canReadLine(ba, from_pos);

	while ( pos > -1 ) {
		QByteArray line = ba.mid(start, pos-start);
		from_pos = pos + 1;
#if defined(Q_OS_WIN) || defined(Q_OS_OS2)
		if ((from_pos < ba.size()) && (ba.at(from_pos)=='\n')) from_pos++;
#endif
		start = from_pos;

		emit lineAvailable(line);

		pos = canReadLine(ba, from_pos);
	}

	remaining_output = ba.mid(from_pos);
}
Esempio n. 7
0
IBMediaControlC::IBMediaControlC(QObject * parent):MyProcess(parent)
{
    init();
    connect(this,SIGNAL(lineAvailable(QString)),this,SLOT(parseLine(QString)));
}