QTfrontend/ui/page/pageroomslist.cpp
changeset 6732 c906dc78091f
parent 6700 e04da46ee43c
child 6735 050237b1500f
equal deleted inserted replaced
6731:ddd391083f50 6732:c906dc78091f
    22 #include <QComboBox>
    22 #include <QComboBox>
    23 #include <QLabel>
    23 #include <QLabel>
    24 #include <QLineEdit>
    24 #include <QLineEdit>
    25 #include <QMessageBox>
    25 #include <QMessageBox>
    26 #include <QHeaderView>
    26 #include <QHeaderView>
    27 #include <QTableWidget>
    27 #include <QTableView>
    28 
    28 
    29 #include "ammoSchemeModel.h"
    29 #include "ammoSchemeModel.h"
    30 #include "pageroomslist.h"
    30 #include "pageroomslist.h"
    31 #include "hwconsts.h"
    31 #include "hwconsts.h"
    32 #include "chatwidget.h"
    32 #include "chatwidget.h"
    42     roomName->setMaxLength(60);
    42     roomName->setMaxLength(60);
    43     newRoomLayout->addWidget(roomNameLabel);
    43     newRoomLayout->addWidget(roomNameLabel);
    44     newRoomLayout->addWidget(roomName);
    44     newRoomLayout->addWidget(roomName);
    45     pageLayout->addLayout(newRoomLayout, 0, 0, 1, 2);
    45     pageLayout->addLayout(newRoomLayout, 0, 0, 1, 2);
    46 
    46 
    47     roomsList = new QTableWidget(this);
    47     roomsList = new QTableView(this);
    48     roomsList->setSelectionBehavior(QAbstractItemView::SelectRows);
    48     roomsList->setSelectionBehavior(QAbstractItemView::SelectRows);
    49     roomsList->verticalHeader()->setVisible(false);
    49     roomsList->verticalHeader()->setVisible(false);
    50     roomsList->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
    50     roomsList->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
    51     roomsList->setAlternatingRowColors(true);
    51     roomsList->setAlternatingRowColors(true);
    52     roomsList->setShowGrid(false);
    52     roomsList->setShowGrid(false);
   190 void PageRoomsList::setAdmin(bool flag)
   190 void PageRoomsList::setAdmin(bool flag)
   191 {
   191 {
   192     BtnAdmin->setVisible(flag);
   192     BtnAdmin->setVisible(flag);
   193 }
   193 }
   194 
   194 
       
   195 /*
   195 void PageRoomsList::setRoomsList(const QStringList & list)
   196 void PageRoomsList::setRoomsList(const QStringList & list)
   196 {
   197 {
   197     QBrush red(QColor(255, 0, 0));
   198     QBrush red(QColor(255, 0, 0));
   198     QBrush orange(QColor(127, 127, 0));
   199     QBrush orange(QColor(127, 127, 0));
   199     QBrush yellow(QColor(255, 255, 0));
   200     QBrush yellow(QColor(255, 255, 0));
   207         selection = item->text();
   208         selection = item->text();
   208 
   209 
   209     roomsList->clear();
   210     roomsList->clear();
   210     roomsList->setColumnCount(7);
   211     roomsList->setColumnCount(7);
   211     roomsList->setHorizontalHeaderLabels(
   212     roomsList->setHorizontalHeaderLabels(
   212         QStringList() <<
   213 
   213         QTableWidget::tr("Room Name") <<
       
   214         QTableWidget::tr("C") <<
       
   215         QTableWidget::tr("T") <<
       
   216         QTableWidget::tr("Owner") <<
       
   217         QTableWidget::tr("Map") <<
       
   218         QTableWidget::tr("Rules") <<
       
   219         QTableWidget::tr("Weapons")
       
   220     );
   214     );
   221 
   215 
   222     // set minimum sizes
   216     // set minimum sizes
   223 //  roomsList->horizontalHeader()->resizeSection(0, 200);
   217 //  roomsList->horizontalHeader()->resizeSection(0, 200);
   224 //  roomsList->horizontalHeader()->resizeSection(1, 50);
   218 //  roomsList->horizontalHeader()->resizeSection(1, 50);
   409         }
   403         }
   410     }
   404     }
   411 
   405 
   412 //  roomsList->resizeColumnsToContents();
   406 //  roomsList->resizeColumnsToContents();
   413 }
   407 }
       
   408 */
   414 
   409 
   415 void PageRoomsList::onCreateClick()
   410 void PageRoomsList::onCreateClick()
   416 {
   411 {
   417     if (roomName->text().size())
   412     if (roomName->text().size())
   418         emit askForCreateRoom(roomName->text());
   413         emit askForCreateRoom(roomName->text());
   423                               tr("OK"));
   418                               tr("OK"));
   424 }
   419 }
   425 
   420 
   426 void PageRoomsList::onJoinClick()
   421 void PageRoomsList::onJoinClick()
   427 {
   422 {
       
   423     /*
   428     QTableWidgetItem * curritem = roomsList->item(roomsList->currentRow(), 0);
   424     QTableWidgetItem * curritem = roomsList->item(roomsList->currentRow(), 0);
   429     if (!curritem)
   425     if (!curritem)
   430     {
   426     {
   431         QMessageBox::critical(this,
   427         QMessageBox::critical(this,
   432                               tr("Error"),
   428                               tr("Error"),
   451     }
   447     }
   452     else
   448     else
   453     {
   449     {
   454         emit askForJoinRoom(curritem->data(Qt::DisplayRole).toString());
   450         emit askForJoinRoom(curritem->data(Qt::DisplayRole).toString());
   455     }
   451     }
       
   452 */
   456 }
   453 }
   457 
   454 
   458 void PageRoomsList::onRefreshClick()
   455 void PageRoomsList::onRefreshClick()
   459 {
   456 {
   460     emit askForRoomList();
   457     emit askForRoomList();