Cleaned up commented out deprecated stuff.
[emufront] / src / mainwindow.cpp
index 928ea76..caee9af 100644 (file)
@@ -1,34 +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 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"
-#include "dialogs/platformdialog.h"
-#include "dialogs/mediatypedialog.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 "platformeditview.h"
+#include "mediatypeeditview.h"
+#include "filepatheditview.h"
+#include "setupeditview.h"
+#include "externalexecutableeditview.h"
+#include "externalexecutablemodel.h"
+#include "datfileutil.h"
+#include "databasemanager.h"
+#include "dbcreator.h"
+#include "dbconfig.h"
+#include "setupmodel.h"
+#include "platformmodel.h"
+#include "mediatypemodel.h"
 
 QString MainWindow::aboutStr = trUtf8(
         "<h2>EmuFront</h2>"
@@ -50,17 +56,21 @@ MainWindow::MainWindow(bool reset)
     if (tmpDirFilePath.isEmpty())
         tmpDirFilePath = QDir::homePath();
     qDebug() << "Temporary dir is " << tmpDirFilePath;
-    launcher = new EmuLauncher(errorMessage, this, tmpDirFilePath);
+    supModel = new SetupModel(this);
+    plfModel = new PlatformModel(this);
+    mdtModel = new MediaTypeModel(this);
+       emuModel = new ExternalExecutableModel(this);
+    launcher = new EmuLauncher(errorMessage, supModel, emuModel, this, tmpDirFilePath);
     setCentralWidget(launcher);
     createActions();
     createMenus();
     createStatusBar();
     readSettings();
-    platformDialog = 0;
-    mediaTypeDialog = 0;
-    mediaImagePathDialog = 0;
-    setupMainDialog = 0;
-    executableMainDialog = 0;
+    plfDialog = 0;
+    mdtDialog = 0;
+    mediaImagePathView = 0;
+    setupMainView = 0;
+    emulatorEditView = 0;
 }
 
 void MainWindow::connectSignals()
@@ -69,27 +79,27 @@ void MainWindow::connectSignals()
 
 void MainWindow::createActions()
 {
-    configPlatformAction = new QAction(tr("&Platforms"), this);
-    configPlatformAction->setStatusTip(tr("Configure platforms"));
-    connect(configPlatformAction, SIGNAL(triggered()),
-           this, SLOT(configurePlatforms()));
+    configPlatformsAction = new QAction(tr("&Set Platforms"), this);
+    configPlatformsAction->setStatusTip(tr("Add, edit and delete platforms"));
+    connect(configPlatformsAction, SIGNAL(triggered()),
+        this, SLOT(configurePlatformss()));
 
-    configMediaTypeAction = new QAction(tr("&Media Types"), this);
-    configMediaTypeAction->setStatusTip(tr("Configure media types"));
-    connect(configMediaTypeAction, SIGNAL(triggered()), this, SLOT(configureMediaTypes()));
+    configMediaTypesAction = new QAction(tr("&Set Media Types"), this);
+    configMediaTypesAction->setStatusTip(tr("Add, edit and delete media types"));
+    connect(configMediaTypesAction, SIGNAL(triggered()), this, SLOT(configureMediaTypess()));
 
-    configMediaImagePathAction = new QAction(tr("Media &Image Paths"), this);
-    configMediaImagePathAction->setStatusTip(tr("Configure media image file paths."));
-    connect(configMediaImagePathAction, SIGNAL(triggered()),
-        this, SLOT(configureMediaImagePaths()));
+    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()));
 
-    configSetupAction = new QAction(tr("S&etups"), this);
-    configSetupAction->setStatusTip(tr("Configure set ups"));
-    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->setStatusTip(tr("Configure emulators"));
-    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."));
@@ -113,71 +123,68 @@ void MainWindow::createActions()
     connect(aboutAction, SIGNAL(triggered()), this, SLOT(about()));
 }
 
-void MainWindow::configurePlatforms()
+void MainWindow::configurePlatformss()
 {
-   if (!platformDialog)
-   {
-       platformDialog = new PlatformDialog(this);
-       connect(platformDialog, SIGNAL(finished(int)), this, SLOT(updateData()));
-   }
-   activateDialog(platformDialog);
+    if (!plfDialog) {
+        plfDialog = new PlatformEditView(plfModel, this);
+        connect(plfDialog, SIGNAL(finished(int)), this, SLOT(updateData()));
+    }
+    activateDialog(plfDialog);
 }
 
