Downgraded GPL license from v3 to v2 to be compatible with OSDaB-ZIP
[emufront] / src / dataobjects / mediaimagecontainer.cpp
1 // EmuFront
2 // Copyright 2010 Mikko Keinänen
3 //
4 // This file is part of EmuFront.
5 //
6 //
7 // EmuFront is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License version 2 as published by
9 // the Free Software Foundation and appearing in the file gpl.txt included in the
10 // packaging of this file.
11 //
12 // EmuFront is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with EmuFront.  If not, see <http://www.gnu.org/licenses/>.
19
20 #include <QDebug>
21 #include "mediaimagecontainer.h"
22
23 MediaImageContainer::MediaImageContainer()
24     : EmuFrontFile(EmuFrontFile::FileType_MediaImageContainer)
25 {
26     lstMediaImage = QList<MediaImage*>();
27     filePath = 0;
28 }
29
30 MediaImageContainer::MediaImageContainer(int id, QString name, 
31     QString checksum, int size, QList<MediaImage *>images, FilePathObject *fpo)
32     : EmuFrontFile(id, name, checksum, size, EmuFrontFile::FileType_MediaImageContainer),
33         lstMediaImage(images), filePath(fpo)
34 { }
35
36 MediaImageContainer::MediaImageContainer(QString name, QString checksum,
37     int size, QList<MediaImage *>images, FilePathObject *fpo)
38     : EmuFrontFile(-1, name, checksum, size, EmuFrontFile::FileType_MediaImageContainer),
39         lstMediaImage(images), filePath(fpo)
40 { }
41
42 MediaImageContainer::~MediaImageContainer()
43 {
44     qDeleteAll(lstMediaImage);
45     delete filePath;
46 }
47
48 MediaImageContainer::MediaImageContainer(MediaImageContainer &mic)
49     : EmuFrontFile(mic)
50 {
51     lstMediaImage = QList<MediaImage*>();
52     foreach(MediaImage *mi, mic.lstMediaImage)
53         lstMediaImage.append(new MediaImage(*mi));
54     filePath = new FilePathObject(*(mic.filePath));
55 }
56
57 MediaImageContainer& MediaImageContainer::operator =(MediaImageContainer &mic)
58 {
59      if (this == &mic) return *this;
60     id = mic.id;
61     name = mic.name;
62     type = mic.type;
63     checkSum = mic.checkSum;
64     size = mic.size;
65     qDeleteAll(lstMediaImage);
66     foreach(MediaImage *mi, mic.lstMediaImage)
67         lstMediaImage.append(new MediaImage(*mi));
68     filePath = new FilePathObject(*(mic.filePath));
69     return (*this);
70 }
71
72 void MediaImageContainer::setMediaImages(QList<MediaImage *> list)
73 {
74     qDeleteAll(lstMediaImage);
75     lstMediaImage = list;
76 }
77
78 QList<MediaImage *> MediaImageContainer::getMediaImages() const
79 {   return lstMediaImage; }
80
81 void MediaImageContainer::addMediaImage(MediaImage *mi)
82 {   lstMediaImage.append(mi); }
83
84 void MediaImageContainer::clearMediaImages()
85 {
86     qDeleteAll(lstMediaImage);
87     lstMediaImage.clear();
88 }
89
90 FilePathObject* MediaImageContainer::getFilePath() const
91 { return filePath; }
92
93 void MediaImageContainer::setFilePath(FilePathObject *fp)
94 { filePath = fp; }