Keep field information in sqlb::Table object rather than DBBrowserObject · timrichards/sqlitebrowser@7d4248e · GitHub
Skip to content

Commit 7d4248e

Browse files
committed
Keep field information in sqlb::Table object rather than DBBrowserObject
Keep all the table and field information in a sqlb::Table object (which itself is stored in DBBrowserObject) rather than storing field information in DBBrowserObject and sqlb::Table objects at the same time.
1 parent d076134 commit 7d4248e

5 files changed

Lines changed: 20 additions & 22 deletions

File tree

‎src/DbStructureModel.cpp‎

Lines changed: 3 additions & 3 deletions

‎src/ImportCsvDialog.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ void ImportCsvDialog::accept()
9191
{
9292
if(i.value().gettype() == "table" && i.value().getname() == ui->editName->text())
9393
{
94-
if(i.value().fldmap.size() != numfields)
94+
if(i.value().table.fields().size() != numfields)
9595
{
9696
QMessageBox::warning(this, QApplication::applicationName(),
9797
tr("There is already a table of that name and an import into an existing table is only possible if the number of columns match."));

‎src/MainWindow.cpp‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,13 +268,13 @@ void MainWindow::populateStructure()
268268
if((*it).gettype() == "table" || (*it).gettype() == "view")
269269
{
270270
QStandardItemModel* tablefieldmodel = new QStandardItemModel();
271-
tablefieldmodel->setRowCount((*it).fldmap.count());
271+
tablefieldmodel->setRowCount((*it).table.fields().count());
272272
tablefieldmodel->setColumnCount(1);
273273

274274
int fldrow = 0;
275-
for(int i=0; i < (*it).fldmap.size(); ++i, ++fldrow)
275+
for(int i=0; i < (*it).table.fields().size(); ++i, ++fldrow)
276276
{
277-
QString fieldname = (*it).fldmap.at(i)->name();
277+
QString fieldname = (*it).table.fields().at(i)->name();
278278
QStandardItem* fldItem = new QStandardItem(fieldname);
279279
fldItem->setIcon(QIcon(":/icons/field"));
280280
tablefieldmodel->setItem(fldrow, 0, fldItem);

‎src/sqlitedb.cpp‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -750,8 +750,8 @@ QStringList DBBrowserDB::getTableFields(const QString & tablename) const
750750
{
751751
if((*it).getname() == tablename)
752752
{
753-
for(int i=0;i<(*it).fldmap.size();i++)
754-
res.append((*it).fldmap.at(i)->name());
753+
for(int i=0;i<(*it).table.fields().size();i++)
754+
res.append((*it).table.fields().at(i)->name());
755755
}
756756
}
757757
return res;
@@ -834,8 +834,7 @@ void DBBrowserDB::updateSchema( )
834834
// pragma SQLite offers.
835835
if((*it).gettype() == "table")
836836
{
837-
sqlb::Table t((*it).getname());
838-
(*it).fldmap = t.parseSQL((*it).getsql()).first.fields();
837+
(*it).table = sqlb::Table::parseSQL((*it).getsql()).first;
839838
} else if((*it).gettype() == "view") {
840839
statement = QString("PRAGMA TABLE_INFO(`%1`);").arg((*it).getname());
841840
logSQL(statement, kLogMsg_App);
@@ -849,7 +848,7 @@ void DBBrowserDB::updateSchema( )
849848
QString val_type = QString::fromUtf8((const char *)sqlite3_column_text(vm, 2));
850849

851850
sqlb::FieldPtr f(new sqlb::Field(val_name, val_type));
852-
(*it).addField(f);
851+
(*it).table.addField(f);
853852
}
854853
}
855854
sqlite3_finalize(vm);

‎src/sqlitedb.h‎

Lines changed: 9 additions & 10 deletions

0 commit comments

Comments
 (0)