1
/***************************************************************************
2
* Copyright (C) 2009 by The qGo Project *
4
* This file is part of qGo. *
6
* qGo is free software: you can redistribute it and/or modify *
7
* it under the terms of the GNU General Public License as published by *
8
* the Free Software Foundation; either version 2 of the License, or *
9
* (at your option) any later version. *
11
* This program is distributed in the hope that it will be useful, *
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
* GNU General Public License for more details. *
16
* You should have received a copy of the GNU General Public License *
17
* along with this program; if not, see <http://www.gnu.org/licenses/> *
18
* or write to the Free Software Foundation, Inc., *
19
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
20
***************************************************************************/
24
#include "createroomdialog.h"
25
#include "networkconnection.h"
26
/* CreateRoomDialog requires qformlayout.h which is a Qt 4.4 file
27
* not even in Qt 4.3, so I am temporarily removing it since its
28
* not made use of anyway. FIXME */
30
CreateRoomDialog::CreateRoomDialog(NetworkConnection * conn) : connection(conn)
34
ui.roomTypeTab->removeTab(5); //specialty versions
35
ui.roomTypeTab->setTabEnabled(3, false); //review
36
ui.roomTypeTab->setTabEnabled(4, false); //multi
38
/*namelabel = new QLabel(tr("%1 %2").arg(name).arg(rank));
39
dialoglabel = new QLabel(tr("wants to play a match..."));
40
timelabel = new QLabel(tr("%1 seconds").arg(seconds));
42
createButton = new QPushButton(tr("&Create"));
43
createButton->setDefault(true);
45
cancelButton = new QPushButton(tr("&Cancel"));
47
buttonBox = new QDialogButtonBox(Qt::Horizontal);
48
buttonBox->addButton(createButton, QDialogButtonBox::ActionRole);
49
buttonBox->addButton(cancelButton, QDialogButtonBox::ActionRole);
51
connect(createButton, SIGNAL(clicked()), this, SLOT(slot_create()));
52
connect(cancelButton, SIGNAL(clicked()), this, SLOT(slot_cancel()));
54
QGridLayout * mainLayout = new QGridLayout;
55
mainLayout->setSizeConstraint(QLayout::SetFixedSize);
56
mainLayout->addWidget(namelabel, 0, 0);
57
mainLayout->addWidget(dialoglabel, 1, 0);
58
mainLayout->addWidget(timelabel, 2, 0);
59
mainLayout->addWidget(buttonBox, 3, 0);
60
setLayout(mainLayout);
62
setWindowTitle(tr("Create Room"));*/
64
connect(ui.createButton, SIGNAL(clicked()), this, SLOT(slot_create()));
65
connect(ui.cancelButton, SIGNAL(clicked()), this, SLOT(slot_cancel()));
67
connect(ui.privateCB, SIGNAL(clicked(bool)), this, SLOT(slot_privateCB(bool)));
69
connect(ui.roomTypeTab, SIGNAL(currentChanged(int)), SLOT(slot_roomTypeTab(int)));
71
connect(ui.opponentStrongerRB, SIGNAL(clicked()), this, SLOT(slot_opponentStrongerRB()));
72
connect(ui.opponentEvenRB, SIGNAL(clicked()), this, SLOT(slot_opponentEvenRB()));
73
connect(ui.opponentWeakerRB, SIGNAL(clicked()), this, SLOT(slot_opponentWeakerRB()));
74
connect(ui.opponentAnyRB, SIGNAL(clicked()), this, SLOT(slot_opponentAnyRB()));
76
connect(ui.timeQuickRB, SIGNAL(clicked()), this, SLOT(slot_timeQuickRB()));
77
connect(ui.timeNormalRB, SIGNAL(clicked()), this, SLOT(slot_timeNormalRB()));
78
connect(ui.timePonderousRB, SIGNAL(clicked()), this, SLOT(slot_timePonderousRB()));
79
connect(ui.timeAnyRB, SIGNAL(clicked()), this, SLOT(slot_timeAnyRB()));
81
connect(ui.oneOnOneRB, SIGNAL(clicked()), this, SLOT(slot_oneOnOneRB()));
82
connect(ui.pairRB, SIGNAL(clicked()), this, SLOT(slot_pairRB()));
83
ui.pairRB->setEnabled(false);
86
connect(ui.teachingRB, SIGNAL(clicked()), this, SLOT(slot_teachingRB()));
87
connect(ui.liveRB, SIGNAL(clicked()), this, SLOT(slot_liveRB()));
88
#endif //THISISQT44ONLY
91
void CreateRoomDialog::slot_privateCB(bool checked)
93
checked = false; //for the warning
95
ui.passwordLabel->setEnabled(checked);
96
ui.passwordEdit->setEnabled(checked);
98
ui.passwordEdit->clear();
99
#endif //THISISQT44ONLY
102
void CreateRoomDialog::slot_roomTypeTab(void)
105
void CreateRoomDialog::slot_opponentStrongerRB(void)
108
void CreateRoomDialog::slot_opponentEvenRB(void)
111
void CreateRoomDialog::slot_opponentWeakerRB(void)
114
void CreateRoomDialog::slot_opponentAnyRB(void)
118
void CreateRoomDialog::slot_timeQuickRB(void)
121
void CreateRoomDialog::slot_timeNormalRB(void)
124
void CreateRoomDialog::slot_timePonderousRB(void)
127
void CreateRoomDialog::slot_timeAnyRB(void)
130
void CreateRoomDialog::slot_oneOnOneRB(void)
133
void CreateRoomDialog::slot_pairRB(void)
136
void CreateRoomDialog::slot_teachingRB(void)
139
void CreateRoomDialog::slot_liveRB(void)
143
CreateRoomDialog::~CreateRoomDialog()
148
void CreateRoomDialog::slot_create(void)
151
#ifdef THISISQT44ONLY
152
RoomCreate * room = new RoomCreate();
153
/* FIXME This could be problematic if the index
154
* can change when we remove tabs, but that's
155
* a ways away right now.*/
156
room->type = (RoomCreate::roomType)ui.roomTypeTab->currentIndex();
157
switch(ui.roomTypeTab->currentIndex())
159
case RoomCreate::GAME:
161
case RoomCreate::GOMOKU:
163
case RoomCreate::CHAT:
165
case RoomCreate::REVIEW:
168
case RoomCreate::MULTI:
171
case RoomCreate::VARIATION:
175
connection->sendCreateRoom(room);
177
#endif //THISISQT44ONLY
180
void CreateRoomDialog::slot_cancel(void)