Bring back functionality to "Join" button
authorunc0rr
Thu, 23 Feb 2012 23:13:48 +0400
changeset 6736 efad396abee9
parent 6735 050237b1500f
child 6737 ce5fbd98370f
Bring back functionality to "Join" button
QTfrontend/model/roomslistmodel.cpp
QTfrontend/ui/page/pageroomslist.cpp
QTfrontend/ui/page/pageroomslist.h
--- a/QTfrontend/model/roomslistmodel.cpp	Thu Feb 23 22:58:52 2012 +0400
+++ b/QTfrontend/model/roomslistmodel.cpp	Thu Feb 23 23:13:48 2012 +0400
@@ -5,6 +5,7 @@
 {
     m_headerData =
     QStringList()
+     << QString()
      << tr("Room Name")
      << tr("C")
      << tr("T")
@@ -35,14 +36,14 @@
     if(parent.isValid())
         return 0;
     else
-        return 7;
+        return 8;
 }
 
 QVariant RoomsListModel::data(const QModelIndex &index, int role) const
 {
     if (!index.isValid() || index.row() < 0
             || index.row() >= m_data.size()
-            || index.column() >= 7
+            || index.column() >= 8
             || (role != Qt::EditRole && role != Qt::DisplayRole)
        )
         return QVariant();
@@ -116,7 +117,6 @@
     QStringList result;
 
     result = info;
-    result.removeFirst();
 
     return result;
 }
--- a/QTfrontend/ui/page/pageroomslist.cpp	Thu Feb 23 22:58:52 2012 +0400
+++ b/QTfrontend/ui/page/pageroomslist.cpp	Thu Feb 23 23:13:48 2012 +0400
@@ -165,8 +165,6 @@
         QPair<QString,QString> ammo = cDefaultAmmos.at(i);
         CBWeapons->addItem(ammo.first.toAscii().constData());
     }
-
-    gameInLobby = false;
 }
 
 
@@ -420,9 +418,9 @@
 
 void PageRoomsList::onJoinClick()
 {
-    /*
-    QTableWidgetItem * curritem = roomsList->item(roomsList->currentRow(), 0);
-    if (!curritem)
+    QModelIndexList mdl = roomsList->selectionModel()->selectedRows();
+
+    if(mdl.size() != 1)
     {
         QMessageBox::critical(this,
                               tr("Error"),
@@ -431,25 +429,13 @@
         return;
     }
 
-    for (int i = 0; i < listFromServer.size(); i += 8)
-    {
-        if (listFromServer[i + 1] == curritem->data(Qt::DisplayRole).toString())
-        {
-            gameInLobby = listFromServer[i].compare("True");
-            break;
-        }
-    }
+    bool gameInLobby = roomsList->model()->index(mdl[0].row(), 0).data().toString().compare("True");
+    QString roomName = roomsList->model()->index(mdl[0].row(), 1).data().toString();
 
-    if (gameInLobby)
-    {
-        gameInLobbyName = curritem->data(Qt::DisplayRole).toString();
-        emit askForRoomList();
-    }
+    if (!gameInLobby)
+        emit askJoinConfirmation(roomName);
     else
-    {
-        emit askForJoinRoom(curritem->data(Qt::DisplayRole).toString());
-    }
-*/
+        emit askForJoinRoom(roomName);
 }
 
 void PageRoomsList::onRefreshClick()
@@ -490,12 +476,14 @@
 {
     roomsList->setModel(model);
 
+    roomsList->hideColumn(0);
+
     QHeaderView * h = roomsList->horizontalHeader();
-    h->resizeSection(0, 200);
-    h->resizeSection(1, 50);
+    h->resizeSection(1, 200);
     h->resizeSection(2, 50);
-    h->resizeSection(3, 100);
+    h->resizeSection(3, 50);
     h->resizeSection(4, 100);
     h->resizeSection(5, 100);
     h->resizeSection(6, 100);
+    h->resizeSection(7, 100);
 }
--- a/QTfrontend/ui/page/pageroomslist.h	Thu Feb 23 22:58:52 2012 +0400
+++ b/QTfrontend/ui/page/pageroomslist.h	Thu Feb 23 23:13:48 2012 +0400
@@ -77,9 +77,6 @@
     private:
         QSettings * m_gameSettings;
 
-        bool gameInLobby;
-        QString gameInLobbyName;
-        QStringList listFromServer;
         AmmoSchemeModel * ammoSchemeModel;
 
 };