#include <QtGui>
#include <QProcess>
#include <QSqlTableModel>
+#include <QItemSelectionModel>
#include "utils/OSDaB-Zip/unzip.h"
#include "emulauncher.h"
#include "db/dbmediatype.h"
void EmuLauncher::initWidgets()
{
micTable = new QTableView(this);
- micTable->setSelectionMode(QAbstractItemView::SingleSelection);
+ micTable->setSelectionMode(QAbstractItemView::MultiSelection);
mediaTypeSelectBox = new EFFileObjectComboBox(dbMediaType, this);
platformSelectBox = new EFFileObjectComboBox(dbPlatform, this);
execSelectBox = new ExecutableComboBox(dbExec, this);
if (!execSelectBox || execSelectBox->currentIndex() == -1) {
throw EmuFrontException(tr("Emulator not selected!"));
}
- // TODO: multiple media image container selection
- QModelIndex mindex = micTable->currentIndex();
- if (!mindex.isValid()) {
+ //QModelIndex mindex = micTable->currentIndex();
+ QItemSelectionModel *selModel = micTable->selectionModel();
+ QModelIndexList listMIndex = selModel->selectedIndexes();
+ /*if (!mindex.isValid()) {
+ throw EmuFrontException(tr("Media image container not selected!"));
+ }*/
+ if (listMIndex.count() < 1) {
throw EmuFrontException(tr("Media image container not selected!"));
}
+ qDebug() << listMIndex.count() << " items selected.";
+ // TODO: multiple media image container selection
+ QModelIndex mindex = listMIndex.first();
EmuFrontObject *obImg = dbMic->getDataObjectFromModel(&mindex);
if (!obImg) {
throw EmuFrontException(tr("Failed fetching selected media image container."));
delete mic;
if (!proc) {
proc = new QProcess(this); // This has to be done in the heap
- connect(proc, SIGNAL(error(QProcess::ProcessError)), this, SLOT(processError()));
+ connect(proc, SIGNAL(error(QProcess::ProcessError)), this, SLOT(processError(QProcess::ProcessError)));
+ connect(proc, SIGNAL(finished(int)), this, SLOT(processFinished(int)));
}
proc->start(cmdWithParams, QIODevice::ReadOnly);
}
-void EmuLauncher::processError()
+void EmuLauncher::processError(QProcess::ProcessError e)
{
+ QString stdErr = proc->readAllStandardError();
QMessageBox::warning(this, tr("Emulator"),
- tr("Launching emulator failed with: ").append(proc->errorString()), QMessageBox::Ok );
+ tr("Launching emulator failed with: %1.\n").arg(e)
+ .append(";\n").append(proc->errorString().append(";\n")
+ .append(stdErr)), QMessageBox::Ok );
+}
+
+void EmuLauncher::processFinished(int a)
+{
+ QString stdErr = proc->readAllStandardError();
+ QString stdMsg = proc->readAllStandardOutput();
+ QString msg = tr("Emulator has finished with: %1.\n").arg(a).append(stdMsg);
+ if (a) msg.append("; ").append(proc->errorString()).append(";\n").append(stdErr);
+ QMessageBox::information(this, tr("Emulator finished"), msg, QMessageBox::Ok);
}