diff options
author | Christian Ehrlicher <[email protected]> | 2018-02-02 21:08:44 +0100 |
---|---|---|
committer | Christian Ehrlicher <[email protected]> | 2018-02-05 17:06:43 +0000 |
commit | 076087717e4b6ee0953902b24676e54a73ff5fff (patch) | |
tree | a5a8d60941e561a48dad473e5eb3a61c776fadbd /src/widgets/doc/snippets/common-table-model/model.cpp | |
parent | a0717c60b30be5f7aa4c9dcde06a42f9ee532f0f (diff) |
Documentation: Update CommonTableModel/StringListModel snippets
Update CommonTableModel/StringListModel snippets:
- 0 -> nullptr
- use 'override'
- replace "" with QString()
- use QStringLiteral instead QString
- pass role to dataChanged() signal
Change-Id: I5949d1bd6fee3186f12191f1f6235ae18908096e
Reviewed-by: Topi Reiniƶ <[email protected]>
Diffstat (limited to 'src/widgets/doc/snippets/common-table-model/model.cpp')
-rw-r--r-- | src/widgets/doc/snippets/common-table-model/model.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/widgets/doc/snippets/common-table-model/model.cpp b/src/widgets/doc/snippets/common-table-model/model.cpp index 96df100f260..2f6e9f11445 100644 --- a/src/widgets/doc/snippets/common-table-model/model.cpp +++ b/src/widgets/doc/snippets/common-table-model/model.cpp @@ -68,7 +68,7 @@ TableModel::TableModel(int rows, int columns, QObject *parent) QStringList newList; for (int column = 0; column < qMax(1, columns); ++column) { - newList.append(""); + newList.append(QString()); } for (int row = 0; row < qMax(1, rows); ++row) { @@ -129,9 +129,9 @@ QVariant TableModel::headerData(int section, Qt::Orientation orientation, return QVariant(); if (orientation == Qt::Horizontal) - return QString("Column %1").arg(section); + return QStringLiteral("Column %1").arg(section); else - return QString("Row %1").arg(section); + return QStringLiteral("Row %1").arg(section); } /*! @@ -164,7 +164,7 @@ bool TableModel::setData(const QModelIndex &index, return false; rowList[index.row()][index.column()] = value.toString(); - emit dataChanged(index, index); + emit dataChanged(index, index, {role}); return true; } @@ -180,7 +180,7 @@ bool TableModel::insertRows(int position, int rows, const QModelIndex &parent) for (int row = 0; row < rows; ++row) { QStringList items; for (int column = 0; column < columns; ++column) - items.append(""); + items.append(QString()); rowList.insert(position, items); } @@ -202,7 +202,7 @@ bool TableModel::insertColumns(int position, int columns, for (int row = 0; row < rows; ++row) { for (int column = position; column < columns; ++column) { - rowList[row].insert(position, ""); + rowList[row].insert(position, QString()); } } |