Refresh model after update on data (TODO: maybe a common model
[emufront] / src / mainwindow.cpp
index 858aede..25da5ad 100644 (file)
@@ -1,38 +1,44 @@
-// 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/>.
-
+/*
+** 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 <QtGui>
 #include "mainwindow.h"
 #include "emulauncher.h"
 // TODO: deprecated
-#include "dialogs/platformdialog.h"
-#include "dialogs/platformmaindialog.h"
-#include "dialogs/mediatypedialog.h"
+//#include "platformdialog.h"
+#include "platformeditview.h"
+//#include "mediatypedialog.h"
+#include "mediatypeeditview.h"
+// TODO: DEPRECATED
+//#include "mediaimagepathmaindialog.h"
+#include "filepatheditview.h"
+// TODO: deprecated
+//#include "setupmaindialog.h"
+#include "setupeditview.h"
 // TODO: deprecated
-#include "dialogs/mediatypemaindialog.h"
-#include "dialogs/mediaimagepathmaindialog.h"
-#include "dialogs/setupmaindialog.h"
-#include "dialogs/executablemaindialog.h"
-#include "utils/datfileutil.h"
-#include "db/databasemanager.h"
-#include "db/dbcreator.h"
-#include "db/dbconfig.h"
+//#include "executablemaindialog.h"
+#include "externalexecutableeditview.h"
+#include "datfileutil.h"
+#include "databasemanager.h"
+#include "dbcreator.h"
+#include "dbconfig.h"
 
 QString MainWindow::aboutStr = trUtf8(
         "<h2>EmuFront</h2>"
@@ -61,14 +67,20 @@ MainWindow::MainWindow(bool reset)
     createStatusBar();
     readSettings();
     // TODO: deprecated
-    platformDialog = 0;
+    //platformDialog = 0;
     plfDialog = 0;
     // TODO: deprecated
-    mediaTypeDialog = 0;
+    //mediaTypeDialog = 0;
     mdtDialog = 0;
-    mediaImagePathDialog = 0;
-    setupMainDialog = 0;
-    executableMainDialog = 0;
+    // TODO: DEPRECATED
+    //mediaImagePathDialog = 0;
+    mediaImagePathView = 0;
+    // TODO: deprecated
+    //setupMainDialog = 0;
+    setupMainView = 0;
+    // TODO: deprecated
+    //executableMainDialog = 0;
+    emulatorEditView = 0;
 }
 
 void MainWindow::connectSignals()
@@ -78,10 +90,10 @@ void MainWindow::connectSignals()
 void MainWindow::createActions()
 {
     // TODO: deprecated
-    configPlatformAction = new QAction(tr("&Platforms"), this);
+    /*configPlatformAction = new QAction(tr("&Platforms"), this);
     configPlatformAction->setStatusTip(tr("Configure platforms"));
     connect(configPlatformAction, SIGNAL(triggered()),
-        this, SLOT(configurePlatforms()));
+        this, SLOT(configurePlatforms()));*/
 
     configPlatformsAction = new QAction(tr("&Set Platforms"), this);
     configPlatformsAction->setStatusTip(tr("Add, edit and delete platforms"));
@@ -89,26 +101,42 @@ void MainWindow::createActions()
         this, SLOT(configurePlatformss()));
 
     // TODO: deprecated
-    configMediaTypeAction = new QAction(tr("&Media Types"), this);
+    /*configMediaTypeAction = new QAction(tr("&Media Types"), this);
     configMediaTypeAction->setStatusTip(tr("Configure media types"));
-    connect(configMediaTypeAction, SIGNAL(triggered()), this, SLOT(configureMediaTypes()));
+    connect(configMediaTypeAction, SIGNAL(triggered()), this, SLOT(configureMediaTypes()));*/
 
     configMediaTypesAction = new QAction(tr("&Set Media Types"), this);
