+
+
+// level should be resetted to show solution!
+// create new widget
+void FieldView::showSolution()
+{
+ stop();
+ inSolution=true;
+ solutionMove=0;
+ solutionTimer=new QTimer(this);
+ connect(solutionTimer,SIGNAL(timeout()),this,SLOT(playSolutionMove()));
+ playSolutionMove();
+}
+
+void FieldView::stop()
+{
+ disconnect(this,SIGNAL(animationEnd()),this,SLOT(playSolutionMove()));
+ if(solutionTimer!=0)
+ {
+ solutionTimer->stop();
+ delete solutionTimer;
+ solutionTimer=0;
+ }
+ inSolution=false;
+}
+
+void FieldView::playSolutionMove()
+{
+ // drawn from original
+ char chX=playField->solution.at(solutionMove * 2).toAscii();
+ char chY=playField->solution.at(solutionMove * 2 + 1).toAscii();
+
+ int x=chX-'a';
+ int dest_x=x+1;
+ if( chX<='Z')
+ {
+ x = chX-'A';
+ dest_x=x-1;
+ }
+
+ int y=chY-'a';
+ if(chY<='Z'){
+ y=chY-'A';
+ dest_x=x+1;
+ }
+
+ if(x<0 || x>PF::FIELD_WIDTH || y<0 || y>PF::FIELD_HEIGHT)
+ {
+ stop();
+ } else
+ {
+ solutionMove++;
+ move(x,y,dest_x);
+ solutionTimer->start(500);
+ }
+}