- int mtid, plfid = -1;
- MediaType *mt = 0;
- Platform *plf = 0;
- try {
- mt = dynamic_cast<MediaType*>(mediaTypeSelectBox->getSelected());
- plf = dynamic_cast<Platform*>(platformSelectBox->getSelected());
- }
- catch(EmuFrontException &e){
- errorMessage->showMessage(e.what());
- return;
- }
- mtid = mt ? mt->getId() : -1;
- plfid = plf ? plf->getId() : -1;
- if (mt) delete mt;
- if (plf) delete plf;
+ if (setupSelectBox->currentIndex() == -1) return;
+
+ // 1. get selected platform and media type id
+ QAbstractItemModel *setupAbsModel = setupSelectBox->model();
+ SetupModel *supModel = qobject_cast<SetupModel *>(setupAbsModel);
+ if (!supModel) return;
+ QModelIndex plfInd =
+ supModel->index(setupSelectBox->currentIndex(), SetupModel::Setup_PlatformId);
+ int plfid = supModel->data(plfInd).toInt();
+ QModelIndex mtInd =
+ supModel->index(setupSelectBox->currentIndex(), SetupModel::Setup_MediaTypeId);
+ int mtid = supModel->data(mtInd).toInt();
+
+ if (mtid < 0 || plfid < 0) return;