-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgametree.h
67 lines (58 loc) · 1.3 KB
/
gametree.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef GAMETREE_H
#define GAMETREE_H
#include <QtGui/QAbstractScrollArea>
#include <QtCore/QMap>
#include <QtCore/QVector>
#include <QtCore/QLinkedList>
#include <QtGui/QMenu>
#include <QtGui/QAction>
#include "sgfgame.h"
class Node
{
public:
SgfTree* sgfNode;
long pos;
QVector <Node*> children;
Node* parent;
Node();
~Node();
};
class GameTree : public QAbstractScrollArea
{
Q_OBJECT
static const int m_nodeHeight = 35;
static const int m_nodeWidth = 30 ;
static const int m_nodeSize = 20;
int m_viewportWidth;
int m_viewportHeight;
SgfGame *m_game;
Node *m_tree;
int m_scanDepth;
int m_treeWidth;
QVector <QMap <long, Node*> > m_layers;
QVector <long> m_layerWidth;
QPainter *vpPainter;
long m_currCol, m_currRow;
Node* m_currNode;
Node* m_nodeToDelete;
protected slots:
void setCurrentNode(SgfTree*);
void addNewNode(SgfTree*);
void rebuildTree();
void deleteNode();
protected:
void mousePressEvent(QMouseEvent *);
void resizeEvent(QResizeEvent *);
void paintEvent(QPaintEvent *);
long scanNode(Node* node);
long rescanNode(Node* node);
void drawNode(Node *node);
void keyPressEvent(QKeyEvent *);
public:
void setGame(SgfGame *gm);
GameTree(QWidget *parent=NULL, SgfGame* gm=NULL);
~GameTree();
signals:
void nodeSelected(SgfTree* newNode, SgfTree* oldNode);
};
#endif // GAMETREE_H