diff options
author | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2018-11-24 17:29:15 +0100 |
---|---|---|
committer | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2018-12-17 19:50:38 +0000 |
commit | af84f12298e7ba51d4121f9dd7a1b6e3ba050266 (patch) | |
tree | e50ee76c43ae66b638cfc367cf74cbeda7de0a28 /examples/widgets/itemviews/puzzle/piecesmodel.cpp | |
parent | b8720e3e7a93121cd2e6dc081d872e8000ce81c9 (diff) |
Cleanup Itemviews examples
Cleanup the Itemviews examples
- use nullptr instead 0
- use for loop instead foreach
- include own header first
- remove uselss includes
Change-Id: I32e9f64356e42038707d063dcad977239ce1fe9e
Reviewed-by: Luca Beldi <v.ronin@yahoo.it>
Reviewed-by: Sze Howe Koh <szehowe.koh@gmail.com>
Diffstat (limited to 'examples/widgets/itemviews/puzzle/piecesmodel.cpp')
-rw-r--r-- | examples/widgets/itemviews/puzzle/piecesmodel.cpp | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/examples/widgets/itemviews/puzzle/piecesmodel.cpp b/examples/widgets/itemviews/puzzle/piecesmodel.cpp index 28b46836f4..a9c53ed2cd 100644 --- a/examples/widgets/itemviews/puzzle/piecesmodel.cpp +++ b/examples/widgets/itemviews/puzzle/piecesmodel.cpp @@ -134,7 +134,7 @@ QMimeData *PiecesModel::mimeData(const QModelIndexList &indexes) const QDataStream stream(&encodedData, QIODevice::WriteOnly); - foreach (QModelIndex index, indexes) { + for (const QModelIndex &index : indexes) { if (index.isValid()) { QPixmap pixmap = qvariant_cast<QPixmap>(data(index, Qt::UserRole)); QPoint location = data(index, Qt::UserRole+1).toPoint(); @@ -190,10 +190,7 @@ bool PiecesModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int PiecesModel::rowCount(const QModelIndex &parent) const { - if (parent.isValid()) - return 0; - else - return pixmaps.size(); + return parent.isValid() ? 0 : pixmaps.size(); } Qt::DropActions PiecesModel::supportedDropActions() const @@ -201,7 +198,7 @@ Qt::DropActions PiecesModel::supportedDropActions() const return Qt::CopyAction | Qt::MoveAction; } -void PiecesModel::addPieces(const QPixmap& pixmap) +void PiecesModel::addPieces(const QPixmap &pixmap) { if (!pixmaps.isEmpty()) { beginRemoveRows(QModelIndex(), 0, pixmaps.size() - 1); |