-
Notifications
You must be signed in to change notification settings - Fork 1
/
moveattributewidget.cpp
87 lines (77 loc) · 2.07 KB
/
moveattributewidget.cpp
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include "moveattributewidget.h"
#include <QVBoxLayout>
MoveAttributeWidget::MoveAttributeWidget(QWidget *parent, SgfGame* gm) :
QWidget(parent)
{
m_view = new QTextEdit(this);
m_view->setReadOnly(true);
QVBoxLayout *la = new QVBoxLayout(this);
la->addWidget(m_view);
setLayout(la);
setGame(gm);
}
void MoveAttributeWidget::setGame(SgfGame *gm)
{
m_game = gm;
if (m_game)
{
connect(m_game, SIGNAL(nodeAttributesChanged()), this, SLOT(readAttributes()));
readAttributes();
}
}
QString MoveAttributeWidget::nodeAnnotToString(SgfTree::NodeAnnot annot)
{
switch (annot)
{
case (SgfTree::GoodForBlack):
return tr("Good for black");
case (SgfTree::GoodForWhite):
return tr("Good for white");
case (SgfTree::Even):
return tr("Even");
case (SgfTree::Unclear):
return tr("Unclear");
default:
return QString();
}
}
QString MoveAttributeWidget::moveAnnotToString(SgfTree::MoveAnnot annot)
{
switch (annot)
{
case (SgfTree::Bad):
return tr("Bad");
case (SgfTree::Doubtful):
return tr("Doubtful");
case (SgfTree::Interesting):
return tr("Interesting");
case (SgfTree::Tesuji):
return tr("Tesuji (good move)");
default:
return QString();
}
}
void MoveAttributeWidget::readAttributes()
{
QString format = tr(
"<table>"
"<tr><td>Position characteristics:</td><td>%1</td></tr>"
"<tr><td>Move characteristics:</td><td>%2</td></tr>"
"<tr><td>Black captured:</td><td>%3</td></tr>"
"<tr><td>White captured:</td><td>%4</td></tr>"
"<tr><td>Black territory:</td><td>%5</td></tr>"
"<tr><td>White territory:</td><td>%6</td></tr>"
"<tr><td>Black score:</td><td>%7</td></tr>"
"<tr><td>White score:</td><td>%8</td></tr>"
"</table>"
).arg(nodeAnnotToString(m_game->currentMove()->nodeAnnot()),
moveAnnotToString(m_game->currentMove()->moveAnnot()),
QString::number(m_game->killed(cBlack)),
QString::number(m_game->killed(cWhite)),
QString::number(m_game->square(cBlack)),
QString::number(m_game->square(cWhite)),
QString::number(m_game->score(cBlack)),
QString::number(m_game->score(cWhite))
);
m_view->setHtml(format);
}