ICSAPI::parseVerbose is now used instead of VariantInfo::getVerboseMove.
[tagua.git] / src / movelist_table.cpp
blobe42c2f78bc67993297635793dcd2c9f1733eb3e4
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 <QApplication>
12 #include <QMenu>
13 #include <QHBoxLayout>
14 #include <QVBoxLayout>
15 #include <QScrollArea>
16 #include <QToolButton>
17 #include <QTabWidget>
18 #include <QScrollBar>
19 #include <kicon.h>
20 #include "mastersettings.h"
21 #include "movelist_textual.h"
22 #include "movelist_notifier.h"
23 #include "movelist_widget.h"
24 #include "movelist_table.h"
26 namespace MoveList {
28 //BEGIN Table------------------------------------------------------------------
30 Table::Table(QWidget* w)
31 : QWidget(w) {
32 setWindowTitle("Move List");
34 QVBoxLayout *vbox = new QVBoxLayout(this);
35 QHBoxLayout *hbox = new QHBoxLayout();
36 hbox->setMargin(0);
37 hbox->setSpacing(1);
38 vbox->setMargin(1);
39 vbox->setSpacing(1);
41 QToolButton *b1 = new QToolButton(this);
42 m_undo = new QAction(KIcon("undo"), "&Undo", this);
43 m_undo->setShortcut(Qt::CTRL+Qt::Key_Z);
44 connect(m_undo, SIGNAL(triggered()), this, SLOT(onUndo()));
45 b1->setDefaultAction(m_undo);
46 b1->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
47 hbox->addWidget(b1);
49 QToolButton *b2 = new QToolButton(this);
50 m_redo = new QAction(KIcon("redo"), "Re&do", this);
51 m_redo->setShortcut(Qt::CTRL+Qt::SHIFT+Qt::Key_Z);
52 connect(m_redo, SIGNAL(triggered()), this, SLOT(onRedo()));
53 b2->setDefaultAction(m_redo);
54 b2->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
55 hbox->addWidget(b2);
57 hbox->addStretch(1);
59 vbox->addLayout(hbox);
61 QTabWidget *tw = new QTabWidget(this);
62 tw->setTabPosition(QTabWidget::West);
63 vbox->addWidget(tw);
65 m_scroll_area = new QScrollArea(tw);
66 m_movelist = new Widget(m_scroll_area, this);
67 m_scroll_area->setFocusPolicy(Qt::NoFocus);
68 m_scroll_area->setWidgetResizable(true);
69 m_scroll_area->setWidget(m_movelist);
70 m_scroll_area->resize(50,100);
71 tw->addTab(m_scroll_area, KIcon("prefMoveList"), "&List");
73 m_movelist_textual = NULL;
74 //m_movelist_textual = new Textual(tw);
75 //tw->addTab(m_movelist_textual->widget(), KIcon("html"), "&Html");
78 void Table::settingsChanged() {
79 if(m_movelist) m_movelist->settingsChanged();
80 if(m_movelist_textual) m_movelist_textual->settingsChanged();
83 void Table::setLoaderTheme(const ThemeInfo& theme) {
84 if(m_movelist) m_movelist->setLoaderTheme(theme);
85 if(m_movelist_textual) m_movelist_textual->setLoaderTheme(theme);
88 void Table::onUndo() {
89 if(m_movelist->notifier)
90 if(m_movelist) m_movelist->notifier->onUserUndo();
93 void Table::onRedo() {
94 if(m_movelist->notifier)
95 if(m_movelist) m_movelist->notifier->onUserRedo();
98 void Table::setComment(const Index& index, const QString& comment) {
99 if(m_movelist) m_movelist->setComment(index, comment);
100 if(m_movelist_textual) m_movelist_textual->setComment(index, comment);
103 void Table::setVComment(const Index& index, int v, const QString& comment, bool confirm_promotion) {
104 if(!confirm_promotion)
105 if(m_movelist) m_movelist->setVComment(index, v, comment);
106 if(m_movelist_textual) m_movelist_textual->setVComment(index, v, comment);
109 void Table::setMove(const Index& index, int turn, const DecoratedMove& move,
110 const QString& comment, bool confirm_promotion) {
111 if(!confirm_promotion)
112 if(m_movelist) m_movelist->setMove(index, turn, move, comment);
113 if(m_movelist_textual) m_movelist_textual->setMove(index, turn, move, comment);
116 void Table::setMove(const Index& index, int turn, const QString& move,
117 const QString& comment, bool confirm_promotion) {
118 if(!confirm_promotion)
119 if(m_movelist) m_movelist->setMove(index, turn, move, comment);
120 if(m_movelist_textual) m_movelist_textual->setMove(index, turn, move, comment);
123 void Table::remove(const Index& index, bool confirm_promotion) {
124 if(!confirm_promotion)
125 if(m_movelist) m_movelist->remove(index);
126 if(m_movelist_textual) m_movelist_textual->remove(index);
129 void Table::Table::promoteVariation(const Index& ix, int v) {
130 if(m_movelist) m_movelist->promoteVariation(ix, v);
131 //m_movelist_textual->promoteVariation(index);
134 void Table::select(const Index& index, bool confirm_promotion) {
135 if(!confirm_promotion)
136 if(m_movelist) m_movelist->select(index);
137 if(m_movelist_textual) m_movelist_textual->select(index);
140 void Table::reset() {
141 m_undo->setEnabled(false);
142 m_redo->setEnabled(false);
143 if(m_movelist) m_movelist->reset();
144 if(m_movelist_textual) m_movelist_textual->reset();
147 Notifier* Table::getNotifier() {
148 return m_movelist->getNotifier();
151 void Table::setNotifier(Notifier* n, bool detach_prev) {
152 if(m_movelist) m_movelist->setNotifier(n, detach_prev);
153 if(m_movelist_textual) m_movelist_textual->setNotifier(n, false); //false here, it is important
156 int Table::layoutStyle() {
157 return m_movelist->layoutStyle();
160 void Table::setLayoutStyle(int x) {
161 if(m_movelist) m_movelist->setLayoutStyle(x);
162 if(m_movelist_textual) m_movelist_textual->setLayoutStyle(x);
165 void Table::enableUndo(bool e) {
166 m_undo->setEnabled(e);
169 void Table::enableRedo(bool e) {
170 m_redo->setEnabled(e);
173 //END Table--------------------------------------------------------------------
175 } //end namespace MoveList