-// 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*/, FilePathObject *fpo)
+ QString checksum, int size, QMap<QString, EmuFrontObject*>images, FilePathObject *fpo)
: EmuFrontFile(id, name, checksum, size, EmuFrontFile::FileType_MediaImageContainer),
- lstMediaImage(images)/*, setup(setup)*/, filePath(fpo)
+ lstMediaImage(images), filePath(fpo)
{ }
MediaImageContainer::MediaImageContainer(QString name, QString checksum,
- int size, QList<MediaImage *>images/*, Setup *setup*/, FilePathObject *fpo)
+ int size, QMap<QString, EmuFrontObject*>images, FilePathObject *fpo)
: EmuFrontFile(-1, name, checksum, size, EmuFrontFile::FileType_MediaImageContainer),
- lstMediaImage(images)/*, setup(setup)*/, filePath(fpo)
+ lstMediaImage(images), filePath(fpo)
{ }
MediaImageContainer::~MediaImageContainer()
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));
}
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);
- /*foreach(MediaImage *mi, lstMediaImage) {
- delete mi;
- mi = 0;
- }*/
lstMediaImage.clear();
- qDebug() << lstMediaImage.count();
}
-/*Setup* MediaImageContainer::getSetup() const
-{ return setup; }
-
-void MediaImageContainer::setSetup(Setup *s)
-{ setup = s; }*/
-
FilePathObject* MediaImageContainer::getFilePath() const
{ return filePath; }