#include <QtGui>
#include <QtSql>
#include <QDebug>
#include "tablemodel.h"
tableModel::tableModel()
{
model->setTable("tx_submission_data");
model
->setRelation
(28,
QSqlRelation("tx_submission_epterm",
"uid",
"epterm"));
model
->setRelation
(29,
QSqlRelation("tx_submission_status",
"uid",
"status"));
model
->setRelation
(30,
QSqlRelation("tx_submission_status",
"uid",
"status"));
model
->setRelation
(31,
QSqlRelation("tx_submission_status",
"uid",
"status"));
model
->setRelation
(32,
QSqlRelation("tx_submission_status",
"uid",
"status"));
model
->setRelation
(33,
QSqlRelation("tx_submission_status",
"uid",
"status"));
model
->setRelation
(34,
QSqlRelation("tx_submission_status",
"uid",
"status"));
model->removeColumns(1,7);
model->removeColumn(5);
model->removeColumn(6);
model->removeColumn(6);
model->removeColumn(6);
model->removeColumn(7);
model->removeColumn(7);
model->removeColumn(7);
model->removeColumn(7);
model->removeColumn(7);
model->removeColumn(7);
model->removeColumn(7);
model->removeColumn(8);
model->removeColumn(11);
model->select();
viewTable->setModel(model);
viewTable->setSortingEnabled(TRUE);
viewTable->setAlternatingRowColors(TRUE);
//viewTable->hideColumn(0);
viewTable->resizeColumnsToContents();
connect(submitPb, SIGNAL(clicked(bool)), model, SLOT(submitAll()) );
connect(revertPb, SIGNAL(clicked(bool)), model, SLOT(revertAll() ) );
connect(addPb, SIGNAL(clicked(bool)), this, SLOT(addPerson() ) );
connect(deletePb, SIGNAL(clicked(bool)), this, SLOT(deletePerson() ) );
lay->addWidget(viewTable, 0, 0, 1, 4);
lay->addWidget(submitPb, 1, 0);
lay->addWidget(revertPb, 1, 1);
lay->addWidget(addPb, 1, 2);
lay->addWidget(deletePb, 1, 3);
// CSS
qApp->setStyleSheet("QTableView {background-color: #eeeeee; background-image: url(:/bg.png); color: blue;}");
}
void tableModel::addPerson()
{
int row = model->rowCount();
model->insertRow(row);
viewTable->setCurrentIndex(index);
viewTable->edit(index);
QMessageBox::warning(this, trUtf8
("Person hinzufügen"), trUtf8
("Sie müssen alle Felder ausfüllen!") );
}
void tableModel::deletePerson()
{
}
tableModel::~tableModel()
{
}
#include <QtGui>
#include <QtSql>
#include <QDebug>
#include "tablemodel.h"
tableModel::tableModel()
{
QPushButton *submitPb = new QPushButton(QObject::trUtf8("Änderungen speichern"));
QPushButton *revertPb = new QPushButton(QObject::trUtf8("Änderungen verwerfen"));
QPushButton *addPb = new QPushButton(QObject::trUtf8("Neue Person"));
QPushButton *deletePb = new QPushButton(QObject::trUtf8("Lösche Person"));
QSqlRelationalTableModel *model = new QSqlRelationalTableModel(this);
model->setTable("tx_submission_data");
model->setRelation(28,QSqlRelation("tx_submission_epterm","uid", "epterm"));
model->setRelation(29,QSqlRelation("tx_submission_status","uid", "status"));
model->setRelation(30,QSqlRelation("tx_submission_status","uid", "status"));
model->setRelation(31,QSqlRelation("tx_submission_status","uid", "status"));
model->setRelation(32,QSqlRelation("tx_submission_status","uid", "status"));
model->setRelation(33,QSqlRelation("tx_submission_status","uid", "status"));
model->setRelation(34,QSqlRelation("tx_submission_status","uid", "status"));
model->setEditStrategy(QSqlTableModel::OnManualSubmit);
model->removeColumns(1,7);
model->removeColumn(5);
model->removeColumn(6);
model->removeColumn(6);
model->removeColumn(6);
model->removeColumn(7);
model->removeColumn(7);
model->removeColumn(7);
model->removeColumn(7);
model->removeColumn(7);
model->removeColumn(7);
model->removeColumn(7);
model->removeColumn(8);
model->removeColumn(11);
model->select();
QTableView *viewTable = new QTableView;
viewTable->setModel(model);
viewTable->setItemDelegate(new QSqlRelationalDelegate(this));
viewTable->setSortingEnabled(TRUE);
viewTable->setAlternatingRowColors(TRUE);
//viewTable->hideColumn(0);
viewTable->setSelectionMode(QAbstractItemView::SingleSelection);
viewTable->setSelectionBehavior(QAbstractItemView::SelectRows);
viewTable->resizeColumnsToContents();
connect(submitPb, SIGNAL(clicked(bool)), model, SLOT(submitAll()) );
connect(revertPb, SIGNAL(clicked(bool)), model, SLOT(revertAll() ) );
connect(addPb, SIGNAL(clicked(bool)), this, SLOT(addPerson() ) );
connect(deletePb, SIGNAL(clicked(bool)), this, SLOT(deletePerson() ) );
QGridLayout *lay = new QGridLayout(this);
lay->addWidget(viewTable, 0, 0, 1, 4);
lay->addWidget(submitPb, 1, 0);
lay->addWidget(revertPb, 1, 1);
lay->addWidget(addPb, 1, 2);
lay->addWidget(deletePb, 1, 3);
// CSS
qApp->setStyleSheet("QTableView {background-color: #eeeeee; background-image: url(:/bg.png); color: blue;}");
}
void tableModel::addPerson()
{
int row = model->rowCount();
model->insertRow(row);
QModelIndex index = model->index(row, Person_Name);
viewTable->setCurrentIndex(index);
viewTable->edit(index);
QMessageBox::warning(this, trUtf8("Person hinzufügen"), trUtf8("Sie müssen alle Felder ausfüllen!") );
}
void tableModel::deletePerson()
{
}
tableModel::~tableModel()
{
}
To copy to clipboard, switch view to plain text mode
Bookmarks