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>
19 NewGame::NewGame(QWidget
* parent
, bool allowCurrent
)
21 , m_custom_opt_widget(NULL
)
22 , m_custom_opt_layout(NULL
) {
25 std::cout
<< "allow current = " << allowCurrent
<< std::endl
;
26 m_allow_current
= allowCurrent
;
27 connect(cmbVariant
, SIGNAL(currentIndexChanged(const QString
&)),
28 this, SLOT(variantChanged(const QString
&)));
30 m_custom_opt_layout
= new QHBoxLayout(widgetCustom
);
32 const Variant::Variants
& all
= Variant::allVariants();
33 for(Variant::Variants::const_iterator it
= all
.begin(); it
!= all
.end(); ++it
)
34 cmbVariant
->addItem(it
->first
, QVariant(it
->first
));
37 QString
NewGame::variant() const {
38 QString res
= cmbVariant
->itemData(cmbVariant
->currentIndex()).toString();
42 bool NewGame::playFromCurrent() const {
43 return rdCurrent
->isChecked();
46 bool NewGame::isCustom() const {
47 return rdCustom
->isChecked();
50 void NewGame::variantChanged(const QString
& var
) {
51 std::cout
<< "var = " << var
<< std::endl
;
52 bool enabled
= m_allow_current
&& var
== "Chess";
53 rdCurrent
->setEnabled(enabled
);
55 rdStandard
->setChecked(true);
57 if(m_custom_opt_widget
)
58 delete m_custom_opt_widget
;
59 m_custom_options
= OptList();
60 VariantInfo
* vi
= Variant::variant(var
);
62 m_custom_options
= vi
->positionOptions();
63 m_custom_opt_widget
= new OptionWidget(m_custom_options
, widgetCustom
);
64 m_custom_opt_layout
->addWidget(m_custom_opt_widget
);