Implement room create and join
authorunc0rr
Wed, 08 Oct 2008 13:52:31 +0000
changeset 1314 e56b178d6d62
parent 1313 f4c54e9e1b8c
child 1315 c2f09811bb8c
Implement room create and join
QTfrontend/pages.cpp
QTfrontend/pages.h
--- a/QTfrontend/pages.cpp	Wed Oct 08 13:40:29 2008 +0000
+++ b/QTfrontend/pages.cpp	Wed Oct 08 13:52:31 2008 +0000
@@ -623,14 +623,20 @@
   AbstractPage(parent)
 {
 	QGridLayout * pageLayout = new QGridLayout(this);
-	
+
+	roomName = new QLineEdit(this);
+	pageLayout->addWidget(roomName, 0, 0);
 	roomsList = new QListWidget(this);
-	pageLayout->addWidget(roomsList, 0, 0, 4, 1);
+	pageLayout->addWidget(roomsList, 1, 0, 3, 1);
 	
 	BtnBack = addButton(":/res/Exit.png", pageLayout, 4, 0, true);
 	BtnCreate = addButton(tr("Create"), pageLayout, 0, 1);
 	BtnJoin = addButton(tr("Join"), pageLayout, 1, 1);
 	BtnRefresh = addButton(tr("Refresh"), pageLayout, 2, 1);
+
+	connect(BtnCreate, SIGNAL(clicked()), this, SLOT(onCreateClick()));
+	connect(BtnJoin, SIGNAL(clicked()), this, SLOT(onJoinClick()));
+	connect(roomsList, SIGNAL(doubleClicked (const QModelIndex &)), this, SLOT(onJoinClick()));
 }
 
 void PageRoomsList::setRoomsList(const QStringList & list)
@@ -639,3 +645,29 @@
 	roomsList->addItems(list);
 	roomsList->sortItems();
 }
+
+void PageRoomsList::onCreateClick()
+{
+	if (roomName->text().size())
+		emit askForCreateRoom(roomName->text());
+	else
+		QMessageBox::critical(this,
+				tr("Error"),
+				tr("Please, select record from the list"),
+				tr("OK"));
+}
+
+void PageRoomsList::onJoinClick()
+{
+	QListWidgetItem * curritem = roomsList->currentItem();
+	if (!curritem)
+	{
+		QMessageBox::critical(this,
+				tr("Error"),
+				tr("Please, select room from the list"),
+				tr("OK"));
+		return ;
+	}
+	emit askForJoinRoom(curritem->data(Qt::DisplayRole).toString());
+}
+
--- a/QTfrontend/pages.h	Wed Oct 08 13:40:29 2008 +0000
+++ b/QTfrontend/pages.h	Wed Oct 08 13:52:31 2008 +0000
@@ -343,6 +343,7 @@
 public:
 	PageRoomsList(QWidget* parent = 0);
 
+	QLineEdit * roomName;
 	QListWidget * roomsList;
 	QPushButton * BtnBack;
 	QPushButton * BtnCreate;
@@ -351,6 +352,10 @@
 	
 public slots:
 	void setRoomsList(const QStringList & list);
+
+private slots:
+	void onCreateClick();
+	void onJoinClick();
 	
 signals:
 	void askForCreateRoom(const QString &);