Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/sql/models/qsqltablemodel.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    266266    programmatically, without binding it to a view:
    267267
    268     \snippet doc/src/snippets/sqldatabase/sqldatabase.cpp 25
     268    \snippet doc/src/snippets/sqldatabase/sqldatabase.cpp 21
    269269
    270270    The code snippet above extracts the \c salary field from record 4 in
     
    394394    returns false.
    395395
     396    \note Calling select() will revert any unsubmitted changes and remove any inserted columns.
     397
    396398    \sa setTable(), setFilter(), selectStatement()
    397399*/
     
    424426        return QVariant();
    425427
     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
    426432    QModelIndex item = indexInQuery(index);
    427433
     
    451457        break; }
    452458    }
    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);
    454462}
    455463
     
    10961104            if (idx >= rowCount())
    10971105                return false;
    1098             if (d->cache.value(idx).op == QSqlTableModelPrivate::Insert)
     1106            if (d->cache.value(idx).op == QSqlTableModelPrivate::Insert) {
    10991107                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 {
    11011112                d->cache[idx].op = QSqlTableModelPrivate::Delete;
    11021113                d->cache[idx].primaryValues = d->primaryValues(indexInQuery(createIndex(idx, 0)).row());
     
    12261237{
    12271238    Q_D(const QSqlTableModel);
    1228     const QModelIndex it = QSqlQueryModel::indexInQuery(item);
     1239    const QModelIndex it = QSqlQueryModel::indexInQuery(item); // this adjusts columns only
    12291240    if (d->strategy == OnManualSubmit) {
    12301241        int rowOffset = 0;
     
    13331344                mrow.rec.setValue(idx, record.value(i));
    13341345        }
     1346
     1347        if (isOk)
     1348            emit dataChanged(createIndex(row, 0), createIndex(row, columnCount() - 1));
    13351349        return isOk; }
    13361350    }
Note: See TracChangeset for help on using the changeset viewer.