Debian Codegraph @

src/network/createroomdialog.cpp

raw symbols SCIP
1 /***************************************************************************
2 * Copyright (C) 2009 by The qGo Project *
3 * *
4 * This file is part of qGo. *
5 * *
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. *
10 * *
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. *
15 * *
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 ***************************************************************************/
21
22
23 #include <QtWidgets>
24 #include "createroomdialog.h"
25 #include "networkconnection.h"
26
27 CreateRoomDialog::CreateRoomDialog(NetworkConnection * conn) : connection(conn)
28 {
29 setupUi(this);
30 roomTypeTab->removeTab(5); //specialty versions
31 roomTypeTab->setTabEnabled(3, false); //review
32 roomTypeTab->setTabEnabled(4, false); //multi
33
34 /*namelabel = new QLabel(tr("%1 %2").arg(name).arg(rank));
35 dialoglabel = new QLabel(tr("wants to play a match..."));
36 timelabel = new QLabel(tr("%1 seconds").arg(seconds));
37
38 createButton = new QPushButton(tr("&Create"));
39 createButton->setDefault(true);
40
41 cancelButton = new QPushButton(tr("&Cancel"));
42
43 buttonBox = new QDialogButtonBox(Qt::Horizontal);
44 buttonBox->addButton(createButton, QDialogButtonBox::ActionRole);
45 buttonBox->addButton(cancelButton, QDialogButtonBox::ActionRole);
46
47 connect(createButton, clicked()), this, slot_create()));
48 connect(cancelButton, clicked()), this, slot_cancel()));
49
50 QGridLayout * mainLayout = new QGridLayout;
51 mainLayout->setSizeConstraint(QLayout::SetFixedSize);
52 mainLayout->addWidget(namelabel, 0, 0);
53 mainLayout->addWidget(dialoglabel, 1, 0);
54 mainLayout->addWidget(timelabel, 2, 0);
55 mainLayout->addWidget(buttonBox, 3, 0);
56 setLayout(mainLayout);
57
58 setWindowTitle(tr("Create Room"));*/
59
60 connect(createButton, &QPushButton::clicked, this, &CreateRoomDialog::slot_create);
61 connect(cancelButton, &QPushButton::clicked, this, &CreateRoomDialog::slot_cancel);
62
63 connect(privateCB, &QCheckBox::clicked, this, &CreateRoomDialog::slot_privateCB);
64
65 connect(roomTypeTab, &QTabWidget::currentChanged, this, &CreateRoomDialog::slot_roomTypeTab);
66
67 connect(opponentStrongerRB, &QRadioButton::clicked, this, &CreateRoomDialog::slot_opponentStrongerRB);
68 connect(opponentEvenRB, &QRadioButton::clicked, this, &CreateRoomDialog::slot_opponentEvenRB);
69 connect(opponentWeakerRB, &QRadioButton::clicked, this, &CreateRoomDialog::slot_opponentWeakerRB);
70 connect(opponentAnyRB, &QRadioButton::clicked, this, &CreateRoomDialog::slot_opponentAnyRB);
71
72 connect(timeQuickRB, &QRadioButton::clicked, this, &CreateRoomDialog::slot_timeQuickRB);
73 connect(timeNormalRB, &QRadioButton::clicked, this, &CreateRoomDialog::slot_timeNormalRB);
74 connect(timePonderousRB, &QRadioButton::clicked, this, &CreateRoomDialog::slot_timePonderousRB);
75 connect(timeAnyRB, &QRadioButton::clicked, this, &CreateRoomDialog::slot_timeAnyRB);
76
77 connect(oneOnOneRB, &QRadioButton::clicked, this, &CreateRoomDialog::slot_oneOnOneRB);
78 connect(pairRB, &QRadioButton::clicked, this, &CreateRoomDialog::slot_pairRB);
79 pairRB->setEnabled(false);
80
81 connect(teachingRB, &QRadioButton::clicked, this, &CreateRoomDialog::slot_teachingRB);
82 connect(liveRB, &QRadioButton::clicked, this, &CreateRoomDialog::slot_liveRB);
83 }
84
85 void CreateRoomDialog::slot_privateCB(bool checked)
86 {
87 checked = false; //for the warning
88 passwordLabel->setEnabled(checked);
89 passwordEdit->setEnabled(checked);
90 if(!checked)
91 passwordEdit->clear();
92 }
93
94 void CreateRoomDialog::slot_roomTypeTab(void)
95 {
96 }
97 void CreateRoomDialog::slot_opponentStrongerRB(void)
98 {
99 }
100 void CreateRoomDialog::slot_opponentEvenRB(void)
101 {
102 }
103 void CreateRoomDialog::slot_opponentWeakerRB(void)
104 {
105 }
106 void CreateRoomDialog::slot_opponentAnyRB(void)
107 {
108 }
109
110 void CreateRoomDialog::slot_timeQuickRB(void)
111 {
112 }
113 void CreateRoomDialog::slot_timeNormalRB(void)
114 {
115 }
116 void CreateRoomDialog::slot_timePonderousRB(void)
117 {
118 }
119 void CreateRoomDialog::slot_timeAnyRB(void)
120 {
121 }
122 void CreateRoomDialog::slot_oneOnOneRB(void)
123 {
124 }
125 void CreateRoomDialog::slot_pairRB(void)
126 {
127 }
128 void CreateRoomDialog::slot_teachingRB(void)
129 {
130 }
131 void CreateRoomDialog::slot_liveRB(void)
132 {
133 }
134
135 CreateRoomDialog::~CreateRoomDialog()
136 {
137
138 }
139
140 void CreateRoomDialog::slot_create(void)
141 {
142 RoomCreate * room = new RoomCreate();
143 /* FIXME This could be problematic if the index
144 * can change when we remove tabs, but that's
145 * a ways away right now.*/
146 room->type = (RoomCreate::roomType)roomTypeTab->currentIndex();
147 switch(roomTypeTab->currentIndex())
148 {
149 case RoomCreate::GAME:
150 break;
151 case RoomCreate::GOMOKU:
152 break;
153 case RoomCreate::CHAT:
154 break;
155 case RoomCreate::REVIEW:
156 done(0);
157 break;
158 case RoomCreate::MULTI:
159 done(0);
160 break;
161 case RoomCreate::VARIATION:
162 done(0);
163 break;
164 }
165 connection->sendCreateRoom(room);
166 done(1);
167 }
168
169 void CreateRoomDialog::slot_cancel(void)
170 {
171 done(0);
172 }