summaryrefslogtreecommitdiffstats
path: root/src/widgets/itemviews
diff options
context:
space:
mode:
authorMark Brand <mabrand@mabrand.nl>2012-03-13 11:40:25 +0100
committerQt by Nokia <qt-info@nokia.com>2012-03-15 00:50:47 +0100
commit9e87104295b019a1afa49f856ddcef07249d1afb (patch)
treed15f145dfe562a9b2b78708cf8611a6eef50c30b /src/widgets/itemviews
parent273508205c4dbc6a3e1c6f1ea5e60a30c468219b (diff)
QTableView: call model->submit() on row change
QTreeView already does this in the exact same way. It's necessary to call submit() so edit strategy OnRowChange in QSqlTableModel will work as expected. Change-Id: Ib430143e8a71f3b0bcd842fcc772cc7ee4525f0a Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'src/widgets/itemviews')
-rw-r--r--src/widgets/itemviews/qtableview.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/widgets/itemviews/qtableview.cpp b/src/widgets/itemviews/qtableview.cpp
index 57f29641de..a5e03ca9e4 100644
--- a/src/widgets/itemviews/qtableview.cpp
+++ b/src/widgets/itemviews/qtableview.cpp
@@ -1071,6 +1071,10 @@ void QTableView::setModel(QAbstractItemModel *model)
disconnect(d->model, SIGNAL(columnsRemoved(QModelIndex,int,int)),
this, SLOT(_q_updateSpanRemovedColumns(QModelIndex,int,int)));
}
+ if (d->selectionModel) { // support row editing
+ disconnect(d->selectionModel, SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),
+ d->model, SLOT(submit()));
+ }
if (model) { //and connect to the new one
connect(model, SIGNAL(rowsInserted(QModelIndex,int,int)),
this, SLOT(_q_updateSpanInsertedRows(QModelIndex,int,int)));
@@ -1123,9 +1127,21 @@ void QTableView::setSelectionModel(QItemSelectionModel *selectionModel)
{
Q_D(QTableView);
Q_ASSERT(selectionModel);
+ if (d->selectionModel) {
+ // support row editing
+ disconnect(d->selectionModel, SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),
+ d->model, SLOT(submit()));
+ }
+
d->verticalHeader->setSelectionModel(selectionModel);
d->horizontalHeader->setSelectionModel(selectionModel);
QAbstractItemView::setSelectionModel(selectionModel);
+
+ if (d->selectionModel) {
+ // support row editing
+ connect(d->selectionModel, SIGNAL(currentRowChanged(QModelIndex,QModelIndex)),
+ d->model, SLOT(submit()));
+ }
}
/*!