Warning, file /games/kmahjongg/src/gameremovedtiles.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 SPDX-FileCopyrightText: 2019 Christian Krippendorf <Coding@Christian-Krippendorf.de> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef GAMEREMOVEDTILES_H 0008 #define GAMEREMOVEDTILES_H 0009 0010 // Qt 0011 #include <QGraphicsObject> 0012 #include <QList> 0013 0014 // KMahjongg 0015 #include "kmtypes.h" 0016 0017 // Forward declarations 0018 class KMahjonggTileset; 0019 class GameData; 0020 0021 0022 /** 0023 * A QGraphicsObject for representing the removed tiles of the current game. 0024 * @author Christian Krippendorf 0025 */ 0026 class GameRemovedTiles : public QGraphicsObject 0027 { 0028 Q_OBJECT 0029 0030 public: 0031 /** 0032 * Constructor 0033 * @param item The parent item 0034 */ 0035 explicit GameRemovedTiles(QGraphicsObject *item = nullptr); 0036 ~GameRemovedTiles() override; 0037 0038 /** 0039 * Overrides the paint method of QGraphicsItem 0040 */ 0041 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, 0042 QWidget *widget) override; 0043 0044 /** 0045 * Set size of element 0046 * @param width Width of element in pixels 0047 * @param height Height of element in pixels 0048 */ 0049 void setSize(qreal width, qreal height); 0050 0051 /** 0052 * Overrides the boundingRect method of QGraphicsItem 0053 */ 0054 QRectF boundingRect() const override; 0055 0056 /** 0057 * Returns the rect of the item 0058 * @return The rect of the item 0059 */ 0060 QRectF rect() const; 0061 0062 /** 0063 * Called in GameView::resizeTileset() before reloading the tiles 0064 */ 0065 void prepareForGeometryChange(); 0066 0067 /** 0068 * Add an removed tile. 0069 * @param itemPos POSITION object of the item. 0070 */ 0071 void addItem(const POSITION & itemPos); 0072 0073 /** 0074 * Set the game data object. 0075 * @param gameData the game data object. 0076 */ 0077 void setGameData(GameData * gameData); 0078 0079 /** 0080 * Remove a tile. 0081 */ 0082 void removeLastItem(); 0083 0084 /** 0085 * Set the tileset for the tile pixmaps. 0086 * @param tiles KMahjonggTileset object. 0087 */ 0088 void setTileset(KMahjonggTileset * tiles); 0089 0090 /** 0091 * Calculate all values that necessary to paint all tiles. 0092 */ 0093 void updateTileCalculations(); 0094 0095 /** 0096 * Reset system for empty game. 0097 */ 0098 void reset(); 0099 0100 /** 0101 * Remove the last two added tiles. 0102 */ 0103 void undo(); 0104 0105 private: 0106 qreal m_width; 0107 qreal m_height; 0108 qreal m_borderWidthFrac; 0109 qreal m_tileScale; 0110 qreal m_titleHeightFrac; 0111 qreal m_borderWidthPixel; 0112 qreal m_titleHeightPixel; 0113 qreal m_tileSpaceRow; 0114 qreal m_tileSpaceCol; 0115 qreal m_tileFaceWidth; 0116 qreal m_tileFaceHeight; 0117 qreal m_faceScale; 0118 qreal m_tileFaceWidthScaled; 0119 qreal m_tileFaceHeightScaled; 0120 unsigned int m_maxTilesRow; 0121 unsigned int m_maxTilesCol; 0122 0123 QList<USHORT> * m_itemFaces; 0124 KMahjonggTileset * m_tiles; 0125 GameData * m_gameData; 0126 }; 0127 0128 #endif // GAMEREMOVEDTILES_H