Some more optimisations in SqliteTableModel

This improves the performance of a couple of often called functions in
SqliteTableModel some more.
This commit is contained in:
Martin Kleusberg
2019-10-05 17:45:33 +02:00
parent 6f7fb74809
commit fad8a847ae
5 changed files with 47 additions and 55 deletions

View File

@@ -213,7 +213,7 @@ void AddRecordDialog::populateFields()
tbitem->setText(kName, QString::fromStdString(f.name()));
tbitem->setText(kType, QString::fromStdString(f.type()));
tbitem->setData(kType, Qt::UserRole, QString::fromStdString(f.affinity()));
tbitem->setData(kType, Qt::UserRole, f.affinity());
// NOT NULL fields are indicated in bold.
if (f.notnull()) {
@@ -303,7 +303,7 @@ void AddRecordDialog::updateSqlText()
fields << sqlb::escapeIdentifier(item->text(kName));
value.toDouble(&isNumeric);
// If it has a numeric format and has no text affinity, do not quote it.
if (isNumeric && item->data(kType, Qt::UserRole).toString() != "TEXT")
if (isNumeric && item->data(kType, Qt::UserRole).toInt() != sqlb::Field::TextAffinity)
vals << value.toString();
else
vals << QString("'%1'").arg(value.toString().replace("'", "''"));