Added a skeleton implementation for editing media image file paths.
authorMikko Keinänen <mikko.keinanen@gmail.com>
Tue, 25 May 2010 21:52:13 +0000 (00:52 +0300)
committerMikko Keinänen <mikko.keinanen@gmail.com>
Tue, 25 May 2010 21:52:13 +0000 (00:52 +0300)
12 files changed:
src/db/dbmediaimagepath.cpp [new file with mode: 0644]
src/db/dbmediaimagepath.h [new file with mode: 0644]
src/dialogs/dataobjecteditdialog.cpp [new file with mode: 0644]
src/dialogs/dataobjecteditdialog.h [new file with mode: 0644]
src/dialogs/dbobjectdialog.h
src/dialogs/mediaimagepathdialog.cpp [new file with mode: 0644]
src/dialogs/mediaimagepathdialog.h [new file with mode: 0644]
src/dialogs/mediaimagepathmaindialog.cpp [new file with mode: 0644]
src/dialogs/mediaimagepathmaindialog.h [new file with mode: 0644]
src/dialogs/namedialog.cpp
src/dialogs/namedialog.h
src/emufront.pro

diff --git a/src/db/dbmediaimagepath.cpp b/src/db/dbmediaimagepath.cpp
new file mode 100644 (file)
index 0000000..c5a4200
--- /dev/null
@@ -0,0 +1,63 @@
+// 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.
+//
+// Foobar 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 Foobar.  If not, see <http://www.gnu.org/licenses/>.
+
+#include <QSqlTableModel>
+#include "dbmediaimagepath.h"
+#include "../dataobjects/filepathobject.h"
+
+DbMediaImagePath::DbMediaImagePath(QObject *parent) : DatabaseManager(parent)
+{
+}
+
+QSqlTableModel* DbMediaImagePath::getDataModel()
+{
+    return sqlTableModel;
+}
+
+EmuFrontObject* DbMediaImagePath::getDataObjectFromModel(QModelIndex *index)
+{
+    return new FilePathObject;
+}
+
+bool DbMediaImagePath::updateDataObjectToModel(const EmuFrontObject *ob)
+{
+    return false;
+}
+
+bool DbMediaImagePath::insertDataObjectToModel(const EmuFrontObject *ob)
+{
+    return false;
+}
+
+int DbMediaImagePath::countDataObjectRefs(int id) const
+{
+    return 0;
+}
+
+// WARNING: this will delete also all the databindings to selected media image path
+bool DbMediaImagePath::deleteDataObjectFromModel(QModelIndex *index)
+{
+    return false;
+}
+
+QSqlTableModel* DbMediaImagePath::getData()
+{
+   QSqlTableModel *model = new QSqlTableModel(this);
+   return model;
+}
diff --git a/src/db/dbmediaimagepath.h b/src/db/dbmediaimagepath.h
new file mode 100644 (file)
index 0000000..be36384
--- /dev/null
@@ -0,0 +1,41 @@
+// 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.
+//
+// Foobar 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 Foobar.  If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef DBMEDIAIMAGEPATH_H
+#define DBMEDIAIMAGEPATH_H
+
+#include "databasemanager.h"
+
+class DbMediaImagePath : public DatabaseManager
+{
+public:
+    DbMediaImagePath(QObject *);
+    virtual QSqlTableModel* getDataModel();
+    virtual EmuFrontObject* getDataObjectFromModel(QModelIndex*);
+    virtual bool updateDataObjectToModel(const EmuFrontObject*);
+    bool insertDataObjectToModel(const EmuFrontObject*);
+    bool deleteDataObjectFromModel(QModelIndex*);
+    int countDataObjectRefs(int) const;
+
+private:
+    virtual QSqlTableModel* getData();
+
+};
+
+#endif // DBMEDIAIMAGEPATH_H
diff --git a/src/dialogs/dataobjecteditdialog.cpp b/src/dialogs/dataobjecteditdialog.cpp
new file mode 100644 (file)
index 0000000..54af8c7
--- /dev/null
@@ -0,0 +1,25 @@
+// 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.
+//
+// Foobar 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 Foobar.  If not, see <http://www.gnu.org/licenses/>.
+
+#include "dataobjecteditdialog.h"
+
+DataObjectEditDialog::DataObjectEditDialog(QWidget *parent, EmuFrontObject *ob)
+    : EmuFrontDialog(parent), efObject(ob)
+{
+}
diff --git a/src/dialogs/dataobjecteditdialog.h b/src/dialogs/dataobjecteditdialog.h
new file mode 100644 (file)
index 0000000..6a8cb7c
--- /dev/null
@@ -0,0 +1,36 @@
+// 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.
+//
+// Foobar 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 Foobar.  If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef DATAOBJECTEDITDIALOG_H
+#define DATAOBJECTEDITDIALOG_H
+
+#include "emufrontdialog.h"
+#include "../dataobjects/emufrontobject.h"
+
+class DataObjectEditDialog : public EmuFrontDialog
+{
+       Q_OBJECT
+public:
+    DataObjectEditDialog(QWidget *parent, EmuFrontObject *ob);
+    virtual void setDataObject(EmuFrontObject *) = 0;
+protected:
+    EmuFrontObject *efObject;
+};
+
+#endif // DATAOBJECTEDITDIALOG_H
index 9a08ee3..c3a16aa 100644 (file)
@@ -21,7 +21,7 @@
 #define DBOBJECTDIALOG_H
 
 #include "emufrontdialog.h"
