Changeset 846 for trunk/src/sql/models/qsqltablemodel.cpp
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/src/sql/models/qsqltablemodel.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 266 266 programmatically, without binding it to a view: 267 267 268 \snippet doc/src/snippets/sqldatabase/sqldatabase.cpp 2 5268 \snippet doc/src/snippets/sqldatabase/sqldatabase.cpp 21 269 269 270 270 The code snippet above extracts the \c salary field from record 4 in … … 394 394 returns false. 395 395 396 \note Calling select() will revert any unsubmitted changes and remove any inserted columns. 397 396 398 \sa setTable(), setFilter(), selectStatement() 397 399 */ … … 424 426 return QVariant(); 425 427 428 // Problem.. we need to use QSQM::indexInQuery to handle inserted columns 429 // but inserted rows we need to handle 430 // and indexInQuery is not virtual (grrr) so any values we pass to QSQM need 431 // to handle the insertedRows 426 432 QModelIndex item = indexInQuery(index); 427 433 … … 451 457 break; } 452 458 } 453 return QSqlQueryModel::data(item, role); 459 460 // We need to handle row mapping here, but not column mapping 461 return QSqlQueryModel::data(index.sibling(item.row(), index.column()), role); 454 462 } 455 463 … … 1096 1104 if (idx >= rowCount()) 1097 1105 return false; 1098 if (d->cache.value(idx).op == QSqlTableModelPrivate::Insert) 1106 if (d->cache.value(idx).op == QSqlTableModelPrivate::Insert) { 1099 1107 revertRow(idx); 1100 else { 1108 // Reverting a row means all the other cache entries have been adjusted downwards 1109 // so fake this by adjusting row 1110 --row; 1111 } else { 1101 1112 d->cache[idx].op = QSqlTableModelPrivate::Delete; 1102 1113 d->cache[idx].primaryValues = d->primaryValues(indexInQuery(createIndex(idx, 0)).row()); … … 1226 1237 { 1227 1238 Q_D(const QSqlTableModel); 1228 const QModelIndex it = QSqlQueryModel::indexInQuery(item); 1239 const QModelIndex it = QSqlQueryModel::indexInQuery(item); // this adjusts columns only 1229 1240 if (d->strategy == OnManualSubmit) { 1230 1241 int rowOffset = 0; … … 1333 1344 mrow.rec.setValue(idx, record.value(i)); 1334 1345 } 1346 1347 if (isOk) 1348 emit dataChanged(createIndex(row, 0), createIndex(row, columnCount() - 1)); 1335 1349 return isOk; } 1336 1350 }
Note:
See TracChangeset
for help on using the changeset viewer.