Implemented Executable editor (for configurating emulators).
authorMikko Keinänen <mikko.keinanen@gmail.com>
Tue, 5 Oct 2010 20:54:42 +0000 (23:54 +0300)
committerMikko Keinänen <mikko.keinanen@gmail.com>
Tue, 5 Oct 2010 20:54:42 +0000 (23:54 +0300)
13 files changed:
doc/uml-dialogs.dia
src/db/dbexecutable.cpp
src/db/dbexecutable.h
src/dialogs/executableeditdialog.cpp [new file with mode: 0644]
src/dialogs/executableeditdialog.h [new file with mode: 0644]
src/dialogs/executablemaindialog.cpp [new file with mode: 0644]
src/dialogs/executablemaindialog.h [new file with mode: 0644]
src/dialogs/setupeditdialog.cpp
src/dialogs/setupeditdialog.h
src/emufront.pro
src/mainwindow.cpp
src/mainwindow.h
www/index.html

index 924938f..da7d0ff 100644 (file)
Binary files a/doc/uml-dialogs.dia and b/doc/uml-dialogs.dia differ
index 0b3ce08..dc0217b 100644 (file)
@@ -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;
+}
+
index dac954c..8abde64 100644 (file)
@@ -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 (file)
index 0000000..9b15a02
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+
+#include <QtGui>
+#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<Executable*>(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<Executable*>(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<Setup*>(o);
+    return ex;
+}
+
+void ExecutableEditDialog::updateData()
+{
+    setupComBox->updateDataModel();
+}
diff --git a/src/dialogs/executableeditdialog.h b/src/dialogs/executableeditdialog.h
new file mode 100644 (file)
index 0000000..5987861
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+
+#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 (file)
index 0000000..877a338
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+
+#include <QtGui>
+#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<Executable*>(dbObject));
+}
+
+void ExecutableMainDialog::deleteCurrentObject()
+{
+   delete dynamic_cast<Executable*>(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 (file)
index 0000000..55dfb03
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+
+#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
index e12ad85..1fa8017 100644 (file)
@@ -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();
index eb21559..fa86ce1 100644 (file)
@@ -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;
index 9c48fca..477f0f7 100644 (file)
@@ -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 += 
index bfb1efa..f1f149c 100644 (file)
@@ -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()
index 326395a..5c98993 100644 (file)
@@ -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;
index be200b0..e0ef0d1 100644 (file)
@@ -10,7 +10,7 @@
                <h1>Welcome to EmuFront!</h1>
 
                <p>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.</p>
 
                <p>EmuFront is Open Source Software licenced under GPL version 2.</p>