-#include "namedialog.h"
+#include "dataobjecteditdialog.h"
 #include "../db/databasemanager.h"
 #include "../dataobjects/emufrontobject.h"
 
@@ -60,7 +60,7 @@ protected:
     void activateNameDialog();
     void initDataTable();
     bool confirmDelete(QString name, int numRefs);
-    NameDialog *nameDialog;
+    DataObjectEditDialog *nameDialog;
     DatabaseManager *dbManager;
     QTableView *objectList;
     EmuFrontObject *dbObject;
diff --git a/src/dialogs/mediaimagepathdialog.cpp b/src/dialogs/mediaimagepathdialog.cpp
new file mode 100644 (file)
index 0000000..a0605c7
--- /dev/null
@@ -0,0 +1,80 @@
+// 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.
+//
+// Foobar 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 Foobar.  If not, see <http://www.gnu.org/licenses/>.
+
+#include <QtGui>
+#include <QSqlTableModel>
+#include "../db/dbplatform.h"
+#include "../db/dbmediatype.h"
+#include "mediaimagepathdialog.h"
+
+MediaImagePathDialog::MediaImagePathDialog(QWidget *parent, EmuFrontObject *efObject)
+    : DataObjectEditDialog(parent, efObject)
+{
+    initWidgets();
+    populateMediaTypeComBox();
+    populatePlatformComBox();
+    layout();
+    connectSignals();
+}
+
+void MediaImagePathDialog::connectSignals()
+{
+}
+
+void MediaImagePathDialog::initWidgets()
+{
+    // these widgets will be automatically parented using layout components
+    buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal);
+    filePathLabel = new QLabel;
+    filePathButton = new QPushButton(tr("&Browse filepath"));
+    mediaTypeComBox = new QComboBox;
+    platformComBox = new QComboBox;
+}
+
+void MediaImagePathDialog::populateMediaTypeComBox()
+{
+}
+
+void MediaImagePathDialog::populatePlatformComBox()
+{
+}
+
+void MediaImagePathDialog::layout()
+{
+   QLabel *platformLabel = new QLabel(tr("&Platform"));
+   platformLabel->setBuddy(platformComBox);
+   QLabel *mediaTypeLabel = new QLabel(tr("Media&Type"));
+   mediaTypeLabel->setBuddy(mediaTypeComBox);
+
+   QGridLayout *gridLayout = new QGridLayout;
+   gridLayout->addWidget(platformLabel, 0, 0);
+   gridLayout->addWidget(platformComBox, 0, 1);
+   gridLayout->addWidget(mediaTypeLabel, 1, 0);
+   gridLayout->addWidget(mediaTypeComBox, 1, 1);
+   gridLayout->addWidget(filePathButton, 2, 0);
+   gridLayout->addWidget(filePathLabel, 2, 1);
+   gridLayout->addWidget(buttonBox, 3, 0, 1, 2);
+   setLayout(gridLayout);
+
+   setWindowTitle(tr("Set media image paths"));
+}
+
+void MediaImagePathDialog::setDataObject(EmuFrontObject *)
+{
+}
diff --git a/src/dialogs/mediaimagepathdialog.h b/src/dialogs/mediaimagepathdialog.h
new file mode 100644 (file)
index 0000000..de9717f
--- /dev/null
@@ -0,0 +1,52 @@
+// 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.
+//
+// Foobar 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 Foobar.  If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef MEDIAIMAGEPATHDIALOG_H
+#define MEDIAIMAGEPATHDIALOG_H
+
+#include "dataobjecteditdialog.h"
+
+class QDialogButtonBox;
+class QComboBox;
+class QLabel;
+class QPushButton;
+
+class MediaImagePathDialog : public DataObjectEditDialog
+{
+    Q_OBJECT
+
+public:
+    MediaImagePathDialog(QWidget *parent, EmuFrontObject*);
+    virtual void setDataObject(EmuFrontObject *);
+
+private:
+    QDialogButtonBox *buttonBox;
+    QComboBox *mediaTypeComBox;
+    QComboBox *platformComBox;
+    QLabel *filePathLabel;
+    QPushButton *filePathButton;
+
+    void initWidgets();
+    void layout();
+    void connectSignals();
+    void populateMediaTypeComBox();
+    void populatePlatformComBox();
+};
+
+#endif // MEDIAIMAGEPATHDIALOG_H
diff --git a/src/dialogs/mediaimagepathmaindialog.cpp b/src/dialogs/mediaimagepathmaindialog.cpp
new file mode 100644 (file)
index 0000000..26427e9
--- /dev/null
@@ -0,0 +1,81 @@
+// 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.
+//
+// Foobar 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 Foobar.  If not, see <http://www.gnu.org/licenses/>.
+
+#include <QtGui>
+
+#include "mediaimagepathmaindialog.h"
+#include "mediaimagepathdialog.h"
+#include "../dataobjects/filepathobject.h"
+#include "../db/dbmediaimagepath.h"
+
+
+MediaImagePathMainDialog::MediaImagePathMainDialog(QWidget *parent)
+    : DbObjectDialog(parent)
+{
+    setWindowTitle(tr("Set media image paths"));
+    nameDialog = new MediaImagePathDialog(this, dynamic_cast<FilePathObject*>(dbObject));
+    dbManager = new DbMediaImagePath(this);
+    initDataTable();
+    connectSignals();
+}
+
+void MediaImagePathMainDialog::connectSignals()
+{
+}
+
+MediaImagePathMainDialog::~MediaImagePathMainDialog()
+{
+    delete dynamic_cast<FilePathObject*>(dbObject);
+}
+
+int MediaImagePathMainDialog::deleteObject()
+{
+    return 0;
+}
+
+void MediaImagePathMainDialog::addObject()
+{
+
+}
+
+void MediaImagePathMainDialog::editObject()
+{
+
+}
+
+void MediaImagePathMainDialog::deleteCurrentObject()
+{
+
+}
+
+void MediaImagePathMainDialog::updateDb(const EmuFrontObject *) const
+{
+
+}
+
+void MediaImagePathMainDialog::insertDb(const EmuFrontObject *) const
+{
+
+}
+
+bool MediaImagePathMainDialog::deleteItem()
+{
+    return false;
+}
+
diff --git a/src/dialogs/mediaimagepathmaindialog.h b/src/dialogs/mediaimagepathmaindialog.h
new file mode 100644 (file)
index 0000000..9627a19
--- /dev/null
@@ -0,0 +1,46 @@
+// 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.
+//
+// Foobar 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 Foobar.  If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef MEDIAIMAGEPATHMAINDIALOG_H
+#define MEDIAIMAGEPATHMAINDIALOG_H
+
+#include "dbobjectdialog.h"
+
+class MediaImagePathMainDialog : public DbObjectDialog
+{
+    Q_OBJECT
+
+public:
+    MediaImagePathMainDialog(QWidget *parent);
+    ~MediaImagePathMainDialog();
+
+protected:
+    virtual int deleteObject();
+    virtual void deleteCurrentObject();
+    virtual void addObject();
+    virtual void editObject();
+    virtual bool deleteItem();
+    virtual void updateDb(const EmuFrontObject*) const;
+    virtual void insertDb(const EmuFrontObject*) const;
+
+private:
+    void connectSignals();
+};
+
+#endif // MEDIAIMAGEPATHMAINDIALOG_H
index 82147f0..a341f13 100644 (file)
@@ -21,7 +21,7 @@
 #include "namedialog.h"
 
 NameDialog::NameDialog(QWidget *parent, EmuFrontObject *efObj)
