mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
initial commit
This commit is contained in:
commit
a11f93df4d
99 changed files with 7493 additions and 0 deletions
36
cockatrice/src/zoneviewlayout.cpp
Normal file
36
cockatrice/src/zoneviewlayout.cpp
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#include "zoneviewlayout.h"
|
||||
#include "zoneviewwidget.h"
|
||||
#include "player.h"
|
||||
|
||||
ZoneViewLayout::ZoneViewLayout(CardDatabase *_db, QGraphicsItem *parent)
|
||||
: QGraphicsWidget(parent), db(_db)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ZoneViewLayout::reorganize()
|
||||
{
|
||||
qDebug(QString("ZoneViewLayout: activate: count=%1").arg(views.size()).toLatin1());
|
||||
resize(views.size() * 150, 1000);
|
||||
for (int i = 0; i < views.size(); i++) {
|
||||
views.at(i)->setPos(i * 150, 0);
|
||||
}
|
||||
emit sizeChanged();
|
||||
}
|
||||
|
||||
void ZoneViewLayout::addItem(Player *player, const QString &zoneName, int numberCards)
|
||||
{
|
||||
ZoneViewWidget *item = new ZoneViewWidget(db, player, player->getZones()->findZone(zoneName), numberCards, this);
|
||||
views.append(item);
|
||||
connect(item, SIGNAL(closePressed(ZoneViewWidget *)), this, SLOT(removeItem(ZoneViewWidget *)));
|
||||
reorganize();
|
||||
}
|
||||
|
||||
void ZoneViewLayout::removeItem(ZoneViewWidget *item)
|
||||
{
|
||||
qDebug("ZoneViewLayout::removeItem");
|
||||
views.removeAt(views.indexOf(item));
|
||||
scene()->removeItem(item);
|
||||
delete item;
|
||||
reorganize();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue