Show error message when changing table data fails

Give the user an error message when setting new data for a cell fails.
This is especially useful when the problem is caused by foreign key
constraints.
This commit is contained in:
Martin Kleusberg
2013-05-07 20:25:35 +02:00
parent 432180ec03
commit d6ed7e932f

View File

@@ -1,6 +1,8 @@
#include "sqlitetablemodel.h"
#include "sqlitedb.h"
#include <QDebug>
#include <QMessageBox>
#include <QApplication>
SqliteTableModel::SqliteTableModel(QObject* parent, DBBrowserDB* db, size_t chunkSize)
: QAbstractTableModel(parent)
@@ -160,6 +162,7 @@ bool SqliteTableModel::setData(const QModelIndex& index, const QVariant& value,
emit(dataChanged(index, index));
return true;
} else {
QMessageBox::warning(0, qApp->applicationName(), tr("Error changing data:\n%1").arg(m_db->lastErrorMessage));
return false;
}
}