return false;
}
-
+/* Throws EmuFrontException */
int DbMediaImageContainer::storeMediaImageContainer(EmuFrontObject *efo)
{
MediaImageContainer *mic
= dynamic_cast<MediaImageContainer *>(efo);
if (!mic->getFilePath())
- throw new EmuFrontException("Cannot install media image "
+ throw EmuFrontException("Cannot install media image "
"container to database without a file path object!");
// multiple media image containers with matching checksum will be stored
QMap<QString, EmuFrontObject*> images = mic->getMediaImages();
QList<int> ids = dbMediaImage->storeMediaImages(images);
- qDebug() << "Stored " << ids.count() << " media images.";
+ //qDebug() << "Stored " << ids.count() << " media images.";
if (ids.count() <= 0)
return -1;
fileId = insertDataObjectToModel(mic);
- qDebug() << "Inserted media image container to file table with id " << fileId << ".";
+ //qDebug() << "Inserted media image container to file table with id " << fileId << ".";
if (fileId < 0) {
// TODO: note we most surely need to catch the exception
// in the calling code block and clean
// all the media image and ...containers from
// the memory!
- throw new EmuFrontException(
+ throw EmuFrontException(
QString(tr("Inserting media image container %1 to file database failed"))
.arg(mic->getName()));
}
if (!linkMediaImageContainerToPath(mic)){
DbFile::deleteDataObject(fileId);
- throw new EmuFrontException("Failed inserting media image to database!");
+ throw EmuFrontException("Failed inserting media image to database!");
}
- qDebug() << "Inserted media image container " << fileId << " to mediaimagecontainer table.";
+ //qDebug() << "Inserted media image container " << fileId << " to mediaimagecontainer table.";
linkMediaImagesWithContainer(fileId, images.values());
- qDebug() << "Linked media image container with media images.";
+ //qDebug() << "Linked media image container with media images.";
} catch (EmuFrontException e) {
dbMediaImage->removeOrphanedMediaImages(ids);
throw e;
"INNER JOIN mediatype ON setup.mediatypeid = mediatype.id "
"%1 "
"ORDER BY file.name").arg(whereClause);
- qDebug() << select;
+ //qDebug() << select;
return select;
}
);
}
+/* Throws EmuFrontException */
EmuFrontObject* DbMediaImageContainer::recordToDataObject(const QSqlRecord *rec)
{
// TODO: checks!
int size = rec->value(MIC_FileSize).toInt();
int fpId = rec->value(MIC_FilePathId).toInt();
FilePathObject *fpo
- = dynamic_cast<FilePathObject*>(dbFilePath->getDataObject(fpId));
+ = dynamic_cast<FilePathObject*>(dbFilePath->getDataObject(fpId)); /* Throws EmuFrontException */
//int supId = rec->value(MIC_SetupId).toInt();
//Setup *sup = dbSetup->getDataObject(supId)
QMap<QString, EmuFrontObject*> images = dbMediaImage->getMediaImages(id);
*/
void DbMediaImageContainer::storeContainers(QList<MediaImageContainer *> lst, FilePathObject *fpo)
{
- qDebug() << "Storing media image containers to database.";
foreach(MediaImageContainer *mic, lst)
{
- qDebug() << "Media image container " << mic->getName();
+ //qDebug() << "Media image container " << mic->getName();
int micFileId = storeMediaImageContainer(mic);
}
}
+/* Throws EmuFrontException */
void DbMediaImageContainer::linkMediaImagesWithContainer(int micId, QList<EmuFrontObject*> mediaImages)
{
if (micId < 0 || mediaImages.count() <= 0)
MediaImage *mi = 0;
foreach(EmuFrontObject *efo, mediaImages) {
mi = dynamic_cast<MediaImage*>(efo);
- qDebug() << "Linking media image container " << micId
- << " to media image " << mi->getId() << ", " << mi->getName() << ".";
+ /*qDebug() << "Linking media image container " << micId
+ << " to media image " << mi->getId() << ", " << mi->getName() << ".";*/
if (!linkMediaImageToMediaImageContainer(mi, micId)) {
- throw new EmuFrontException(QString("Failed linking media "
+ throw EmuFrontException(QString("Failed linking media "
"image container %1 to a media image %2").arg(micId).arg(mi->getId()));
}
}
void DbMediaImageContainer::filter(int mediaTypeId, int platformId)
{
- qDebug() << "Filtering media images with media type " << mediaTypeId
- << " and platform " << platformId;
+ /*qDebug() << "Filtering media images with media type " << mediaTypeId
+ << " and platform " << platformId;*/
QList<QString> filters;
if (mediaTypeId >= 0)
filters.append(QString("mediatype.id=%1").arg(mediaTypeId));
return QString("DELETE FROM file WHERE id=:id");
}
+/* Throws EmuFrontException */
EmuFrontObject* DbMediaImageContainer::getMediaImageContainerByChecksum(QString checksum)
{
return getDataObject(QString("file.checksum LIKE '%1'").arg(checksum));