QTfrontend/ui/page/pageroomslist.cpp
changeset 6993 47830cf50574
parent 6991 1ec44dde5eb9
child 6995 6b44c0f11476
--- a/QTfrontend/ui/page/pageroomslist.cpp	Wed May 02 11:43:43 2012 +0100
+++ b/QTfrontend/ui/page/pageroomslist.cpp	Wed May 02 13:00:10 2012 +0200
@@ -28,6 +28,8 @@
 
 #include <QSortFilterProxyModel>
 
+#include "roomslistmodel.h"
+
 #include "ammoSchemeModel.h"
 #include "pageroomslist.h"
 #include "hwconsts.h"
@@ -477,28 +479,28 @@
     chatWidget->setUser(nickname);
 }
 
-void PageRoomsList::setModel(QAbstractTableModel *model)
+void PageRoomsList::setModel(RoomsListModel *model)
 {
     roomsModel = new QSortFilterProxyModel(this);
     roomsModel->setSourceModel(model);
     roomsModel->setDynamicSortFilter(true);
     roomsModel->setSortCaseSensitivity(Qt::CaseInsensitive);
-    roomsModel->sort(0, Qt::AscendingOrder);
+    roomsModel->sort(RoomsListModel::StateColumn, Qt::AscendingOrder);
     roomsList->setModel(roomsModel);
 
-    roomsList->hideColumn(0);
+    roomsList->hideColumn(RoomsListModel::StateColumn);
 
     QHeaderView * h = roomsList->horizontalHeader();
 
     h->setSortIndicatorShown(true);
 
-    h->setResizeMode(1, QHeaderView::Stretch);
-    h->resizeSection(2, 32);
-    h->resizeSection(3, 32);
-    h->resizeSection(4, 100);
-    h->resizeSection(5, 100);
-    h->resizeSection(6, 100);
-    h->resizeSection(7, 100);
+    h->setResizeMode(RoomsListModel::NameColumn, QHeaderView::Stretch);
+    h->resizeSection(RoomsListModel::PlayerCountColumn, 32);
+    h->resizeSection(RoomsListModel::TeamCountColumn, 32);
+    h->resizeSection(RoomsListModel::OwnerColumn, 100);
+    h->resizeSection(RoomsListModel::MapColumn, 100);
+    h->resizeSection(RoomsListModel::SchemeColumn, 100);
+    h->resizeSection(RoomsListModel::WeaponsColumn, 100);
 
     connect(h, SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)),
             this, SLOT(onSortIndicatorChanged(int, Qt::SortOrder)));
@@ -509,7 +511,8 @@
 {
     // three state sorting: asc -> dsc -> default (by room state)
     if ((order == Qt::AscendingOrder) && (logicalIndex == roomsModel->sortColumn()))
-        roomsList->horizontalHeader()->setSortIndicator(0, Qt::AscendingOrder);
+        roomsList->horizontalHeader()->setSortIndicator(
+            RoomsListModel::StateColumn, Qt::AscendingOrder);
     else
         roomsModel->sort(logicalIndex, order);
 }