refactoring.
sqlTableModel->setFilter("");
sqlTableModel->select();
}
+
+// sql must return a count(*) value
+int DatabaseManager::countRows(QString tableName, QString columnName, int id) const
+{
+ QString sql = QString("SELECT COUNT(*) FROM %1 WHERE %2 = %3")
+ .arg(tableName).arg(columnName).arg(id);
+ int numEntries = 0;
+ QSqlQuery query(sql);
+ if (query.next())
+ numEntries = query.value(0).toInt();
+ return numEntries;
+}
class QSqlError;
class QFile;
class QSqlTableModel;
+class QModelIndex;
+class EmuFrontObject;
class DatabaseManager : public QObject
{
~DatabaseManager();
virtual QSqlTableModel* getDataModel() = 0;
+ virtual EmuFrontObject* getDataObjectFromModel(QModelIndex*) = 0;
+ virtual bool updateDataObjectToModel(const EmuFrontObject*) = 0;
+ virtual bool insertDataObjectToModel(const EmuFrontObject*) = 0;
+ virtual bool deleteDataObjectFromModel(QModelIndex*) = 0;
+ virtual int countDataObjectRefs(int id) const = 0;
static bool openDB();
void resetModel() const;
enum {
Filetype_MediaTypeIcon = 3 };
protected:
- QSqlTableModel *sqlTableModel;
+ QSqlTableModel* sqlTableModel;
+ //virtual QSqlTableModel* getDataModel() = 0;
+ int countRows(QString tableName, QString columnName, int id) const;
private:
static const QString DB_FILENAME;
--- /dev/null
+// 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 <QSqlRecord>
+#include <QSqlQuery>
+#include <QSqlTableModel>
+#include <QDebug>
+#include "dbmediatype.h"
+
+const QString DbMediaType::DB_TABLE_NAME_MEDIATYPE = QString("mediatype");
+
+
+DbMediaType::DbMediaType(QObject *parent) : DatabaseManager(parent)
+{
+ sqlTableModel = getData();
+}
+
+QSqlTableModel* DbMediaType::getDataModel()
+{
+ return sqlTableModel;
+}
+
+EmuFrontObject* DbMediaType::getDataObjectFromModel(QModelIndex *index)
+{
+ QSqlRecord record = sqlTableModel->record(index->row());
+ int id = record.value(MediaType_Id).toInt();
+ QString name = record.value(MediaType_Name).toString();
+ QString fileName = record.value(MediaType_Filename).toString();
+ //qDebug() << "Got platform Name " << name << " id " << id;
+ return new MediaType(id, name, fileName);
+}
+
+bool DbMediaType::updateDataObjectToModel(const EmuFrontObject *ob)
+{
+ const MediaType *plf = dynamic_cast<const MediaType*>(ob);
+ bool ret = false;
+ sqlTableModel->setFilter(QString("id = %1").arg(plf->getId()));
+ sqlTableModel->select();
+ if (sqlTableModel->rowCount() == 1)
+ {
+ QSqlRecord record = sqlTableModel->record(0);
+ record.setValue("name", plf->getName());
+ record.setValue("filename", plf->getFilename());
+ sqlTableModel->setRecord(0, record);
+ ret = sqlTableModel->submitAll();
+ }
+ resetModel();
+ return ret;
+}
+
+bool DbMediaType::insertDataObjectToModel(const EmuFrontObject *ob)
+{
+ const MediaType *plf = dynamic_cast<const MediaType*>(ob);
+ int row = 0;
+ sqlTableModel->insertRows(row, 1);
+ // the null value for index will be set implicitily
+ // when we don't assign any value to cell 0 in the sql table model
+ //sqlTableModel->setData(sqlTableModel->index(row, 0), NULL);
+ sqlTableModel->setData(sqlTableModel->index(row, 1), plf->getName());
+ sqlTableModel->setData(sqlTableModel->index(row, 2), plf->getFilename());
+ return sqlTableModel->submitAll();
+}
+
+int DbMediaType::countDataObjectRefs(int id) const
+{
+ return countRows("imagecontainer", "mediatypeid", id);
+}
+
+// WARNING: this will delete also all the databindings to selected platform
+bool DbMediaType::deleteDataObjectFromModel(QModelIndex *index)
+{
+ QSqlDatabase::database().transaction();
+ QSqlRecord record = sqlTableModel->record(index->row());
+ int id = record.value(MediaType_Id).toInt();
+ qDebug() << "Deleting mediatype " << id;
+ int count = countDataObjectRefs(id);
+ if (count > 0)
+ {
+ QSqlQuery query;
+ if (!query.exec(QString("DELETE FROM imagecontainer WHERE mediatypeid = %1").arg(id)))
+ {
+ qDebug() << "Deleting data bindings failed!";
+ QSqlDatabase::database().rollback();
+ return false;
+ }
+ }
+ sqlTableModel->removeRow(index->row());
+ sqlTableModel->submitAll();
+ return QSqlDatabase::database().commit();
+}
+
+QSqlTableModel* DbMediaType::getData()
+{
+ QSqlTableModel *model = new QSqlTableModel(this);
+ model->setTable(DB_TABLE_NAME_MEDIATYPE);
+ model->setSort(MediaType_Name, Qt::AscendingOrder);
+ model->setHeaderData(MediaType_Name, Qt::Horizontal, tr("Name"));
+ model->select();
+ return model;
+}
--- /dev/null
+// 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 DBMEDIATYPE_H
+#define DBMEDIATYPE_H
+
+#include "databasemanager.h"
+#include "../dataobjects/mediatype.h"
+
+class QModelIndex;
+
+class DbMediaType : public DatabaseManager
+{
+public:
+ DbMediaType(QObject*);
+ virtual QSqlTableModel* getDataModel();
+ virtual EmuFrontObject* getDataObjectFromModel(QModelIndex*);
+ virtual bool updateDataObjectToModel(const EmuFrontObject*);
+ virtual bool insertDataObjectToModel(const EmuFrontObject*);
+ virtual bool deleteDataObjectFromModel(QModelIndex*);
+ virtual int countDataObjectRefs(int) const;
+
+private:
+ enum {
+ MediaType_Id = 0,
+ MediaType_Name = 1,
+ MediaType_Filename = 2 };
+ static const QString DB_TABLE_NAME_MEDIATYPE;
+ virtual QSqlTableModel* getData();
+
+};
+
+#endif // DBMEDIATYPE_H
return sqlTableModel;
}
-Platform* DbPlatform::getPlatformFromModel(QModelIndex *index)
+EmuFrontObject* DbPlatform::getDataObjectFromModel(QModelIndex *index)
{
QSqlRecord record = sqlTableModel->record(index->row());
int id = record.value(Platform_Id).toInt();
return new Platform(id, name, fileName);
}
-bool DbPlatform::updatePlatformToModel(const Platform *ob)
+bool DbPlatform::updateDataObjectToModel(const EmuFrontObject *ob)
{
+ const Platform *plf = dynamic_cast<const Platform*>(ob);
bool ret = false;
- sqlTableModel->setFilter(QString("id = %1").arg(ob->getId()));
+ sqlTableModel->setFilter(QString("id = %1").arg(plf->getId()));
sqlTableModel->select();
if (sqlTableModel->rowCount() == 1)
{
QSqlRecord record = sqlTableModel->record(0);
- record.setValue("name", ob->getName());
- record.setValue("filename", ob->getFilename());
+ record.setValue("name", plf->getName());
+ record.setValue("filename", plf->getFilename());
sqlTableModel->setRecord(0, record);
ret = sqlTableModel->submitAll();
}
return ret;
}
-bool DbPlatform::insertPlatformToModel(const Platform *ob)
+bool DbPlatform::insertDataObjectToModel(const EmuFrontObject *ob)
{
+ const Platform *plf = dynamic_cast<const Platform*>(ob);
int row = 0;
sqlTableModel->insertRows(row, 1);
// the null value for index will be set implicitily
// when we don't assign any value to cell 0 in the sql table model
//sqlTableModel->setData(sqlTableModel->index(row, 0), NULL);
- sqlTableModel->setData(sqlTableModel->index(row, 1), ob->getName());
- sqlTableModel->setData(sqlTableModel->index(row, 2), ob->getFilename());
+ sqlTableModel->setData(sqlTableModel->index(row, 1), plf->getName());
+ sqlTableModel->setData(sqlTableModel->index(row, 2), plf->getFilename());
return sqlTableModel->submitAll();
}
-int DbPlatform::countPlatformBindings(int id) const
+int DbPlatform::countDataObjectRefs(int id) const
{
- int numEntries = 0;
- QSqlQuery query(QString("SELECT COUNT(*) FROM imagecontainer WHERE platformid = %1").arg(id));
- if (query.next())
- numEntries = query.value(0).toInt();
- return numEntries;
+ return countRows("imagecontainer", "platformid", id);
}
// WARNING: this will delete also all the databindings to selected platform
-bool DbPlatform::deletePlatformFromModel(QModelIndex *index)
+bool DbPlatform::deleteDataObjectFromModel(QModelIndex *index)
{
QSqlDatabase::database().transaction();
QSqlRecord record = sqlTableModel->record(index->row());
int id = record.value(Platform_Id).toInt();
qDebug() << "Deleting platform " << id;
- int count = countPlatformBindings(id);
+ int count = countDataObjectRefs(id);
if (count > 0)
{
QSqlQuery query;
public:
DbPlatform(QObject *);
virtual QSqlTableModel* getDataModel();
- Platform* getPlatformFromModel(QModelIndex*);
- bool updatePlatformToModel(const Platform *);
- bool insertPlatformToModel(const Platform *);
- bool deletePlatformFromModel(QModelIndex*);
- int countPlatformBindings(int) const;
+ virtual EmuFrontObject* getDataObjectFromModel(QModelIndex*);
+ virtual bool updateDataObjectToModel(const EmuFrontObject*);
+ bool insertDataObjectToModel(const EmuFrontObject*);
+ bool deleteDataObjectFromModel(QModelIndex*);
+ int countDataObjectRefs(int) const;
private:
enum {
setButtonsEnabled(false);
}
-void DbObjectDialog::updateData()
-{
- qDebug() << "DbObjectDialog::updateData()";
- updateList();
-}
-
void DbObjectDialog::activateNameDialog()
{
if (!nameDialog) return;
nameDialog->activateWindow();
}
+void DbObjectDialog::initDataTable()
+{
+ objectList->setModel(dbManager->getDataModel());
+ objectList->setSelectionMode(QAbstractItemView::SingleSelection);
+ objectList->resizeColumnsToContents();
+}
+void DbObjectDialog::updateData()
+{
+ qDebug() << "Update data";
+ // update data model
+ if (!dbObject) return;
+
+ qDebug() << "dbObject is not 0";
+
+ qDebug() << "We have a " + dbObject->getName();
+
+ qDebug() << "Data will be inserted/updated...";
+
+ // if data object id > -1 we are updating the data otherwise we are inserting new data
+ if (dbObject->getId() > -1) updateDb(dbObject);
+ else insertDb(dbObject);
+
+ // we don't need dbObject anymore
+ deleteCurrentObject();
+ dbObject = 0;
+ updateList();
+}
+
+void DbObjectDialog::deleteCurrentObject()
+{
+ delete dbObject;
+}
+
+bool DbObjectDialog::confirmDelete(QString name, int numRefs)
+{
+ int r = QMessageBox::warning(this, tr("Confirm delete"),
+ QString("Do you really want to delete %1 with %2 data bindings?")
+ .arg(name).arg(numRefs),
+ QMessageBox::Yes | QMessageBox::No);
+ if ( r == QMessageBox::No )
+ return false;
+ return true;
+}
void addButtonClicked();
void deleteButtonClicked();
void listObjectClicked(const QModelIndex &);
- virtual void updateData();
+ void updateData();
void updateList() const;
+ private slots:
protected:
virtual int deleteObject() =0;
+ // implementation specific, deletes current data object from memory
+ virtual void deleteCurrentObject();
virtual void addObject() =0;
virtual void editObject() =0;
virtual bool deleteItem() = 0;
virtual void insertDb(const EmuFrontObject*) const = 0;
void connectSignals();
void activateNameDialog();
+ void initDataTable();
+ bool confirmDelete(QString name, int numRefs);
NameDialog *nameDialog;
DatabaseManager *dbManager;
QTableView *objectList;
+// 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 <QAbstractItemView>
+#include <QSqlTableModel>
+#include <QTextStream>
+#include "../db/dbmediatype.h"
+#include "../dataobjects/mediatype.h"
#include "mediatypedialog.h"
+#include "mediatypenamedialog.h"
+
+MediaTypeDialog::MediaTypeDialog(QWidget* parent)
+ :DbObjectDialog(parent)
+{
+ setWindowTitle(tr("Set media types"));
+ //nameDialog = 0;
+ nameDialog = new MediaTypeNameDialog(this, dynamic_cast<MediaType*>(dbObject));
+ dbManager = new DbMediaType(this);
+ initDataTable();
+
+ // do not move to parent class:
+ connectSignals();
+
+}
+
+MediaTypeDialog::~MediaTypeDialog()
+{
+ delete dynamic_cast<MediaType*>(dbObject);
+}
-MediaTypeDialog::MediaTypeDialog()
+void MediaTypeDialog::addObject()
{
+ delete dynamic_cast<MediaType*>(dbObject);
+ dbObject = new MediaType;
+ nameDialog->setDataObject(dbObject);
+ activateNameDialog();
+}
+
+void MediaTypeDialog::editObject()
+{
+ qDebug() << "editObject called";
+ QModelIndex index = objectList->currentIndex();
+ if (!index.isValid())
+ return;
+ qDebug() << "we have a valid index";
+ delete dbObject;
+ dbObject = (dynamic_cast<DbMediaType*>(dbManager))->getDataObjectFromModel(&index);
+ nameDialog->setDataObject(dbObject);
+ activateNameDialog();
+}
+
+void MediaTypeDialog::deleteCurrentObject()
+{
+ delete dynamic_cast<MediaType*>(dbObject);
+}
+
+int MediaTypeDialog::deleteObject()
+{
+ return 0;
+}
+
+void MediaTypeDialog::updateDb(const EmuFrontObject *ob) const
+{
+ if (!ob) return;
+ qDebug() << "Updating media type" << ob->getName();
+ (dynamic_cast<DbMediaType*>(dbManager))->updateDataObjectToModel(ob);
+}
+
+void MediaTypeDialog::insertDb(const EmuFrontObject *ob) const
+{
+ (dynamic_cast<DbMediaType*>(dbManager))->insertDataObjectToModel(ob);
+}
+
+bool MediaTypeDialog::deleteItem()
+{
+ qDebug() << "MediaTypeDialog::deleteItem()";
+ QModelIndex index = objectList->currentIndex();
+ if (!index.isValid()) return false;
+
+ qDebug() << "Index is valid";
+
+ // TODO: when implementing data bindings to platform
+ // we need to check if platform being removed has bindings
+ // and a) ask user if this platform should be removed
+ // b) remove all the data associated to this platform
+
+ EmuFrontObject *ob = dynamic_cast<DbMediaType*>(dbManager)->getDataObjectFromModel(&index);
+ if (!ob) return false;
+
+ MediaType *plf = dynamic_cast<MediaType*>(ob);
+
+ qDebug() << "Got platform" << plf->getName();
+
+ int numBindings = dynamic_cast<DbMediaType*>(dbManager)->countDataObjectRefs(plf->getId());
+ if (numBindings > 0 && !confirmDelete(plf->getName(), numBindings))
+ {
+ return false;
+ }
+ delete plf;
+ bool delOk = (dynamic_cast<DbMediaType *>(dbManager))->deleteDataObjectFromModel(&index);
+ if (!delOk)
+ {
+ qDebug() << "delete failed";
+ return false;
+ }
+ updateList();
+ objectList->setFocus();
+ return false;
}
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 slots:
- virtual void updateData();
};
#endif // MEDIATYPEDIALOG_H
--- /dev/null
+// 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 "mediatypenamedialog.h"
+
+MediaTypeNameDialog::MediaTypeNameDialog(QWidget *parent, MediaType *efObj)
+ : NameDialog(parent, efObj)
+{
+ setWindowTitle(tr("Set media type"));
+}
+
+MediaTypeNameDialog::~MediaTypeNameDialog()
+{
+ // no need to delete efObject here, the calling widget will take care of it
+ // delete dynamic_cast<Platform*>(efObject);
+}
+
+void MediaTypeNameDialog::setDataObject(QString name)
+{
+ efObject->setName(name);
+ (dynamic_cast<MediaType*>(efObject))->setFilename("");
+}
+
+void MediaTypeNameDialog::setDataObject(EmuFrontObject *ob)
+{
+ if (!ob) return;
+ efObject = dynamic_cast<MediaType*>(ob);
+ QString name = efObject->getName();
+ nameEdit->setText(name);
+
+ qDebug() << "Setting name to " << efObject->getName();
+ nameEdit->setText(efObject->getName());
+}
--- /dev/null
+// 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 MEDIATYPENAMEDIALOG_H
+#define MEDIATYPENAMEDIALOG_H
+
+#include "namedialog.h"
+#include "../dataobjects/mediatype.h"
+
+class MediaTypeNameDialog : public NameDialog
+{
+ Q_OBJECT
+public:
+ MediaTypeNameDialog(QWidget *parent, MediaType*);
+ ~MediaTypeNameDialog();
+ virtual void setDataObject(EmuFrontObject*);
+
+
+protected:
+ virtual void setDataObject(QString name);
+
+};
+
+#endif // MEDIATYPENAMEDIALOG_H
#include "platformnamedialog.h"
-QTextStream cout(stdout, QIODevice::WriteOnly);
+//QTextStream cout(stdout, QIODevice::WriteOnly);
PlatformDialog::PlatformDialog(QWidget *parent)
: DbObjectDialog(parent)
//nameDialog = 0;
nameDialog = new PlatformNameDialog(this, dynamic_cast<Platform*>(dbObject));
dbManager = new DbPlatform(this);
-
- // let's create a table model for platforms
+ initDataTable();
- objectList->setModel(dbManager->getDataModel());
- objectList->setSelectionMode(QAbstractItemView::SingleSelection);
- //objectList->setColumnHidden(Platform_Id, true);
- objectList->resizeColumnsToContents();
-
// do not move to parent class:
connectSignals();
}
return;
qDebug() << "we have a valid index";
delete dbObject;
- dbObject = (dynamic_cast<DbPlatform*>(dbManager))->getPlatformFromModel(&index);
+ dbObject = (dynamic_cast<DbPlatform*>(dbManager))->getDataObjectFromModel(&index);
nameDialog->setDataObject(dbObject);
activateNameDialog();
}
-void PlatformDialog::updateData()
+void PlatformDialog::deleteCurrentObject()
{
- qDebug() << "Update data";
- // update data model
- if (!dbObject) return;
-
- qDebug() << "dbObject is not 0";
-
- qDebug() << "We have a " + dbObject->getName();
-
- qDebug() << "Data will be inserted/updated...";
-
- // if data object id > -1 we are updating the data otherwise we are inserting new data
- if (dbObject->getId() > -1) updateDb(dbObject);
- else insertDb(dbObject);
-
- // we don't need dbObject anymore
delete dynamic_cast<Platform*>(dbObject);
- dbObject = 0;
-
- // refresh...
- DbObjectDialog::updateData();
}
+
void PlatformDialog::updateDb(const EmuFrontObject *ob) const
{
if (!ob) return;
qDebug() << "Updating platform " << ob->getName();
- (dynamic_cast<DbPlatform*>(dbManager))->updatePlatformToModel(dynamic_cast<const Platform*>(ob));
+ (dynamic_cast<DbPlatform*>(dbManager))->updateDataObjectToModel(ob);
}
void PlatformDialog::insertDb(const EmuFrontObject *ob) const
{
- (dynamic_cast<DbPlatform*>(dbManager))->insertPlatformToModel(dynamic_cast<const Platform*>(ob));
+ (dynamic_cast<DbPlatform*>(dbManager))->insertDataObjectToModel(ob);
}
bool PlatformDialog::deleteItem()
// and a) ask user if this platform should be removed
// b) remove all the data associated to this platform
- Platform *plf = dynamic_cast<DbPlatform*>(dbManager)->getPlatformFromModel(&index);
- if (!plf) return false;
+ EmuFrontObject *ob = dynamic_cast<DbPlatform*>(dbManager)->getDataObjectFromModel(&index);
+ if (!ob) return false;
+
+ Platform *plf = dynamic_cast<Platform*>(ob);
qDebug() << "Got platform" << plf->getName();
- int numBindings = dynamic_cast<DbPlatform*>(dbManager)->countPlatformBindings(plf->getId());
- if (numBindings > 0)
+ int numBindings = dynamic_cast<DbPlatform*>(dbManager)->countDataObjectRefs(plf->getId());
+ if (numBindings > 0 && !confirmDelete(plf->getName(), numBindings))
{
- qDebug() << "Got " << numBindings << " bindings";
- int r = QMessageBox::warning(this, tr("Delete platform"),
- QString("Do you really want to delete platform %1 with %2 data bindings?")
- .arg(plf->getName()).arg(numBindings),
- QMessageBox::Yes | QMessageBox::No);
- if ( r == QMessageBox::No )
return false;
}
delete plf;
- bool delOk = (dynamic_cast<DbPlatform *>(dbManager))->deletePlatformFromModel(&index);
+ bool delOk = (dynamic_cast<DbPlatform *>(dbManager))->deleteDataObjectFromModel(&index);
if (!delOk)
{
qDebug() << "delete failed";
{
Q_OBJECT
- public:
+public:
PlatformDialog(QWidget *parent = 0);
~PlatformDialog();
- protected:
- virtual int deleteObject();
+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 slots:
- virtual void updateData();
};
#endif
db/dbcreator.h \
dialogs/mediatypedialog.h \
dataobjects/emufrontfileobject.h \
- dataobjects/mediatype.h
+ dataobjects/mediatype.h \
+ db/dbmediatype.h \
+ dialogs/mediatypenamedialog.h
SOURCES += main.cpp \
mainwindow.cpp \
db/databasemanager.cpp \
db/dbcreator.cpp \
dialogs/mediatypedialog.cpp \
dataobjects/emufrontfileobject.cpp \
- dataobjects/mediatype.cpp
+ dataobjects/mediatype.cpp \
+ db/dbmediatype.cpp \
+ dialogs/mediatypenamedialog.cpp