-void MainWindow::configureMediaTypes()
+void MainWindow::configureMediaTypess()
 {
-    if (!mediaTypeDialog)
+    if (!mdtDialog)
     {
-        mediaTypeDialog = new MediaTypeDialog(this);
-        connect(mediaTypeDialog, SIGNAL(finished(int)), this, SLOT(updateData()));
+        mdtDialog = new MediaTypeEditView(mdtModel, this);
+        connect(mdtDialog, SIGNAL(finished(int)), this, SLOT(updateData()));
    }
-   activateDialog(mediaTypeDialog);
+   activateDialog(mdtDialog);
 }
 
-void MainWindow::configureMediaImagePaths()
+void MainWindow::configureMediaImagePathss()
 {
-    if (!mediaImagePathDialog)
+    if (!mediaImagePathView)
     {
-        mediaImagePathDialog = new MediaImagePathMainDialog(this);
+        mediaImagePathView = new FilePathEditView(supModel, this);
     }
-    activateDialog(mediaImagePathDialog);
+    activateDialog(mediaImagePathView);
 }
 
-void MainWindow::configureSetups()
+void MainWindow::configureSetupss()
 {
-    if (!setupMainDialog)
-    {
-        qDebug() << "MainWindow: Creating a setup main dialog.";
-        setupMainDialog = new SetupMainDialog(this);
+    if (!setupMainView) {
+        setupMainView = new SetupEditView(plfModel, mdtModel, supModel, this);
     }
-    activateDialog(setupMainDialog);
-    setupMainDialog->refreshDataModel();
+    activateDialog(setupMainView);
 }
 
-void MainWindow::configureEmulators()
+void MainWindow::configureEmulatorss()
 {
-    if (!executableMainDialog) {
-        executableMainDialog = new ExecutableMainDialog(this);
-        connect(executableMainDialog, SIGNAL(finished(int)), this, SLOT(updateData()));
+    if (!emulatorEditView) {
+        emulatorEditView = new ExternalExecutableEditView(supModel, emuModel, this);
     }
-    activateDialog(executableMainDialog);
-    executableMainDialog->refreshDataModel();
+    activateDialog(emulatorEditView);
 }
 
 void MainWindow::configureTmpDir()
 {
-    /*if (!tmpFolderDialog) {
-        tmpFolderDialog = new TmpFolderEditDialog(this, tmpDirFilePath);
-    }
-    activateDialog(tmpFolderDialog);*/
-
     QString fpath = QFileDialog::getExistingDirectory(this,
         tr("Select a directory"), tmpDirFilePath,
         QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
     QDir d(fpath);
     if (d.exists() && d.isReadable()) {
         tmpDirFilePath = fpath;
-        DbConfig::setTmpDir(tmpDirFilePath);
-        launcher->setTmpDirPath(tmpDirFilePath);
+        if (DbConfig::setTmpDir(tmpDirFilePath)) {
+            QMessageBox::information(
+                this,
+                tr("Temp dir updated"),
+                tr("The directory for temporary files "
+                    "has been updated to '%1'.")
+                    .arg(tmpDirFilePath)
+            );
+            launcher->setTmpDirPath(tmpDirFilePath);
+        }
     }
 }
 
@@ -221,11 +228,11 @@ void MainWindow::createMenus()
     configMenu = menuBar()->addMenu(tr("&Config"));
     configMenu->addAction(configTmpDirAction);
     configMenu->addSeparator();
-    configMenu->addAction(configPlatformAction);
-    configMenu->addAction(configMediaTypeAction);
-    configMenu->addAction(configSetupAction);
-    configMenu->addAction(configMediaImagePathAction);
-    configMenu->addAction(configEmulatorAction);
+    configMenu->addAction(configPlatformsAction);
+    configMenu->addAction(configMediaTypesAction);
+    configMenu->addAction(configSetupsAction);
+    configMenu->addAction(configMediaImagePathsAction);
+    configMenu->addAction(configEmulatorsAction);
     configMenu->addSeparator();
     configMenu->addAction(manageDatFilesAction);
 
@@ -294,7 +301,7 @@ bool MainWindow::testDB(bool reset)
             else throw EmuFrontException("The current database is not compatible!"
                                          " Cannot continue.");
         }
-
+    
         if (reset) {
             createDB();
         }