nice ellipses :)
This commit is contained in:
parent
7e13352a95
commit
175512a2ad
13 changed files with 144 additions and 101 deletions
|
@ -45,7 +45,7 @@ void CardZone::addCard(CardItem *card, bool reorganize, int x, int y)
|
|||
view->addCard(new CardItem(player->getDb(), card->getName(), card->getId()), reorganize, x, y);
|
||||
|
||||
addCardImpl(card, x, y);
|
||||
|
||||
|
||||
if (reorganize)
|
||||
reorganizeCards();
|
||||
}
|
||||
|
@ -67,9 +67,9 @@ CardItem *CardZone::takeCard(int position, int cardId, const QString &cardName)
|
|||
{
|
||||
if (position >= cards->size())
|
||||
return NULL;
|
||||
|
||||
|
||||
CardItem *c = cards->takeAt(position);
|
||||
|
||||
|
||||
if (view)
|
||||
view->removeCard(position);
|
||||
|
||||
|
@ -103,3 +103,26 @@ void CardZone::moveAllToZone(const QString &targetZone, int targetX)
|
|||
for (int i = cards->size() - 1; i >= 0; i--)
|
||||
player->client->moveCard(cards->at(i)->getId(), getName(), targetZone, targetX);
|
||||
}
|
||||
|
||||
void CardZone::paintCardNumberEllipse(QPainter *painter)
|
||||
{
|
||||
painter->save();
|
||||
|
||||
QString numStr = QString::number(cards->size());
|
||||
QFont font("Times", 32, QFont::Bold);
|
||||
QFontMetrics fm(font);
|
||||
QRect br = fm.boundingRect(numStr);
|
||||
double w = br.width() * 1.42;
|
||||
double h = br.height() * 1.42;
|
||||
if (w < h)
|
||||
w = h;
|
||||
|
||||
painter->setPen(QPen(QColor("black")));
|
||||
painter->setBrush(QColor(255, 255, 255, 150));
|
||||
painter->drawEllipse(QRectF((boundingRect().width() - w) / 2.0, (boundingRect().height() - h) / 2.0, w, h));
|
||||
|
||||
painter->setFont(font);
|
||||
painter->drawText(boundingRect(), Qt::AlignCenter, numStr);
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
class Player;
|
||||
class ZoneViewZone;
|
||||
class QMenu;
|
||||
class QPainter;
|
||||
|
||||
class CardZone : public QGraphicsItem {
|
||||
protected:
|
||||
|
@ -20,6 +21,7 @@ protected:
|
|||
bool isShufflable;
|
||||
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||
virtual void addCardImpl(CardItem *card, int x, int y) = 0;
|
||||
void paintCardNumberEllipse(QPainter *painter);
|
||||
public:
|
||||
enum { Type = typeZone };
|
||||
int type() const { return Type; }
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <QTextStream>
|
||||
#include <QXmlStreamReader>
|
||||
#include <QXmlStreamWriter>
|
||||
#include <QProgressDialog>
|
||||
#include "decklist.h"
|
||||
#include "carddatabase.h"
|
||||
|
||||
|
@ -57,12 +58,12 @@ bool DeckList::saveToFile_Native(QIODevice *device)
|
|||
QXmlStreamWriter xml(device);
|
||||
xml.setAutoFormatting(true);
|
||||
xml.writeStartDocument();
|
||||
|
||||
|
||||
xml.writeStartElement("cockatrice_deck");
|
||||
xml.writeAttribute("version", "1");
|
||||
xml.writeTextElement("deckname", name);
|
||||
xml.writeTextElement("comments", comments);
|
||||
|
||||
|
||||
xml.writeStartElement("decklist");
|
||||
for (int i = 0; i < size(); i++) {
|
||||
DecklistRow *r = at(i);
|
||||
|
@ -75,9 +76,9 @@ bool DeckList::saveToFile_Native(QIODevice *device)
|
|||
xml.writeAttribute("name", r->getCard());
|
||||
}
|
||||
xml.writeEndElement(); // decklist
|
||||
|
||||
|
||||
xml.writeEndElement(); // cockatrice_deck
|
||||
|
||||
|
||||
xml.writeEndDocument();
|
||||
return true;
|
||||
}
|
||||
|
@ -89,20 +90,20 @@ bool DeckList::loadFromFile_Plain(QIODevice *device)
|
|||
QString line = in.readLine().simplified();
|
||||
if (line.startsWith("//"))
|
||||
continue;
|
||||
|
||||
|
||||
bool isSideboard = false;
|
||||
if (line.startsWith("SB:", Qt::CaseInsensitive)) {
|
||||
line = line.mid(3).trimmed();
|
||||
isSideboard = true;
|
||||
}
|
||||
|
||||
|
||||
// Filter out MWS edition symbols and basic land extras
|
||||
QRegExp rx("\\[.*\\]");
|
||||
line.remove(rx);
|
||||
rx.setPattern("\\(.*\\)");
|
||||
line.remove(rx);
|
||||
line = line.simplified();
|
||||
|
||||
|
||||
int i = line.indexOf(' ');
|
||||
bool ok;
|
||||
int number = line.left(i).toInt(&ok);
|
||||
|
@ -123,7 +124,7 @@ bool DeckList::saveToFile_Plain(QIODevice *device)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool DeckList::loadFromFile(const QString &fileName, FileFormat fmt)
|
||||
bool DeckList::loadFromFile(const QString &fileName, FileFormat fmt, QWidget *parent)
|
||||
{
|
||||
QFile file(fileName);
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
|
@ -136,7 +137,7 @@ bool DeckList::loadFromFile(const QString &fileName, FileFormat fmt)
|
|||
case CockatriceFormat: result = loadFromFile_Native(&file); break;
|
||||
}
|
||||
if (result)
|
||||
cacheCardPictures();
|
||||
cacheCardPictures(parent);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -150,7 +151,7 @@ bool DeckList::saveToFile(const QString &fileName, FileFormat fmt)
|
|||
QFile file(fileName);
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
return false;
|
||||
|
||||
|
||||
bool result = false;
|
||||
switch (fmt) {
|
||||
case PlainTextFormat: result = saveToFile_Plain(&file); break;
|
||||
|
@ -161,11 +162,11 @@ bool DeckList::saveToFile(const QString &fileName, FileFormat fmt)
|
|||
|
||||
bool DeckList::loadDialog(QWidget *parent)
|
||||
{
|
||||
QFileDialog dialog(parent);
|
||||
QFileDialog dialog(parent, tr("Load deck"));
|
||||
dialog.setNameFilters(fileNameFilters);
|
||||
if (!dialog.exec())
|
||||
return false;
|
||||
|
||||
|
||||
QString fileName = dialog.selectedFiles().at(0);
|
||||
FileFormat fmt;
|
||||
switch (fileNameFilters.indexOf(dialog.selectedNameFilter())) {
|
||||
|
@ -173,8 +174,8 @@ bool DeckList::loadDialog(QWidget *parent)
|
|||
case 1: fmt = PlainTextFormat; break;
|
||||
default: fmt = PlainTextFormat; break;
|
||||
}
|
||||
|
||||
if (loadFromFile(fileName, fmt)) {
|
||||
|
||||
if (loadFromFile(fileName, fmt, parent)) {
|
||||
lastFileName = fileName;
|
||||
lastFileFormat = fmt;
|
||||
return true;
|
||||
|
@ -184,14 +185,14 @@ bool DeckList::loadDialog(QWidget *parent)
|
|||
|
||||
bool DeckList::saveDialog(QWidget *parent)
|
||||
{
|
||||
QFileDialog dialog(parent);
|
||||
QFileDialog dialog(parent, tr("Save deck"));
|
||||
dialog.setAcceptMode(QFileDialog::AcceptSave);
|
||||
dialog.setConfirmOverwrite(true);
|
||||
dialog.setDefaultSuffix("cod");
|
||||
dialog.setNameFilters(fileNameFilters);
|
||||
if (!dialog.exec())
|
||||
return false;
|
||||
|
||||
|
||||
QString fileName = dialog.selectedFiles().at(0);
|
||||
DeckList::FileFormat fmt;
|
||||
switch (fileNameFilters.indexOf(dialog.selectedNameFilter())) {
|
||||
|
@ -199,7 +200,7 @@ bool DeckList::saveDialog(QWidget *parent)
|
|||
case 1: fmt = DeckList::PlainTextFormat; break;
|
||||
default: fmt = DeckList::PlainTextFormat; break;
|
||||
}
|
||||
|
||||
|
||||
if (saveToFile(fileName, fmt)) {
|
||||
lastFileName = fileName;
|
||||
lastFileFormat = fmt;
|
||||
|
@ -208,10 +209,15 @@ bool DeckList::saveDialog(QWidget *parent)
|
|||
return false;
|
||||
}
|
||||
|
||||
void DeckList::cacheCardPictures()
|
||||
void DeckList::cacheCardPictures(QWidget *parent)
|
||||
{
|
||||
for (int i = 0; i < size(); i++)
|
||||
QProgressDialog progress(tr("Caching card pictures..."), QString(), 0, size(), parent);
|
||||
progress.setWindowModality(Qt::WindowModal);
|
||||
|
||||
for (int i = 0; i < size(); i++) {
|
||||
db->getCard(at(i)->getCard())->getPixmap();
|
||||
progress.setValue(i + 1);
|
||||
}
|
||||
}
|
||||
|
||||
void DeckList::cleanList()
|
||||
|
|
|
@ -19,36 +19,37 @@ public:
|
|||
bool isSideboard() const { return sideboard; }
|
||||
};
|
||||
|
||||
class DeckList : public QList<DecklistRow *> {
|
||||
class DeckList : public QObject, public QList<DecklistRow *> {
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum FileFormat { PlainTextFormat, CockatriceFormat };
|
||||
private:
|
||||
static const QStringList fileNameFilters;
|
||||
void cacheCardPictures();
|
||||
void cacheCardPictures(QWidget *parent = 0);
|
||||
CardDatabase *db;
|
||||
QString name, comments;
|
||||
QString lastFileName;
|
||||
FileFormat lastFileFormat;
|
||||
public slots:
|
||||
void setName(const QString &_name) { name = _name; }
|
||||
void setComments(const QString &_comments) { comments = _comments; }
|
||||
public:
|
||||
|
||||
DeckList(CardDatabase *_db);
|
||||
~DeckList();
|
||||
void setName(const QString &_name) { name = _name; }
|
||||
QString getName() const { return name; }
|
||||
void setComments(const QString &_comments) { comments = _comments; }
|
||||
QString getComments() const { return comments; }
|
||||
QString getLastFileName() const { return lastFileName; }
|
||||
FileFormat getLastFileFormat() const { return lastFileFormat; }
|
||||
|
||||
|
||||
bool loadFromFile_Native(QIODevice *device);
|
||||
bool saveToFile_Native(QIODevice *device);
|
||||
bool loadFromFile_Plain(QIODevice *device);
|
||||
bool saveToFile_Plain(QIODevice *device);
|
||||
bool loadFromFile(const QString &fileName, FileFormat fmt);
|
||||
bool loadFromFile(const QString &fileName, FileFormat fmt, QWidget *parent = 0);
|
||||
bool saveToFile(const QString &fileName, FileFormat fmt);
|
||||
bool loadDialog(QWidget *parent = 0);
|
||||
bool saveDialog(QWidget *parent = 0);
|
||||
|
||||
|
||||
void cleanList();
|
||||
};
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ GraveZone::GraveZone(Player *_p, QGraphicsItem *parent)
|
|||
: CardZone(_p, "grave", false, false, parent)
|
||||
{
|
||||
cards = new CardList(true);
|
||||
setCacheMode(DeviceCoordinateCache); // Do not move this line to the parent constructor!
|
||||
}
|
||||
|
||||
QRectF GraveZone::boundingRect() const
|
||||
|
@ -16,18 +17,16 @@ QRectF GraveZone::boundingRect() const
|
|||
return QRectF(0, 0, CARD_WIDTH, CARD_HEIGHT);
|
||||
}
|
||||
|
||||
void GraveZone::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/)
|
||||
void GraveZone::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
if (!cards->isEmpty())
|
||||
cards->at(0)->paint(painter, option, widget);
|
||||
|
||||
painter->save();
|
||||
|
||||
painter->fillRect(boundingRect(), QColor("yellow"));
|
||||
|
||||
painter->setFont(QFont("Times", 32, QFont::Bold));
|
||||
painter->setPen(QPen(QColor("black")));
|
||||
painter->setBackground(QBrush(QColor(255, 255, 255, 100)));
|
||||
painter->setBackgroundMode(Qt::OpaqueMode);
|
||||
painter->drawText(boundingRect(), Qt::AlignCenter, QString::number(cards->size()));
|
||||
|
||||
|
||||
paintCardNumberEllipse(painter);
|
||||
painter->drawRect(QRectF(0.5, 0.5, CARD_WIDTH - 1, CARD_HEIGHT - 1));
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
|
@ -70,7 +69,7 @@ void GraveZone::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||
|
||||
if (cards->empty())
|
||||
return;
|
||||
|
||||
|
||||
bool faceDown = event->modifiers().testFlag(Qt::ShiftModifier);
|
||||
CardItem *card = cards->at(0);
|
||||
CardDragItem *drag = card->createDragItem(this, card->getId(), event->pos(), event->scenePos(), faceDown);
|
||||
|
@ -78,8 +77,7 @@ void GraveZone::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||
setCursor(Qt::OpenHandCursor);
|
||||
}
|
||||
|
||||
void GraveZone::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
void GraveZone::mouseReleaseEvent(QGraphicsSceneMouseEvent */*event*/)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
setCursor(Qt::OpenHandCursor);
|
||||
}
|
||||
|
|
|
@ -10,9 +10,9 @@ LibraryZone::LibraryZone(Player *_p, QGraphicsItem *parent)
|
|||
: CardZone(_p, "deck", false, true, parent)
|
||||
{
|
||||
cards = new CardList(false);
|
||||
setCacheMode(DeviceCoordinateCache); // Do not move this line to the parent constructor!
|
||||
setCursor(Qt::OpenHandCursor);
|
||||
setCacheMode(DeviceCoordinateCache);
|
||||
|
||||
|
||||
image = player->getDb()->getCard()->getPixmap();
|
||||
}
|
||||
|
||||
|
@ -21,21 +21,15 @@ QRectF LibraryZone::boundingRect() const
|
|||
return QRectF(0, 0, CARD_WIDTH, CARD_HEIGHT);
|
||||
}
|
||||
|
||||
void LibraryZone::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
void LibraryZone::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget */*widget*/)
|
||||
{
|
||||
Q_UNUSED(option);
|
||||
Q_UNUSED(widget);
|
||||
painter->save();
|
||||
|
||||
QRectF foo = option->matrix.mapRect(boundingRect());
|
||||
QPixmap bar = image->scaled((int) foo.width(), (int) foo.height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||
painter->drawPixmap(boundingRect(), bar, bar.rect());
|
||||
|
||||
painter->setFont(QFont("Times", 32, QFont::Bold));
|
||||
painter->setPen(QPen(QColor("black")));
|
||||
painter->setBackground(QBrush(QColor(255, 255, 255, 100)));
|
||||
painter->setBackgroundMode(Qt::OpaqueMode);
|
||||
painter->drawText(boundingRect(), Qt::AlignCenter, QString::number(cards->size()));
|
||||
paintCardNumberEllipse(painter);
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
|
@ -81,7 +75,7 @@ void LibraryZone::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||
|
||||
if (cards->empty())
|
||||
return;
|
||||
|
||||
|
||||
bool faceDown = event->modifiers().testFlag(Qt::ShiftModifier);
|
||||
CardItem *card = cards->at(0);
|
||||
CardDragItem *drag = card->createDragItem(this, 0, event->pos(), event->scenePos(), faceDown);
|
||||
|
|
|
@ -156,18 +156,19 @@ void Player::gameEvent(ServerEventData *event)
|
|||
// Clean up existing zones first
|
||||
for (int i = 0; i < zones.size(); i++)
|
||||
zones.at(i)->clearContents();
|
||||
|
||||
|
||||
area->clearCounters();
|
||||
|
||||
CardZone *deck = zones.findZone("deck");
|
||||
for (; deck_cards; deck_cards--)
|
||||
deck->addCard(new CardItem(db), false, -1);
|
||||
deck->reorganizeCards();
|
||||
|
||||
CardZone *sb = zones.findZone("sb");
|
||||
for (; sb_cards; sb_cards--)
|
||||
sb->addCard(new CardItem(db), false, -1);
|
||||
sb->reorganizeCards();
|
||||
|
||||
for (int i = 0; i < zones.size(); i++)
|
||||
zones.at(i)->reorganizeCards();
|
||||
|
||||
if (local) {
|
||||
client->addCounter("life", QColor("white"), 20);
|
||||
|
@ -219,7 +220,7 @@ void Player::gameEvent(ServerEventData *event)
|
|||
qDebug("moveCard: card not found");
|
||||
|
||||
card->deleteDragItem();
|
||||
|
||||
|
||||
card->setFaceDown(facedown);
|
||||
|
||||
// The log event has to be sent before the card is added to the target zone
|
||||
|
|
|
@ -9,6 +9,7 @@ RfgZone::RfgZone(Player *_p, QGraphicsItem *parent)
|
|||
: CardZone(_p, "rfg", false, false, parent)
|
||||
{
|
||||
cards = new CardList(true);
|
||||
setCacheMode(DeviceCoordinateCache); // Do not move this line to the parent constructor!
|
||||
}
|
||||
|
||||
QRectF RfgZone::boundingRect() const
|
||||
|
@ -18,17 +19,13 @@ QRectF RfgZone::boundingRect() const
|
|||
|
||||
void RfgZone::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
{
|
||||
Q_UNUSED(option);
|
||||
Q_UNUSED(widget);
|
||||
if (!cards->isEmpty())
|
||||
cards->at(0)->paint(painter, option, widget);
|
||||
|
||||
painter->save();
|
||||
|
||||
painter->fillRect(boundingRect(), QColor("yellow"));
|
||||
|
||||
painter->setFont(QFont("Times", 32, QFont::Bold));
|
||||
painter->setPen(QPen(QColor("black")));
|
||||
painter->setBackground(QBrush(QColor(255, 255, 255, 100)));
|
||||
painter->setBackgroundMode(Qt::OpaqueMode);
|
||||
painter->drawText(boundingRect(), Qt::AlignCenter, QString::number(cards->size()));
|
||||
|
||||
paintCardNumberEllipse(painter);
|
||||
painter->drawRect(QRectF(0.5, 0.5, CARD_WIDTH - 1, CARD_HEIGHT - 1));
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
|
@ -72,7 +69,7 @@ void RfgZone::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||
|
||||
if (cards->empty())
|
||||
return;
|
||||
|
||||
|
||||
bool faceDown = event->modifiers().testFlag(Qt::ShiftModifier);
|
||||
CardItem *card = cards->at(0);
|
||||
CardDragItem *drag = card->createDragItem(this, card->getId(), event->pos(), event->scenePos(), faceDown);
|
||||
|
@ -80,8 +77,7 @@ void RfgZone::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||
setCursor(Qt::OpenHandCursor);
|
||||
}
|
||||
|
||||
void RfgZone::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
void RfgZone::mouseReleaseEvent(QGraphicsSceneMouseEvent */*event*/)
|
||||
{
|
||||
Q_UNUSED(event);
|
||||
setCursor(Qt::OpenHandCursor);
|
||||
}
|
||||
|
|
|
@ -13,29 +13,50 @@ WndDeckEditor::WndDeckEditor(CardDatabase *_db, QWidget *parent)
|
|||
databaseView->setModel(databaseModel);
|
||||
databaseView->setSortingEnabled(true);
|
||||
connect(databaseView->selectionModel(), SIGNAL(currentRowChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(updateCardInfoLeft(const QModelIndex &, const QModelIndex &)));
|
||||
|
||||
|
||||
QVBoxLayout *leftFrame = new QVBoxLayout;
|
||||
leftFrame->addWidget(databaseView);
|
||||
|
||||
cardInfo = new CardInfoWidget(db);
|
||||
|
||||
QVBoxLayout *middleFrame = new QVBoxLayout;
|
||||
middleFrame->addWidget(cardInfo);
|
||||
middleFrame->addStretch();
|
||||
|
||||
deckModel = new DeckListModel(db, this);
|
||||
deckView = new QTreeView();
|
||||
deckView->setModel(deckModel);
|
||||
connect(deckView->selectionModel(), SIGNAL(currentRowChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(updateCardInfoRight(const QModelIndex &, const QModelIndex &)));
|
||||
|
||||
cardInfo = new CardInfoWidget(db);
|
||||
|
||||
QVBoxLayout *middleFrame = new QVBoxLayout;
|
||||
middleFrame->addWidget(cardInfo);
|
||||
middleFrame->addStretch();
|
||||
|
||||
|
||||
QLabel *nameLabel = new QLabel(tr("Deck &name:"));
|
||||
nameEdit = new QLineEdit;
|
||||
nameLabel->setBuddy(nameEdit);
|
||||
connect(nameEdit, SIGNAL(textChanged(const QString &)), deckModel->getDeckList(), SLOT(setName(const QString &)));
|
||||
QLabel *commentsLabel = new QLabel(tr("&Comments:"));
|
||||
commentsEdit = new QLineEdit;
|
||||
commentsLabel->setBuddy(commentsEdit);
|
||||
connect(commentsEdit, SIGNAL(textChanged(const QString &)), deckModel->getDeckList(), SLOT(setComments(const QString &)));
|
||||
QGridLayout *grid = new QGridLayout;
|
||||
grid->addWidget(nameLabel, 0, 0);
|
||||
grid->addWidget(nameEdit, 0, 1);
|
||||
grid->addWidget(commentsLabel, 1, 0);
|
||||
grid->addWidget(commentsEdit, 1, 1);
|
||||
|
||||
QVBoxLayout *rightFrame = new QVBoxLayout;
|
||||
rightFrame->addLayout(grid);
|
||||
rightFrame->addWidget(deckView);
|
||||
|
||||
QHBoxLayout *mainLayout = new QHBoxLayout;
|
||||
mainLayout->addWidget(databaseView);
|
||||
mainLayout->addLayout(leftFrame);
|
||||
mainLayout->addLayout(middleFrame);
|
||||
mainLayout->addWidget(deckView);
|
||||
|
||||
mainLayout->addLayout(rightFrame);
|
||||
|
||||
QWidget *centralWidget = new QWidget;
|
||||
centralWidget->setLayout(mainLayout);
|
||||
setCentralWidget(centralWidget);
|
||||
|
||||
|
||||
setWindowTitle(tr("Card database"));
|
||||
|
||||
|
||||
aNewDeck = new QAction(tr("&New deck"), this);
|
||||
connect(aNewDeck, SIGNAL(triggered()), this, SLOT(actNewDeck()));
|
||||
aLoadDeck = new QAction(tr("&Load deck..."), this);
|
||||
|
@ -46,8 +67,8 @@ WndDeckEditor::WndDeckEditor(CardDatabase *_db, QWidget *parent)
|
|||
connect(aSaveDeck, SIGNAL(triggered()), this, SLOT(actSaveDeck()));
|
||||
aSaveDeckAs = new QAction(tr("&Save deck as..."), this);
|
||||
connect(aSaveDeckAs, SIGNAL(triggered()), this, SLOT(actSaveDeckAs()));
|
||||
|
||||
deckMenu = menuBar()->addMenu(tr("Deck"));
|
||||
|
||||
deckMenu = menuBar()->addMenu(tr("&Deck"));
|
||||
deckMenu->addAction(aNewDeck);
|
||||
deckMenu->addAction(aLoadDeck);
|
||||
deckMenu->addAction(aSaveDeck);
|
||||
|
@ -84,6 +105,8 @@ void WndDeckEditor::actLoadDeck()
|
|||
lastFileName = l->getLastFileName();
|
||||
lastFileFormat = l->getLastFileFormat();
|
||||
deckView->reset();
|
||||
nameEdit->setText(l->getName());
|
||||
commentsEdit->setText(l->getComments());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,13 +10,14 @@ class CardDatabaseModel;
|
|||
class DeckListModel;
|
||||
class QTreeView;
|
||||
class CardInfoWidget;
|
||||
class QLineEdit;
|
||||
|
||||
class WndDeckEditor : public QMainWindow {
|
||||
Q_OBJECT
|
||||
private slots:
|
||||
void updateCardInfoLeft(const QModelIndex ¤t, const QModelIndex &previous);
|
||||
void updateCardInfoRight(const QModelIndex ¤t, const QModelIndex &previous);
|
||||
|
||||
|
||||
void actNewDeck();
|
||||
void actLoadDeck();
|
||||
void actSaveDeck();
|
||||
|
@ -25,12 +26,13 @@ private:
|
|||
QString lastFileName;
|
||||
DeckList::FileFormat lastFileFormat;
|
||||
CardDatabase *db;
|
||||
|
||||
|
||||
CardDatabaseModel *databaseModel;
|
||||
DeckListModel *deckModel;
|
||||
QTreeView *databaseView, *deckView;
|
||||
CardInfoWidget *cardInfo;
|
||||
|
||||
QLineEdit *nameEdit, *commentsEdit;
|
||||
|
||||
QMenu *deckMenu;
|
||||
QAction *aNewDeck, *aLoadDeck, *aSaveDeck, *aSaveDeckAs;
|
||||
public:
|
||||
|
|
|
@ -22,7 +22,7 @@ void ZoneViewLayout::reorganize()
|
|||
for (int i = 0; i < views.size(); i++) {
|
||||
QRectF viewSize = views.at(i)->windowFrameRect();
|
||||
qreal w = viewSize.right() - viewSize.left();
|
||||
qreal h = viewSize.bottom() - viewSize.top();
|
||||
// qreal h = viewSize.bottom() - viewSize.top();
|
||||
views.at(i)->setPos(totalWidth, y);
|
||||
totalWidth += w;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ ZoneViewWidget::ZoneViewWidget(CardDatabase *_db, Player *_player, CardZone *_or
|
|||
{
|
||||
setWindowTitle(QString("%1's %2").arg(player->getName()).arg(_origZone->getName()));
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
|
||||
qreal y = 10;
|
||||
if (_origZone->getIsShufflable() && (numberCards == 0)) {
|
||||
shuffleCheckBox = new QCheckBox("shuffle when closing");
|
||||
|
@ -25,18 +25,18 @@ ZoneViewWidget::ZoneViewWidget(CardDatabase *_db, Player *_player, CardZone *_or
|
|||
qreal left, top, right, bottom;
|
||||
getWindowFrameMargins(&left, &top, &right, &bottom);
|
||||
qreal h = scene()->sceneRect().height() - (top + bottom);
|
||||
|
||||
|
||||
scrollBar = new QScrollBar(Qt::Vertical);
|
||||
QGraphicsProxyWidget *scrollProxy = new QGraphicsProxyWidget(this);
|
||||
scrollProxy->setWidget(scrollBar);
|
||||
scrollProxy->setPos(138, y);
|
||||
scrollProxy->resize(scrollProxy->size().width(), h - y);
|
||||
|
||||
|
||||
qreal w = 138 + scrollProxy->size().width();
|
||||
resize(w, h);
|
||||
setMinimumSize(w, h);
|
||||
setMaximumSize(w, h);
|
||||
|
||||
|
||||
zone = new ZoneViewZone(player, _origZone, numberCards, this);
|
||||
zone->setPos(3, y);
|
||||
zone->setHeight(h - y);
|
||||
|
@ -50,13 +50,13 @@ void ZoneViewWidget::zoneDumpReceived(int commandId, QList<ServerZoneCard *> car
|
|||
{
|
||||
if (commandId != cmdId)
|
||||
return;
|
||||
|
||||
|
||||
for (int i = 0; i < cards.size(); i++) {
|
||||
ServerZoneCard *temp = cards[i];
|
||||
|
||||
|
||||
CardItem *card = new CardItem(db, temp->getName(), i, zone);
|
||||
zone->addCard(card, false, i);
|
||||
|
||||
|
||||
delete temp;
|
||||
}
|
||||
zone->reorganizeCards();
|
||||
|
|
|
@ -21,11 +21,8 @@ QRectF ZoneViewZone::boundingRect() const
|
|||
return QRectF(0, 0, CARD_WIDTH * 1.75, height);
|
||||
}
|
||||
|
||||
void ZoneViewZone::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
void ZoneViewZone::paint(QPainter */*painter*/, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/)
|
||||
{
|
||||
Q_UNUSED(painter);
|
||||
Q_UNUSED(option);
|
||||
Q_UNUSED(widget);
|
||||
}
|
||||
|
||||
bool ZoneViewZone::initializeCards()
|
||||
|
|
Loading…
Reference in a new issue