Sorting views
+ When viewing a sorted view (like revealing hand, or looking at library), the cards will now be sorted in columns based on the main card type. + Settings are now saved.
This commit is contained in:
parent
8fee9c6c4b
commit
e4e3a1d2e5
6 changed files with 136 additions and 49 deletions
|
@ -44,6 +44,8 @@ SettingsCache::SettingsCache()
|
||||||
|
|
||||||
zoneViewSortByName = settings->value("zoneview/sortbyname", true).toBool();
|
zoneViewSortByName = settings->value("zoneview/sortbyname", true).toBool();
|
||||||
zoneViewSortByType = settings->value("zoneview/sortbytype", true).toBool();
|
zoneViewSortByType = settings->value("zoneview/sortbytype", true).toBool();
|
||||||
|
zoneViewPileView = settings->value("zoneview/pileview", true).toBool();
|
||||||
|
zoneViewShuffle = settings->value("zoneview/shuffle", true).toBool();
|
||||||
|
|
||||||
soundEnabled = settings->value("sound/enabled", false).toBool();
|
soundEnabled = settings->value("sound/enabled", false).toBool();
|
||||||
soundPath = settings->value("sound/path").toString();
|
soundPath = settings->value("sound/path").toString();
|
||||||
|
@ -250,6 +252,16 @@ void SettingsCache::setZoneViewSortByType(int _zoneViewSortByType)
|
||||||
settings->setValue("zoneview/sortbytype", zoneViewSortByType);
|
settings->setValue("zoneview/sortbytype", zoneViewSortByType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SettingsCache::setZoneViewPileView(int _zoneViewPileView){
|
||||||
|
zoneViewPileView = _zoneViewPileView;
|
||||||
|
settings->setValue("zoneview/pileview", zoneViewPileView);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingsCache::setZoneViewShuffle(int _zoneViewShuffle) {
|
||||||
|
zoneViewShuffle = _zoneViewShuffle;
|
||||||
|
settings->setValue("zoneview/shuffle", zoneViewShuffle);
|
||||||
|
}
|
||||||
|
|
||||||
void SettingsCache::setSoundEnabled(int _soundEnabled)
|
void SettingsCache::setSoundEnabled(int _soundEnabled)
|
||||||
{
|
{
|
||||||
soundEnabled = _soundEnabled;
|
soundEnabled = _soundEnabled;
|
||||||
|
|
|
@ -55,7 +55,7 @@ private:
|
||||||
int minPlayersForMultiColumnLayout;
|
int minPlayersForMultiColumnLayout;
|
||||||
bool tapAnimation;
|
bool tapAnimation;
|
||||||
bool chatMention;
|
bool chatMention;
|
||||||
bool zoneViewSortByName, zoneViewSortByType;
|
bool zoneViewSortByName, zoneViewSortByType, zoneViewPileView, zoneViewShuffle;
|
||||||
bool soundEnabled;
|
bool soundEnabled;
|
||||||
QString soundPath;
|
QString soundPath;
|
||||||
bool priceTagFeature;
|
bool priceTagFeature;
|
||||||
|
@ -96,6 +96,8 @@ public:
|
||||||
bool getChatMention() const { return chatMention; }
|
bool getChatMention() const { return chatMention; }
|
||||||
bool getZoneViewSortByName() const { return zoneViewSortByName; }
|
bool getZoneViewSortByName() const { return zoneViewSortByName; }
|
||||||
bool getZoneViewSortByType() const { return zoneViewSortByType; }
|
bool getZoneViewSortByType() const { return zoneViewSortByType; }
|
||||||
|
bool getZoneViewPileView() const { return zoneViewPileView; }
|
||||||
|
bool getZoneViewShuffle() const { return zoneViewShuffle; }
|
||||||
bool getSoundEnabled() const { return soundEnabled; }
|
bool getSoundEnabled() const { return soundEnabled; }
|
||||||
QString getSoundPath() const { return soundPath; }
|
QString getSoundPath() const { return soundPath; }
|
||||||
bool getPriceTagFeature() const { return priceTagFeature; }
|
bool getPriceTagFeature() const { return priceTagFeature; }
|
||||||
|
@ -136,6 +138,8 @@ public slots:
|
||||||
void setChatMention(int _chatMention);
|
void setChatMention(int _chatMention);
|
||||||
void setZoneViewSortByName(int _zoneViewSortByName);
|
void setZoneViewSortByName(int _zoneViewSortByName);
|
||||||
void setZoneViewSortByType(int _zoneViewSortByType);
|
void setZoneViewSortByType(int _zoneViewSortByType);
|
||||||
|
void setZoneViewPileView(int _zoneViewPileView);
|
||||||
|
void setZoneViewShuffle(int _zoneViewShuffle);
|
||||||
void setSoundEnabled(int _soundEnabled);
|
void setSoundEnabled(int _soundEnabled);
|
||||||
void setSoundPath(const QString &_soundPath);
|
void setSoundPath(const QString &_soundPath);
|
||||||
void setPriceTagFeature(int _priceTagFeature);
|
void setPriceTagFeature(int _priceTagFeature);
|
||||||
|
|
|
@ -63,7 +63,7 @@ ZoneViewWidget::ZoneViewWidget(Player *_player, CardZone *_origZone, int numberC
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
setZValue(2000000006);
|
setZValue(2000000006);
|
||||||
setFlag(ItemIgnoresTransformations);
|
setFlag(ItemIgnoresTransformations);
|
||||||
|
|
||||||
QGraphicsLinearLayout *hbox = new QGraphicsLinearLayout(Qt::Horizontal);
|
QGraphicsLinearLayout *hbox = new QGraphicsLinearLayout(Qt::Horizontal);
|
||||||
titleLabel = new TitleLabel;
|
titleLabel = new TitleLabel;
|
||||||
connect(titleLabel, SIGNAL(mouseMoved(QPointF)), this, SLOT(moveWidget(QPointF)));
|
connect(titleLabel, SIGNAL(mouseMoved(QPointF)), this, SLOT(moveWidget(QPointF)));
|
||||||
|
@ -72,47 +72,44 @@ ZoneViewWidget::ZoneViewWidget(Player *_player, CardZone *_origZone, int numberC
|
||||||
closeButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
closeButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||||
QGraphicsProxyWidget *closeButtonProxy = new QGraphicsProxyWidget;
|
QGraphicsProxyWidget *closeButtonProxy = new QGraphicsProxyWidget;
|
||||||
closeButtonProxy->setWidget(closeButton);
|
closeButtonProxy->setWidget(closeButton);
|
||||||
|
|
||||||
hbox->addItem(titleLabel);
|
hbox->addItem(titleLabel);
|
||||||
hbox->addItem(closeButtonProxy);
|
hbox->addItem(closeButtonProxy);
|
||||||
QGraphicsLinearLayout *vbox = new QGraphicsLinearLayout(Qt::Vertical);
|
QGraphicsLinearLayout *vbox = new QGraphicsLinearLayout(Qt::Vertical);
|
||||||
|
|
||||||
vbox->addItem(hbox);
|
vbox->addItem(hbox);
|
||||||
|
|
||||||
if (numberCards < 0) {
|
if (numberCards < 0) {
|
||||||
sortByNameCheckBox = new QCheckBox;
|
|
||||||
QGraphicsProxyWidget *sortByNameProxy = new QGraphicsProxyWidget;
|
QGraphicsProxyWidget *sortByNameProxy = new QGraphicsProxyWidget;
|
||||||
sortByNameProxy->setWidget(sortByNameCheckBox);
|
sortByNameProxy->setWidget(&sortByNameCheckBox);
|
||||||
vbox->addItem(sortByNameProxy);
|
vbox->addItem(sortByNameProxy);
|
||||||
|
|
||||||
sortByTypeCheckBox = new QCheckBox;
|
|
||||||
QGraphicsProxyWidget *sortByTypeProxy = new QGraphicsProxyWidget;
|
QGraphicsProxyWidget *sortByTypeProxy = new QGraphicsProxyWidget;
|
||||||
sortByTypeProxy->setWidget(sortByTypeCheckBox);
|
sortByTypeProxy->setWidget(&sortByTypeCheckBox);
|
||||||
vbox->addItem(sortByTypeProxy);
|
vbox->addItem(sortByTypeProxy);
|
||||||
} else {
|
|
||||||
sortByNameCheckBox = 0;
|
QGraphicsProxyWidget *pileViewProxy = new QGraphicsProxyWidget;
|
||||||
sortByTypeCheckBox = 0;
|
pileViewProxy->setWidget(&pileViewCheckBox);
|
||||||
|
vbox->addItem(pileViewProxy);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_origZone->getIsShufflable() && (numberCards == -1)) {
|
if (_origZone->getIsShufflable() && (numberCards == -1)) {
|
||||||
shuffleCheckBox = new QCheckBox;
|
shuffleCheckBox.setChecked(settingsCache->getZoneViewShuffle());
|
||||||
shuffleCheckBox->setChecked(true);
|
|
||||||
QGraphicsProxyWidget *shuffleProxy = new QGraphicsProxyWidget;
|
QGraphicsProxyWidget *shuffleProxy = new QGraphicsProxyWidget;
|
||||||
shuffleProxy->setWidget(shuffleCheckBox);
|
shuffleProxy->setWidget(&shuffleCheckBox);
|
||||||
vbox->addItem(shuffleProxy);
|
vbox->addItem(shuffleProxy);
|
||||||
} else
|
}
|
||||||
shuffleCheckBox = 0;
|
|
||||||
|
|
||||||
extraHeight = vbox->sizeHint(Qt::PreferredSize).height();
|
extraHeight = vbox->sizeHint(Qt::PreferredSize).height();
|
||||||
resize(150, 150);
|
resize(150, 150);
|
||||||
|
|
||||||
QGraphicsLinearLayout *zoneHBox = new QGraphicsLinearLayout(Qt::Horizontal);
|
QGraphicsLinearLayout *zoneHBox = new QGraphicsLinearLayout(Qt::Horizontal);
|
||||||
|
|
||||||
zoneContainer = new QGraphicsWidget(this);
|
zoneContainer = new QGraphicsWidget(this);
|
||||||
zoneContainer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
zoneContainer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||||
zoneContainer->setFlag(QGraphicsItem::ItemClipsChildrenToShape);
|
zoneContainer->setFlag(QGraphicsItem::ItemClipsChildrenToShape);
|
||||||
zoneHBox->addItem(zoneContainer);
|
zoneHBox->addItem(zoneContainer);
|
||||||
|
|
||||||
scrollBar = new QScrollBar(Qt::Vertical);
|
scrollBar = new QScrollBar(Qt::Vertical);
|
||||||
scrollBar->setMinimum(0);
|
scrollBar->setMinimum(0);
|
||||||
scrollBar->setSingleStep(50);
|
scrollBar->setSingleStep(50);
|
||||||
|
@ -120,36 +117,55 @@ ZoneViewWidget::ZoneViewWidget(Player *_player, CardZone *_origZone, int numberC
|
||||||
QGraphicsProxyWidget *scrollBarProxy = new QGraphicsProxyWidget;
|
QGraphicsProxyWidget *scrollBarProxy = new QGraphicsProxyWidget;
|
||||||
scrollBarProxy->setWidget(scrollBar);
|
scrollBarProxy->setWidget(scrollBar);
|
||||||
zoneHBox->addItem(scrollBarProxy);
|
zoneHBox->addItem(scrollBarProxy);
|
||||||
|
|
||||||
vbox->addItem(zoneHBox);
|
vbox->addItem(zoneHBox);
|
||||||
|
|
||||||
zone = new ZoneViewZone(player, _origZone, numberCards, _revealZone, _writeableRevealZone, zoneContainer);
|
zone = new ZoneViewZone(player, _origZone, numberCards, _revealZone, _writeableRevealZone, zoneContainer);
|
||||||
connect(zone, SIGNAL(wheelEventReceived(QGraphicsSceneWheelEvent *)), this, SLOT(handleWheelEvent(QGraphicsSceneWheelEvent *)));
|
connect(zone, SIGNAL(wheelEventReceived(QGraphicsSceneWheelEvent *)), this, SLOT(handleWheelEvent(QGraphicsSceneWheelEvent *)));
|
||||||
|
|
||||||
if (sortByNameCheckBox) {
|
if (numberCards < 0) {
|
||||||
connect(sortByNameCheckBox, SIGNAL(stateChanged(int)), zone, SLOT(setSortByName(int)));
|
connect(&sortByNameCheckBox, SIGNAL(stateChanged(int)), this, SLOT(processSortByName(int)));
|
||||||
connect(sortByTypeCheckBox, SIGNAL(stateChanged(int)), zone, SLOT(setSortByType(int)));
|
connect(&sortByTypeCheckBox, SIGNAL(stateChanged(int)), this, SLOT(processSortByType(int)));
|
||||||
sortByNameCheckBox->setChecked(settingsCache->getZoneViewSortByName());
|
connect(&pileViewCheckBox, SIGNAL(stateChanged(int)), this, SLOT(processSetPileView(int)));
|
||||||
sortByTypeCheckBox->setChecked(settingsCache->getZoneViewSortByType());
|
sortByNameCheckBox.setChecked(settingsCache->getZoneViewSortByName());
|
||||||
|
sortByTypeCheckBox.setChecked(settingsCache->getZoneViewSortByType());
|
||||||
|
pileViewCheckBox.setChecked(settingsCache->getZoneViewPileView());
|
||||||
|
if (!settingsCache->getZoneViewSortByType())
|
||||||
|
pileViewCheckBox.setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
retranslateUi();
|
retranslateUi();
|
||||||
setLayout(vbox);
|
setLayout(vbox);
|
||||||
|
|
||||||
connect(zone, SIGNAL(optimumRectChanged()), this, SLOT(resizeToZoneContents()));
|
connect(zone, SIGNAL(optimumRectChanged()), this, SLOT(resizeToZoneContents()));
|
||||||
connect(zone, SIGNAL(beingDeleted()), this, SLOT(zoneDeleted()));
|
connect(zone, SIGNAL(beingDeleted()), this, SLOT(zoneDeleted()));
|
||||||
zone->initializeCards(cardList);
|
zone->initializeCards(cardList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ZoneViewWidget::processSortByType(int value) {
|
||||||
|
pileViewCheckBox.setEnabled(value);
|
||||||
|
settingsCache->setZoneViewSortByType(value);
|
||||||
|
zone->setPileView(pileViewCheckBox.isChecked());
|
||||||
|
zone->setSortByType(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZoneViewWidget::processSortByName(int value) {
|
||||||
|
settingsCache->setZoneViewSortByName(value);
|
||||||
|
zone->setSortByName(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZoneViewWidget::processSetPileView(int value) {
|
||||||
|
settingsCache->setZoneViewPileView(value);
|
||||||
|
zone->setPileView(value);
|
||||||
|
}
|
||||||
|
|
||||||
void ZoneViewWidget::retranslateUi()
|
void ZoneViewWidget::retranslateUi()
|
||||||
{
|
{
|
||||||
titleLabel->setText(zone->getTranslatedName(false, CaseNominative));
|
titleLabel->setText(zone->getTranslatedName(false, CaseNominative));
|
||||||
if (sortByNameCheckBox)
|
sortByNameCheckBox.setText(tr("sort by name"));
|
||||||
sortByNameCheckBox->setText(tr("sort by name"));
|
sortByTypeCheckBox.setText(tr("sort by type"));
|
||||||
if (sortByTypeCheckBox)
|
shuffleCheckBox.setText(tr("shuffle when closing"));
|
||||||
sortByTypeCheckBox->setText(tr("sort by type"));
|
pileViewCheckBox.setText(tr("pile view"));
|
||||||
if (shuffleCheckBox)
|
|
||||||
shuffleCheckBox->setText(tr("shuffle when closing"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZoneViewWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
void ZoneViewWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
|
@ -172,10 +188,10 @@ void ZoneViewWidget::resizeToZoneContents()
|
||||||
QSizeF newSize(qMax(QGraphicsWidget::layout()->effectiveSizeHint(Qt::MinimumSize, QSizeF()).width(), zoneRect.width() + scrollBar->width() + 10), zoneRect.height() + extraHeight + 10);
|
QSizeF newSize(qMax(QGraphicsWidget::layout()->effectiveSizeHint(Qt::MinimumSize, QSizeF()).width(), zoneRect.width() + scrollBar->width() + 10), zoneRect.height() + extraHeight + 10);
|
||||||
setMaximumSize(newSize);
|
setMaximumSize(newSize);
|
||||||
resize(newSize);
|
resize(newSize);
|
||||||
|
|
||||||
zone->setGeometry(QRectF(0, -scrollBar->value(), zoneContainer->size().width(), totalZoneHeight));
|
zone->setGeometry(QRectF(0, -scrollBar->value(), zoneContainer->size().width(), totalZoneHeight));
|
||||||
scrollBar->setMaximum(totalZoneHeight - zoneRect.height());
|
scrollBar->setMaximum(totalZoneHeight - zoneRect.height());
|
||||||
|
|
||||||
if (layout())
|
if (layout())
|
||||||
layout()->invalidate();
|
layout()->invalidate();
|
||||||
}
|
}
|
||||||
|
@ -200,9 +216,9 @@ void ZoneViewWidget::closeEvent(QCloseEvent *event)
|
||||||
cmd.set_zone_name(zone->getName().toStdString());
|
cmd.set_zone_name(zone->getName().toStdString());
|
||||||
player->sendGameCommand(cmd);
|
player->sendGameCommand(cmd);
|
||||||
}
|
}
|
||||||
if (shuffleCheckBox)
|
if (shuffleCheckBox.isChecked())
|
||||||
if (shuffleCheckBox->isChecked())
|
player->sendGameCommand(Command_Shuffle());
|
||||||
player->sendGameCommand(Command_Shuffle());
|
settingsCache->setZoneViewShuffle(shuffleCheckBox.isChecked());
|
||||||
emit closePressed(this);
|
emit closePressed(this);
|
||||||
deleteLater();
|
deleteLater();
|
||||||
event->accept();
|
event->accept();
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define ZONEVIEWWIDGET_H
|
#define ZONEVIEWWIDGET_H
|
||||||
|
|
||||||
#include <QGraphicsWidget>
|
#include <QGraphicsWidget>
|
||||||
|
#include <QCheckBox>
|
||||||
|
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
|
@ -42,13 +43,19 @@ private:
|
||||||
TitleLabel *titleLabel;
|
TitleLabel *titleLabel;
|
||||||
QPushButton *closeButton;
|
QPushButton *closeButton;
|
||||||
QScrollBar *scrollBar;
|
QScrollBar *scrollBar;
|
||||||
QCheckBox *sortByNameCheckBox, *sortByTypeCheckBox, *shuffleCheckBox;
|
QCheckBox sortByNameCheckBox;
|
||||||
|
QCheckBox sortByTypeCheckBox;
|
||||||
|
QCheckBox shuffleCheckBox;
|
||||||
|
QCheckBox pileViewCheckBox;
|
||||||
|
|
||||||
int extraHeight;
|
int extraHeight;
|
||||||
Player *player;
|
Player *player;
|
||||||
signals:
|
signals:
|
||||||
void closePressed(ZoneViewWidget *zv);
|
void closePressed(ZoneViewWidget *zv);
|
||||||
private slots:
|
private slots:
|
||||||
|
void processSortByType(int value);
|
||||||
|
void processSortByName(int value);
|
||||||
|
void processSetPileView(int value);
|
||||||
void resizeToZoneContents();
|
void resizeToZoneContents();
|
||||||
void handleWheelEvent(QGraphicsSceneWheelEvent *event);
|
void handleWheelEvent(QGraphicsSceneWheelEvent *event);
|
||||||
void handleScrollBarChange(int value);
|
void handleScrollBarChange(int value);
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "carddragitem.h"
|
#include "carddragitem.h"
|
||||||
#include "carditem.h"
|
#include "carditem.h"
|
||||||
|
#include "carddatabase.h"
|
||||||
#include "pb/command_dump_zone.pb.h"
|
#include "pb/command_dump_zone.pb.h"
|
||||||
#include "pb/command_move_card.pb.h"
|
#include "pb/command_move_card.pb.h"
|
||||||
#include "pb/serverinfo_card.pb.h"
|
#include "pb/serverinfo_card.pb.h"
|
||||||
|
@ -102,18 +103,52 @@ void ZoneViewZone::reorganizeCards()
|
||||||
CardList cardsToDisplay(cards);
|
CardList cardsToDisplay(cards);
|
||||||
if (sortByName || sortByType)
|
if (sortByName || sortByType)
|
||||||
cardsToDisplay.sort((sortByName ? CardList::SortByName : 0) | (sortByType ? CardList::SortByType : 0));
|
cardsToDisplay.sort((sortByName ? CardList::SortByName : 0) | (sortByType ? CardList::SortByType : 0));
|
||||||
|
|
||||||
|
int typeColumn = 0;
|
||||||
|
int longestRow = 0;
|
||||||
|
if (pileView && sortByType) // we need sort by type enabled for the feature to work
|
||||||
|
setPileViewPositions(cardCount, cardsToDisplay, typeColumn, longestRow);
|
||||||
|
else {
|
||||||
|
for (int i = 0; i < cardCount; i++) {
|
||||||
|
CardItem *c = cardsToDisplay.at(i);
|
||||||
|
qreal x = (i / rows) * CARD_WIDTH;
|
||||||
|
qreal y = (i % rows) * CARD_HEIGHT / 3;
|
||||||
|
c->setPos(x + 5, y + 5);
|
||||||
|
c->setRealZValue(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pileView && sortByType)
|
||||||
|
optimumRect = QRectF(0, 0, qMax(typeColumn + 1, 3) * CARD_WIDTH + 20, ((longestRow - 1) * CARD_HEIGHT) / 3 + CARD_HEIGHT + 60);
|
||||||
|
else
|
||||||
|
optimumRect = QRectF(0, 0, qMax(cols, 1) * CARD_WIDTH + 20, ((rows - 1) * CARD_HEIGHT) / 3 + CARD_HEIGHT + 20);
|
||||||
|
updateGeometry();
|
||||||
|
emit optimumRectChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZoneViewZone::setPileViewPositions(int cardCount, CardList &cardsToDisplay, int &typeColumn, int &longestRow){
|
||||||
|
int typeRow = 0;
|
||||||
|
bool cardTypeMatch = true;
|
||||||
for (int i = 0; i < cardCount; i++) {
|
for (int i = 0; i < cardCount; i++) {
|
||||||
CardItem *c = cardsToDisplay.at(i);
|
CardItem *c = cardsToDisplay.at(i);
|
||||||
qreal x = (i / rows) * CARD_WIDTH;
|
QString cardType = c->getInfo()->getMainCardType();
|
||||||
qreal y = (i % rows) * CARD_HEIGHT / 3;
|
|
||||||
|
if (i){
|
||||||
|
// last card and this card have a matching main type?
|
||||||
|
cardTypeMatch = cardType.compare(cardsToDisplay.at(i-1)->getInfo()->getMainCardType()) == 0 ? true : false;
|
||||||
|
if (!cardTypeMatch) { // if no match then move card to next column
|
||||||
|
typeColumn++;
|
||||||
|
longestRow = qMax(typeRow, longestRow);
|
||||||
|
typeRow = 0;
|
||||||
|
} else // add below current card
|
||||||
|
typeRow++;
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal x = typeColumn * CARD_WIDTH;
|
||||||
|
qreal y = typeRow * CARD_HEIGHT / 3;
|
||||||
c->setPos(x + 5, y + 5);
|
c->setPos(x + 5, y + 5);
|
||||||
c->setRealZValue(i);
|
c->setRealZValue(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
optimumRect = QRectF(0, 0, qMax(cols, 3) * CARD_WIDTH + 10, ((rows - 1) * CARD_HEIGHT) / 3 + CARD_HEIGHT + 10);
|
|
||||||
updateGeometry();
|
|
||||||
emit optimumRectChanged();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZoneViewZone::setSortByName(int _sortByName)
|
void ZoneViewZone::setSortByName(int _sortByName)
|
||||||
|
@ -125,6 +160,13 @@ void ZoneViewZone::setSortByName(int _sortByName)
|
||||||
void ZoneViewZone::setSortByType(int _sortByType)
|
void ZoneViewZone::setSortByType(int _sortByType)
|
||||||
{
|
{
|
||||||
sortByType = _sortByType;
|
sortByType = _sortByType;
|
||||||
|
if (!sortByType)
|
||||||
|
pileView = false;
|
||||||
|
reorganizeCards();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZoneViewZone::setPileView(int _pileView) {
|
||||||
|
pileView = _pileView;
|
||||||
reorganizeCards();
|
reorganizeCards();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,12 +19,17 @@ private:
|
||||||
CardZone *origZone;
|
CardZone *origZone;
|
||||||
bool revealZone, writeableRevealZone;
|
bool revealZone, writeableRevealZone;
|
||||||
bool sortByName, sortByType;
|
bool sortByName, sortByType;
|
||||||
|
bool pileView;
|
||||||
public:
|
public:
|
||||||
ZoneViewZone(Player *_p, CardZone *_origZone, int _numberCards = -1, bool _revealZone = false, bool _writeableRevealZone = false, QGraphicsItem *parent = 0);
|
ZoneViewZone(Player *_p, CardZone *_origZone, int _numberCards = -1, bool _revealZone = false, bool _writeableRevealZone = false, QGraphicsItem *parent = 0);
|
||||||
~ZoneViewZone();
|
~ZoneViewZone();
|
||||||
QRectF boundingRect() const;
|
QRectF boundingRect() const;
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
void reorganizeCards();
|
void reorganizeCards();
|
||||||
|
|
||||||
|
void setPileViewPositions(int cardCount, CardList &cardsToDisplay, int &typeColumn, int &longestRow);
|
||||||
|
|
||||||
|
|
||||||
void initializeCards(const QList<const ServerInfo_Card *> &cardList = QList<const ServerInfo_Card *>());
|
void initializeCards(const QList<const ServerInfo_Card *> &cardList = QList<const ServerInfo_Card *>());
|
||||||
void removeCard(int position);
|
void removeCard(int position);
|
||||||
int getNumberCards() const { return numberCards; }
|
int getNumberCards() const { return numberCards; }
|
||||||
|
@ -36,6 +41,7 @@ public:
|
||||||
public slots:
|
public slots:
|
||||||
void setSortByName(int _sortByName);
|
void setSortByName(int _sortByName);
|
||||||
void setSortByType(int _sortByType);
|
void setSortByType(int _sortByType);
|
||||||
|
void setPileView(int _pileView);
|
||||||
private slots:
|
private slots:
|
||||||
void zoneDumpReceived(const Response &r);
|
void zoneDumpReceived(const Response &r);
|
||||||
signals:
|
signals:
|
||||||
|
|
Loading…
Reference in a new issue