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.
13 #include <QHBoxLayout>
20 NewGame::NewGame(QWidget
* parent
, bool allowCurrent
)
22 , m_custom_opt_widget(NULL
)
23 , m_custom_opt_layout(NULL
) {
26 std::cout
<< "allow current = " << allowCurrent
<< std::endl
;
27 m_allow_current
= allowCurrent
;
28 connect(cmbVariant
, SIGNAL(currentIndexChanged(const QString
&)),
29 this, SLOT(variantChanged(const QString
&)));
31 m_custom_opt_layout
= new QHBoxLayout(widgetCustom
);
33 QStringList variants
= Variants::instance().all();
34 foreach (QString variant
, variants
) {
35 cmbVariant
->addItem(variant
, QVariant(variant
));
39 QString
NewGame::variant() const {
40 QString res
= cmbVariant
->itemData(cmbVariant
->currentIndex()).toString();
44 bool NewGame::playFromCurrent() const {
45 return rdCurrent
->isChecked();
48 bool NewGame::isCustom() const {
49 return rdCustom
->isChecked();
52 void NewGame::variantChanged(const QString
& var
) {
53 std::cout
<< "var = " << var
<< std::endl
;
54 bool enabled
= m_allow_current
&& var
== "Chess";
55 rdCurrent
->setEnabled(enabled
);
57 rdStandard
->setChecked(true);
59 if(m_custom_opt_widget
)
60 delete m_custom_opt_widget
;
61 m_custom_options
= OptList();
62 VariantPtr vi
= Variants::instance().get(var
);
64 m_custom_options
= vi
->positionOptions();
65 m_custom_opt_widget
= new OptionWidget(m_custom_options
, widgetCustom
);
66 m_custom_opt_layout
->addWidget(m_custom_opt_widget
);