diff options
author | Shawn Rutledge <shawn.rutledge@qt.io> | 2019-02-12 10:18:11 +0100 |
---|---|---|
committer | Shawn Rutledge <shawn.rutledge@qt.io> | 2019-02-14 09:16:17 +0000 |
commit | 8a62975ecb554f4c3f131aeaf73858e529398cae (patch) | |
tree | 5ff9534ece26bba0146222d827f5a8784d9c9225 /src/qml/types | |
parent | cd5d2f596c3fe70f012dd0bcc58e7a8ac81448f2 (diff) |
QQmlTableView::data: use local column and row variables
...instead of calling index.column() and index.row() repeatedly
Change-Id: I13ea0d8942b750329d2e40e778b17548e148dd43
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/qml/types')
-rw-r--r-- | src/qml/types/qqmltablemodel.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/qml/types/qqmltablemodel.cpp b/src/qml/types/qqmltablemodel.cpp index 67b7639a38..cf3fc0298a 100644 --- a/src/qml/types/qqmltablemodel.cpp +++ b/src/qml/types/qqmltablemodel.cpp @@ -602,16 +602,16 @@ QVariant QQmlTableModel::data(const QModelIndex &index, int role) const if ((role < Qt::UserRole || role >= Qt::UserRole + mRoleNames.size()) && role != Qt::DisplayRole) return QVariant(); - const QVariantList rowData = mRows.at(index.row()).toList(); - const QVariantMap columnData = rowData.at(index.column()).toMap(); + const QVariantList rowData = mRows.at(row).toList(); + const QVariantMap columnData = rowData.at(column).toMap(); int effectiveRole = role; if (role == Qt::DisplayRole) { // If the execution got to this point, then the user is requesting data for the display role, // but didn't specify any role with the name "display". // So, we give them the data of the implicit display role. - Q_ASSERT(mDefaultDisplayRoles.contains(index.column())); - effectiveRole = mDefaultDisplayRoles.value(index.column()); + Q_ASSERT(mDefaultDisplayRoles.contains(column)); + effectiveRole = mDefaultDisplayRoles.value(column); } const QString propertyName = QString::fromUtf8(roleNames().value(effectiveRole)); @@ -634,18 +634,18 @@ bool QQmlTableModel::setData(const QModelIndex &index, const QVariant &value, in int effectiveRole = role; if (role == Qt::DisplayRole) { - Q_ASSERT(mDefaultDisplayRoles.contains(index.column())); - effectiveRole = mDefaultDisplayRoles.value(index.column()); + Q_ASSERT(mDefaultDisplayRoles.contains(column)); + effectiveRole = mDefaultDisplayRoles.value(column); } - const QVariantList rowData = mRows.at(index.row()).toList(); + const QVariantList rowData = mRows.at(row).toList(); const QString propertyName = QString::fromUtf8(roleNames().value(effectiveRole)); qCDebug(lcTableModel).nospace() << "setData() called with index " << index << ", value " << value << " and role " << propertyName; // Verify that the role exists for this column. - const ColumnPropertyInfo propertyInfo = findColumnPropertyInfo(index.column(), propertyName); + const ColumnPropertyInfo propertyInfo = findColumnPropertyInfo(column, propertyName); if (!propertyInfo.isValid()) { QString message; QDebug stream(&message); @@ -679,12 +679,12 @@ bool QQmlTableModel::setData(const QModelIndex &index, const QVariant &value, in } } - QVariantMap modifiedColumn = rowData.at(index.column()).toMap(); + QVariantMap modifiedColumn = rowData.at(column).toMap(); modifiedColumn[propertyName] = value; QVariantList modifiedRow = rowData; - modifiedRow[index.column()] = modifiedColumn; - mRows[index.row()] = modifiedRow; + modifiedRow[column] = modifiedColumn; + mRows[row] = modifiedRow; QVector<int> rolesChanged; rolesChanged.append(role); |