--- /dev/null
+// EmuFront
+// Copyright 2010 Mikko Keinänen
+//
+// This file is part of EmuFront.
+//
+//
+// EmuFront is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as published by
+// the Free Software Foundation and appearing in the file gpl.txt included in the
+// packaging of this file.
+//
+// EmuFront is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with EmuFront. If not, see <http://www.gnu.org/licenses/>.
+
+#include "emufrontquerymodel.h"
+
+EmuFrontQueryModel::EmuFrontQueryModel(QObject *parent) :
+ QSqlQueryModel(parent)
+{
+}
--- /dev/null
+// EmuFront
+// Copyright 2010 Mikko Keinänen
+//
+// This file is part of EmuFront.
+//
+//
+// EmuFront is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as published by
+// the Free Software Foundation and appearing in the file gpl.txt included in the
+// packaging of this file.
+//
+// EmuFront is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with EmuFront. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef EMUFRONTQUERYMODEL_H
+#define EMUFRONTQUERYMODEL_H
+
+#include <QSqlQueryModel>
+
+class EmuFrontQueryModel : public QSqlQueryModel
+{
+ Q_OBJECT
+public:
+ EmuFrontQueryModel(QObject *parent = 0);
+
+signals:
+
+public slots:
+
+protected:
+ QString tableName;
+};
+
+#endif // EMUFRONTQUERYMODEL_H
--- /dev/null
+// EmuFront
+// Copyright 2010 Mikko Keinänen
+//
+// This file is part of EmuFront.
+//
+//
+// EmuFront is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as published by
+// the Free Software Foundation and appearing in the file gpl.txt included in the
+// packaging of this file.
+//
+// EmuFront is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with EmuFront. If not, see <http://www.gnu.org/licenses/>.
+
+#include <QtSql>
+#include "platformmodel.h"
+
+PlatformModel::PlatformModel(QObject *parent) :
+ EmuFrontQueryModel(parent)
+{
+ tableName = "platform";
+ refresh();
+}
+
+Qt::ItemFlags PlatformModel::flags(const QModelIndex &index) const
+{
+ Qt::ItemFlags flags = QSqlQueryModel::flags(index);
+ if (index.column() == EmuFrontFileObject_Name) {
+ flags |= Qt::ItemIsEditable;
+ }
+ return flags;
+}
+
+bool PlatformModel::setData(const QModelIndex &index, const QVariant &value, int /*role*/)
+{
+ if(index.column() != EmuFrontFileObject_Name)
+ return false;
+
+ QModelIndex primaryKeyIndex
+ = QSqlQueryModel::index(index.row(), EmuFrontFileObject_Id);
+
+ int id = data(primaryKeyIndex).toInt();
+ clear();
+
+ bool ok;
+ if (index.column() == EmuFrontFileObject_Name) {
+ ok = setName(id, value.toString());
+ }
+
+ refresh();
+ return ok;
+}
+
+void PlatformModel::refresh()
+ {
+ setQuery(constructSelect());
+ setHeaderData(EmuFrontFileObject_Id, Qt::Horizontal, tr("ID"));
+ setHeaderData(EmuFrontFileObject_Name, Qt::Horizontal, tr("Name"));
+ setHeaderData(EmuFrontFileObject_FileId, Qt::Horizontal, tr("FileID"));
+ setHeaderData(EmuFrontFileObject_FileName, Qt::Horizontal, tr("File Name"));
+ setHeaderData(EmuFrontFileObject_FileCheckSum, Qt::Horizontal, tr("File Checksum"));
+ setHeaderData(EmuFrontFileObject_FileSize, Qt::Horizontal, tr("File Size"));
+ setHeaderData(EmuFrontFileObject_FileType, Qt::Horizontal, tr("File Type"));
+ setHeaderData(EmuFrontFileObject_FileUpdateTime, Qt::Horizontal, tr("File Updated"));
+ }
+
+QString PlatformModel::constructSelect(QString where) const
+{
+ return QString("SELECT maintbl.id AS FileObjectId, "
+ "maintbl.name AS Name, "
+ "file.id AS FileId, "
+ "file.name AS FileName, "
+ "file.type AS FileType, "
+ "file.checksum AS FileChecksum, "
+ "file.size AS FileSize, "
+ "file.updatetime AS FileUpdateTime "
+ "FROM %1 AS maintbl "
+ "LEFT OUTER JOIN file ON maintbl.fileid=file.id "
+ "%2 "
+ "ORDER BY Name").arg(tableName).arg(where);
+}
+
+bool PlatformModel::setName(int id, const QString &name)
+{
+ QSqlQuery query;
+ query.prepare("update platform set name = :name where id = :id");
+ query.bindValue(":name", name);
+ query.bindValue(":id", id);
+ return query.exec();
+}
+
--- /dev/null
+// EmuFront
+// Copyright 2010 Mikko Keinänen
+//
+// This file is part of EmuFront.
+//
+//
+// EmuFront is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as published by
+// the Free Software Foundation and appearing in the file gpl.txt included in the
+// packaging of this file.
+//
+// EmuFront is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with EmuFront. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef PLATFORMMODEL_H
+#define PLATFORMMODEL_H
+
+#include "emufrontquerymodel.h"
+
+class PlatformModel : public EmuFrontQueryModel
+{
+ Q_OBJECT
+public:
+ PlatformModel(QObject *parent = 0);
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+ bool setData(const QModelIndex &index, const QVariant &value, int role);
+ enum {
+ EmuFrontFileObject_Id,
+ EmuFrontFileObject_Name,
+ EmuFrontFileObject_FileId,
+ EmuFrontFileObject_FileName,
+ EmuFrontFileObject_FileType,
+ EmuFrontFileObject_FileCheckSum,
+ EmuFrontFileObject_FileSize,
+ EmuFrontFileObject_FileUpdateTime
+ };
+
+signals:
+
+public slots:
+
+private:
+
+ void refresh();
+ QString constructSelect(QString where = "") const;
+ bool setName(int id, const QString &name);
+
+};
+
+#endif // PLATFORMMODEL_H
void DbObjectDialog::connectSignals()
{
- connect(buttonBox, SIGNAL(accepted()), this, SLOT(close()));
+ connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(objectList, SIGNAL(clicked(const QModelIndex &)),
this, SLOT(listObjectClicked(const QModelIndex &)));
connect(editButton, SIGNAL(clicked()), this, SLOT(editButtonClicked()));
--- /dev/null
+// EmuFront
+// Copyright 2010 Mikko Keinänen
+//
+// This file is part of EmuFront.
+//
+//
+// EmuFront is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as published by
+// the Free Software Foundation and appearing in the file gpl.txt included in the
+// packaging of this file.
+//
+// EmuFront is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with EmuFront. If not, see <http://www.gnu.org/licenses/>.
+
+#include <QtGui>
+#include "emufrontdatadialog.h"
+
+EmuFrontDataDialog::EmuFrontDataDialog(QWidget *parent) :
+ EmuFrontDialog(parent)
+{
+ editButton = new QPushButton(tr("&Edit"));
+ editButton->setEnabled(false);
+ addButton = new QPushButton(tr("&Add"));
+ deleteButton = new QPushButton(tr("&Delete"));
+ deleteButton->setEnabled(false);
+ objectList = new QTableView(this);
+ buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok, Qt::Vertical);
+ buttonBox->addButton(editButton, QDialogButtonBox::ActionRole);
+ buttonBox->addButton(addButton, QDialogButtonBox::ActionRole);
+ buttonBox->addButton(deleteButton, QDialogButtonBox::ActionRole);
+ // this be called from the implementing classes:
+ //connectSignals();
+ layout();
+}
+
+void EmuFrontDataDialog::postInit()
+{
+ connectSignals();
+ setHiddenColumns();
+ hideColumns();
+}
+
+void EmuFrontDataDialog::layout()
+{
+ QHBoxLayout *mainLayout = new QHBoxLayout;
+ mainLayout->addWidget(objectList);
+ mainLayout->addWidget(buttonBox);
+ setLayout(mainLayout);
+}
+
+void EmuFrontDataDialog::hideColumns()
+{
+ foreach(int c, hiddenColumns)
+ objectList->hideColumn(c);
+}
+
+void EmuFrontDataDialog::connectSignals()
+{
+ connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
+ /*connect(objectList, SIGNAL(clicked(const QModelIndex &)),
+ this, SLOT(listObjectClicked(const QModelIndex &)));*/
+ connect(editButton, SIGNAL(clicked()), this, SLOT(editButtonClicked()));
+ connect(addButton, SIGNAL(clicked()), this, SLOT(addButtonClicked()));
+ connect(deleteButton, SIGNAL(clicked()), this, SLOT(deleteButtonClicked()));
+}
+
+void EmuFrontDataDialog::editButtonClicked()
+{
+ qDebug() << "Edit button clicked";
+}
+
+void EmuFrontDataDialog::deleteButtonClicked()
+{
+ qDebug() << "Delete button clicked";
+}
+
+void EmuFrontDataDialog::addButtonClicked()
+{
+ qDebug() << "Delete button clicked";
+}
--- /dev/null
+// EmuFront
+// Copyright 2010 Mikko Keinänen
+//
+// This file is part of EmuFront.
+//
+//
+// EmuFront is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as published by
+// the Free Software Foundation and appearing in the file gpl.txt included in the
+// packaging of this file.
+//
+// EmuFront is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with EmuFront. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef EMUFRONTDATADIALOG_H
+#define EMUFRONTDATADIALOG_H
+
+#include "emufrontdialog.h"
+#include "db/emufrontquerymodel.h"
+
+class QDialogButtonBox;
+class QTableView;
+
+class EmuFrontDataDialog : public EmuFrontDialog
+{
+ Q_OBJECT
+public:
+ EmuFrontDataDialog(QWidget *parent = 0);
+
+private slots:
+ void editButtonClicked();
+ void addButtonClicked();
+ void deleteButtonClicked();
+
+protected:
+ EmuFrontQueryModel *model;
+ QList<int> hiddenColumns;
+ QDialogButtonBox *buttonBox;
+ QTableView *objectList;
+ void postInit();
+
+private:
+ QPushButton *editButton;
+ QPushButton *addButton;
+ QPushButton *deleteButton;
+ void layout();
+ virtual void setHiddenColumns() = 0;
+ void hideColumns();
+ virtual void connectSignals();
+
+};
+
+#endif // EMUFRONTDATADIALOG_H
--- /dev/null
+// EmuFront
+// Copyright 2010 Mikko Keinänen
+//
+// This file is part of EmuFront.
+//
+//
+// EmuFront is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as published by
+// the Free Software Foundation and appearing in the file gpl.txt included in the
+// packaging of this file.
+//
+// EmuFront is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with EmuFront. If not, see <http://www.gnu.org/licenses/>.
+
+#include <QtGui>
+#include "platformmaindialog.h"
+#include "db/platformmodel.h"
+
+PlatformMainDialog::PlatformMainDialog(QWidget *parent) :
+ EmuFrontDataDialog(parent)
+{
+ model = new PlatformModel(this);
+ objectList->setModel(model);
+ postInit();
+}
+
+void PlatformMainDialog::setHiddenColumns()
+{
+ hiddenColumns << PlatformModel::EmuFrontFileObject_Id;
+ hiddenColumns << PlatformModel::EmuFrontFileObject_FileId;
+ hiddenColumns << PlatformModel::EmuFrontFileObject_FileType;
+ hiddenColumns << PlatformModel::EmuFrontFileObject_FileCheckSum;
+}
--- /dev/null
+// EmuFront
+// Copyright 2010 Mikko Keinänen
+//
+// This file is part of EmuFront.
+//
+//
+// EmuFront is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as published by
+// the Free Software Foundation and appearing in the file gpl.txt included in the
+// packaging of this file.
+//
+// EmuFront is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with EmuFront. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef PLATFORMMAINDIALOG_H
+#define PLATFORMMAINDIALOG_H
+
+#include "emufrontdatadialog.h"
+
+
+class PlatformMainDialog : public EmuFrontDataDialog
+{
+ Q_OBJECT
+public:
+ PlatformMainDialog(QWidget *parent = 0);
+private:
+ virtual void setHiddenColumns();
+
+ };
+
+#endif // PLATFORMMAINDIALOG_H
dialogs/browsefilepathdialog.h \
db/dbconfig.h \
utils/datfileutil.h \
- widgets/fileextensionwidget.h
+ widgets/fileextensionwidget.h \
+ db/platformmodel.h \
+ dialogs/platformmaindialog.h \
+ dialogs/emufrontdatadialog.h \
+ db/emufrontquerymodel.h
SOURCES += main.cpp \
mainwindow.cpp \
db/databasemanager.cpp \
dialogs/browsefilepathdialog.cpp \
db/dbconfig.cpp \
utils/datfileutil.cpp \
- widgets/fileextensionwidget.cpp
+ widgets/fileextensionwidget.cpp \
+ db/platformmodel.cpp \
+ dialogs/platformmaindialog.cpp \
+ dialogs/emufrontdatadialog.cpp \
+ db/emufrontquerymodel.cpp
OTHER_FILES +=
CONFIG += mobility
#include "mainwindow.h"
#include "emulauncher.h"
#include "dialogs/platformdialog.h"
+#include "dialogs/platformmaindialog.h"
#include "dialogs/mediatypedialog.h"
#include "dialogs/mediaimagepathmaindialog.h"
#include "dialogs/setupmaindialog.h"
configPlatformAction = new QAction(tr("&Platforms"), this);
configPlatformAction->setStatusTip(tr("Configure platforms"));
connect(configPlatformAction, SIGNAL(triggered()),
- this, SLOT(configurePlatforms()));
+ this, SLOT(configurePlatforms()));
+
+ configPlatformsAction = new QAction(tr("&Set Platforms"), this);
+ configPlatformsAction->setStatusTip(tr("Add, edit and delete platforms"));
+ connect(configPlatformsAction, SIGNAL(triggered()),
+ this, SLOT(configurePlatformss()));
configMediaTypeAction = new QAction(tr("&Media Types"), this);
configMediaTypeAction->setStatusTip(tr("Configure media types"));
activateDialog(platformDialog);
}
+void MainWindow::configurePlatformss()
+{
+ plfDialog = new PlatformMainDialog(this);
+ connect(plfDialog, SIGNAL(finished(int)), this, SLOT(updateData()));
+ activateDialog(plfDialog);
+}
+
void MainWindow::configureMediaTypes()
{
if (!mediaTypeDialog)
configMenu->addAction(configTmpDirAction);
configMenu->addSeparator();
configMenu->addAction(configPlatformAction);
+ configMenu->addAction(configPlatformsAction);
configMenu->addAction(configMediaTypeAction);
configMenu->addAction(configSetupAction);
configMenu->addAction(configMediaImagePathAction);
class QAction;
class PlatformDialog;
+class PlatformMainDialog;
class MediaTypeDialog;
class MediaImagePathMainDialog;
class SetupMainDialog;
void closeEvent(QCloseEvent *event);
private slots:
- void configurePlatforms();
+ void configurePlatforms();
+ void configurePlatformss();
void configureMediaTypes();
void configureMediaImagePaths();
void configureSetups();
void activateDialog(EmuFrontDialog*) const;
bool testDB(bool reset);
void createDB() const;
- PlatformDialog *platformDialog;
+ PlatformDialog *platformDialog;
+ PlatformMainDialog *plfDialog;
MediaTypeDialog *mediaTypeDialog;
MediaImagePathMainDialog *mediaImagePathDialog;
SetupMainDialog *setupMainDialog;
QMenu *fileMenu;
QMenu *helpMenu;
QAction *configPlatformAction;
+ QAction *configPlatformsAction;
QAction *configMediaTypeAction;
QAction *configMediaImagePathAction;
QAction *configSetupAction;