+ if (parent.isValid())
+ return false; // This is a flat model
+ if (rowCount() < row)
+ row = rowCount() + 1;
+
+ // Fetch a setup for an initial selection
+ int supId = -1;
+ QSqlQuery q;
+ q.exec(QString("SELECT setup.id, "
+ // The following is to get the correct order:
+ "platform.name || ' ' || mediatype.name AS SetupName "
+ "FROM setup "
+ "INNER JOIN platform ON setup.platformid=platform.id "
+ "INNER JOIN mediatype ON setup.mediatypeid=mediatype.id "
+ "ORDER BY SetupName "
+ "LIMIT 1"));
+ if (q.first()) {
+ supId = q.value(0).toInt();
+ qDebug() << "Got id " << supId << " for default setup.";
+ }
+ else {
+ throw EmuFrontException(tr("No setups yet available for file path configuration!"));
+ }
+ q.prepare(QString("INSERT INTO executable "
+ "(id, name, executable, options, type, setupid) "
+ "VALUES (NULL, '', '', '', :type, :supid)"
+ ));
+ beginInsertRows(QModelIndex(), row, row + count - 1);
+ for(int i = 0; i < count; ++i) {
+ q.bindValue(":supid", supId);
+ q.bindValue(":type", Executable::ExecutableType_Emulator);
+ if (!q.exec()) {
+ throw EmuFrontException(tr("Failed creating new external executable row: %1").
+ arg(q.lastError().text()));
+ }
+ }
+ endInsertRows();
+ refresh();
+ return true;