Modified the license text comment type.
[emufront] / src / dataobjects / mediaimagecontainer.cpp
index bfb6467..4c8004b 100644 (file)
@@ -1,52 +1,65 @@
-// 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.
-//
-// 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 EmuFront.  If not, see <http://www.gnu.org/licenses/>.
-
+/*
+** 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 version 2 as published by
+** the Free Software Foundation and appearing in the file gpl.txt included in the
+** packaging of this file.
+**
+** 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 EmuFront.  If not, see <http://www.gnu.org/licenses/>.
+*/
+#include <QDebug>
 #include "mediaimagecontainer.h"
 
 MediaImageContainer::MediaImageContainer()
     : EmuFrontFile(EmuFrontFile::FileType_MediaImageContainer)
 {
-    lstMediaImage = QList<MediaImage*>();
-    setup = 0;
+    lstMediaImage = QMap<QString, EmuFrontObject*>();
+    filePath = 0;
 }
 
-MediaImageContainer::MediaImageContainer(int id, QString name, QString checksum, int size, QList<MediaImage *>images, Setup *setup)
-    : EmuFrontFile(id, name, checksum, size, EmuFrontFile::FileType_MediaImageContainer), lstMediaImage(images), setup(setup)
+MediaImageContainer::MediaImageContainer(int id, QString name, 
+    QString checksum, int size, QMap<QString, EmuFrontObject*>images, FilePathObject *fpo)
+    : EmuFrontFile(id, name, checksum, size, EmuFrontFile::FileType_MediaImageContainer),
+        lstMediaImage(images), filePath(fpo)
 { }
 
-MediaImageContainer::MediaImageContainer(QString name, QString checksum, int size, QList<MediaImage *>images, Setup *setup)
-    : EmuFrontFile(-1, name, checksum, size, EmuFrontFile::FileType_MediaImageContainer), lstMediaImage(images), setup(setup)
+MediaImageContainer::MediaImageContainer(QString name, QString checksum,
+    int size, QMap<QString, EmuFrontObject*>images, FilePathObject *fpo)
+    : EmuFrontFile(-1, name, checksum, size, EmuFrontFile::FileType_MediaImageContainer),
+        lstMediaImage(images), filePath(fpo)
 { }
 
 MediaImageContainer::~MediaImageContainer()
 {
     qDeleteAll(lstMediaImage);
-    delete setup;
+    delete filePath;
 }
 
 MediaImageContainer::MediaImageContainer(MediaImageContainer &mic)
     : EmuFrontFile(mic)
 {
-    lstMediaImage = QList<MediaImage*>();
-    foreach(MediaImage *mi, mic.lstMediaImage)
-        lstMediaImage.append(new MediaImage(*mi));
-    setup = new Setup(*(mic.setup));
+    lstMediaImage = QMap<QString, EmuFrontObject*>();
+
+    QMapIterator<QString, EmuFrontObject*> it(mic.lstMediaImage);
+    MediaImage *mi = 0;
+    while(it.hasNext()) {
+        it.next();
+        mi = dynamic_cast<MediaImage*>(it.value());
+        lstMediaImage[mi->getCheckSum()] = new MediaImage(*mi);
+    }
+
+    filePath = new FilePathObject(*(mic.filePath));
 }
 
 MediaImageContainer& MediaImageContainer::operator =(MediaImageContainer &mic)
@@ -58,26 +71,38 @@ MediaImageContainer& MediaImageContainer::operator =(MediaImageContainer &mic)
     checkSum = mic.checkSum;
     size = mic.size;
     qDeleteAll(lstMediaImage);
-    foreach(MediaImage *mi, mic.lstMediaImage)
-        lstMediaImage.append(new MediaImage(*mi));
-    setup = new Setup(*(mic.setup));
+
+    QMapIterator<QString, EmuFrontObject*> it(mic.lstMediaImage);
+    MediaImage *mi = 0;
+    while(it.hasNext()) {
+        it.next();
+        mi = dynamic_cast<MediaImage*>(it.value());
+        lstMediaImage[mi->getCheckSum()] = new MediaImage(*mi);
+    }
+    filePath = new FilePathObject(*(mic.filePath));
     return (*this);
 }
 
-void MediaImageContainer::setMediaImages(QList<MediaImage *> list)
+void MediaImageContainer::setMediaImages(QMap<QString, EmuFrontObject*> list)
 {
     qDeleteAll(lstMediaImage);
     lstMediaImage = list;
 }
 
-QList<MediaImage *> MediaImageContainer::getMediaImages() const
+QMap<QString, EmuFrontObject*> MediaImageContainer::getMediaImages() const
 {   return lstMediaImage; }
 
 void MediaImageContainer::addMediaImage(MediaImage *mi)
-{   lstMediaImage.append(mi); }
+{   lstMediaImage[mi->getCheckSum()] = mi; }
+
+void MediaImageContainer::clearMediaImages()
+{
+    qDeleteAll(lstMediaImage);
+    lstMediaImage.clear();
+}
 
-Setup* MediaImageContainer::getSetup() const
-{ return setup; }
+FilePathObject* MediaImageContainer::getFilePath() const
+{ return filePath; }
 
-void MediaImageContainer::setSetup(Setup *s)
-{ setup = s; }
+void MediaImageContainer::setFilePath(FilePathObject *fp)
+{ filePath = fp; }