From: Mikko Keinänen Date: Tue, 5 Oct 2010 20:54:42 +0000 (+0300) Subject: Implemented Executable editor (for configurating emulators). X-Git-Url: http://git.maemo.org/git/?a=commitdiff_plain;h=715ec50f3c909082074b28383881a577d63e5988;hp=2942a569f82d0f4416146b840ef57e02e4cbcc14;p=emufront Implemented Executable editor (for configurating emulators). --- diff --git a/doc/uml-dialogs.dia b/doc/uml-dialogs.dia index 924938f..da7d0ff 100644 Binary files a/doc/uml-dialogs.dia and b/doc/uml-dialogs.dia differ diff --git a/src/db/dbexecutable.cpp b/src/db/dbexecutable.cpp index 0b3ce08..dc0217b 100644 --- a/src/db/dbexecutable.cpp +++ b/src/db/dbexecutable.cpp @@ -141,3 +141,12 @@ bool DbExecutable::deleteDataObject(int id) const return false; } +QSqlQueryModel* DbExecutable::getData() +{ + QSqlQueryModel *model = new QSqlQueryModel; + QString select = constructSelect(); + // TODO ... + model->setQuery(select); + return model; +} + diff --git a/src/db/dbexecutable.h b/src/db/dbexecutable.h index dac954c..8abde64 100644 --- a/src/db/dbexecutable.h +++ b/src/db/dbexecutable.h @@ -38,7 +38,8 @@ public: Executable_Executable, Executable_Options, Executable_TypeId, - Executable_SetupId + Executable_SetupId, + Executable_SetupName }; protected: virtual EmuFrontObject* recordToDataObject(const QSqlRecord*); @@ -47,6 +48,7 @@ protected: virtual QString constructSelect(QString whereClause = "") const; virtual bool deleteDataObject(int id) const; private: + virtual QSqlQueryModel* getData(); DbSetup *dbSetup; }; diff --git a/src/dialogs/executableeditdialog.cpp b/src/dialogs/executableeditdialog.cpp new file mode 100644 index 0000000..9b15a02 --- /dev/null +++ b/src/dialogs/executableeditdialog.cpp @@ -0,0 +1,146 @@ +// 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 as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// 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 . + +#include +#include "executableeditdialog.h" +#include "../db/dbexecutable.h" +#include "../db/dbsetup.h" +#include "../dataobjects/executable.h" +#include "../dataobjects/setup.h" +#include "../widgets/setupcombobox.h" +#include "../exceptions/emufrontexception.h" + +ExecutableEditDialog::ExecutableEditDialog(QWidget *parent, EmuFrontObject *obj) + : DataObjectEditDialog(parent, obj) +{ + dbExecutable = 0; + dbSetup = new DbSetup(this); + initWidgets(); + connectSignals(); + layout(); +} + +void ExecutableEditDialog::initWidgets() +{ + setupComBox = new SetupComboBox(dbSetup, this); + nameEdit = new QLineEdit; + nameEdit->setToolTip(tr("Set an individual short " + "description for this emulator configuration.")); + execEdit = new QLineEdit; + execEdit->setToolTip(tr("Emulator executable in $PATH " + "or absolute path to emulator executable.")); + optEdit = new QLineEdit; + optEdit->setToolTip(tr("Command line parameters for the " + "emulator executable including $1 as file 1 to be " + "assigned to emulator, $2 as file 2, etc.")); +} + +void ExecutableEditDialog::layout() +{ + QLabel *nameLabel = new QLabel(tr("&Description")); + nameLabel->setBuddy(nameEdit); + QLabel *execLabel = new QLabel(tr("&Executable")); + execLabel->setBuddy(execEdit); + QLabel *optLabel = new QLabel(tr("&Parameters")); + optLabel->setBuddy(optEdit); + QLabel *setupLabel = new QLabel(tr("&Setup")); + setupLabel->setBuddy(setupComBox); + QGridLayout *gridLayout = new QGridLayout; + gridLayout->addWidget(nameLabel, 0, 0); + gridLayout->addWidget(nameEdit, 0, 1); + gridLayout->addWidget(execLabel, 1, 0); + gridLayout->addWidget(execEdit, 1, 1); + gridLayout->addWidget(optLabel, 2, 0); + gridLayout->addWidget(optEdit, 2, 1); + gridLayout->addWidget(setupLabel, 3, 0); + gridLayout->addWidget(setupComBox, 3, 1); + QVBoxLayout *mainLayout = new QVBoxLayout; + mainLayout->addLayout(gridLayout); + mainLayout->addWidget(buttonBox); + setLayout(mainLayout); + setWindowTitle(tr("Edit emulator configuration")); +} + +void ExecutableEditDialog::acceptChanges() +{ + Executable *ex = dynamic_cast(efObject); + try { + Setup *su = getSelectedSetup(); + if (!su) { + throw new EmuFrontException(tr("Setup not selected")); + } + QString name = nameEdit->text().trimmed(); + if (name.isEmpty()){ + throw new EmuFrontException(tr("Name is not set")); + } + QString exec = execEdit->text().trimmed(); + if (exec.isEmpty()){ + throw new EmuFrontException(tr("Executable is not set")); + } + QString opts = optEdit->text().trimmed(); + if (opts.isEmpty()) { + throw new EmuFrontException(tr("Options not set")); + } + Setup *supTmp = ex->getSetup(); + if (supTmp != su) { + delete supTmp; + ex->setSetup(su); + } + ex->setName(name); + ex->setExecutable(exec); + ex->setOptions(opts); + emit dataObjectUpdated(); + efObject = 0; + close(); + } catch(EmuFrontException x) { + QMessageBox::information(this, + tr("Updating emulator"), + x.what(), QMessageBox::Ok); + return; + } +} + +void ExecutableEditDialog::setDataObject(EmuFrontObject *ob) +{ + if (!ob) return; + efObject = ob; + Executable *ex = dynamic_cast(ob); + if (ex->getSetup()) setSelectedSetup(ex->getSetup()); + nameEdit->setText(ex->getName()); + execEdit->setText(ex->getExecutable()); + optEdit->setText(ex->getOptions()); +} + +void ExecutableEditDialog::setSelectedSetup(const Setup *su) +{ + setupComBox->setSelected(su); +} + +Setup* ExecutableEditDialog::getSelectedSetup() const +{ + EmuFrontObject *o = setupComBox->getSelected(); + if (!o) return 0; + Setup *ex = dynamic_cast(o); + return ex; +} + +void ExecutableEditDialog::updateData() +{ + setupComBox->updateDataModel(); +} diff --git a/src/dialogs/executableeditdialog.h b/src/dialogs/executableeditdialog.h new file mode 100644 index 0000000..5987861 --- /dev/null +++ b/src/dialogs/executableeditdialog.h @@ -0,0 +1,56 @@ +// 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 as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// 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 . + +#ifndef EXECUTABLEEDITDIALOG_H +#define EXECUTABLEEDITDIALOG_H + +#include "dataobjecteditdialog.h" + +class DbExecutable; +class DbSetup; +class Setup; +class SetupComboBox; +class QLineEdit; + +class ExecutableEditDialog : public DataObjectEditDialog +{ + Q_OBJECT +public: + ExecutableEditDialog(QWidget *parent, EmuFrontObject*); + virtual void setDataObject(EmuFrontObject *); + virtual void updateData(); + +protected slots: + virtual void acceptChanges(); + +private: + DbExecutable *dbExecutable; + DbSetup *dbSetup; + SetupComboBox *setupComBox; + void initWidgets(); + void layout(); + void setSelectedSetup(const Setup*); + Setup* getSelectedSetup() const; + QLineEdit *nameEdit; + QLineEdit *execEdit; + QLineEdit *optEdit; + +}; + +#endif // EXECUTABLEEDITDIALOG_H diff --git a/src/dialogs/executablemaindialog.cpp b/src/dialogs/executablemaindialog.cpp new file mode 100644 index 0000000..877a338 --- /dev/null +++ b/src/dialogs/executablemaindialog.cpp @@ -0,0 +1,59 @@ +// 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 as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// 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 . + +#include +#include "executablemaindialog.h" +#include "executableeditdialog.h" +#include "../db/dbexecutable.h" +#include "../dataobjects/executable.h" + +ExecutableMainDialog::ExecutableMainDialog(QWidget *parent) + : DbObjectDialog(parent) +{ + setWindowTitle(tr("Emulators")); + dbManager = new DbExecutable(this); + initDataTable(); + initEditDialog(); + objectList->hideColumn(DbExecutable::Executable_Id); + objectList->hideColumn(DbExecutable::Executable_TypeId); + objectList->hideColumn(DbExecutable::Executable_SetupId); + connectSignals(); +} + +ExecutableMainDialog::~ExecutableMainDialog() +{ + deleteCurrentObject(); +} + +void ExecutableMainDialog::initEditDialog() +{ + nameDialog = new ExecutableEditDialog( + this, dynamic_cast(dbObject)); +} + +void ExecutableMainDialog::deleteCurrentObject() +{ + delete dynamic_cast(dbObject); + dbObject = 0; +} + +EmuFrontObject* ExecutableMainDialog::createObject() +{ + return new Executable; +} diff --git a/src/dialogs/executablemaindialog.h b/src/dialogs/executablemaindialog.h new file mode 100644 index 0000000..55dfb03 --- /dev/null +++ b/src/dialogs/executablemaindialog.h @@ -0,0 +1,40 @@ +// 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 as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// 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 . + +#ifndef EXECUTABLEMAINDIALOG_H +#define EXECUTABLEMAINDIALOG_H + +#include "dbobjectdialog.h" + +class ExecutableMainDialog : public DbObjectDialog +{ + Q_OBJECT + +public: + ExecutableMainDialog(QWidget *parent); + ~ExecutableMainDialog(); + +protected: + virtual void deleteCurrentObject(); + virtual EmuFrontObject* createObject(); + virtual void initEditDialog(); + +}; + +#endif // EXECUTABLEMAINDIALOG_H diff --git a/src/dialogs/setupeditdialog.cpp b/src/dialogs/setupeditdialog.cpp index e12ad85..1fa8017 100644 --- a/src/dialogs/setupeditdialog.cpp +++ b/src/dialogs/setupeditdialog.cpp @@ -74,7 +74,8 @@ void SetupEditDialog::acceptChanges() Platform *plf = getSelectedPlatform(); if (!plf) { - QMessageBox::information(this, tr("Platform"), tr("Platform not selected"), QMessageBox::Ok); + QMessageBox::information(this, tr("Platform"), + tr("Platform not selected"), QMessageBox::Ok); return; } qDebug() << "Platform selected " << plf->getName(); diff --git a/src/dialogs/setupeditdialog.h b/src/dialogs/setupeditdialog.h index eb21559..fa86ce1 100644 --- a/src/dialogs/setupeditdialog.h +++ b/src/dialogs/setupeditdialog.h @@ -56,8 +56,8 @@ private: void initWidgets(); void layout(); - void populateMediaTypeComBox(); - void populatePlatformComBox(); + //void populateMediaTypeComBox(); + //void populatePlatformComBox(); void setSelectedMediaType(const MediaType*); void setSelectedPlatform(const Platform*); MediaType* getSelectedMediaType() const; diff --git a/src/emufront.pro b/src/emufront.pro index 9c48fca..477f0f7 100644 --- a/src/emufront.pro +++ b/src/emufront.pro @@ -58,7 +58,9 @@ HEADERS += mainwindow.h \ widgets/effileobjectcombobox.h \ widgets/setupcombobox.h \ dataobjects/executable.h \ - db/dbexecutable.h + db/dbexecutable.h \ + dialogs/executablemaindialog.h \ + dialogs/executableeditdialog.h SOURCES += main.cpp \ mainwindow.cpp \ db/databasemanager.cpp \ @@ -104,5 +106,7 @@ SOURCES += main.cpp \ widgets/effileobjectcombobox.cpp \ widgets/setupcombobox.cpp \ dataobjects/executable.cpp \ - db/dbexecutable.cpp + db/dbexecutable.cpp \ + dialogs/executablemaindialog.cpp \ + dialogs/executableeditdialog.cpp OTHER_FILES += diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index bfb1efa..f1f149c 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -24,6 +24,7 @@ #include "dialogs/mediatypedialog.h" #include "dialogs/mediaimagepathmaindialog.h" #include "dialogs/setupmaindialog.h" +#include "dialogs/executablemaindialog.h" #include "db/databasemanager.h" MainWindow::MainWindow() @@ -39,6 +40,7 @@ MainWindow::MainWindow() mediaTypeDialog = 0; mediaImagePathDialog = 0; setupMainDialog = 0; + executableMainDialog = 0; } void MainWindow::createActions() @@ -61,6 +63,10 @@ void MainWindow::createActions() configSetupAction->setStatusTip(tr("Configure set ups")); connect(configSetupAction, SIGNAL(triggered()), this, SLOT(configureSetups())); + configEmulatorAction = new QAction(tr("Em&ulators"), this); + configEmulatorAction->setStatusTip(tr("Configure emulators")); + connect(configEmulatorAction, SIGNAL(triggered()), this, SLOT(configureEmulators())); + exitAction = new QAction(tr("&Exit"), this); exitAction->setShortcut(tr("Ctrl+Q")); exitAction->setStatusTip(tr("Exit EmuFront")); @@ -105,6 +111,15 @@ void MainWindow::configureSetups() setupMainDialog->refreshDataModel(); } +void MainWindow::configureEmulators() +{ + if (!executableMainDialog) { + executableMainDialog = new ExecutableMainDialog(this); + } + activateDialog(executableMainDialog); + executableMainDialog->refreshDataModel(); +} + void MainWindow::activateDialog(EmuFrontDialog* dia) const { dia->show(); @@ -122,6 +137,7 @@ void MainWindow::createMenus() configMenu->addAction(configMediaTypeAction); configMenu->addAction(configMediaImagePathAction); configMenu->addAction(configSetupAction); + configMenu->addAction(configEmulatorAction); } void MainWindow::createStatusBar() diff --git a/src/mainwindow.h b/src/mainwindow.h index 326395a..5c98993 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -27,6 +27,7 @@ class PlatformDialog; class MediaTypeDialog; class MediaImagePathMainDialog; class SetupMainDialog; +class ExecutableMainDialog; class QLabel; class DatabaseManager; class EmuFrontDialog; @@ -48,6 +49,7 @@ private slots: void configureMediaTypes(); void configureMediaImagePaths(); void configureSetups(); + void configureEmulators(); private: void createActions(); @@ -61,12 +63,14 @@ private: MediaTypeDialog *mediaTypeDialog; MediaImagePathMainDialog *mediaImagePathDialog; SetupMainDialog *setupMainDialog; + ExecutableMainDialog *executableMainDialog; QMenu *configMenu; QMenu *fileMenu; QAction *configPlatformAction; QAction *configMediaTypeAction; QAction *configMediaImagePathAction; QAction *configSetupAction; + QAction *configEmulatorAction; QAction *exitAction; QLabel *messageLabel; DatabaseManager *dbManager; diff --git a/www/index.html b/www/index.html index be200b0..e0ef0d1 100644 --- a/www/index.html +++ b/www/index.html @@ -10,7 +10,7 @@

Welcome to EmuFront!

EmuFront is an universal (multi-system) emulator front-end implemented in - QT, C++ and SQLite. The main target are Maemo and MeeGo + QT, C++ and SQLite. The main targets are Maemo and MeeGo platforms.

EmuFront is Open Source Software licenced under GPL version 2.