From: Mikko Keinänen Date: Tue, 19 Oct 2010 18:39:04 +0000 (+0300) Subject: Fixed selection of multiple images for multiple image slots in emulator X-Git-Url: http://vcs.maemo.org/git/?a=commitdiff_plain;h=d79e79c9de669d9d96905853bb35b1f64767c4bd;p=emufront Fixed selection of multiple images for multiple image slots in emulator command line options. --- diff --git a/src/emulauncher.cpp b/src/emulauncher.cpp index a190248..063cccd 100644 --- a/src/emulauncher.cpp +++ b/src/emulauncher.cpp @@ -122,12 +122,8 @@ void EmuLauncher::launchEmu() 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!")); } @@ -142,10 +138,8 @@ void EmuLauncher::launchEmu() 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(); @@ -160,10 +154,6 @@ void EmuLauncher::launchEmu() mediaImageContainers << mic; QMap contained = mic->getMediaImages(); mediaImages.unite(contained); - /*QMapIterator it(contained); - while (it.hasNext()){ - mediaImages << it.value(); - }*/ } if (mediaImages.count() < 1) { @@ -172,7 +162,7 @@ void EmuLauncher::launchEmu() // 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("(\\s\\$\\d+)"); QStringList list; int pos = 0; while ((pos = rx.indexIn(opts, pos)) != -1) { @@ -182,8 +172,12 @@ void EmuLauncher::launchEmu() bool ok; QList 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) { @@ -193,6 +187,10 @@ void EmuLauncher::launchEmu() MediaImage *mi = dynamic_cast(efo); mediaImages.remove(mi->getCheckSum()); } + if (list.count() == mediaImages.count() && mediaImages.count() == 1) { + // there should be only one media image left in mediaImages map + selectedImages << mediaImages.values().first(); + } } else if (mediaImages.count() > 1) { // show select boot image dialog