QInputDialog.
--- /dev/null
+#include "emufrontinputdialog.h"
+#include <QMap>
+#include "../dataobjects/emufrontobject.h"
+
+EmuFrontInputDialog::EmuFrontInputDialog(QWidget *parent, Qt::WindowFlags flags)
+ : QInputDialog(parent, flags)
+{
+}
+
+EmuFrontObject* EmuFrontInputDialog::getItem(QWidget *parent, const QString &title, const QString &label,
+ const QList<EmuFrontObject*> &items, int current, bool editable,
+ bool *ok, Qt::WindowFlags flags)
+{
+ QStringList l;
+ QMap<QString, EmuFrontObject*> map;
+ foreach(EmuFrontObject *efo, items){
+ l << efo->getName();
+ map[efo->getName()] = efo;
+ }
+ QString sel = QInputDialog::getItem(parent, title, label, l, current, editable, ok, flags);
+ return map.value(sel, 0);
+}
--- /dev/null
+#ifndef EMUFRONTINPUTDIALOG_H
+#define EMUFRONTINPUTDIALOG_H
+
+#include <QInputDialog>
+
+class EmuFrontObject;
+class EmuFrontInputDialog : public QInputDialog
+{
+public:
+ EmuFrontInputDialog(QWidget *parent = 0, Qt::WindowFlags flags = 0);
+ static EmuFrontObject* getItem(QWidget *parent, const QString &title, const QString &label,
+ const QList<EmuFrontObject*> &items, int current = 0, bool editable = true,
+ bool *ok = 0, Qt::WindowFlags flags = 0);
+};
+
+#endif // EMUFRONTINPUTDIALOG_H
--- /dev/null
+// EmuFront
+// Copyright 2010 Mikko Keinänen
+//
+// This file is part of EmuFront.
+//
+//
+// EmuFront is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as published by
+// the Free Software Foundation and appearing in the file gpl.txt included in the
+// packaging of this file.
+//
+// EmuFront is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with EmuFront. If not, see <http://www.gnu.org/licenses/>.
+
+#include "listdialog.h"
+#include <QtGui>
+#include "../dataobjects/emufrontobject.h"
+
+ListDialog::ListDialog(QWidget *parent)
+ : QDialog(parent)
+{
+ listView = new QListWidget(this);
+ buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok, Qt::Vertical);
+
+}
+
+void ListDialog::setData(QList<EmuFrontObject *> list)
+{
+ foreach(EmuFrontObject *efo, list) {
+ listView->addItem(efo->getName());
+ }
+}
+
+void ListDialog::layout()
+{
+ QHBoxLayout *mainLayout = new QHBoxLayout;
+ mainLayout->addWidget(listView);
+ mainLayout->addWidget(buttonBox);
+ setLayout(mainLayout);
+}
--- /dev/null
+// EmuFront
+// Copyright 2010 Mikko Keinänen
+//
+// This file is part of EmuFront.
+//
+//
+// EmuFront is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as published by
+// the Free Software Foundation and appearing in the file gpl.txt included in the
+// packaging of this file.
+//
+// EmuFront is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with EmuFront. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef LISTDIALOG_H
+#define LISTDIALOG_H
+
+#include <QDialog>
+
+class QListWidget;
+class QDialogButtonBox;
+class EmuFrontObject;
+
+class ListDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ ListDialog(QWidget *parent = 0);
+ void setData(QList<EmuFrontObject*>);
+private:
+ QListWidget *listView;
+ QDialogButtonBox *buttonBox;
+ void layout();
+};
+
+#endif // LISTDIALOG_H
widgets/executablecombobox.h \
utils/processhelper.h \
utils/unziphelper.h \
- utils/emuhelper.h
+ utils/emuhelper.h \
+ dialogs/listdialog.h \
+ dialogs/emufrontinputdialog.h
SOURCES += main.cpp \
mainwindow.cpp \
db/databasemanager.cpp \
widgets/executablecombobox.cpp \
utils/processhelper.cpp \
utils/unziphelper.cpp \
- utils/emuhelper.cpp
+ utils/emuhelper.cpp \
+ dialogs/listdialog.cpp \
+ dialogs/emufrontinputdialog.cpp
OTHER_FILES +=
#include "widgets/executablecombobox.h"
#include "dataobjects/executable.h"
#include "utils/emuhelper.h"
+#include "dialogs/emufrontinputdialog.h"
EmuLauncher::EmuLauncher(QWidget *parent) :
QWidget(parent)
void EmuLauncher::launchEmu()
{
+ QList<EmuFrontObject*> mediaImages;
+ QList<MediaImageContainer*> mediaImageContainers;
+ Executable *exe;
try {
if (!micTable || !micTable->model()) {
throw EmuFrontException(tr("No search results available!"));
if (!obExe) {
throw EmuFrontException(tr("Failed fetching selected emulator!"));
}
- Executable *exe = dynamic_cast<Executable*>(obExe);
+ exe = dynamic_cast<Executable*>(obExe);
if (!exe) {
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
- QList<MediaImage*> mediaImages;
- QList<MediaImageContainer*> mediaImageContainers;
foreach(QModelIndex mind, listMIndex) {
EmuFrontObject *obImg = dbMic->getDataObjectFromModel(&mind);
if (!obImg) {
}
mediaImageContainers << mic;
QList<MediaImage*> contained = mic->getMediaImages();
- mediaImages << contained;
+ foreach(MediaImage *mi, contained)
+ mediaImages << mi;
}
if (mediaImages.count() < 1) {
- delete exe;
throw new EmuFrontException("No media images available!");
}
pos += rx.matchedLength();
}
+ QList<MediaImage*> selectedImages;
if (list.count() > 1) {
+ for(int i = 0; i < list.count(); i++) {
+ //QInputDialog::getItem();
+ // TODO: Use input dialog here
+ // Create a new input dialog class for emufrontobjects
+ }
// TODO: show dialog to set the media order (the images will be assigned to slots in the order in respect to the image list)
}
- else {
- // TODO: show select boot image dialog
+ else if (mediaImages.count() > 1) {
+ // show select boot image dialog
+ bool ok;
+ EmuFrontObject *efo = EmuFrontInputDialog::getItem(
+ this, tr("Select boot image"), tr("Select"), mediaImages, 0, false, &ok);
+ if (!ok) {
+ throw new EmuFrontException(tr("Boot image selection was canceled, aborting."));
+ }
}
// in the both cases the (ordered) list of media images will be passed to emuHelper
- foreach(MediaImage *mi, mediaImages) {
+ foreach(EmuFrontObject *mi, mediaImages) {
qDebug() << "Media image " << mi->getName();
}
emuHelper->launch(exe, mediaImageContainers, mediaImages);
} catch (EmuFrontException efe) {
+ delete exe;
+ qDeleteAll(mediaImageContainers);
+ qDeleteAll(mediaImages);
QMessageBox::information(this, tr("Launching emulator"),
efe.what(), QMessageBox::Ok);
return;
unzipHelper = new UnzipHelper(this);
}
-void EmuHelper::launch(const Executable * ex, QList<MediaImageContainer *> micList, QList<MediaImage *> miList)
+void EmuHelper::launch(const Executable * ex, QList<MediaImageContainer *> &micList, QList<EmuFrontObject *> &miList)
{
// extract the media image container to tmp folder
// (TODO: tmp folder configuration)
class Executable;
class MediaImageContainer;
class MediaImage;
+class EmuFrontObject;
class UnzipHelper;
class EmuHelper : public ProcessHelper
Q_OBJECT
public:
explicit EmuHelper(QObject *parent = 0);
- void launch(const Executable * ex, QList<MediaImageContainer *> micList, QList<MediaImage *> miList);
+ void launch(const Executable * ex, QList<MediaImageContainer *> &micList, QList<EmuFrontObject*> &miList);
private slots:
void processError(QProcess::ProcessError);
void processFinished(int);