// along with Foobar. If not, see <http://www.gnu.org/licenses/>.
#include <QDialogButtonBox>
+#include <QSqlQueryModel>
+#include <QSqlRecord>
+#include <QComboBox>
#include "dataobjecteditdialog.h"
DataObjectEditDialog::DataObjectEditDialog(QWidget *parent, EmuFrontObject *ob, Qt::Orientation orientation)
connect(buttonBox, SIGNAL(accepted()), this, SLOT(acceptChanges()));
connect(buttonBox, SIGNAL(rejected()), this, SLOT(rejectChanges()));
}
+
+void DataObjectEditDialog::setSelected(QComboBox *cbox, const EmuFrontObject *ob, int idIndex)
+{
+ if (!ob) return;
+ QSqlQueryModel *model = dynamic_cast<QSqlQueryModel*>(cbox->model());
+ for (int i = 0; i < model->rowCount(); ++i)
+ {
+ QSqlRecord rec = model->record(i);
+ if (rec.value(idIndex) == ob->getId())
+ {
+ cbox->setCurrentIndex(i);
+ break;
+ }
+ }
+}
#include "../dataobjects/emufrontobject.h"
class QDialogButtonBox;
+class QComboBox;
class DataObjectEditDialog : public EmuFrontDialog
{
virtual void connectSignals();
EmuFrontObject *efObject;
QDialogButtonBox *buttonBox;
+ void setSelected(QComboBox*, const EmuFrontObject*, int idIndex);
protected slots:
virtual void acceptChanges() =0;
setSelected(mediaTypeComBox, plf, DbMediaType::MediaType_Id);
}*/
-// TODO: this might be useful to lever to upper classes
-void MediaImagePathDialog::setSelected(QComboBox *cbox, const EmuFrontObject *ob, int idIndex)
-{
- if (!ob) return;
- QSqlTableModel *model = dynamic_cast<QSqlTableModel*>(cbox->model());
- for (int i = 0; i < model->rowCount(); ++i)
- {
- QSqlRecord rec = model->record(i);
- if (rec.value(idIndex) == ob->getId())
- {
- cbox->setCurrentIndex(i);
- break;
- }
- }
-}
Setup* MediaImagePathDialog::getSelectedSetup()
{
void setSelectedSetup(const Setup *);
//void setSelectedMediaType(const MediaType *);
//void setSelectedPlatform(const Platform *);
- void setSelected(QComboBox*, const EmuFrontObject*, int idIndex);
Setup* getSelectedSetup();
//Platform* getSelectedPlatform() const;
//MediaType* getSelectedMediaType() const;
--- /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 as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Foobar 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
+
+#include <QtGui>
+#include "setupeditdialog.h"
+#include "../widgets/stringlistwidget.h"
+#include "../db/dbmediatype.h"
+#include "../db/dbplatform.h"
+#include "../db/dbsetup.h"
+
+
+SetupEditDialog::SetupEditDialog(QWidget *parent, EmuFrontObject* obj)
+ : DataObjectEditDialog(parent, obj)
+{
+ mediaTypeComBox = new QComboBox;
+ platformComBox = new QComboBox;
+ dbSetup = new DbSetup(this);
+ dbPlatform = new DbPlatform(this);
+ dbMediaType = new DbMediaType(this);
+ supportedFileTypesList = new StringListWidget;
+}
+
+void SetupEditDialog::acceptChanges()
+{
+}
+
+void SetupEditDialog::rejectChanges()
+{
+}
+
+void SetupEditDialog::setDataObject(EmuFrontObject *ob)
+{
+}
--- /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 as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Foobar 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef SETUPEDITDIALOG_H
+#define SETUPEDITDIALOG_H
+
+#include "dataobjecteditdialog.h"
+
+class QComboBox;
+class DbSetup;
+class DbMediaType;
+class DbPlatform;
+class StringListWidget;
+
+class SetupEditDialog : public DataObjectEditDialog
+{
+ Q_OBJECT
+
+public:
+ SetupEditDialog(QWidget *parent, EmuFrontObject*);
+ //~SetupEditDialog();
+ virtual void setDataObject(EmuFrontObject *);
+
+protected slots:
+ virtual void acceptChanges();
+ virtual void rejectChanges();
+
+private:
+ QComboBox *mediaTypeComBox;
+ QComboBox *platformComBox;
+ DbSetup *dbSetup;
+ DbPlatform *dbPlatform;
+ DbMediaType *dbMediaType;
+ StringListWidget *supportedFileTypesList;
+};
+
+#endif // SETUPEDITDIALOG_H
db/dbsetup.h \
db/dbtablemodelmanager.h \
db/dbquerymodelmanager.h \
- dialogs/setupmaindialog.h
+ dialogs/setupmaindialog.h \
+ dialogs/setupeditdialog.h \
+ widgets/stringlistwidget.h
SOURCES += main.cpp \
mainwindow.cpp \
db/databasemanager.cpp \
db/dbsetup.cpp \
db/dbtablemodelmanager.cpp \
db/dbquerymodelmanager.cpp \
- dialogs/setupmaindialog.cpp
+ dialogs/setupmaindialog.cpp \
+ dialogs/setupeditdialog.cpp \
+ widgets/stringlistwidget.cpp
OTHER_FILES +=
--- /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 as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Foobar 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
+
+#include "stringlistwidget.h"
+#include <QtGui>
+
+StringListWidget::StringListWidget(QWidget *parent, bool sort, int sortIndex) :
+ QWidget(parent), sort(sort), sortIndex(sortIndex)
+{
+ //model = new QStringListModel(this);
+ initUi();
+ connectSignals();
+}
+
+void StringListWidget::initUi()
+{
+ stringList = new QListWidget(this);
+ //stringList->setModel(model);
+ btnAdd = new QPushButton(tr("&Add"), this);
+ btnRemove = new QPushButton(tr("&Remove"), this);
+
+ QVBoxLayout *rightLayout = new QVBoxLayout;
+ rightLayout->addWidget(btnAdd);
+ rightLayout->addWidget(btnRemove);
+ rightLayout->addStretch();
+
+ QHBoxLayout *mainLayout = new QHBoxLayout;
+ mainLayout->addWidget(stringList);
+ mainLayout->addLayout(rightLayout);
+
+ setLayout(mainLayout);
+}
+
+void StringListWidget::connectSignals()
+{
+ connect(btnAdd, SIGNAL(clicked()), this, SLOT(addClicked()));
+ connect(btnRemove, SIGNAL(clicked()), this, SLOT(removeClicked()));
+}
+
+void StringListWidget::addClicked()
+{
+ QString input = QInputDialog::getText(this, tr("Add"), tr("Add new item"));
+ if (input.isEmpty()) return;
+ stringList->addItem(input);
+ stringList->sortItems();
+ /*QStringList l = model->stringList();
+ l << input;
+ model->setStringList(l);
+ if (sort) model->sort(sortIndex);*/
+ //emit stringListUpdated;
+}
+
+void StringListWidget::removeClicked()
+{
+ qDebug() << "StringListWidget::removeClicked";
+ /*QModelIndexList selected = stringList->selectedIndexes();
+ if (selected.count() < 1) return;
+ qDebug() << selected.count() << " items selected for removal.";
+ foreach(QModelIndex i, selected)
+ {
+ if (!i.isValid()) continue;
+ int row = i.row();
+ model->removeRows(row, 1);
+ }*/
+ //emit stringListUpdated;
+}
+
+QStringList StringListWidget::getItems()
+{
+ //return model->stringList();
+ QStringList l;
+ return l;
+}
+
+void StringListWidget::setItems(QStringList list)
+{
+ //model->setStringList(list);
+}
--- /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 as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Foobar 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 Foobar. If not, see <http://www.gnu.org/licenses/>.
+
+#ifndef STRINGLISTWIDGET_H
+#define STRINGLISTWIDGET_H
+
+#include <QWidget>
+
+//class QStringListModel;
+class QListWidget;
+class QPushButton;
+
+class StringListWidget : public QWidget
+{
+ Q_OBJECT
+public:
+ explicit StringListWidget(QWidget *parent = 0, bool sort = true, int sortIndex = 0);
+ QStringList getItems();
+ void setItems(QStringList);
+
+signals:
+ void stringListUpdated();
+
+private slots:
+ void addClicked();
+ void removeClicked();
+
+private:
+ void initUi();
+ void connectSignals();
+ //QStringListModel *model;
+ QListWidget *stringList;
+ QPushButton *btnAdd;
+ QPushButton *btnRemove;
+ bool sort;
+ int sortIndex;
+};
+
+#endif // STRINGLISTWIDGET_H