set selected data type on imported by Edit database cell

Data type isn't decided by column type, but cell's type.
And, 2 bugs is fixed.
1. prevention in-place editing data
2. the lack of tr() on text literal
This commit is contained in:
gimKondo
2015-04-28 00:16:12 +09:00
committed by gim_kondo
parent a7b5c3f182
commit 54cea17f3a
6 changed files with 19 additions and 7 deletions

View File

@@ -295,6 +295,13 @@ sqlb::ForeignKeyClause SqliteTableModel::getForeignKeyClause(int column) const
}
bool SqliteTableModel::setData(const QModelIndex& index, const QVariant& value, int role)
{
// This function is for in-place editing.
// So, BLOB flag is false every times.
return setTypedData(index, false, value, role);
}
bool SqliteTableModel::setTypedData(const QModelIndex& index, bool isBlob, const QVariant& value, int role)
{
if(index.isValid() && role == Qt::EditRole)
{
@@ -306,7 +313,7 @@ bool SqliteTableModel::setData(const QModelIndex& index, const QVariant& value,
if(oldValue == newValue && oldValue.isNull() == newValue.isNull())
return true;
if(m_db->updateRecord(m_sTable, m_headers.at(index.column()), m_data[index.row()].at(0), newValue, isBinary(index)))
if(m_db->updateRecord(m_sTable, m_headers.at(index.column()), m_data[index.row()].at(0), newValue, isBlob))
{
// Only update the cache if this row has already been read, if not there's no need to do any changes to the cache
if(index.row() < m_data.size())