ZoneViewWidget::ZoneViewWidget(Player *_player, CardZone *_origZone, int numberCards, bool _revealZone, const QList<ServerInfo_Card *> &cardList)
	: QGraphicsWidget(0, Qt::Tool | Qt::CustomizeWindowHint | Qt::WindowSystemMenuHint | Qt::WindowTitleHint/* | Qt::WindowCloseButtonHint*/), player(_player)
{
	setAttribute(Qt::WA_DeleteOnClose);
	setZValue(2000000006);
	
	QFont font;
	font.setPixelSize(10);
	setFont(font);

	QGraphicsLinearLayout *vbox = new QGraphicsLinearLayout(Qt::Vertical);
	
	if (numberCards < 0) {
		sortByNameCheckBox = new QCheckBox;
		QGraphicsProxyWidget *sortByNameProxy = new QGraphicsProxyWidget;
		sortByNameProxy->setWidget(sortByNameCheckBox);
		vbox->addItem(sortByNameProxy);

		sortByTypeCheckBox = new QCheckBox;
		QGraphicsProxyWidget *sortByTypeProxy = new QGraphicsProxyWidget;
		sortByTypeProxy->setWidget(sortByTypeCheckBox);
		vbox->addItem(sortByTypeProxy);
	} else {
		sortByNameCheckBox = 0;
		sortByTypeCheckBox = 0;
	}
	
	if (_origZone->getIsShufflable() && (numberCards == -1)) {
		shuffleCheckBox = new QCheckBox;
		shuffleCheckBox->setChecked(true);
		QGraphicsProxyWidget *shuffleProxy = new QGraphicsProxyWidget;
		shuffleProxy->setWidget(shuffleCheckBox);
		vbox->addItem(shuffleProxy);
	} else
		shuffleCheckBox = 0;
	
	extraHeight = vbox->sizeHint(Qt::PreferredSize).height();
	resize(150, 150);

	zone = new ZoneViewZone(player, _origZone, numberCards, _revealZone, this);
	connect(zone, SIGNAL(optimumRectChanged()), this, SLOT(resizeToZoneContents()));
	connect(zone, SIGNAL(beingDeleted()), this, SLOT(zoneDeleted()));
	vbox->addItem(zone);
	zone->initializeCards(cardList);
	
	if (sortByNameCheckBox) {
		connect(sortByNameCheckBox, SIGNAL(stateChanged(int)), zone, SLOT(setSortByName(int)));
		connect(sortByTypeCheckBox, SIGNAL(stateChanged(int)), zone, SLOT(setSortByType(int)));
		sortByNameCheckBox->setChecked(settingsCache->getZoneViewSortByName());
		sortByTypeCheckBox->setChecked(settingsCache->getZoneViewSortByType());
	}

	setLayout(vbox);
	retranslateUi();
}
ZoneViewWidget::ZoneViewWidget(Player *_player, CardZone *_origZone, int numberCards, bool _revealZone, bool _writeableRevealZone, const QList<const ServerInfo_Card *> &cardList)
    : QGraphicsWidget(0, Qt::Tool | Qt::FramelessWindowHint), player(_player)
{
    setAcceptHoverEvents(true);
    setAttribute(Qt::WA_DeleteOnClose);
    setZValue(2000000006);
    setFlag(ItemIgnoresTransformations);

    QGraphicsLinearLayout *hbox = new QGraphicsLinearLayout(Qt::Horizontal);
    titleLabel = new TitleLabel;
    connect(titleLabel, SIGNAL(mouseMoved(QPointF)), this, SLOT(moveWidget(QPointF)));
    closeButton = new QPushButton("X");
    connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
    closeButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
    QGraphicsProxyWidget *closeButtonProxy = new QGraphicsProxyWidget;
    closeButtonProxy->setWidget(closeButton);

    hbox->addItem(titleLabel);
    hbox->addItem(closeButtonProxy);
    QGraphicsLinearLayout *vbox = new QGraphicsLinearLayout(Qt::Vertical);

    vbox->addItem(hbox);

    if (numberCards < 0) {
        QGraphicsProxyWidget *sortByNameProxy = new QGraphicsProxyWidget;
        sortByNameProxy->setWidget(&sortByNameCheckBox);
        vbox->addItem(sortByNameProxy);

        QGraphicsProxyWidget *sortByTypeProxy = new QGraphicsProxyWidget;
        sortByTypeProxy->setWidget(&sortByTypeCheckBox);
        vbox->addItem(sortByTypeProxy);

        QGraphicsProxyWidget *lineProxy = new QGraphicsProxyWidget;
        QFrame *line = new QFrame;
        line->setFrameShape(QFrame::HLine);
        line->setFrameShadow(QFrame::Sunken);
        lineProxy->setWidget(line);
        vbox->addItem(lineProxy);

        QGraphicsProxyWidget *pileViewProxy = new QGraphicsProxyWidget;
        pileViewProxy->setWidget(&pileViewCheckBox);
        vbox->addItem(pileViewProxy);
    }

    if (_origZone->getIsShufflable() && (numberCards == -1)) {
        shuffleCheckBox.setChecked(settingsCache->getZoneViewShuffle());
        QGraphicsProxyWidget *shuffleProxy = new QGraphicsProxyWidget;
        shuffleProxy->setWidget(&shuffleCheckBox);
        vbox->addItem(shuffleProxy);
    }

    extraHeight = vbox->sizeHint(Qt::PreferredSize).height();
    resize(150, 150);

    QGraphicsLinearLayout *zoneHBox = new QGraphicsLinearLayout(Qt::Horizontal);

    zoneContainer = new QGraphicsWidget(this);
    zoneContainer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    zoneContainer->setFlag(QGraphicsItem::ItemClipsChildrenToShape);
    zoneHBox->addItem(zoneContainer);

    scrollBar = new QScrollBar(Qt::Vertical);
    scrollBar->setMinimum(0);
    scrollBar->setSingleStep(50);
    connect(scrollBar, SIGNAL(valueChanged(int)), this, SLOT(handleScrollBarChange(int)));
    QGraphicsProxyWidget *scrollBarProxy = new QGraphicsProxyWidget;
    scrollBarProxy->setWidget(scrollBar);
    zoneHBox->addItem(scrollBarProxy);

    vbox->addItem(zoneHBox);

    zone = new ZoneViewZone(player, _origZone, numberCards, _revealZone, _writeableRevealZone, zoneContainer);
    connect(zone, SIGNAL(wheelEventReceived(QGraphicsSceneWheelEvent *)), this, SLOT(handleWheelEvent(QGraphicsSceneWheelEvent *)));

    // numberCard is the num of cards we want to reveal from an area. Ex: scry the top 3 cards.
    // If the number is < 0 then it means that we can make the area sorted and we dont care about the order.
    if (numberCards < 0) {
        connect(&sortByNameCheckBox, SIGNAL(stateChanged(int)), this, SLOT(processSortByName(int)));
        connect(&sortByTypeCheckBox, SIGNAL(stateChanged(int)), this, SLOT(processSortByType(int)));
        connect(&pileViewCheckBox, SIGNAL(stateChanged(int)), this, SLOT(processSetPileView(int)));
        sortByNameCheckBox.setChecked(settingsCache->getZoneViewSortByName());
        sortByTypeCheckBox.setChecked(settingsCache->getZoneViewSortByType());
        pileViewCheckBox.setChecked(settingsCache->getZoneViewPileView());
        if (!settingsCache->getZoneViewSortByType())
            pileViewCheckBox.setEnabled(false);
    }
Exemple #3
0
ZoneViewWidget::ZoneViewWidget(Player *_player, CardZone *_origZone, int numberCards, bool _revealZone, const QList<ServerInfo_Card *> &cardList)
	: QGraphicsWidget(0, Qt::Tool | Qt::FramelessWindowHint), player(_player)
{
	setAcceptHoverEvents(true);
	setAttribute(Qt::WA_DeleteOnClose);
	setZValue(2000000006);
	setFlag(ItemIgnoresTransformations);
	
	QGraphicsLinearLayout *hbox = new QGraphicsLinearLayout(Qt::Horizontal);
	titleLabel = new TitleLabel;
	connect(titleLabel, SIGNAL(mouseMoved(QPointF)), this, SLOT(moveWidget(QPointF)));
	closeButton = new QPushButton("X");
	connect(closeButton, SIGNAL(clicked()), this, SLOT(close()));
	closeButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
	QGraphicsProxyWidget *closeButtonProxy = new QGraphicsProxyWidget;
	closeButtonProxy->setWidget(closeButton);
	
	hbox->addItem(titleLabel);
	hbox->addItem(closeButtonProxy);
	QGraphicsLinearLayout *vbox = new QGraphicsLinearLayout(Qt::Vertical);
	
	vbox->addItem(hbox);
	
	if (numberCards < 0) {
		sortByNameCheckBox = new QCheckBox;
		QGraphicsProxyWidget *sortByNameProxy = new QGraphicsProxyWidget;
		sortByNameProxy->setWidget(sortByNameCheckBox);
		vbox->addItem(sortByNameProxy);

		sortByTypeCheckBox = new QCheckBox;
		QGraphicsProxyWidget *sortByTypeProxy = new QGraphicsProxyWidget;
		sortByTypeProxy->setWidget(sortByTypeCheckBox);
		vbox->addItem(sortByTypeProxy);
	} else {
		sortByNameCheckBox = 0;
		sortByTypeCheckBox = 0;
	}
	
	if (_origZone->getIsShufflable() && (numberCards == -1)) {
		shuffleCheckBox = new QCheckBox;
		shuffleCheckBox->setChecked(true);
		QGraphicsProxyWidget *shuffleProxy = new QGraphicsProxyWidget;
		shuffleProxy->setWidget(shuffleCheckBox);
		vbox->addItem(shuffleProxy);
	} else
		shuffleCheckBox = 0;
	
	extraHeight = vbox->sizeHint(Qt::PreferredSize).height();
	resize(150, 150);

	zone = new ZoneViewZone(player, _origZone, numberCards, _revealZone, this);
	vbox->addItem(zone);
	
	if (sortByNameCheckBox) {
		connect(sortByNameCheckBox, SIGNAL(stateChanged(int)), zone, SLOT(setSortByName(int)));
		connect(sortByTypeCheckBox, SIGNAL(stateChanged(int)), zone, SLOT(setSortByType(int)));
		sortByNameCheckBox->setChecked(settingsCache->getZoneViewSortByName());
		sortByTypeCheckBox->setChecked(settingsCache->getZoneViewSortByType());
	}

	retranslateUi();
	setLayout(vbox);
	
	connect(zone, SIGNAL(optimumRectChanged()), this, SLOT(resizeToZoneContents()));
	connect(zone, SIGNAL(beingDeleted()), this, SLOT(zoneDeleted()));
	zone->initializeCards(cardList);
}