12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- #include "DieItem.h"
- DieItem::DieItem(int row, int col, PICK_DIE_STATUS status, qreal size, QGraphicsItem* parent)
- : QGraphicsRectItem(parent), row(row), col(col), status(status) {
- setRect(0, 0, size, size);
- setBrush(getColorByStatus(status));
-
- setPen(QPen(QColor(0, 0, 0), 0.5));
- }
- void DieItem::setSelected(bool selected) {
- if (selected) {
- setPen(QPen(Qt::green, 1));
- } else {
- setPen(QPen(Qt::black, 0.5));
- }
- qDebug() << "DieItem clicked: Row:" << row << "Col:" << col;
- }
- QColor DieItem::getColorByStatus(PICK_DIE_STATUS status) {
- switch (status) {
- case DIE_EXIST: return QColor(0, 102, 255);
- case NO_EXIST: return QColor(200, 200, 200);
- case PICK_ING: return QColor(255, 255, 0);
- case SKIP_DIE: return QColor(128, 128, 128);
- case EDGE_DIE: return QColor(255, 165, 0);
- default: return QColor(0, 0, 0);
- }
- }
- int DieItem::getRow() const {
- return row;
- }
- int DieItem::getCol() const {
- return col;
- }
|