632 QGridLayout * pageLayout = new QGridLayout(this); |
633 QGridLayout * pageLayout = new QGridLayout(this); |
633 |
634 |
634 roomName = new QLineEdit(this); |
635 roomName = new QLineEdit(this); |
635 roomName->setMaxLength(60); |
636 roomName->setMaxLength(60); |
636 pageLayout->addWidget(roomName, 0, 0); |
637 pageLayout->addWidget(roomName, 0, 0); |
637 roomsList = new QListWidget(this); |
638 |
|
639 roomsList = new QTableWidget(this); |
|
640 roomsList->setColumnCount(3); |
|
641 roomsList->setSelectionBehavior(QAbstractItemView::SelectRows); |
|
642 roomsList->verticalHeader()->setVisible(false); |
|
643 roomsList->horizontalHeader()->setResizeMode(QHeaderView::Interactive); |
|
644 roomsList->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch); |
|
645 |
638 pageLayout->addWidget(roomsList, 1, 0, 3, 1); |
646 pageLayout->addWidget(roomsList, 1, 0, 3, 1); |
639 serverMessage = new QTextBrowser(this); |
647 serverMessage = new QTextBrowser(this); |
640 serverMessage->setOpenExternalLinks(true); |
648 serverMessage->setOpenExternalLinks(true); |
641 pageLayout->addWidget(serverMessage, 4, 0, 1, 2); |
649 pageLayout->addWidget(serverMessage, 4, 0, 1, 2); |
642 |
650 |
653 |
661 |
654 |
662 |
655 void PageRoomsList::setRoomsList(const QStringList & list) |
663 void PageRoomsList::setRoomsList(const QStringList & list) |
656 { |
664 { |
657 roomsList->clear(); |
665 roomsList->clear(); |
658 roomsList->addItems(list); |
666 roomsList->setHorizontalHeaderLabels( |
659 roomsList->sortItems(); |
667 QStringList() << |
|
668 QTableWidget::tr("Room name") << |
|
669 QTableWidget::tr("Players number") << |
|
670 QTableWidget::tr("Round in progress") |
|
671 ); |
|
672 |
|
673 if (list.size() % 3) |
|
674 return; |
|
675 |
|
676 roomsList->setRowCount(list.size() / 3); |
|
677 for(int i = 0; i < list.size(); i += 3) |
|
678 for(int t = 0; t < 3; t++) |
|
679 { |
|
680 QTableWidgetItem * item = new QTableWidgetItem(list[i + t]); |
|
681 item->setFlags(Qt::ItemIsSelectable); |
|
682 roomsList->setItem(i, t, item); |
|
683 } |
|
684 //roomsList->resizeColumnsToContents(); |
660 } |
685 } |
661 |
686 |
662 void PageRoomsList::onCreateClick() |
687 void PageRoomsList::onCreateClick() |
663 { |
688 { |
664 if (roomName->text().size()) |
689 if (roomName->text().size()) |
670 tr("OK")); |
695 tr("OK")); |
671 } |
696 } |
672 |
697 |
673 void PageRoomsList::onJoinClick() |
698 void PageRoomsList::onJoinClick() |
674 { |
699 { |
675 QListWidgetItem * curritem = roomsList->currentItem(); |
700 QTableWidgetItem * curritem = roomsList->item(roomsList->currentRow(), 0); |
676 if (!curritem) |
701 if (!curritem) |
677 { |
702 { |
678 QMessageBox::critical(this, |
703 QMessageBox::critical(this, |
679 tr("Error"), |
704 tr("Error"), |
680 tr("Please, select room from the list"), |
705 tr("Please, select room from the list"), |