| 1 |
// Copyright (C) 2016 The Qt Company Ltd. |
| 2 |
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause |
| 3 |
|
| 4 |
#ifndef PIECESLIST_H |
| 5 |
#define PIECESLIST_H |
| 6 |
|
| 7 |
#include <QAbstractListModel> |
| 8 |
#include <QPixmap> |
| 9 |
#include <QPoint> |
| 10 |
#include <QStringList> |
| 11 |
#include <QList> |
| 12 |
|
| 13 |
QT_BEGIN_NAMESPACE |
| 14 |
class QMimeData; |
| 15 |
QT_END_NAMESPACE |
| 16 |
|
| 17 |
class PiecesModel : public QAbstractListModel |
| 18 |
{ |
| 19 |
Q_OBJECT |
| 20 |
|
| 21 |
public: |
| 22 |
explicit PiecesModel(int pieceSize, QObject *parent = nullptr); |
| 23 |
|
| 24 |
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; |
| 25 |
Qt::ItemFlags flags(const QModelIndex &index) const override; |
| 26 |
bool removeRows(int row, int count, const QModelIndex &parent) override; |
| 27 |
|
| 28 |
bool dropMimeData(const QMimeData *data, Qt::DropAction action, |
| 29 |
int row, int column, const QModelIndex &parent) override; |
| 30 |
QMimeData *mimeData(const QModelIndexList &indexes) const override; |
| 31 |
QStringList mimeTypes() const override; |
| 32 |
int rowCount(const QModelIndex &parent) const override; |
| 33 |
Qt::DropActions supportedDropActions() const override; |
| 34 |
|
| 35 |
void addPiece(const QPixmap &pixmap, const QPoint &location); |
| 36 |
void addPieces(const QPixmap &pixmap); |
| 37 |
|
| 38 |
private: |
| 39 |
QList<QPoint> locations; |
| 40 |
QList<QPixmap> pixmaps; |
| 41 |
|
| 42 |
int m_PieceSize; |
| 43 |
}; |
| 44 |
|
| 45 |
#endif // PIECESLIST_H |