void AbstractCounter::incrementCounter() { const int delta = static_cast<QAction *>(sender())->data().toInt(); Command_IncCounter cmd; cmd.set_counter_id(id); cmd.set_delta(delta); player->sendGameCommand(cmd); }
void AbstractCounter::mousePressEvent(QGraphicsSceneMouseEvent *event) { if (event->button() == Qt::LeftButton) { Command_IncCounter cmd; cmd.set_counter_id(id); cmd.set_delta(1); player->sendGameCommand(cmd); event->accept(); } else if (event->button() == Qt::RightButton) { Command_IncCounter cmd; cmd.set_counter_id(id); cmd.set_delta(-1); player->sendGameCommand(cmd); event->accept(); } else if (event->button() == Qt::MidButton) { if (menu) menu->exec(event->screenPos()); event->accept(); } else event->ignore(); }