2 // Copyright 2010 Mikko Keinänen
4 // This file is part of EmuFront.
7 // EmuFront is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License version 2 as published by
9 // the Free Software Foundation and appearing in the file gpl.txt included in the
10 // packaging of this file.
12 // EmuFront is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with EmuFront. If not, see <http://www.gnu.org/licenses/>.
21 #include "emufrontdatadialog.h"
23 EmuFrontDataDialog::EmuFrontDataDialog(QWidget *parent) :
24 EmuFrontDialog(parent)
26 editButton = new QPushButton(tr("&Edit"));
27 editButton->setEnabled(false);
28 addButton = new QPushButton(tr("&Add"));
29 deleteButton = new QPushButton(tr("&Delete"));
30 deleteButton->setEnabled(false);
31 objectList = new QTableView(this);
32 buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok, Qt::Vertical);
33 buttonBox->addButton(editButton, QDialogButtonBox::ActionRole);
34 buttonBox->addButton(addButton, QDialogButtonBox::ActionRole);
35 buttonBox->addButton(deleteButton, QDialogButtonBox::ActionRole);
36 // this be called from the implementing classes:
41 void EmuFrontDataDialog::postInit()
48 void EmuFrontDataDialog::layout()
50 QHBoxLayout *mainLayout = new QHBoxLayout;
51 mainLayout->addWidget(objectList);
52 mainLayout->addWidget(buttonBox);
53 setLayout(mainLayout);
56 void EmuFrontDataDialog::hideColumns()
58 foreach(int c, hiddenColumns)
59 objectList->hideColumn(c);
62 void EmuFrontDataDialog::connectSignals()
64 connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
65 /*connect(objectList, SIGNAL(clicked(const QModelIndex &)),
66 this, SLOT(listObjectClicked(const QModelIndex &)));*/
67 connect(editButton, SIGNAL(clicked()), this, SLOT(editButtonClicked()));
68 connect(addButton, SIGNAL(clicked()), this, SLOT(addButtonClicked()));
69 connect(deleteButton, SIGNAL(clicked()), this, SLOT(deleteButtonClicked()));
72 void EmuFrontDataDialog::editButtonClicked()
74 qDebug() << "Edit button clicked";
77 void EmuFrontDataDialog::deleteButtonClicked()
79 qDebug() << "Delete button clicked";
82 void EmuFrontDataDialog::addButtonClicked()
84 qDebug() << "Delete button clicked";
85 int row = objectList->currentIndex().row();
86 if (row == -1) row = 0;
87 model->insertRows(row, 1);
88 QModelIndex ind = model->index(row, 1);
90 qDebug() << "Invalid index";
93 objectList->setCurrentIndex(ind);
94 objectList->edit(ind);