mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-27 00:53:55 -07:00
Clang-format (#3028)
* 1/3 Add .clang-format file and travis compilation check * 2/3 Run clang-format * 3/3 Fix compilation problems due to include reordering * 3bis/3 AfterControlStatement: false
This commit is contained in:
parent
8dbdd24c8e
commit
b29bd9e070
272 changed files with 13378 additions and 9535 deletions
|
|
@ -1,12 +1,12 @@
|
|||
#ifndef DECKVIEW_H
|
||||
#define DECKVIEW_H
|
||||
|
||||
#include "abstractcarddragitem.h"
|
||||
#include <QGraphicsScene>
|
||||
#include <QGraphicsView>
|
||||
#include <QMap>
|
||||
#include <QMultiMap>
|
||||
#include <QPixmap>
|
||||
#include "abstractcarddragitem.h"
|
||||
|
||||
#include "pb/move_card_to_zone.pb.h"
|
||||
|
||||
|
|
@ -17,65 +17,90 @@ class DeckViewCardContainer;
|
|||
class DeckViewCardDragItem;
|
||||
class MoveCardToZone;
|
||||
|
||||
class DeckViewCard : public AbstractCardItem {
|
||||
class DeckViewCard : public AbstractCardItem
|
||||
{
|
||||
private:
|
||||
QString originZone;
|
||||
DeckViewCardDragItem *dragItem;
|
||||
|
||||
public:
|
||||
DeckViewCard(const QString &_name = QString(), const QString &_originZone = QString(), QGraphicsItem *parent = 0);
|
||||
~DeckViewCard();
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
const QString &getOriginZone() const { return originZone; }
|
||||
const QString &getOriginZone() const
|
||||
{
|
||||
return originZone;
|
||||
}
|
||||
|
||||
protected:
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
||||
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
|
||||
};
|
||||
|
||||
class DeckViewCardDragItem : public AbstractCardDragItem {
|
||||
class DeckViewCardDragItem : public AbstractCardDragItem
|
||||
{
|
||||
private:
|
||||
DeckViewCardContainer *currentZone;
|
||||
void handleDrop(DeckViewCardContainer *target);
|
||||
|
||||
public:
|
||||
DeckViewCardDragItem(DeckViewCard *_item, const QPointF &_hotSpot, AbstractCardDragItem *parentDrag = 0);
|
||||
void updatePosition(const QPointF &cursorScenePos);
|
||||
|
||||
protected:
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
|
||||
};
|
||||
|
||||
class DeckViewCardContainer : public QGraphicsItem {
|
||||
class DeckViewCardContainer : public QGraphicsItem
|
||||
{
|
||||
private:
|
||||
static const int separatorY = 20;
|
||||
static const int paddingY = 10;
|
||||
static bool sortCardsByName(DeckViewCard * c1, DeckViewCard * c2);
|
||||
|
||||
static bool sortCardsByName(DeckViewCard *c1, DeckViewCard *c2);
|
||||
|
||||
QString name;
|
||||
QList<DeckViewCard *> cards;
|
||||
QMultiMap<QString, DeckViewCard *> cardsByType;
|
||||
QList<QPair<int, int> > currentRowsAndCols;
|
||||
QList<QPair<int, int>> currentRowsAndCols;
|
||||
qreal width, height;
|
||||
int getCardTypeTextWidth() const;
|
||||
|
||||
public:
|
||||
enum { Type = typeDeckViewCardContainer };
|
||||
int type() const { return Type; }
|
||||
enum
|
||||
{
|
||||
Type = typeDeckViewCardContainer
|
||||
};
|
||||
int type() const
|
||||
{
|
||||
return Type;
|
||||
}
|
||||
DeckViewCardContainer(const QString &_name);
|
||||
QRectF boundingRect() const;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
void addCard(DeckViewCard *card);
|
||||
void removeCard(DeckViewCard *card);
|
||||
const QList<DeckViewCard *> &getCards() const { return cards; }
|
||||
const QString &getName() const { return name; }
|
||||
const QList<DeckViewCard *> &getCards() const
|
||||
{
|
||||
return cards;
|
||||
}
|
||||
const QString &getName() const
|
||||
{
|
||||
return name;
|
||||
}
|
||||
void setWidth(qreal _width);
|
||||
|
||||
QList<QPair<int, int> > getRowsAndCols() const;
|
||||
QSizeF calculateBoundingRect(const QList<QPair<int, int> > &rowsAndCols) const;
|
||||
void rearrangeItems(const QList<QPair<int, int> > &rowsAndCols);
|
||||
QList<QPair<int, int>> getRowsAndCols() const;
|
||||
QSizeF calculateBoundingRect(const QList<QPair<int, int>> &rowsAndCols) const;
|
||||
void rearrangeItems(const QList<QPair<int, int>> &rowsAndCols);
|
||||
};
|
||||
|
||||
class DeckViewScene : public QGraphicsScene {
|
||||
class DeckViewScene : public QGraphicsScene
|
||||
{
|
||||
Q_OBJECT
|
||||
signals:
|
||||
void newCardAdded(AbstractCardItem *card);
|
||||
void sideboardPlanChanged();
|
||||
|
||||
private:
|
||||
bool locked;
|
||||
DeckList *deck;
|
||||
|
|
@ -83,13 +108,23 @@ private:
|
|||
qreal optimalAspectRatio;
|
||||
void clearContents();
|
||||
void rebuildTree();
|
||||
|
||||
public:
|
||||
DeckViewScene(QObject *parent = 0);
|
||||
~DeckViewScene();
|
||||
void setLocked(bool _locked) { locked = _locked; }
|
||||
bool getLocked() const { return locked; }
|
||||
void setLocked(bool _locked)
|
||||
{
|
||||
locked = _locked;
|
||||
}
|
||||
bool getLocked() const
|
||||
{
|
||||
return locked;
|
||||
}
|
||||
void setDeck(const DeckList &_deck);
|
||||
void setOptimalAspectRatio(qreal _optimalAspectRatio) { optimalAspectRatio = _optimalAspectRatio; }
|
||||
void setOptimalAspectRatio(qreal _optimalAspectRatio)
|
||||
{
|
||||
optimalAspectRatio = _optimalAspectRatio;
|
||||
}
|
||||
void rearrangeItems();
|
||||
void updateContents();
|
||||
QList<MoveCard_ToZone> getSideboardPlan() const;
|
||||
|
|
@ -97,10 +132,12 @@ public:
|
|||
void applySideboardPlan(const QList<MoveCard_ToZone> &plan);
|
||||
};
|
||||
|
||||
class DeckView : public QGraphicsView {
|
||||
class DeckView : public QGraphicsView
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
DeckViewScene *deckViewScene;
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
public slots:
|
||||
|
|
@ -108,11 +145,18 @@ public slots:
|
|||
signals:
|
||||
void newCardAdded(AbstractCardItem *card);
|
||||
void sideboardPlanChanged();
|
||||
|
||||
public:
|
||||
DeckView(QWidget *parent = 0);
|
||||
void setDeck(const DeckList &_deck);
|
||||
void setLocked(bool _locked) { deckViewScene->setLocked(_locked); }
|
||||
QList<MoveCard_ToZone> getSideboardPlan() const { return deckViewScene->getSideboardPlan(); }
|
||||
void setLocked(bool _locked)
|
||||
{
|
||||
deckViewScene->setLocked(_locked);
|
||||
}
|
||||
QList<MoveCard_ToZone> getSideboardPlan() const
|
||||
{
|
||||
return deckViewScene->getSideboardPlan();
|
||||
}
|
||||
void mouseDoubleClickEvent(QMouseEvent *event);
|
||||
void resetSideboardPlan();
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue