# HG changeset patch # User unc0rr # Date 1224691499 0 # Node ID ada2411c1d60bdd8e54ff23fca96c599829f2b71 # Parent 29eedf717d0fbd62e66137efc440a86cce9afa04 Show additional info in rooms list diff -r 29eedf717d0f -r ada2411c1d60 QTfrontend/pages.cpp --- a/QTfrontend/pages.cpp Wed Oct 22 15:45:16 2008 +0000 +++ b/QTfrontend/pages.cpp Wed Oct 22 16:04:59 2008 +0000 @@ -34,6 +34,7 @@ #include #include #include +#include #include "pages.h" #include "sdlkeys.h" @@ -634,7 +635,14 @@ roomName = new QLineEdit(this); roomName->setMaxLength(60); pageLayout->addWidget(roomName, 0, 0); - roomsList = new QListWidget(this); + + roomsList = new QTableWidget(this); + roomsList->setColumnCount(3); + roomsList->setSelectionBehavior(QAbstractItemView::SelectRows); + roomsList->verticalHeader()->setVisible(false); + roomsList->horizontalHeader()->setResizeMode(QHeaderView::Interactive); + roomsList->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch); + pageLayout->addWidget(roomsList, 1, 0, 3, 1); serverMessage = new QTextBrowser(this); serverMessage->setOpenExternalLinks(true); @@ -655,8 +663,25 @@ void PageRoomsList::setRoomsList(const QStringList & list) { roomsList->clear(); - roomsList->addItems(list); - roomsList->sortItems(); + roomsList->setHorizontalHeaderLabels( + QStringList() << + QTableWidget::tr("Room name") << + QTableWidget::tr("Players number") << + QTableWidget::tr("Round in progress") + ); + + if (list.size() % 3) + return; + + roomsList->setRowCount(list.size() / 3); + for(int i = 0; i < list.size(); i += 3) + for(int t = 0; t < 3; t++) + { + QTableWidgetItem * item = new QTableWidgetItem(list[i + t]); + item->setFlags(Qt::ItemIsSelectable); + roomsList->setItem(i, t, item); + } + //roomsList->resizeColumnsToContents(); } void PageRoomsList::onCreateClick() @@ -672,7 +697,7 @@ void PageRoomsList::onJoinClick() { - QListWidgetItem * curritem = roomsList->currentItem(); + QTableWidgetItem * curritem = roomsList->item(roomsList->currentRow(), 0); if (!curritem) { QMessageBox::critical(this, diff -r 29eedf717d0f -r ada2411c1d60 QTfrontend/pages.h --- a/QTfrontend/pages.h Wed Oct 22 15:45:16 2008 +0000 +++ b/QTfrontend/pages.h Wed Oct 22 16:04:59 2008 +0000 @@ -40,6 +40,7 @@ class QRadioButton; class QTableView; class QTextBrowser; +class QTableWidget; class GameCFGWidget; class TeamSelWidget; @@ -346,7 +347,7 @@ PageRoomsList(QWidget* parent = 0); QLineEdit * roomName; - QListWidget * roomsList; + QTableWidget * roomsList; QPushButton * BtnBack; QPushButton * BtnCreate; QPushButton * BtnJoin;