Changeset 846 for trunk/src/sql/models
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 11 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/qsqlquerymodel.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) … … 280 280 if (val.isValid()) 281 281 return val; 282 if (role == Qt::DisplayRole && d->rec.count() > section) 282 283 // See if it's an inserted column (iiq.column() != -1) 284 QModelIndex dItem = indexInQuery(createIndex(0, section)); 285 286 if (role == Qt::DisplayRole && d->rec.count() > section && dItem.column() != -1) 283 287 return d->rec.fieldName(section); 284 288 } … … 306 310 lastError() can be used to retrieve verbose information if there 307 311 was an error setting the query. 312 313 \note Calling setQuery() will remove any inserted columns. 308 314 309 315 \sa query(), QSqlQuery::isActive(), QSqlQuery::setForwardOnly(), lastError() … … 371 377 372 378 Executes the query \a query for the given database connection \a 373 db. If no database is specified, the default connection is used. 379 db. If no database (or an invalid database) is specified, the 380 default connection is used. 374 381 375 382 lastError() can be used to retrieve verbose information if there -
trunk/src/sql/models/qsqlquerymodel.h
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) -
trunk/src/sql/models/qsqlquerymodel_p.h
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) -
trunk/src/sql/models/qsqlrelationaldelegate.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) -
trunk/src/sql/models/qsqlrelationaldelegate.h
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) … … 60 60 public: 61 61 62 explicit QSqlRelationalDelegate(QObject * parent = 0)63 : QItemDelegate( parent)62 explicit QSqlRelationalDelegate(QObject *aParent = 0) 63 : QItemDelegate(aParent) 64 64 {} 65 65 … … 67 67 {} 68 68 69 QWidget *createEditor(QWidget * parent,69 QWidget *createEditor(QWidget *aParent, 70 70 const QStyleOptionViewItem &option, 71 71 const QModelIndex &index) const … … 74 74 QSqlTableModel *childModel = sqlModel ? sqlModel->relationModel(index.column()) : 0; 75 75 if (!childModel) 76 return QItemDelegate::createEditor( parent, option, index);76 return QItemDelegate::createEditor(aParent, option, index); 77 77 78 QComboBox *combo = new QComboBox( parent);78 QComboBox *combo = new QComboBox(aParent); 79 79 combo->setModel(childModel); 80 80 combo->setModelColumn(childModel->fieldIndex(sqlModel->relation(index.column()).displayColumn())); -
trunk/src/sql/models/qsqlrelationaltablemodel.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) -
trunk/src/sql/models/qsqlrelationaltablemodel.h
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) -
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 } -
trunk/src/sql/models/qsqltablemodel.h
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) -
trunk/src/sql/models/qsqltablemodel_p.h
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)
Note:
See TracChangeset
for help on using the changeset viewer.