DbEmuFrontFileObject is now a DbQueryModelManager instead of
[emufront] / src / db / dbmediaimagecontainer.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 as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
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 "dbmediaimagecontainer.h"
22
23 DbMediaImageContainer::DbMediaImageContainer(QObject *parent)
24     : DbQueryModelManager(parent)
25 {
26     dbMediaImage = new DbMediaImage(parent);
27 }
28
29 bool DbMediaImageContainer::updateDataObjectToModel(const EmuFrontObject *efo)
30 {
31     // TODO
32     return false;
33 }
34
35 int DbMediaImageContainer::insertDataObjectToModel(const EmuFrontObject *efo)
36 {
37     // TODO
38     return -1;
39 }
40
41 bool DbMediaImageContainer::deleteDataObjectFromModel(QModelIndex *i)
42 {
43     // TODO
44     return false;
45 }
46
47 int DbMediaImageContainer::countDataObjectRefs(int id) const
48 {
49     // TODO
50     return -1;
51 }
52
53 QString DbMediaImageContainer::constructSelect(QString whereClause) const
54 {
55     // TODO
56     return "";
57 }
58
59 QString DbMediaImageContainer::constructFilterById(int id) const
60 {
61     // TODO
62     return "";
63 }
64
65 QString DbMediaImageContainer::constructSelectById(int id) const
66 {
67     // TODO
68     return "";
69 }
70
71 EmuFrontObject* DbMediaImageContainer::recordToDataObject(const QSqlRecord *)
72 {
73     // TODO
74     return 0;
75 }
76
77 QSqlQueryModel* DbMediaImageContainer::getData()
78 {
79     // TODO
80     return 0;
81 }
82
83 int DbMediaImageContainer::getMediaImageContainer(QString checksum) const
84 {
85     // TODO
86     return -1;
87 }
88
89
90 /**
91 * Stores media image containers, including the media images included
92 * to database.
93 */
94 void DbMediaImageContainer::storeContainers(QList<MediaImageContainer *> lst)
95 {
96     qDebug() << "Storing media image containers to database.";
97     foreach(MediaImageContainer *mic, lst)
98     {
99         qDebug() << "Media image container " << mic->getName();
100         QList<MediaImage*> images = mic->getMediaImages();
101
102         /* If media image container is already in the db, continue */
103         if (getMediaImageContainer(mic->getCheckSum()) >= 0)
104             continue;
105
106         // this is a new media image container, lets build a list
107         // of media image id's for this container
108         QList<int> ids = dbMediaImage->storeMediaImages(images);
109
110         if (ids.count() > 0)
111         {
112             // store media image to db
113
114             // get last insert id of stored media image
115
116             // link all the media image ids in list to media image container id
117         }
118     }
119 }