Fixed a couple of errors, still not functional.
authorMikko Keinänen <mikko.keinanen@gmail.com>
Sun, 13 Jun 2010 23:19:57 +0000 (02:19 +0300)
committerMikko Keinänen <mikko.keinanen@gmail.com>
Sun, 13 Jun 2010 23:19:57 +0000 (02:19 +0300)
src/db/dbemufrontfileobject.cpp
src/db/dbmediatype.cpp
src/db/dbmediatype.h
src/db/dbplatform.cpp
src/db/dbplatform.h

index 7b3a773..f054893 100644 (file)
@@ -69,6 +69,7 @@ bool DbEmuFrontFileObject::insertDataObjectToModel(const EmuFrontObject *ob)
 {
     const EmuFrontFileObject *plf = dynamic_cast<const EmuFrontFileObject *>(ob);
     int row = 0;
+    if (!sqlTableModel) sqlTableModel = getDataModel();
     QSqlTableModel *tmodel = dynamic_cast<QSqlTableModel*>(sqlTableModel);
     tmodel->insertRows(row, 1);
     // the null value for index will be set implicitily
@@ -113,6 +114,7 @@ bool DbEmuFrontFileObject::deleteDataObjectFromModel(QModelIndex *index)
 QSqlQueryModel* DbEmuFrontFileObject::getData()
 {
     QSqlRelationalTableModel *model = new QSqlRelationalTableModel(this);
+    qDebug() << "table" << tableName;
     model->setTable(tableName);
     model->setRelation(EmuFrontFileObject_FileId, QSqlRelation("file", "id", "name"));
     model->setSort(EmuFrontFileObject_Name, Qt::AscendingOrder);
index ae75d4f..e32381e 100644 (file)
@@ -22,7 +22,9 @@
 //QString DbMediaType::tableName = DbMediaType::DB_TABLE_NAME_MEDIATYPE;
 
 DbMediaType::DbMediaType(QObject *parent) : DbEmuFrontFileObject(parent)
-{  }
+{
+tableName = DbMediaType::DB_TABLE_NAME_MEDIATYPE;
+  }
 
 EmuFrontObject* DbMediaType::createEmuFrontFileObject(int id, QString name, EmuFrontFile *f)
 {   return new MediaType(id, name, f); }
index 9037daa..9fb715d 100644 (file)
@@ -29,7 +29,6 @@ public:
     DbMediaType(QObject *);
 
 protected:
-    static QString tableName;
     virtual EmuFrontObject* createEmuFrontFileObject(int id, QString name, EmuFrontFile *f);
 };
 
index c66623e..887b7b2 100644 (file)
@@ -22,7 +22,9 @@
 //QString DbPlatform::tableName = DbPlatform::DB_TABLE_NAME_PLATFORM;
 
 DbPlatform::DbPlatform(QObject *parent) : DbEmuFrontFileObject(parent)
-{ }
+{
+    tableName = DbPlatform::DB_TABLE_NAME_PLATFORM;
+ }
 
 EmuFrontObject* DbPlatform::createEmuFrontFileObject(int id, QString name, EmuFrontFile *f)
 {   return new Platform(id, name, f); }
index 684ce52..68a9190 100644 (file)
@@ -32,7 +32,6 @@ public:
     DbPlatform(QObject *);
 
 protected:
-    static QString tableName;
     virtual EmuFrontObject* createEmuFrontFileObject(int id, QString name, EmuFrontFile *f);
 };