From c90c389a8a8d9d8661e9772ec4144c5cf2039f23 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegames@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kenolaba/Spy.cpp | 155 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 155 insertions(+) create mode 100644 kenolaba/Spy.cpp (limited to 'kenolaba/Spy.cpp') diff --git a/kenolaba/Spy.cpp b/kenolaba/Spy.cpp new file mode 100644 index 00000000..07f17702 --- /dev/null +++ b/kenolaba/Spy.cpp @@ -0,0 +1,155 @@ +/* Class Spion + * + * Josef Weidendorfer, 10/97 + */ + + +#include +#include +#include + +#include +#include + +#include "BoardWidget.h" +#include "Spy.h" + +Spy::Spy(Board& b) + :board(b) +{ + int i; + + top = new QVBoxLayout(this, 5); + + QLabel *l = new QLabel(this); + l->setText( i18n("Actual examined position:") ); + l->setFixedHeight( l->sizeHint().height() ); + l->setAlignment( AlignVCenter | AlignLeft ); + top->addWidget( l ); + + QHBoxLayout* b1 = new QHBoxLayout(); + top->addLayout( b1, 10 ); + + for(i=0;iaddLayout( b2 ); + + actBoard[i] = new BoardWidget(board,this); + actLabel[i] = new QLabel(this); + actLabel[i]->setText("---"); + // actLabel[i]->setFrameStyle( QFrame::Panel | QFrame::Sunken ); + actLabel[i]->setAlignment( AlignHCenter | AlignVCenter); + actLabel[i]->setFixedHeight( actLabel[i]->sizeHint().height() ); + + b2->addWidget( actBoard[i] ); + b2->addWidget( actLabel[i] ); + connect( actBoard[i], SIGNAL(mousePressed()), this, SLOT(nextStep()) ); + } + + l = new QLabel(this); + l->setText( i18n("Best move so far:") ); + l->setFixedHeight( l->sizeHint().height() ); + l->setAlignment( AlignVCenter | AlignLeft ); + top->addWidget( l ); + + b1 = new QHBoxLayout(); + top->addLayout( b1, 10 ); + + for(i=0;iaddLayout( b2 ); + + bestBoard[i] = new BoardWidget(board,this); + bestLabel[i] = new QLabel(this); + bestLabel[i]->setText("---"); + // bestLabel[i]->setFrameStyle( QFrame::Panel | QFrame::Sunken ); + bestLabel[i]->setAlignment( AlignHCenter | AlignVCenter); + bestLabel[i]->setFixedHeight( bestLabel[i]->sizeHint().height() ); + + b2->addWidget( bestBoard[i] ); + b2->addWidget( bestLabel[i] ); + connect( bestBoard[i], SIGNAL(mousePressed()), this, SLOT(nextStep()) ); + } + + connect( &board, SIGNAL(update(int,int,Move&,bool)), + this, SLOT(update(int,int,Move&,bool)) ); + connect( &board, SIGNAL(updateBest(int,int,Move&,bool)), + this, SLOT(updateBest(int,int,Move&,bool)) ); + top->activate(); + setCaption(i18n("Spy")); + // KWM::setDecoration(winId(), 2); + resize(500,300); +} + +void Spy::keyPressEvent(QKeyEvent *) +{ + nextStep(); +} + +void Spy::nextStep() +{ + next = true; +} + +void Spy::clearActBoards() +{ + for(int i=0;iclearPosition(); + actBoard[i]->draw(); + actLabel[i]->setText("---"); + } +} + +void Spy::update(int depth, int value, Move& m, bool wait) +{ + next = false; + + if (depth>BoardCount-1) return; + actBoard[depth]->showMove(m,3); + // actBoard[depth]->showMove(m,0,false); + + if (!wait) { + actLabel[depth]->setText("---"); + return; + } + + if (depthupdatePosition(true); + actLabel[depth+1]->setNum(value); + board.takeBack(); + + if (depthclearPosition(); + actBoard[depth+2]->draw(); + } + } + + while(!next) + kapp->processEvents(); +} + +void Spy::updateBest(int depth, int value, Move& m, bool cutoff) +{ + if (depth>BoardCount-1) return; + bestBoard[depth]->showMove(m,3); + // board.showMove(m,0); + + if (depthupdatePosition(true); + + QString tmp; + tmp.setNum(value); + if (cutoff) tmp += " (CutOff)"; + bestLabel[depth+1]->setText(tmp); + board.takeBack(); + } +} + + + + + + +#include "Spy.moc" -- cgit v1.2.3