Simple editor for edititng smartlet tables. More...
#include <tableeditor.h>
Public Member Functions | |
TableEditor (const QString &tableName, QWidget *parent=0) | |
~TableEditor () |
Simple editor for edititng smartlet tables.
Use with caution and do not try to open it for large tables!
: QDialog(parent) { qDebug() << "TableEditor: Constructor initiated"; setWindowTitle(tr("Cached Table")); model = new QSqlTableModel(this, Database::staticCon()); model->setTable(tableName); model->setEditStrategy(QSqlTableModel::OnManualSubmit); model->select(); QTableView *view = new QTableView; view->setModel(model); view->resizeColumnsToContents(); view->resizeRowsToContents(); submitButton = new QPushButton(tr("Submit")); submitButton->setDefault(true); addNewRecordButton = new QPushButton(tr("&Add Record")); revertButton = new QPushButton(tr("&Revert")); quitButton = new QPushButton(tr("Quit")); buttonBox = new QDialogButtonBox(Qt::Vertical); buttonBox->addButton(submitButton, QDialogButtonBox::ActionRole); buttonBox->addButton(addNewRecordButton, QDialogButtonBox::ActionRole); buttonBox->addButton(revertButton, QDialogButtonBox::ActionRole); buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole); connect(addNewRecordButton, SIGNAL(clicked()),this, SLOT(addNewRecord())); connect(submitButton, SIGNAL(clicked()), this, SLOT(submit())); connect(revertButton, SIGNAL(clicked()), model, SLOT(revertAll())); connect(quitButton, SIGNAL(clicked()), this, SLOT(close())); QHBoxLayout *mainLayout = new QHBoxLayout; mainLayout->addWidget(view); mainLayout->addWidget(buttonBox); setLayout(mainLayout); }
TableEditor::~TableEditor | ( | ) |
{
qDebug() << "TableEditor: Destructor initiated";
}