//
//
// 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.
+// it under the terms of the GNU General Public License version 2 as published by
+// the Free Software Foundation and appearing in the file gpl.txt included in the
+// packaging of this file.
//
-// Foobar is distributed in the hope that it will be useful,
+// EmuFront 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/>.
+// along with EmuFront. 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 "dbmediatype.h"
+#include "mediatype.h"
#include "mediatypedialog.h"
#include "mediatypenamedialog.h"
MediaTypeDialog::MediaTypeDialog(QWidget* parent)
- :DbObjectDialog(parent)
+ :EmuFrontFileObjectDialog(parent)
{
setWindowTitle(tr("Set media types"));
- //nameDialog = 0;
- nameDialog = new MediaTypeNameDialog(this, dynamic_cast<MediaType*>(dbObject));
dbManager = new DbMediaType(this);
initDataTable();
-
+ initEditDialog();
// do not move to parent class:
connectSignals();
-
+ setColumnsHidden();
+ hideColumns();
}
MediaTypeDialog::~MediaTypeDialog()
deleteCurrentObject();
}
+void MediaTypeDialog::initEditDialog()
+{
+ nameDialog = new MediaTypeNameDialog(this, dynamic_cast<MediaType*>(dbObject));
+ connectNameDialogSignals();
+}
+
EmuFrontObject* MediaTypeDialog::createObject()
{
return new MediaType;
void MediaTypeDialog::deleteCurrentObject()
{
delete dynamic_cast<MediaType*>(dbObject);
+ dbObject = 0;
}
-bool MediaTypeDialog::deleteItem()
+void MediaTypeDialog::cleanUp()
{
- 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;
+ deleteCurrentObject();
+ if (nameDialog) {
+ MediaTypeNameDialog *pnd =
+ dynamic_cast<MediaTypeNameDialog*>(nameDialog);
+ if (pnd) delete pnd;
+ else qDebug() << "Failed to delete MediaTypeNameDialog";
+ nameDialog = 0;
}
- updateList();
- objectList->setFocus();
- return false;
}