File indexing completed on 2024-05-12 04:06:24
0001 /* 0002 SPDX-FileCopyrightText: 2010 Stefan Majewsky <majewsky@gmx.net> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef PALAPELI_MERGEGROUP_H 0008 #define PALAPELI_MERGEGROUP_H 0009 #include "piece.h" 0010 class QGraphicsScene; 0011 #include <QObject> 0012 #include <QPointF> 0013 #include <QSizeF> 0014 0015 namespace Palapeli 0016 { 0017 ///This transaction class handles merging of physically neighboring pieces. 0018 class MergeGroup : public QObject 0019 { 0020 Q_OBJECT 0021 public: 0022 static QList<Palapeli::Piece*> tryGrowMergeGroup(Palapeli::Piece* piece); 0023 0024 ///If \a animated is set, the transaction will wait for the animation to finish and then fire the pieceInstanceTransaction() signal. After this emission, the MergeGroup will delete itself. 0025 ///If \a animated is not set, you have to obtain the generated piece manually from the mergedPiece() method. 0026 MergeGroup(const QList<Palapeli::Piece*>& pieces, QGraphicsScene* scene, const QSizeF& pieceAreaSize, bool animated = true); 0027 0028 void start(); 0029 0030 ///Will return 0 if the animation is still in progress. 0031 Palapeli::Piece* mergedPiece() const; 0032 Q_SIGNALS: 0033 void pieceInstanceTransaction(const QList<Palapeli::Piece*>& deletedPieces, const QList<Palapeli::Piece*>& createdPieces); 0034 private Q_SLOTS: 0035 void createMergedPiece(); 0036 private: 0037 bool m_animated; 0038 QList<Palapeli::Piece*> m_pieces; 0039 Palapeli::Piece* m_mergedPiece; 0040 QGraphicsScene* m_scene; 0041 //parameters of united coordinate system (UCS) 0042 QPointF m_ucsPosition; 0043 QSizeF m_pieceAreaSize; 0044 }; 0045 } 0046 0047 #endif // PALAPELI_MERGEGROUP_H