dbMediaType = new DbMediaType(this);
dbExec = new DbExecutable(this);
dbMic = 0;
- proc = 0;
emuHelper = new EmuHelper(this);
initWidgets();
layout();
EmuLauncher::~EmuLauncher()
{
- if (proc) {
- proc->kill(); // TODO: do this in a more sophisticated way
- delete proc;
- }
+ if (emuHelper) {
+ qDebug() << "EmuLauncher destructor";
+ if (emuHelper->state() == EmuHelper::Running)
+ qDebug() << "EmuHelper process is running, killing...";
+ emuHelper->kill();
+ }
}
void EmuLauncher::updateData()
mediaTypeSelectBox = new EFFileObjectComboBox(dbMediaType, this);
platformSelectBox = new EFFileObjectComboBox(dbPlatform, this);
execSelectBox = new ExecutableComboBox(dbExec, this);
- selectButton = new QPushButton(tr("&Update"));
- launchButton = new QPushButton(tr("&Launch"));
+ selectButton = new QPushButton(tr("&Update"), this);
+ launchButton = new QPushButton(tr("&Launch"), this);
}
void EmuLauncher::layout()
grid->addWidget(micTable, 2, 0, 1, 2);
grid->addWidget(execSelectBox, 3, 0);
grid->addWidget(launchButton, 3, 1);
+ // grid will be implicitily parented to this
setLayout(grid);
}
if (!dbMic) dbMic = new DbMediaImageContainer(this);
dbMic->filter(mtid, plfid);
micTable->setModel(dbMic->getDataModel());
+ micTable->hideColumn(DbMediaImageContainer::MIC_FileId);
+ micTable->hideColumn(DbMediaImageContainer::MIC_FileSize);
+ micTable->hideColumn(DbMediaImageContainer::MIC_FileCheckSum);
+ micTable->hideColumn(DbMediaImageContainer::MIC_FilePathId);
+ micTable->hideColumn(DbMediaImageContainer::MIC_FilePathName);
+ micTable->hideColumn(DbMediaImageContainer::MIC_SetupId);
+ micTable->hideColumn(DbMediaImageContainer::MIC_PlatformName);
+ micTable->hideColumn(DbMediaImageContainer::MIC_PlatformId);
+ micTable->hideColumn(DbMediaImageContainer::MIC_MediaTypeName);
+ micTable->hideColumn(DbMediaImageContainer::MIC_MediaTypeId);
micTable->resizeColumnsToContents();
platformSelectBox->updateDataModel();
mediaTypeSelectBox->updateDataModel();
if (!execSelectBox || execSelectBox->currentIndex() == -1) {
throw EmuFrontException(tr("Emulator not selected!"));
}
- //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!"));
}
throw EmuFrontException(tr("Failed creating Emulator object!"));
}
- // TODO: multiple media image container selection
- // - build a list of selected media image objects
- // - check that the platform and media type (setup) matches
foreach(QModelIndex mind, listMIndex) {
+ if (!mind.isValid()) continue;
EmuFrontObject *obImg = dbMic->getDataObjectFromModel(&mind);
if (!obImg) {
qDebug() << "Failed creating media image container at row " << mind.row();
mediaImageContainers << mic;
QMap<QString, EmuFrontObject*> contained = mic->getMediaImages();
mediaImages.unite(contained);
- /*QMapIterator<QString, MediaImage*> it(contained);
- while (it.hasNext()){
- mediaImages << it.value();
- }*/
}
if (mediaImages.count() < 1) {
// check if command options have slots for nr media images > 1 e.g. "-diska $1 -diskb $2 ..."
QString opts = exe->getOptions();
- QRegExp rx("(\\s\\$\\d+\\s)");
+ QRegExp rx("(\\$\\d+)");
QStringList list;
int pos = 0;
while ((pos = rx.indexIn(opts, pos)) != -1) {
bool ok;
QList<EmuFrontObject*> selectedImages;
+ if (list.count() > mediaImages.count()) {
+ throw EmuFrontException(tr("Select %1 media images for this emulator configuration").arg(list.count()));
+ }
if (list.count() > 1) {
- for(int i = 0; i < list.count(); i++) {
+ int lim = list.count() == mediaImages.count() ? list.count() - 1 : list.count();
+ for(int i = 0; i < lim; i++) {
EmuFrontObject *efo = EmuFrontInputDialog::getItem(
this, tr("Select image no. %1").arg(i+1), tr("Select"), mediaImages.values(), 0, false, &ok);
if (!ok) {
}
selectedImages << efo;
MediaImage *mi = dynamic_cast<MediaImage*>(efo);
- mediaImages.remove(mi->getCheckSum());
+ QString key = mi->getCheckSum();
+ mediaImages.remove(key);
+ }
+ if (mediaImages.count() == 1) {
+ // there should be at least one media image left in mediaImages map
+ selectedImages << mediaImages.values().first();
}
}
else if (mediaImages.count() > 1) {
if (selectedImages.count() < 1)
throw EmuFrontException(tr("No media images selected"));
- emuHelper->launch(exe, mediaImageContainers, selectedImages);
+ emuHelper->launch(exe, mediaImageContainers, selectedImages, list.count());
+ micTable->clearSelection();
} catch (EmuFrontException efe) {
delete exe;
qDeleteAll(mediaImageContainers);
QString stdErr = emuHelper->readAllStandardError();
QMessageBox::warning(this, tr("Emulator"),
tr("Launching emulator failed with: %1.\n").arg(e)
- .append(";\n").append(proc->errorString().append(";\n")
+ .append(";\n").append(emuHelper->errorString().append(";\n")
.append(stdErr)), QMessageBox::Ok );
}
QString stdErr = emuHelper->readAllStandardError();
QString stdMsg = emuHelper->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);
+ if (a) msg.append("; ").append(emuHelper->errorString()).append(";\n").append(stdErr);
QMessageBox::information(this, tr("Emulator finished"), msg, QMessageBox::Ok);
}