Removed all promotion stuff from controllers and UI.
[tagua/yd.git] / src / ui.cpp
blob8b06e5b7bd7c32b65809bca7450a5f160f3c7480
1 /*
2 Copyright (c) 2006 Paolo Capriotti <p.capriotti@sns.it>
3 (c) 2006 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9 */
11 #include <iostream>
12 #include <qapplication.h>
13 #include <qclipboard.h>
14 #include "ui.h"
15 #include "controllers/abstract.h"
17 using namespace boost;
19 UI::UI()
20 : m_current_tab(NULL) {
23 boost::shared_ptr<Controller>& UI::controller() {
24 Q_ASSERT(m_current_tab);
26 return m_controller[m_current_tab];
29 const boost::shared_ptr<Controller>& UI::controller() const {
30 Q_ASSERT(m_current_tab);
32 return m_controller.find(m_current_tab)->second;
35 void UI::addController(QWidget* w, const shared_ptr<Controller>& controller) {
36 m_controller[w] = controller;
39 void UI::setController(const shared_ptr<Controller>& controller) {
40 Q_ASSERT(m_current_tab);
42 m_controller[m_current_tab] = controller;
45 void UI::removeController(QWidget* w) {
46 controller()->end();
47 m_controller.erase(w);
50 void UI::setCurrentTab(QWidget* w) {
51 m_current_tab = w;
54 bool UI::undo() {
55 controller()->undo();
56 return true;
59 bool UI::redo() {
60 controller()->redo();
61 return true;
64 bool UI::truncate() {
65 controller()->truncate();
66 return true;
69 bool UI::promoteVariation() {
70 controller()->promoteVariation();
71 return true;
74 bool UI::back() {
75 return controller()->back();
78 bool UI::forward() {
79 return controller()->forward();
82 void UI::gotoFirst() {
83 controller()->gotoFirst();
86 void UI::gotoLast() {
87 controller()->gotoLast();
90 void UI::pgnCopy() {
91 QClipboard* cb = QApplication::clipboard();
92 cb->setText(controller()->save());
95 void UI::pgnPaste() {
96 QClipboard* cb = QApplication::clipboard();
97 pgnPaste(cb->text());
100 void UI::pgnPaste(const QString&) {
101 //controller()->loadPGN(pgn);
104 void UI::clearBoard() {
105 controller()->clearBoard();
108 void UI::setStartingPosition() {
109 controller()->setStartingPosition();
112 void UI::copyPosition() {
113 QClipboard* cb = QApplication::clipboard();
114 cb->setText(controller()->fen());
117 void UI::pastePosition() {
118 QClipboard* cb = QApplication::clipboard();
119 controller()->setFEN(cb->text());
122 void UI::setTurn(int turn) {
123 controller()->setTurn(turn);
126 AbstractPosition::Ptr UI::position() const {
127 return controller()->currentPosition();
130 void UI::createCtrlAction() {
131 controller()->createCtrlAction();
134 void UI::destroyCtrlAction() {
135 controller()->destroyCtrlAction();
138 ActionCollection* UI::variantActions() const {
139 return controller()->variantActions();
142 EntityToken UI::addPlayingEngine(int side, const shared_ptr<Engine>& engine) {
143 return controller()->addPlayingEngine(side, engine);
146 // EntityToken UI::addAnalysingEngine(const shared_ptr<Engine>& engine) {
147 // return controller()->addAnalysingEngine(engine);
148 // }
150 void UI::removeEntity(const EntityToken& token) {
151 controller()->removeEntity(token);
154 void UI::end() {
155 controller() = controller()->end();
158 void UI::detach() {
159 controller()->detach();
162 QString UI::currentVariant() const {
163 return controller()->variant();