SqliteTableModel: Return from setData() if value hasn't changed

Don't do any changes to the database if the value hasn't actually
changed. This avoids settings the dirty flag when there is no need to.
This commit is contained in:
Martin Kleusberg
2013-05-07 20:51:07 +02:00
parent ea31c8023b
commit 74bdfee384

View File

@@ -156,6 +156,10 @@ bool SqliteTableModel::setData(const QModelIndex& index, const QVariant& value,
{
if(index.isValid() && role == Qt::EditRole)
{
// Don't do anything if the data hasn't changed
if(m_data.at(index.row()).at(index.column()) == value)
return true;
if(m_db->updateRecord(m_sTable, m_headers.at(index.column()), m_data[index.row()].at(0).toInt(), value.toByteArray()))
{
// Only update the cache if this row has already been read, if not there's no need to do any changes to the cache