Changes in the data model: this is not tested yet at all! (compiles
[emufront] / src / dialogs / mediatypedialog.cpp
index 0616692..3f03d8b 100644 (file)
@@ -30,10 +30,10 @@ 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();
+    initEditDialog();
+    objectList->hideColumn(DbMediaType::EmuFrontFileObject_FileId);
 
     // do not move to parent class:
     connectSignals();
@@ -45,52 +45,18 @@ MediaTypeDialog::~MediaTypeDialog()
     deleteCurrentObject();
 }
 
-void MediaTypeDialog::addObject()
+void MediaTypeDialog::initEditDialog()
 {
-    deleteCurrentObject();
-    dbObject = new MediaType;
-    nameDialog->setDataObject(dbObject);
-    activateNameDialog();
+    nameDialog = new MediaTypeNameDialog(this, dynamic_cast<MediaType*>(dbObject));
 }
 
-void MediaTypeDialog::deleteCurrentObject()
+EmuFrontObject* MediaTypeDialog::createObject()
 {
-    delete dynamic_cast<MediaType*>(dbObject);
+    return new MediaType;
 }
 
-bool MediaTypeDialog::deleteItem()
+void MediaTypeDialog::deleteCurrentObject()
 {
-    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;
+    delete dynamic_cast<MediaType*>(dbObject);
+    dbObject = 0;
 }