Source code repository is hosted at Gitorious from now on.
[emufront] / src / dataobjects / setup.cpp
1 /*
2 ** EmuFront
3 ** Copyright 2010 Mikko Keinänen
4 **
5 ** This file is part of EmuFront.
6 **
7 **
8 ** EmuFront is free software: you can redistribute it and/or modify
9 ** it under the terms of the GNU General Public License version 2 as published by
10 ** the Free Software Foundation and appearing in the file gpl.txt included in the
11 ** packaging of this file.
12 **
13 ** EmuFront is distributed in the hope that it will be useful,
14 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 ** GNU General Public License for more details.
17 **
18 ** You should have received a copy of the GNU General Public License
19 ** along with EmuFront.  If not, see <http://www.gnu.org/licenses/>.
20 */
21 #include <QDebug>
22 #include "setup.h"
23 #include "platform.h"
24 #include "mediatype.h"
25
26 Setup::Setup() : EmuFrontObject(), platform(0), mediaType(0)
27 {
28 }
29
30 Setup::Setup(int id, Platform *plf, MediaType *mt, QStringList fileTypeExtensions)
31     : EmuFrontObject(id,
32         QString("%1%2")
33             .arg(plf ? plf->getName() : "")
34             .arg(mt ? mt->getName() : "")), platform(plf), mediaType(mt),
35             fileTypeExtensions(fileTypeExtensions){
36
37 }
38
39 Setup::~Setup()
40 {
41     delete platform;
42     delete mediaType;
43 }
44
45 Setup::Setup(const Setup &s)
46         : EmuFrontObject(s),
47             fileTypeExtensions(s.fileTypeExtensions)
48 {
49     Platform *p = s.platform;
50     MediaType *m = s.mediaType;
51     platform = new Platform(*p);
52     mediaType = new MediaType(*m);
53 }
54
55 Setup& Setup::operator =(const Setup &sup)
56 {
57     if (this == &sup) return *this;
58     id = sup.id;
59     name = sup.name;
60     if (platform) delete platform;
61     Platform *p = sup.platform;
62     MediaType *m = sup.mediaType;
63     platform = new Platform(*p);
64     if (mediaType) delete mediaType;
65     mediaType = new MediaType(*m);
66     return (*this);
67 }
68
69 // TODO:
70 /*bool Setup::operator ==(const Setup &sup)
71 {
72
73     // TODO: more precise ... this is exact copy from EmuFrontObject
74     return (id >= 0 && id == sup.id);
75
76 }
77
78 bool Setup::operator !=(const Setup &sup)
79 {
80     // TODO: more precise ... this is exact copy from EmuFrontObject
81     return !(*this == sup);
82 }*/
83
84 Platform* Setup::getPlatform() const
85 { return platform; }
86 void Setup::setPlatform(Platform *plf)
87 { platform = plf; }
88
89 MediaType* Setup::getMediaType() const
90 { return mediaType; }
91 void Setup::setMediaType(MediaType *mt)
92 { mediaType = mt; }
93
94 QStringList Setup::getSupportedFileTypeExtensions() const
95 { return fileTypeExtensions; }
96 void Setup::setSupportedFileTypeExtensions(QStringList ftx)
97 { fileTypeExtensions = ftx; }