Tracking down error with storing media image files to database.
[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 = 0;
27 }
28
29 bool DbMediaImageContainer::updateDataObjectToModel(const EmuFrontObject *efo)
30 {
31     // TODO
32     return false;
33 }
34
35 bool DbMediaImageContainer::insertDataObjectToModel(const EmuFrontObject *efo)
36 {
37     // TODO
38     return false;
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::constructSelectById(int id) const
60 {
61     // TODO
62     return "";
63 }
64
65 EmuFrontObject* DbMediaImageContainer::recordToDataObject(const QSqlRecord *)
66 {
67     // TODO
68     return 0;
69 }
70
71 QSqlQueryModel* DbMediaImageContainer::getData()
72 {
73     // TODO
74     return 0;
75 }
76
77 int DbMediaImageContainer::getMediaImageContainer(QString checksum) const
78 {
79     // TODO
80     return -1;
81 }
82
83 void DbMediaImageContainer::storeContainers(QList<MediaImageContainer *> lst)
84 {
85     qDebug() << "Storing media image containers to database.";
86     foreach(MediaImageContainer *mic, lst)
87     {
88         qDebug() << "Media image container " << mic->getName();
89         QList<MediaImage*> images = mic->getMediaImages();
90         if (getMediaImageContainer(mic->getCheckSum()) >= 0)
91             continue;
92         // this is a new media image container, lets build a list
93         // of media image id's for this container
94         QList<int> ids = dbMediaImage->storeMediaImages(images);
95
96         if (ids.count() > 0)
97         {
98             // store media image to id
99
100             // get last insert id of stored media image
101
102             // link all the ids in ids-list to media image id
103         }
104     }
105 }