From b36800ea02213f13c3e8b325935d84533d9fa11e Mon Sep 17 00:00:00 2001 From: Peinthor Rene Date: Thu, 28 Mar 2013 19:00:45 +0100 Subject: [PATCH] disable editing of table data if not a new table we currently don't support it --- src/EditTableDialog.cpp | 13 +++++++++---- src/EditTableDialog.h | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/EditTableDialog.cpp b/src/EditTableDialog.cpp index 8302929d..73b1cb48 100644 --- a/src/EditTableDialog.cpp +++ b/src/EditTableDialog.cpp @@ -14,7 +14,8 @@ EditTableDialog::EditTableDialog(DBBrowserDB* db, const QString& tableName, QWid ui(new Ui::EditTableDialog), pdb(db), curTable(tableName), - m_table(tableName) + m_table(tableName), + m_bNewTable(true) { // Create UI ui->setupUi(this); @@ -25,6 +26,8 @@ EditTableDialog::EditTableDialog(DBBrowserDB* db, const QString& tableName, QWid // Editing an existing table? if(curTable != "") { + m_bNewTable = false; // we are editing an existing table + // Existing table, so load and set the current layout QString sTablesql = pdb->getTableSQL(curTable); //qDebug() << sTablesql; @@ -68,7 +71,9 @@ void EditTableDialog::populateFields() foreach(sqlb::FieldPtr f, fields) { QTreeWidgetItem *tbitem = new QTreeWidgetItem(ui->treeWidget); - tbitem->setFlags(tbitem->flags() | Qt::ItemIsEditable); + //currently we don't support editing of field data + if(m_bNewTable) + tbitem->setFlags(tbitem->flags() | Qt::ItemIsEditable); tbitem->setText(kName, f->name()); QComboBox* typeBox = new QComboBox(ui->treeWidget); QObject::connect(typeBox, SIGNAL(activated(int)), this, SLOT(updateTypes())); @@ -100,7 +105,7 @@ void EditTableDialog::accept() { // Are we editing an already existing table or designing a new one? In the first case there is a table name set, // in the latter the current table name is empty - if(curTable == "") + if(m_bNewTable) { // Creation of new table // we commit immediatly so no need to setdirty @@ -326,7 +331,7 @@ void EditTableDialog::removeField() return; // Are we creating a new table or editing an old one? - if(curTable == "") + if(!m_bNewTable) { // Creating a new one diff --git a/src/EditTableDialog.h b/src/EditTableDialog.h index 049bccb3..472b1187 100644 --- a/src/EditTableDialog.h +++ b/src/EditTableDialog.h @@ -54,6 +54,7 @@ private: QStringList types; QStringList fields; SQLiteSyntaxHighlighter* m_sqliteSyntaxHighlighter; + bool m_bNewTable; }; #endif