Changeset 846 for trunk/src/sql/models


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:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/sql/models/qsqlquerymodel.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)
     
    280280        if (val.isValid())
    281281            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)
    283287            return d->rec.fieldName(section);
    284288    }
     
    306310    lastError() can be used to retrieve verbose information if there
    307311    was an error setting the query.
     312
     313    \note Calling setQuery() will remove any inserted columns.
    308314
    309315    \sa query(), QSqlQuery::isActive(), QSqlQuery::setForwardOnly(), lastError()
     
    371377
    372378    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.
    374381
    375382    lastError() can be used to retrieve verbose information if there
  • trunk/src/sql/models/qsqlquerymodel.h

    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)
  • trunk/src/sql/models/qsqlquerymodel_p.h

    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)
  • trunk/src/sql/models/qsqlrelationaldelegate.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)
  • trunk/src/sql/models/qsqlrelationaldelegate.h

    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)
     
    6060public:
    6161
    62 explicit QSqlRelationalDelegate(QObject *parent = 0)
    63     : QItemDelegate(parent)
     62explicit QSqlRelationalDelegate(QObject *aParent = 0)
     63    : QItemDelegate(aParent)
    6464{}
    6565
     
    6767{}
    6868
    69 QWidget *createEditor(QWidget *parent,
     69QWidget *createEditor(QWidget *aParent,
    7070                      const QStyleOptionViewItem &option,
    7171                      const QModelIndex &index) const
     
    7474    QSqlTableModel *childModel = sqlModel ? sqlModel->relationModel(index.column()) : 0;
    7575    if (!childModel)
    76         return QItemDelegate::createEditor(parent, option, index);
     76        return QItemDelegate::createEditor(aParent, option, index);
    7777
    78     QComboBox *combo = new QComboBox(parent);
     78    QComboBox *combo = new QComboBox(aParent);
    7979    combo->setModel(childModel);
    8080    combo->setModelColumn(childModel->fieldIndex(sqlModel->relation(index.column()).displayColumn()));
  • trunk/src/sql/models/qsqlrelationaltablemodel.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)
  • trunk/src/sql/models/qsqlrelationaltablemodel.h

    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)
  • 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    }
  • trunk/src/sql/models/qsqltablemodel.h

    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)
  • trunk/src/sql/models/qsqltablemodel_p.h

    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)
Note: See TracChangeset for help on using the changeset viewer.