-    configMediaTypeAction->setStatusTip(tr("Add, edit and delete media types"));
+    configMediaTypesAction->setStatusTip(tr("Add, edit and delete media types"));
     connect(configMediaTypesAction, SIGNAL(triggered()), this, SLOT(configureMediaTypess()));
 
-    configMediaImagePathAction = new QAction(tr("Media &Image Paths"), this);
+    // TODO: DEPRECATED
+    /*configMediaImagePathAction = new QAction(tr("Media &Image Paths"), this);
     configMediaImagePathAction->setStatusTip(tr("Configure media image file paths."));
     connect(configMediaImagePathAction, SIGNAL(triggered()),
-        this, SLOT(configureMediaImagePaths()));
+        this, SLOT(configureMediaImagePaths()));*/
 
-    configSetupAction = new QAction(tr("S&etups"), this);
+    configMediaImagePathsAction = new QAction(tr("Set media &image paths"), this);
+    configMediaImagePathsAction->setStatusTip(tr("Add, edit and delete media image file paths."));
+    connect(configMediaImagePathsAction, SIGNAL(triggered()),
+        this, SLOT(configureMediaImagePathss()));
+
+    // TODO: deprecated
+    /*configSetupAction = new QAction(tr("S&etups"), this);
     configSetupAction->setStatusTip(tr("Configure set ups"));
-    connect(configSetupAction, SIGNAL(triggered()), this, SLOT(configureSetups()));
+    connect(configSetupAction, SIGNAL(triggered()), this, SLOT(configureSetups()));*/
+
+    configSetupsAction = new QAction(tr("Configure S&etups"), this);
+    configSetupsAction->setStatusTip(tr("Add, edit and delete setups"));
+    connect(configSetupsAction, SIGNAL(triggered()), this, SLOT(configureSetupss()));
 
-    configEmulatorAction = new QAction(tr("Em&ulators"), this);
+    /*configEmulatorAction = new QAction(tr("Em&ulators"), this);
     configEmulatorAction->setStatusTip(tr("Configure emulators"));
-    connect(configEmulatorAction, SIGNAL(triggered()), this, SLOT(configureEmulators()));
+    connect(configEmulatorAction, SIGNAL(triggered()), this, SLOT(configureEmulators()));*/
+
+    configEmulatorsAction = new QAction(tr("Configure Em&ulators"), this);
+    configEmulatorsAction->setStatusTip(tr("Add, edit and delete emulator configurations"));
+    connect(configEmulatorsAction, SIGNAL(triggered()), this, SLOT(configureEmulatorss()));
+
 
     configTmpDirAction = new QAction(tr("&Temp dir"), this);
     configTmpDirAction->setStatusTip(tr("Configure directory for temporary files."));
@@ -133,7 +161,7 @@ void MainWindow::createActions()
 }
 
 // TODO: deprecated
-void MainWindow::configurePlatforms()
+/*void MainWindow::configurePlatforms()
 {
    if (!platformDialog)
    {
@@ -141,19 +169,19 @@ void MainWindow::configurePlatforms()
        connect(platformDialog, SIGNAL(finished(int)), this, SLOT(updateData()));
    }
    activateDialog(platformDialog);
-}
+}*/
 
 void MainWindow::configurePlatformss()
 {
     if (!plfDialog) {
-        plfDialog = new PlatformMainDialog(this);
+        plfDialog = new PlatformEditView(this);
         connect(plfDialog, SIGNAL(finished(int)), this, SLOT(updateData()));
     }
     activateDialog(plfDialog);
 }
 
 // TODO: deprecated
