DbMediaImagePath replaced by more generic DbFilePath.
authorMikko Keinänen <mikko.keinanen@gmail.com>
Fri, 28 May 2010 20:43:29 +0000 (23:43 +0300)
committerMikko Keinänen <mikko.keinanen@gmail.com>
Fri, 28 May 2010 20:43:29 +0000 (23:43 +0300)
src/db/dbfilepath.cpp [new file with mode: 0644]
src/db/dbfilepath.h [new file with mode: 0644]
src/db/dbmediatype.cpp
src/db/dbmediatype.h
src/dialogs/mediaimagepathmaindialog.cpp
src/emufront.pro
src/mainwindow.cpp

diff --git a/src/db/dbfilepath.cpp b/src/db/dbfilepath.cpp
new file mode 100644 (file)
index 0000000..99eef74
--- /dev/null
@@ -0,0 +1,62 @@
+// 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 "dbfilepath.h"
+#include "../dataobjects/filepathobject.h"
+
+DbFilePath::DbFilePath(QObject *parent) : DatabaseManager(parent)
+{
+}
+QSqlTableModel* DbFilePath::getDataModel()
+{
+    return sqlTableModel;
+}
+
+EmuFrontObject* DbFilePath::getDataObjectFromModel(QModelIndex *index)
+{
+    return new FilePathObject;
+}
+
+bool DbFilePath::updateDataObjectToModel(const EmuFrontObject *ob)
+{
+    return false;
+}
+
+bool DbFilePath::insertDataObjectToModel(const EmuFrontObject *ob)
+{
+    return false;
+}
+
+int DbFilePath::countDataObjectRefs(int id) const
+{
+    return 0;
+}
+
+// WARNING: this will delete also all the databindings to selected media image path
+bool DbFilePath::deleteDataObjectFromModel(QModelIndex *index)
+{
+    return false;
+}
+
+QSqlTableModel* DbFilePath::getData()
+{
+   QSqlTableModel *model = new QSqlTableModel(this);
+   return model;
+}
diff --git a/src/db/dbfilepath.h b/src/db/dbfilepath.h
new file mode 100644 (file)
index 0000000..15cc630
--- /dev/null
@@ -0,0 +1,47 @@
+// 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 DBFILEPATH_H
+#define DBFILEPATH_H
+
+#include "databasemanager.h"
+
+class DbFilePath : public DatabaseManager
+{
+public:
+    DbFilePath(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();
+    enum { FilePath_Id = 0,
+           FilePath_Name = 1,
+           FilePath_FileTypeId = 3,
+           FilePath_PlatformId = 4,
+           FilePath_MediaTypeId = 5,
+           FilePath_LastScanned = 6 };
+    static const QString DB_TABLE_NAME_FILEPATH;
+};
+
+#endif // DBFILEPATH_H
index f12be25..6268853 100644 (file)
@@ -22,6 +22,7 @@
 #include <QSqlTableModel>
 #include <QDebug>
 #include "dbmediatype.h"
+#include "../dataobjects/mediatype.h"
 
 const QString DbMediaType::DB_TABLE_NAME_MEDIATYPE = QString("mediatype");
 
index 5552f8d..3f2e045 100644 (file)
@@ -21,9 +21,6 @@
 #define DBMEDIATYPE_H
 
 #include "databasemanager.h"
-#include "../dataobjects/mediatype.h"
-
-class QModelIndex;
 
 class DbMediaType : public DatabaseManager
 {
index fd61cf9..3fb0bba 100644 (file)
@@ -22,7 +22,7 @@
 #include "mediaimagepathmaindialog.h"
 #include "mediaimagepathdialog.h"
 #include "../dataobjects/filepathobject.h"
-#include "../db/dbmediaimagepath.h"
+#include "../db/dbfilepath.h"
 
 
 MediaImagePathMainDialog::MediaImagePathMainDialog(QWidget *parent)
@@ -30,7 +30,7 @@ MediaImagePathMainDialog::MediaImagePathMainDialog(QWidget *parent)
 {
     setWindowTitle(tr("Set media image paths"));
     nameDialog = new MediaImagePathDialog(this, dynamic_cast<FilePathObject*>(dbObject));
-    dbManager = new DbMediaImagePath(this);
+    dbManager = new DbFilePath(this);
     initDataTable();
     // do not move to parent class:
     connectSignals();
index 68910c4..6693392 100644 (file)
@@ -32,7 +32,7 @@ HEADERS += mainwindow.h \
     dialogs/mediaimagepathdialog.h \
     dialogs/mediaimagepathmaindialog.h \
     dialogs/dataobjecteditdialog.h \
-    db/dbmediaimagepath.h
+    db/dbfilepath.h
 SOURCES += main.cpp \
     mainwindow.cpp \
     db/databasemanager.cpp \
@@ -54,4 +54,4 @@ SOURCES += main.cpp \
     dialogs/mediaimagepathdialog.cpp \
     dialogs/mediaimagepathmaindialog.cpp \
     dialogs/dataobjecteditdialog.cpp \
-    db/dbmediaimagepath.cpp
+    db/dbfilepath.cpp
index 7648f52..b6334fa 100644 (file)
@@ -77,12 +77,11 @@ void MainWindow::configureMediaTypes()
 
 void MainWindow::configureMediaImagePaths()
 {
-    /*if (!mediaImagePathDialog)
+    if (!mediaImagePathDialog)
     {
         mediaImagePathDialog = new MediaImagePathMainDialog(this);
     }
     activateDialog(mediaImagePathDialog);
-    */
 }
 
 void MainWindow::activateDialog(EmuFrontDialog* dia) const