From: Mikko Keinänen Date: Sat, 20 Nov 2010 22:02:11 +0000 (+0200) Subject: Fixed bug in main window: selected platform and media types remain X-Git-Url: http://vcs.maemo.org/git/?p=emufront;a=commitdiff_plain;h=c4353a2bafa8739d34febdf0c32b61c6ff65a55e Fixed bug in main window: selected platform and media types remain selected after update button is pressed. --- diff --git a/src/emulauncher.cpp b/src/emulauncher.cpp index f141afe..3e75ed9 100644 --- a/src/emulauncher.cpp +++ b/src/emulauncher.cpp @@ -133,8 +133,6 @@ void EmuLauncher::updateMediaImageContainers() micTable->hideColumn(DbMediaImageContainer::MIC_MediaTypeName); micTable->hideColumn(DbMediaImageContainer::MIC_MediaTypeId); micTable->resizeColumnsToContents(); - platformSelectBox->updateDataModel(); - mediaTypeSelectBox->updateDataModel(); execSelectBox->updateToSetup(plfid, mtid); } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 5354d83..928ea76 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -267,7 +267,7 @@ void MainWindow::updateData() void MainWindow::about() { - QMessageBox::about(this, aboutTitle, aboutStr ); + QMessageBox::about(this, aboutTitle, aboutStr); } bool MainWindow::testDB(bool reset) diff --git a/src/widgets/efcombobox.cpp b/src/widgets/efcombobox.cpp index 5a8db80..2d0a487 100644 --- a/src/widgets/efcombobox.cpp +++ b/src/widgets/efcombobox.cpp @@ -50,28 +50,26 @@ void EFComboBox::updateDataModel(bool reset) Throws EmuFrontException */ -EmuFrontObject* EFComboBox::getSelected() const +EmuFrontObject* EFComboBox::getSelected() { EmuFrontObject *efo = 0; int index = currentIndex(); - qDebug() << "Selected index " << index << "."; if (index < 0) return 0; QSqlQueryModel *qmodel = dynamic_cast(model()); if (!qmodel) { - qDebug() << "No data model available!"; - return 0; + throw EmuFrontException(tr("No data model available!")); } QSqlRecord rec = qmodel->record(index); if (rec.isEmpty()) { - qDebug() << "No record available!"; - return efo; + throw EmuFrontException(tr("No data available for selected item!")); } - qDebug() << "Fetching a data object with id " - << rec.value(dataModelIndex_id).toInt(); - EmuFrontObject *o - = dbManager->getDataObject(rec.value(dataModelIndex_id).toInt()); /* Throws EmuFrontException */ + int id = rec.value(dataModelIndex_id).toInt(); + EmuFrontObject *o = dbManager->getDataObject(id); /* Throws EmuFrontException */ + dbManager->resetModel(); + setCurrentIndex(index); + if (!o) throw EmuFrontException(tr("Failed creating selected data object!")); return o; } diff --git a/src/widgets/efcombobox.h b/src/widgets/efcombobox.h index d3c05a3..c35971e 100644 --- a/src/widgets/efcombobox.h +++ b/src/widgets/efcombobox.h @@ -28,7 +28,7 @@ class EFComboBox : public QComboBox public: EFComboBox(DatabaseManager *dbMan, QWidget *parent = 0); ~EFComboBox(); - EmuFrontObject* getSelected() const; + EmuFrontObject* getSelected(); // This will replace DataObjectEditDialog::setSelected! void setSelected(const EmuFrontObject*); // reset sets the data model to orinal, non filtered setting