-void MainWindow::configureMediaTypes()
+/*void MainWindow::configureMediaTypes()
 {
     if (!mediaTypeDialog)
     {
@@ -161,40 +189,61 @@ void MainWindow::configureMediaTypes()
         connect(mediaTypeDialog, SIGNAL(finished(int)), this, SLOT(updateData()));
    }
    activateDialog(mediaTypeDialog);
-}
+}*/
 
 void MainWindow::configureMediaTypess()
 {
     if (!mdtDialog)
     {
-        mdtDialog = new MediaTypeMainDialog(this);
+        mdtDialog = new MediaTypeEditView(this);
         connect(mdtDialog, SIGNAL(finished(int)), this, SLOT(updateData()));
    }
    activateDialog(mdtDialog);
 }
 
 
-void MainWindow::configureMediaImagePaths()
+// TODO: DEPRECATED
+/*void MainWindow::configureMediaImagePaths()
 {
     if (!mediaImagePathDialog)
     {
         mediaImagePathDialog = new MediaImagePathMainDialog(this);
     }
     activateDialog(mediaImagePathDialog);
+}*/
+
+void MainWindow::configureMediaImagePathss()
+{
+    if (!mediaImagePathView)
+    {
+        mediaImagePathView = new FilePathEditView(this);
+    }
+    activateDialog(mediaImagePathView);
 }
 
-void MainWindow::configureSetups()
+// TODO: deprecated
+/*void MainWindow::configureSetups()
 {
     if (!setupMainDialog)
     {
-        qDebug() << "MainWindow: Creating a setup main dialog.";
         setupMainDialog = new SetupMainDialog(this);
     }
     activateDialog(setupMainDialog);
     setupMainDialog->refreshDataModel();
+}*/
+
+void MainWindow::configureSetupss()
+{
+    if (!setupMainView) {
+        setupMainView = new SetupEditView(this);
+        connect(setupMainView, SIGNAL(finished(int)), this, SLOT(updateData()));
+    }
+    activateDialog(setupMainView);
 }
 
-void MainWindow::configureEmulators()
+
+// TODO: deprecated
+/*void MainWindow::configureEmulators()
 {
     if (!executableMainDialog) {
         executableMainDialog = new ExecutableMainDialog(this);
@@ -202,6 +251,15 @@ void MainWindow::configureEmulators()
     }
     activateDialog(executableMainDialog);
     executableMainDialog->refreshDataModel();
+}*/
+
+void MainWindow::configureEmulatorss()
+{
+    if (!emulatorEditView) {
+        emulatorEditView = new ExternalExecutableEditView(this);
+        connect(emulatorEditView, SIGNAL(finished(int)), this, SLOT(updateData()));
+    }
+    activateDialog(emulatorEditView);
 }
 
 void MainWindow::configureTmpDir()
@@ -263,14 +321,20 @@ void MainWindow::createMenus()
     configMenu->addAction(configTmpDirAction);
     configMenu->addSeparator();
     // TODO: deprecated
-    configMenu->addAction(configPlatformAction);
+    //configMenu->addAction(configPlatformAction);
     configMenu->addAction(configPlatformsAction);
     // TODO: deprecated
-    configMenu->addAction(configMediaTypeAction);
+    //configMenu->addAction(configMediaTypeAction);
     configMenu->addAction(configMediaTypesAction);
-    configMenu->addAction(configSetupAction);
-    configMenu->addAction(configMediaImagePathAction);
-    configMenu->addAction(configEmulatorAction);
+    // TODO: deprecated
+    //configMenu->addAction(configSetupAction);
+    configMenu->addAction(configSetupsAction);
+    // TODO: DEPRECATED
+    //configMenu->addAction(configMediaImagePathAction);
+    configMenu->addAction(configMediaImagePathsAction);
+    // TODO: DEPRECATED
+    //configMenu->addAction(configEmulatorAction);
+    configMenu->addAction(configEmulatorsAction);
     configMenu->addSeparator();
     configMenu->addAction(manageDatFilesAction);
 
@@ -339,7 +403,7 @@ bool MainWindow::testDB(bool reset)
             else throw EmuFrontException("The current database is not compatible!"
                                          " Cannot continue.");
         }
-
+    
         if (reset) {
             createDB();
         }