-        : EmuFrontDialog(parent), efObject(efObj)
+        : DataObjectEditDialog(parent, efObj)
 {
        nameLabel = new QLabel(tr("&Name: "));  
        nameEdit = new QLineEdit;
index 7301be4..f58dd43 100644 (file)
 #define NAMEDIALOG_H
 
 #include "../dataobjects/emufrontobject.h"
-#include "emufrontdialog.h"
+#include "dataobjecteditdialog.h"
 
 class QLabel;
 class QLineEdit;
 class QPushButton;
 class QDialogButtonBox;
 
-class NameDialog : public EmuFrontDialog
+class NameDialog : public DataObjectEditDialog
 {
        Q_OBJECT
 
@@ -50,7 +50,6 @@ protected:
        QLabel *nameLabel;
        QLineEdit *nameEdit;
     QDialogButtonBox *buttonBox;
-    EmuFrontObject *efObject;
 
 private:
        void connectSignals();
index 0437342..68910c4 100644 (file)
@@ -28,7 +28,11 @@ HEADERS += mainwindow.h \
     dataobjects/mediatype.h \
     db/dbmediatype.h \
     dialogs/mediatypenamedialog.h \
-    dataobjects/filepathobject.h
+    dataobjects/filepathobject.h \
+    dialogs/mediaimagepathdialog.h \
+    dialogs/mediaimagepathmaindialog.h \
+    dialogs/dataobjecteditdialog.h \
+    db/dbmediaimagepath.h
 SOURCES += main.cpp \
     mainwindow.cpp \
     db/databasemanager.cpp \
@@ -46,4 +50,8 @@ SOURCES += main.cpp \
     dataobjects/mediatype.cpp \
     db/dbmediatype.cpp \
     dialogs/mediatypenamedialog.cpp \
-    dataobjects/filepathobject.cpp
+    dataobjects/filepathobject.cpp \
+    dialogs/mediaimagepathdialog.cpp \
+    dialogs/mediaimagepathmaindialog.cpp \
+    dialogs/dataobjecteditdialog.cpp \
+    db/dbmediaimagepath.cpp