3 ** Copyright 2010 Mikko Keinänen
5 ** This file is part of EmuFront.
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.
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.
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/>.
22 #include "emufrontfile.h"
23 #include "filemodel.h"
26 FileModel::FileModel(QObject *parent) :
27 EmuFrontQueryModel(parent)
31 QString FileModel::constructSelect(QString where) const
34 "SELECT file.id AS FileId, "
36 "file.type AS FileType, "
37 "file.checksum AS Checksum, "
38 "file.size AS FileSize, "
39 "file.updatetime AS UpdateTime "
46 QString FileModel::constructFilterById(int id) const
48 return QString("file.id = %1").arg(id);
51 EmuFrontObject* FileModel::recordToDataObject(const QSqlRecord *record)
53 int id = record->value(File_Id).toInt();
54 QString name = record->value(File_Name).toString();
55 QString checksum = record->value(File_CheckSum).toString();
56 int size = record->value(File_FileSize).toInt();
57 int type = record->value(File_FileType).toInt();
58 return new EmuFrontFile(id, name, checksum, size, type);