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 "externalexecutablemodel.h"
24 ExternalExecutableModel::ExternalExecutableModel(QObject *parent) :
25 EmuFrontQueryModel(parent)
30 void ExternalExecutableModel::refresh()
32 setQuery(constructSelect());
33 setHeaderData(Executable_Id, Qt::Horizontal, tr("Id"));
34 setHeaderData(Executable_Name, Qt::Horizontal, tr("Name"));
35 setHeaderData(Executable_Executable, Qt::Horizontal, tr("Executable"));
36 setHeaderData(Executable_Options, Qt::Horizontal, tr("Options"));
37 setHeaderData(Executable_TypeId, Qt::Horizontal, tr("Type"));
38 setHeaderData(Executable_SetupId, Qt::Horizontal, tr("Setup id"));
39 setHeaderData(Executable_SetupName, Qt::Horizontal, tr("Setup"));
42 QString ExternalExecutableModel::constructSelect(QString where) const
44 return QString("SELECT "
45 "executable.id AS ExecutableId, "
46 "executable.name AS ExecutableName, "
47 "executable.executable AS Executable, "
48 "executable.options AS ExecutableOptions, "
49 "executable.type AS ExecutableType, "
50 "setup.id As ExecutableSetupId, "
51 "platform.name || ' ' || mediatype.name AS SetupName "
53 "INNER JOIN setup ON executable.setupid = setup.id "
54 "INNER JOIN platform ON setup.platformid=platform.id "
55 "INNER JOIN mediatype ON setup.mediatypeid=mediatype.id "
57 "ORDER BY executable.name").arg(where);
60 Qt::ItemFlags ExternalExecutableModel::flags(const QModelIndex &index) const
62 Qt::ItemFlags flags = QSqlQueryModel::flags(index);
63 int col = index.column();
64 if (col == Executable_Name ||
65 col == Executable_Options ||
66 col == Executable_Executable ||
67 col == Executable_SetupId) {
68 flags |= Qt::ItemIsEditable;
73 bool ExternalExecutableModel::setData(const QModelIndex &index, const QVariant &value, int role)
79 bool ExternalExecutableModel::insertRows(int row, int count, const QModelIndex &parent)
85 bool ExternalExecutableModel::removeRows(int row, int count, const QModelIndex &parent)
91 bool ExternalExecutableModel::setSetup(int isd, int setupId)