QTfrontend/ui/page/pageroomslist.cpp
author unc0rr
Sat, 20 Oct 2012 18:54:03 +0400
changeset 7769 1661680c6b59
parent 7011 f6f09a0954ea
child 7794 ab7b94c03bc9
permissions -rw-r--r--
Don't need this button anymore
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
     1
/*
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
     2
 * Hedgewars, a free turn based strategy game
6952
7f70f37bbf08 license header year range adjustments
sheepluva
parents: 6736
diff changeset
     3
 * Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com>
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
     4
 *
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
     8
 *
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    12
 * GNU General Public License for more details.
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    13
 *
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    17
 */
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    18
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    19
#include <QGridLayout>
6172
809e1076ffe2 fix lobby layout issues
sheepluva
parents: 6165
diff changeset
    20
#include <QHBoxLayout>
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    21
#include <QPushButton>
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    22
#include <QComboBox>
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    23
#include <QLabel>
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    24
#include <QLineEdit>
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    25
#include <QMessageBox>
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    26
#include <QHeaderView>
6732
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents: 6700
diff changeset
    27
#include <QTableView>
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    28
6987
e34415c77342 allow custom sorting of roomslist (by clicking on header sections)
sheepluva
parents: 6977
diff changeset
    29
#include <QSortFilterProxyModel>
e34415c77342 allow custom sorting of roomslist (by clicking on header sections)
sheepluva
parents: 6977
diff changeset
    30
6993
47830cf50574 room list: replace magic table column indexes with enum. makes future changes to the room list format way easier.
sheepluva
parents: 6991
diff changeset
    31
#include "roomslistmodel.h"
47830cf50574 room list: replace magic table column indexes with enum. makes future changes to the room list format way easier.
sheepluva
parents: 6991
diff changeset
    32
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    33
#include "ammoSchemeModel.h"
5204
e1a5f4d5d86a split pages.h into several header files
koda
parents: 5078
diff changeset
    34
#include "pageroomslist.h"
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    35
#include "hwconsts.h"
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    36
#include "chatwidget.h"
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    37
6042
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
    38
QLayout * PageRoomsList::bodyLayoutDefinition()
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    39
{
6042
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
    40
    QGridLayout * pageLayout = new QGridLayout();
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    41
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    42
    QHBoxLayout * newRoomLayout = new QHBoxLayout();
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    43
    QLabel * roomNameLabel = new QLabel(this);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    44
    roomNameLabel->setText(tr("Room Name:"));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    45
    roomName = new QLineEdit(this);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    46
    roomName->setMaxLength(60);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    47
    newRoomLayout->addWidget(roomNameLabel);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    48
    newRoomLayout->addWidget(roomName);
5259
926958e3e87b display player count below and with label, just because it's funny to mess with unC0Rr's code and make him cry :P
sheepluva
parents: 5204
diff changeset
    49
    pageLayout->addLayout(newRoomLayout, 0, 0, 1, 2);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    50
6732
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents: 6700
diff changeset
    51
    roomsList = new QTableView(this);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    52
    roomsList->setSelectionBehavior(QAbstractItemView::SelectRows);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    53
    roomsList->verticalHeader()->setVisible(false);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    54
    roomsList->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    55
    roomsList->setAlternatingRowColors(true);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    56
    roomsList->setShowGrid(false);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    57
    roomsList->setSelectionMode(QAbstractItemView::SingleSelection);
5259
926958e3e87b display player count below and with label, just because it's funny to mess with unC0Rr's code and make him cry :P
sheepluva
parents: 5204
diff changeset
    58
    pageLayout->addWidget(roomsList, 1, 0, 3, 2);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    59
    pageLayout->setRowStretch(2, 100);
6009
14f6fc9869f2 code cleanup/etc
sheepluva
parents: 5602
diff changeset
    60
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    61
    QHBoxLayout * filterLayout = new QHBoxLayout();
6009
14f6fc9869f2 code cleanup/etc
sheepluva
parents: 5602
diff changeset
    62
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    63
    QLabel * stateLabel = new QLabel(this);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    64
    CBState = new QComboBox(this);
6042
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
    65
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    66
    filterLayout->addWidget(stateLabel);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    67
    filterLayout->addWidget(CBState);
6991
1ec44dde5eb9 make search filter field have a useable size on low frontend resolution
sheepluva
parents: 6989
diff changeset
    68
    filterLayout->addStretch(1);
6009
14f6fc9869f2 code cleanup/etc
sheepluva
parents: 5602
diff changeset
    69
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    70
    QLabel * ruleLabel = new QLabel(this);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    71
    ruleLabel->setText(tr("Rules:"));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    72
    CBRules = new QComboBox(this);
6042
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
    73
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    74
    filterLayout->addWidget(ruleLabel);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    75
    filterLayout->addWidget(CBRules);
6991
1ec44dde5eb9 make search filter field have a useable size on low frontend resolution
sheepluva
parents: 6989
diff changeset
    76
    filterLayout->addStretch(1);
6009
14f6fc9869f2 code cleanup/etc
sheepluva
parents: 5602
diff changeset
    77
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    78
    QLabel * weaponLabel = new QLabel(this);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    79
    weaponLabel->setText(tr("Weapons:"));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    80
    CBWeapons = new QComboBox(this);
6042
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
    81
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    82
    filterLayout->addWidget(weaponLabel);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    83
    filterLayout->addWidget(CBWeapons);
6991
1ec44dde5eb9 make search filter field have a useable size on low frontend resolution
sheepluva
parents: 6989
diff changeset
    84
    filterLayout->addStretch(1);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    85
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    86
    QLabel * searchLabel = new QLabel(this);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    87
    searchLabel->setText(tr("Search:"));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    88
    searchText = new QLineEdit(this);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    89
    searchText->setMaxLength(60);
6991
1ec44dde5eb9 make search filter field have a useable size on low frontend resolution
sheepluva
parents: 6989
diff changeset
    90
    searchText->setMinimumWidth(100);
1ec44dde5eb9 make search filter field have a useable size on low frontend resolution
sheepluva
parents: 6989
diff changeset
    91
    searchText->setMaximumWidth(360);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    92
    filterLayout->addWidget(searchLabel);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    93
    filterLayout->addWidget(searchText);
6991
1ec44dde5eb9 make search filter field have a useable size on low frontend resolution
sheepluva
parents: 6989
diff changeset
    94
    filterLayout->setStretchFactor(searchText, 2);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    95
5259
926958e3e87b display player count below and with label, just because it's funny to mess with unC0Rr's code and make him cry :P
sheepluva
parents: 5204
diff changeset
    96
    pageLayout->addLayout(filterLayout, 4, 0, 1, 2);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    97
6165
6fe3e922246e moving and renaming SDLs.*, making it a singleton; cleaning up class responsibilties wrt SDLInteraction; some comments
sheepluva
parents: 6146
diff changeset
    98
    chatWidget = new HWChatWidget(this, m_gameSettings, false);
5259
926958e3e87b display player count below and with label, just because it's funny to mess with unC0Rr's code and make him cry :P
sheepluva
parents: 5204
diff changeset
    99
    pageLayout->addWidget(chatWidget, 5, 0, 1, 3);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   100
    pageLayout->setRowStretch(5, 350);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   101
5259
926958e3e87b display player count below and with label, just because it's funny to mess with unC0Rr's code and make him cry :P
sheepluva
parents: 5204
diff changeset
   102
    BtnCreate = addButton(tr("Create"), pageLayout, 0, 2);
926958e3e87b display player count below and with label, just because it's funny to mess with unC0Rr's code and make him cry :P
sheepluva
parents: 5204
diff changeset
   103
    BtnJoin = addButton(tr("Join"), pageLayout, 1, 2);
926958e3e87b display player count below and with label, just because it's funny to mess with unC0Rr's code and make him cry :P
sheepluva
parents: 5204
diff changeset
   104
    BtnClear = addButton(tr("Clear"), pageLayout, 4, 2);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   105
6146
c7c2dd71ced4 server lobby: don't stretch buttons right of the roomlist - instead let the roomlist use all the available space
sheepluva
parents: 6060
diff changeset
   106
    // strech all but the buttons column
c7c2dd71ced4 server lobby: don't stretch buttons right of the roomlist - instead let the roomlist use all the available space
sheepluva
parents: 6060
diff changeset
   107
    pageLayout->setColumnStretch(0, 1);
c7c2dd71ced4 server lobby: don't stretch buttons right of the roomlist - instead let the roomlist use all the available space
sheepluva
parents: 6060
diff changeset
   108
    pageLayout->setColumnStretch(1, 1);
c7c2dd71ced4 server lobby: don't stretch buttons right of the roomlist - instead let the roomlist use all the available space
sheepluva
parents: 6060
diff changeset
   109
    pageLayout->setColumnStretch(2, 0);
c7c2dd71ced4 server lobby: don't stretch buttons right of the roomlist - instead let the roomlist use all the available space
sheepluva
parents: 6060
diff changeset
   110
6042
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   111
    CBRules->addItem(QComboBox::tr("Any"));
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   112
    CBState->addItem(QComboBox::tr("Any"));
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   113
    CBState->addItem(QComboBox::tr("In lobby"));
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   114
    CBState->addItem(QComboBox::tr("In progress"));
6009
14f6fc9869f2 code cleanup/etc
sheepluva
parents: 5602
diff changeset
   115
6042
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   116
    return pageLayout;
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   117
}
6009
14f6fc9869f2 code cleanup/etc
sheepluva
parents: 5602
diff changeset
   118
6042
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   119
QLayout * PageRoomsList::footerLayoutDefinition()
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   120
{
6172
809e1076ffe2 fix lobby layout issues
sheepluva
parents: 6165
diff changeset
   121
    QHBoxLayout * bottomLayout = new QHBoxLayout();
5259
926958e3e87b display player count below and with label, just because it's funny to mess with unC0Rr's code and make him cry :P
sheepluva
parents: 5204
diff changeset
   122
926958e3e87b display player count below and with label, just because it's funny to mess with unC0Rr's code and make him cry :P
sheepluva
parents: 5204
diff changeset
   123
    lblCount = new QLabel(this);
6172
809e1076ffe2 fix lobby layout issues
sheepluva
parents: 6165
diff changeset
   124
    bottomLayout->addWidget(lblCount, 0, Qt::AlignHCenter);
809e1076ffe2 fix lobby layout issues
sheepluva
parents: 6165
diff changeset
   125
    bottomLayout->setStretchFactor(lblCount, 1);
5259
926958e3e87b display player count below and with label, just because it's funny to mess with unC0Rr's code and make him cry :P
sheepluva
parents: 5204
diff changeset
   126
    lblCount->setText("?");
926958e3e87b display player count below and with label, just because it's funny to mess with unC0Rr's code and make him cry :P
sheepluva
parents: 5204
diff changeset
   127
    lblCount->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
926958e3e87b display player count below and with label, just because it's funny to mess with unC0Rr's code and make him cry :P
sheepluva
parents: 5204
diff changeset
   128
6172
809e1076ffe2 fix lobby layout issues
sheepluva
parents: 6165
diff changeset
   129
    BtnAdmin = addButton(tr("Admin features"), bottomLayout, 1);
809e1076ffe2 fix lobby layout issues
sheepluva
parents: 6165
diff changeset
   130
    BtnAdmin->setMinimumWidth(160);
809e1076ffe2 fix lobby layout issues
sheepluva
parents: 6165
diff changeset
   131
809e1076ffe2 fix lobby layout issues
sheepluva
parents: 6165
diff changeset
   132
    // strech left part
809e1076ffe2 fix lobby layout issues
sheepluva
parents: 6165
diff changeset
   133
    bottomLayout->setStretch(0, 1);
809e1076ffe2 fix lobby layout issues
sheepluva
parents: 6165
diff changeset
   134
    bottomLayout->setStretch(1, 0);
5259
926958e3e87b display player count below and with label, just because it's funny to mess with unC0Rr's code and make him cry :P
sheepluva
parents: 5204
diff changeset
   135
6042
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   136
    return bottomLayout;
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   137
}
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   138
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   139
void PageRoomsList::connectSignals()
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   140
{
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   141
    connect(chatWidget, SIGNAL(nickCountUpdate(const int)), this, SLOT(updateNickCounter(const int)));
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   142
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   143
    connect(BtnCreate, SIGNAL(clicked()), this, SLOT(onCreateClick()));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   144
    connect(BtnJoin, SIGNAL(clicked()), this, SLOT(onJoinClick()));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   145
    connect(BtnClear, SIGNAL(clicked()), this, SLOT(onClearClick()));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   146
    connect(roomsList, SIGNAL(doubleClicked (const QModelIndex &)), this, SLOT(onJoinClick()));
6995
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   147
    connect(CBState, SIGNAL(currentIndexChanged (int)), this, SLOT(onFilterChanged()));
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   148
    connect(CBRules, SIGNAL(currentIndexChanged (int)), this, SLOT(onFilterChanged()));
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   149
    connect(CBWeapons, SIGNAL(currentIndexChanged (int)), this, SLOT(onFilterChanged()));
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   150
    connect(searchText, SIGNAL(textChanged (const QString &)), this, SLOT(onFilterChanged()));
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   151
    connect(this, SIGNAL(askJoinConfirmation (const QString &)), this, SLOT(onJoinConfirmation(const QString &)), Qt::QueuedConnection);
6995
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   152
6996
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   153
    // sorting
6995
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   154
    connect(roomsList->horizontalHeader(), SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)),
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   155
            this, SLOT(onSortIndicatorChanged(int, Qt::SortOrder)));
6042
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   156
}
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   157
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   158
6165
6fe3e922246e moving and renaming SDLs.*, making it a singleton; cleaning up class responsibilties wrt SDLInteraction; some comments
sheepluva
parents: 6146
diff changeset
   159
PageRoomsList::PageRoomsList(QWidget* parent, QSettings * gameSettings) :
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   160
    AbstractPage(parent)
6042
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   161
{
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   162
    m_gameSettings = gameSettings;
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   163
6995
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   164
    roomsModel = NULL;
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   165
    stateFilteredModel = NULL;
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   166
    schemeFilteredModel = NULL;
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   167
    weaponsFilteredModel = NULL;
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   168
6042
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   169
    initPage();
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   170
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   171
    // not the most elegant solution but it works
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   172
    ammoSchemeModel = new AmmoSchemeModel(this, NULL);
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   173
    for (int i = 0; i < ammoSchemeModel->predefSchemesNames.count(); i++)
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   174
        CBRules->addItem(ammoSchemeModel->predefSchemesNames.at(i).toAscii().constData());
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   175
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   176
    CBWeapons->addItem(QComboBox::tr("Any"));
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   177
    for (int i = 0; i < cDefaultAmmos.count(); i++)
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   178
    {
6042
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   179
        QPair<QString,QString> ammo = cDefaultAmmos.at(i);
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   180
        CBWeapons->addItem(ammo.first.toAscii().constData());
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   181
    }
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   182
}
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   183
6180
0992fc5a4ad9 some changes to the css... display:none; works now (e.g. you can use it for user join/leave messages that are not your friends)
sheepluva
parents: 6172
diff changeset
   184
0992fc5a4ad9 some changes to the css... display:none; works now (e.g. you can use it for user join/leave messages that are not your friends)
sheepluva
parents: 6172
diff changeset
   185
void PageRoomsList::displayError(const QString & message)
0992fc5a4ad9 some changes to the css... display:none; works now (e.g. you can use it for user join/leave messages that are not your friends)
sheepluva
parents: 6172
diff changeset
   186
{
0992fc5a4ad9 some changes to the css... display:none; works now (e.g. you can use it for user join/leave messages that are not your friends)
sheepluva
parents: 6172
diff changeset
   187
    chatWidget->displayError(message);
0992fc5a4ad9 some changes to the css... display:none; works now (e.g. you can use it for user join/leave messages that are not your friends)
sheepluva
parents: 6172
diff changeset
   188
}
0992fc5a4ad9 some changes to the css... display:none; works now (e.g. you can use it for user join/leave messages that are not your friends)
sheepluva
parents: 6172
diff changeset
   189
0992fc5a4ad9 some changes to the css... display:none; works now (e.g. you can use it for user join/leave messages that are not your friends)
sheepluva
parents: 6172
diff changeset
   190
0992fc5a4ad9 some changes to the css... display:none; works now (e.g. you can use it for user join/leave messages that are not your friends)
sheepluva
parents: 6172
diff changeset
   191
void PageRoomsList::displayNotice(const QString & message)
0992fc5a4ad9 some changes to the css... display:none; works now (e.g. you can use it for user join/leave messages that are not your friends)
sheepluva
parents: 6172
diff changeset
   192
{
0992fc5a4ad9 some changes to the css... display:none; works now (e.g. you can use it for user join/leave messages that are not your friends)
sheepluva
parents: 6172
diff changeset
   193
    chatWidget->displayNotice(message);
0992fc5a4ad9 some changes to the css... display:none; works now (e.g. you can use it for user join/leave messages that are not your friends)
sheepluva
parents: 6172
diff changeset
   194
}
0992fc5a4ad9 some changes to the css... display:none; works now (e.g. you can use it for user join/leave messages that are not your friends)
sheepluva
parents: 6172
diff changeset
   195
0992fc5a4ad9 some changes to the css... display:none; works now (e.g. you can use it for user join/leave messages that are not your friends)
sheepluva
parents: 6172
diff changeset
   196
void PageRoomsList::displayWarning(const QString & message)
0992fc5a4ad9 some changes to the css... display:none; works now (e.g. you can use it for user join/leave messages that are not your friends)
sheepluva
parents: 6172
diff changeset
   197
{
0992fc5a4ad9 some changes to the css... display:none; works now (e.g. you can use it for user join/leave messages that are not your friends)
sheepluva
parents: 6172
diff changeset
   198
    chatWidget->displayWarning(message);
0992fc5a4ad9 some changes to the css... display:none; works now (e.g. you can use it for user join/leave messages that are not your friends)
sheepluva
parents: 6172
diff changeset
   199
}
0992fc5a4ad9 some changes to the css... display:none; works now (e.g. you can use it for user join/leave messages that are not your friends)
sheepluva
parents: 6172
diff changeset
   200
0992fc5a4ad9 some changes to the css... display:none; works now (e.g. you can use it for user join/leave messages that are not your friends)
sheepluva
parents: 6172
diff changeset
   201
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   202
void PageRoomsList::setAdmin(bool flag)
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   203
{
5283
koda
parents: 5281
diff changeset
   204
    BtnAdmin->setVisible(flag);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   205
}
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   206
6732
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents: 6700
diff changeset
   207
/*
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   208
void PageRoomsList::setRoomsList(const QStringList & list)
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   209
{
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   210
    QBrush red(QColor(255, 0, 0));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   211
    QBrush orange(QColor(127, 127, 0));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   212
    QBrush yellow(QColor(255, 255, 0));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   213
    QBrush green(QColor(0, 255, 0));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   214
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   215
    listFromServer = list;
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   216
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   217
    QString selection = "";
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   218
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   219
    if(QTableWidgetItem *item = roomsList->item(roomsList->currentRow(), 0))
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   220
        selection = item->text();
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   221
5283
koda
parents: 5281
diff changeset
   222
    roomsList->clear();
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   223
    roomsList->setColumnCount(7);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   224
    roomsList->setHorizontalHeaderLabels(
6732
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents: 6700
diff changeset
   225
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   226
    );
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   227
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   228
    // set minimum sizes
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   229
//  roomsList->horizontalHeader()->resizeSection(0, 200);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   230
//  roomsList->horizontalHeader()->resizeSection(1, 50);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   231
//  roomsList->horizontalHeader()->resizeSection(2, 50);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   232
//  roomsList->horizontalHeader()->resizeSection(3, 100);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   233
//  roomsList->horizontalHeader()->resizeSection(4, 100);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   234
//  roomsList->horizontalHeader()->resizeSection(5, 100);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   235
//  roomsList->horizontalHeader()->resizeSection(6, 100);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   236
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   237
    // set resize modes
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   238
//  roomsList->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   239
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   240
    bool gameCanBeJoined = true;
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   241
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   242
    if (list.size() % 8)
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   243
        return;
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   244
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   245
    roomsList->setRowCount(list.size() / 8);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   246
    for(int i = 0, r = 0; i < list.size(); i += 8, r++)
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   247
    {
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   248
        // if we are joining a game
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   249
        // TODO: Should NOT be done here
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   250
        if (gameInLobby)
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   251
        {
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   252
            if (gameInLobbyName == list[i + 1])
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   253
            {
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   254
                gameCanBeJoined = list[i].compare("True");
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   255
            }
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   256
        }
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   257
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   258
        // check filter settings
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   259
#define NO_FILTER_MATCH roomsList->setRowCount(roomsList->rowCount() - 1); --r; continue
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   260
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   261
        if (list[i].compare("True") && CBState->currentIndex() == 2)
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   262
        {
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   263
            NO_FILTER_MATCH;
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   264
        }
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   265
        if (list[i].compare("False") && CBState->currentIndex() == 1)
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   266
        {
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   267
            NO_FILTER_MATCH;
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   268
        }
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   269
        if (CBRules->currentIndex() != 0 && list[i + 6].compare(CBRules->currentText()))
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   270
        {
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   271
            NO_FILTER_MATCH;
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   272
        }
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   273
        if (CBWeapons->currentIndex() != 0 && list[i + 7].compare(CBWeapons->currentText()))
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   274
        {
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   275
            NO_FILTER_MATCH;
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   276
        }
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   277
        bool found = list[i + 1].contains(searchText->text(), Qt::CaseInsensitive);
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   278
        if (!found)
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   279
        {
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   280
            for (int a = 4; a <= 7; ++a)
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   281
            {
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   282
                QString compString = list[i + a];
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   283
                if (a == 5 && compString == "+rnd+")
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   284
                {
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   285
                    compString = "Random Map";
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   286
                }
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   287
                else if (a == 5 && compString == "+maze+")
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   288
                {
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   289
                    compString = "Random Maze";
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   290
                }
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   291
                else if (a == 5 && compString == "+drawn+")
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   292
                {
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   293
                    compString = "Drawn Map";
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   294
                }
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   295
                if (compString.contains(searchText->text(), Qt::CaseInsensitive))
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   296
                {
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   297
                    found = true;
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   298
                    break;
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   299
                }
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   300
            }
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   301
        }
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   302
        if (!searchText->text().isEmpty() && !found)
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   303
        {
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   304
            NO_FILTER_MATCH;
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   305
        }
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   306
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   307
        QTableWidgetItem * item;
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   308
        item = new QTableWidgetItem(list[i + 1]); // room name
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   309
        item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   310
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   311
        // pick appropriate room icon and tooltip (game in progress yes/no; later maybe locked rooms etc.)
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   312
        if(list[i].compare("True"))
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   313
        {
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   314
            item->setIcon(QIcon(":/res/iconTime.png"));// game is in lobby
6699
83dd3447a212 exploit the new setWhatsThis feature in our desktop frontend
koda
parents: 6616
diff changeset
   315
            item->setToolTip(tr("Waiting..."));
83dd3447a212 exploit the new setWhatsThis feature in our desktop frontend
koda
parents: 6616
diff changeset
   316
            item->setWhatsThis(tr("This game is in lobby: you may join and start playing once the game starts."));
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   317
        }
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   318
        else
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   319
        {
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   320
            item->setIcon(QIcon(":/res/iconDamage.png"));// game has started
6699
83dd3447a212 exploit the new setWhatsThis feature in our desktop frontend
koda
parents: 6616
diff changeset
   321
            item->setToolTip(tr("In progress..."));
83dd3447a212 exploit the new setWhatsThis feature in our desktop frontend
koda
parents: 6616
diff changeset
   322
            item->setWhatsThis(tr("This game is in progress: you may join and spectate now but you'll have to wait for the game to end to start playing."));
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   323
        }
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   324
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   325
        roomsList->setItem(r, 0, item);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   326
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   327
        item = new QTableWidgetItem(list[i + 2]); // number of clients
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   328
        item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   329
        item->setTextAlignment(Qt::AlignCenter);
6699
83dd3447a212 exploit the new setWhatsThis feature in our desktop frontend
koda
parents: 6616
diff changeset
   330
        item->setWhatsThis(tr("There are %1 clients connected to this room.", "", list[i + 2].toInt()).arg(list[i + 2]));
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   331
        roomsList->setItem(r, 1, item);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   332
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   333
        item = new QTableWidgetItem(list[i + 3]); // number of teams
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   334
        item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   335
        item->setTextAlignment(Qt::AlignCenter);
6699
83dd3447a212 exploit the new setWhatsThis feature in our desktop frontend
koda
parents: 6616
diff changeset
   336
        item->setWhatsThis(tr("There are %1 teams participating in this room.", "", list[i + 3].toInt()).arg(list[i + 3]));
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   337
        //Should we highlight "full" games? Might get misinterpreted
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   338
        //if(list[i + 3].toInt() >= cMaxTeams)
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   339
        //    item->setForeground(red);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   340
        roomsList->setItem(r, 2, item);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   341
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   342
        item = new QTableWidgetItem(list[i + 4].left(15)); // name of host
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   343
        item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
6699
83dd3447a212 exploit the new setWhatsThis feature in our desktop frontend
koda
parents: 6616
diff changeset
   344
        item->setWhatsThis(tr("%1 is the host. He may adjust settings and start the game.").arg(list[i + 4]));
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   345
        roomsList->setItem(r, 3, item);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   346
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   347
        if(list[i + 5] == "+rnd+")
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   348
        {
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   349
            item = new QTableWidgetItem(tr("Random Map")); // selected map (is randomized)
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   350
// FIXME - need real icons. Disabling until then
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   351
//            item->setIcon(QIcon(":/res/mapRandom.png"));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   352
        }
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   353
        else if (list[i+5] == "+maze+")
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   354
        {
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   355
            item = new QTableWidgetItem(tr("Random Maze"));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   356
// FIXME - need real icons. Disabling until then
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   357
//            item->setIcon(QIcon(":/res/mapMaze.png"));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   358
        }
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   359
        else
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   360
        {
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   361
            item = new QTableWidgetItem(list[i + 5]); // selected map
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   362
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   363
            // check to see if we've got this map
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   364
            // not perfect but a start
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   365
            if(!mapList->contains(list[i + 5]))
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   366
            {
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   367
                item->setForeground(red);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   368
                item->setIcon(QIcon(":/res/mapMissing.png"));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   369
            }
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   370
            else
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   371
            {
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   372
                // todo: mission icon?
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   373
// FIXME - need real icons. Disabling until then
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   374
//               item->setIcon(QIcon(":/res/mapCustom.png"));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   375
            }
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   376
        }
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   377
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   378
        item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
6699
83dd3447a212 exploit the new setWhatsThis feature in our desktop frontend
koda
parents: 6616
diff changeset
   379
        item->setWhatsThis(tr("Games may be played on precreated or randomized maps."));
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   380
        roomsList->setItem(r, 4, item);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   381
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   382
        item = new QTableWidgetItem(list[i + 6].left(24)); // selected game scheme
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   383
        item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
6699
83dd3447a212 exploit the new setWhatsThis feature in our desktop frontend
koda
parents: 6616
diff changeset
   384
        item->setWhatsThis(tr("The Game Scheme defines general options and preferences like Round Time, Sudden Death or Vampirism."));
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   385
        roomsList->setItem(r, 5, item);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   386
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   387
        item = new QTableWidgetItem(list[i + 7].left(24)); // selected weapon scheme
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   388
        item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
6699
83dd3447a212 exploit the new setWhatsThis feature in our desktop frontend
koda
parents: 6616
diff changeset
   389
        item->setWhatsThis(tr("The Weapon Scheme defines available weapons and their ammunition count."));
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   390
        roomsList->setItem(r, 6, item);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   391
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   392
        if(!list[i + 1].compare(selection) && !selection.isEmpty())
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   393
            roomsList->selectionModel()->setCurrentIndex(roomsList->model()->index(r, 0), QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   394
    }
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   395
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   396
    roomsList->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   397
    roomsList->horizontalHeader()->setResizeMode(1, QHeaderView::ResizeToContents);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   398
    roomsList->horizontalHeader()->setResizeMode(2, QHeaderView::ResizeToContents);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   399
    roomsList->horizontalHeader()->setResizeMode(3, QHeaderView::ResizeToContents);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   400
    roomsList->horizontalHeader()->setResizeMode(4, QHeaderView::ResizeToContents);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   401
    roomsList->horizontalHeader()->setResizeMode(5, QHeaderView::ResizeToContents);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   402
    roomsList->horizontalHeader()->setResizeMode(6, QHeaderView::ResizeToContents);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   403
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   404
    // TODO: Should NOT be done here
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   405
    if (gameInLobby)
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   406
    {
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   407
        gameInLobby = false;
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   408
        if (gameCanBeJoined)
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   409
        {
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   410
            emit askForJoinRoom(gameInLobbyName);
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   411
        }
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   412
        else
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   413
        {
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   414
            emit askJoinConfirmation(gameInLobbyName);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   415
        }
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   416
    }
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   417
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   418
//  roomsList->resizeColumnsToContents();
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   419
}
6732
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents: 6700
diff changeset
   420
*/
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   421
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   422
void PageRoomsList::onCreateClick()
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   423
{
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   424
    if (roomName->text().size())
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   425
        emit askForCreateRoom(roomName->text());
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   426
    else
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   427
        QMessageBox::critical(this,
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   428
                              tr("Error"),
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   429
                              tr("Please enter room name"),
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   430
                              tr("OK"));
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   431
}
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   432
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   433
void PageRoomsList::onJoinClick()
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   434
{
6736
efad396abee9 Bring back functionality to "Join" button
unc0rr
parents: 6735
diff changeset
   435
    QModelIndexList mdl = roomsList->selectionModel()->selectedRows();
efad396abee9 Bring back functionality to "Join" button
unc0rr
parents: 6735
diff changeset
   436
efad396abee9 Bring back functionality to "Join" button
unc0rr
parents: 6735
diff changeset
   437
    if(mdl.size() != 1)
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   438
    {
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   439
        QMessageBox::critical(this,
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   440
                              tr("Error"),
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   441
                              tr("Please select room from the list"),
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   442
                              tr("OK"));
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   443
        return;
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   444
    }
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   445
6736
efad396abee9 Bring back functionality to "Join" button
unc0rr
parents: 6735
diff changeset
   446
    bool gameInLobby = roomsList->model()->index(mdl[0].row(), 0).data().toString().compare("True");
efad396abee9 Bring back functionality to "Join" button
unc0rr
parents: 6735
diff changeset
   447
    QString roomName = roomsList->model()->index(mdl[0].row(), 1).data().toString();
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   448
6736
efad396abee9 Bring back functionality to "Join" button
unc0rr
parents: 6735
diff changeset
   449
    if (!gameInLobby)
efad396abee9 Bring back functionality to "Join" button
unc0rr
parents: 6735
diff changeset
   450
        emit askJoinConfirmation(roomName);
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   451
    else
6736
efad396abee9 Bring back functionality to "Join" button
unc0rr
parents: 6735
diff changeset
   452
        emit askForJoinRoom(roomName);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   453
}
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   454
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   455
void PageRoomsList::onRefreshClick()
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   456
{
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   457
    emit askForRoomList();
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   458
}
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   459
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   460
void PageRoomsList::onClearClick()
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   461
{
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   462
    CBState->setCurrentIndex(0);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   463
    CBRules->setCurrentIndex(0);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   464
    CBWeapons->setCurrentIndex(0);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   465
    searchText->clear();
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   466
}
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   467
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   468
void PageRoomsList::onJoinConfirmation(const QString & room)
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   469
{
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   470
    if (QMessageBox::warning(this,
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   471
                             tr("Warning"),
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   472
                             tr("The game you are trying to join has started.\nDo you still want to join the room?"),
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   473
                             QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes)
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   474
    {
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   475
        emit askForJoinRoom(room);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   476
    }
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   477
}
5259
926958e3e87b display player count below and with label, just because it's funny to mess with unC0Rr's code and make him cry :P
sheepluva
parents: 5204
diff changeset
   478
926958e3e87b display player count below and with label, just because it's funny to mess with unC0Rr's code and make him cry :P
sheepluva
parents: 5204
diff changeset
   479
void PageRoomsList::updateNickCounter(int cnt)
926958e3e87b display player count below and with label, just because it's funny to mess with unC0Rr's code and make him cry :P
sheepluva
parents: 5204
diff changeset
   480
{
5602
c89b81817ee4 - Update russian translation
unc0rr
parents: 5283
diff changeset
   481
    lblCount->setText(tr("%1 players online", 0, cnt).arg(cnt));
5259
926958e3e87b display player count below and with label, just because it's funny to mess with unC0Rr's code and make him cry :P
sheepluva
parents: 5204
diff changeset
   482
}
6227
ce60b734fff1 update name autocompletion after nick change (since own nick isn't suggested)
sheepluva
parents: 6180
diff changeset
   483
ce60b734fff1 update name autocompletion after nick change (since own nick isn't suggested)
sheepluva
parents: 6180
diff changeset
   484
void PageRoomsList::setUser(const QString & nickname)
ce60b734fff1 update name autocompletion after nick change (since own nick isn't suggested)
sheepluva
parents: 6180
diff changeset
   485
{
ce60b734fff1 update name autocompletion after nick change (since own nick isn't suggested)
sheepluva
parents: 6180
diff changeset
   486
    chatWidget->setUser(nickname);
ce60b734fff1 update name autocompletion after nick change (since own nick isn't suggested)
sheepluva
parents: 6180
diff changeset
   487
}
6735
050237b1500f Setup rooms list headers
unc0rr
parents: 6732
diff changeset
   488
6995
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   489
void PageRoomsList::setModel(RoomsListModel * model)
6735
050237b1500f Setup rooms list headers
unc0rr
parents: 6732
diff changeset
   490
{
6996
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   491
    // filter chain:
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   492
    // model -> stateFilteredModel -> schemeFilteredModel ->
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   493
    // -> weaponsFilteredModel -> roomsModel (search filter+sorting)
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   494
6995
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   495
    if (roomsModel == NULL)
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   496
    {
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   497
        roomsModel = new QSortFilterProxyModel(this);
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   498
        roomsModel->setDynamicSortFilter(true);
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   499
        roomsModel->setSortCaseSensitivity(Qt::CaseInsensitive);
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   500
        roomsModel->sort(RoomsListModel::StateColumn, Qt::AscendingOrder);
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   501
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   502
        stateFilteredModel = new QSortFilterProxyModel(this);
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   503
        schemeFilteredModel = new QSortFilterProxyModel(this);
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   504
        weaponsFilteredModel = new QSortFilterProxyModel(this);
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   505
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   506
        stateFilteredModel->setDynamicSortFilter(true);
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   507
        schemeFilteredModel->setDynamicSortFilter(true);
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   508
        weaponsFilteredModel->setDynamicSortFilter(true);
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   509
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   510
        roomsModel->setFilterKeyColumn(-1); // search in all columns
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   511
        stateFilteredModel->setFilterKeyColumn(RoomsListModel::StateColumn);
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   512
        schemeFilteredModel->setFilterKeyColumn(RoomsListModel::SchemeColumn);
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   513
        weaponsFilteredModel->setFilterKeyColumn(RoomsListModel::WeaponsColumn);
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   514
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   515
        roomsModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   516
        schemeFilteredModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   517
        weaponsFilteredModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   518
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   519
        schemeFilteredModel->setSourceModel(stateFilteredModel);
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   520
        weaponsFilteredModel->setSourceModel(schemeFilteredModel);
6996
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   521
        roomsModel->setSourceModel(weaponsFilteredModel);
6995
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   522
6996
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   523
        // let the table view display the last model in the filter chain
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   524
        roomsList->setModel(roomsModel);
6995
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   525
    }
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   526
6996
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   527
    stateFilteredModel->setSourceModel(model);
6735
050237b1500f Setup rooms list headers
unc0rr
parents: 6732
diff changeset
   528
6993
47830cf50574 room list: replace magic table column indexes with enum. makes future changes to the room list format way easier.
sheepluva
parents: 6991
diff changeset
   529
    roomsList->hideColumn(RoomsListModel::StateColumn);
6736
efad396abee9 Bring back functionality to "Join" button
unc0rr
parents: 6735
diff changeset
   530
6735
050237b1500f Setup rooms list headers
unc0rr
parents: 6732
diff changeset
   531
    QHeaderView * h = roomsList->horizontalHeader();
6987
e34415c77342 allow custom sorting of roomslist (by clicking on header sections)
sheepluva
parents: 6977
diff changeset
   532
7011
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   533
    h->setSortIndicatorShown(true);
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   534
    h->setSortIndicator(RoomsListModel::StateColumn, Qt::AscendingOrder);
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   535
    h->setResizeMode(RoomsListModel::NameColumn, QHeaderView::Stretch);
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   536
6996
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   537
    if (!restoreHeaderState())
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   538
    {
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   539
        h->resizeSection(RoomsListModel::PlayerCountColumn, 32);
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   540
        h->resizeSection(RoomsListModel::TeamCountColumn, 32);
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   541
        h->resizeSection(RoomsListModel::OwnerColumn, 100);
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   542
        h->resizeSection(RoomsListModel::MapColumn, 100);
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   543
        h->resizeSection(RoomsListModel::SchemeColumn, 100);
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   544
        h->resizeSection(RoomsListModel::WeaponsColumn, 100);
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   545
    }
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   546
7011
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   547
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   548
    // save header state on change
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   549
    connect(roomsList->horizontalHeader(), SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)),
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   550
            this, SLOT(saveHeaderState()));
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   551
    connect(roomsList->horizontalHeader(), SIGNAL(sectionResized(int, int, int)),
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   552
            this, SLOT(saveHeaderState()));
6995
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   553
}
6977
6a2ecad333da adjust column widths
sheepluva
parents: 6952
diff changeset
   554
6987
e34415c77342 allow custom sorting of roomslist (by clicking on header sections)
sheepluva
parents: 6977
diff changeset
   555
e34415c77342 allow custom sorting of roomslist (by clicking on header sections)
sheepluva
parents: 6977
diff changeset
   556
void PageRoomsList::onSortIndicatorChanged(int logicalIndex, Qt::SortOrder order)
e34415c77342 allow custom sorting of roomslist (by clicking on header sections)
sheepluva
parents: 6977
diff changeset
   557
{
6995
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   558
    if (roomsModel == NULL)
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   559
        return;
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   560
7011
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   561
    if (logicalIndex == 0)
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   562
    {
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   563
        roomsModel->sort(0, Qt::AscendingOrder);
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   564
        return;
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   565
    }
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   566
6989
4c35e9cf6057 make column sorting three-state: asc -> dsc -> off/default (= by room state)
sheepluva
parents: 6988
diff changeset
   567
    // three state sorting: asc -> dsc -> default (by room state)
4c35e9cf6057 make column sorting three-state: asc -> dsc -> off/default (= by room state)
sheepluva
parents: 6988
diff changeset
   568
    if ((order == Qt::AscendingOrder) && (logicalIndex == roomsModel->sortColumn()))
6993
47830cf50574 room list: replace magic table column indexes with enum. makes future changes to the room list format way easier.
sheepluva
parents: 6991
diff changeset
   569
        roomsList->horizontalHeader()->setSortIndicator(
47830cf50574 room list: replace magic table column indexes with enum. makes future changes to the room list format way easier.
sheepluva
parents: 6991
diff changeset
   570
            RoomsListModel::StateColumn, Qt::AscendingOrder);
6989
4c35e9cf6057 make column sorting three-state: asc -> dsc -> off/default (= by room state)
sheepluva
parents: 6988
diff changeset
   571
    else
4c35e9cf6057 make column sorting three-state: asc -> dsc -> off/default (= by room state)
sheepluva
parents: 6988
diff changeset
   572
        roomsModel->sort(logicalIndex, order);
6987
e34415c77342 allow custom sorting of roomslist (by clicking on header sections)
sheepluva
parents: 6977
diff changeset
   573
}
6995
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   574
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   575
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   576
void PageRoomsList::onFilterChanged()
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   577
{
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   578
    if (roomsModel == NULL)
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   579
        return;
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   580
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   581
    roomsModel->setFilterWildcard(QString("*%1*").arg(searchText->text()));
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   582
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   583
    int stateIdx = CBState->currentIndex();
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   584
    // any = 0, in lobby/false = 1, in progress/true = 2
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   585
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   586
    if (stateIdx == 0)
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   587
        stateFilteredModel->setFilterWildcard("*"); // "any"
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   588
    else
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   589
        stateFilteredModel->setFilterFixedString(QString(stateIdx == 2));
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   590
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   591
    if (CBRules->currentIndex() == 0)
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   592
        schemeFilteredModel->setFilterWildcard("*"); // "any"
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   593
    else
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   594
        schemeFilteredModel->setFilterWildcard(
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   595
            QString("*%1*").arg(CBRules->currentText()));
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   596
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   597
    if (CBWeapons->currentIndex() == 0)
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   598
        weaponsFilteredModel->setFilterWildcard("*"); // "any"
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   599
    else
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   600
        weaponsFilteredModel->setFilterWildcard(
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   601
            QString("*%1*").arg(CBWeapons->currentText()));
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   602
}
6996
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   603
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   604
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   605
bool PageRoomsList::restoreHeaderState()
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   606
{
7003
e118ee168577 tweak how the header customization is stored in the settings file
sheepluva
parents: 6996
diff changeset
   607
    if (!m_gameSettings->contains("frontend/roomslist_header"))
6996
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   608
        return false;
7011
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   609
    return roomsList->horizontalHeader()->restoreState(QByteArray::fromBase64(
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   610
        (m_gameSettings->value("frontend/roomslist_header").toString().toAscii())));
6996
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   611
}
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   612
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   613
void PageRoomsList::saveHeaderState()
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   614
{
7003
e118ee168577 tweak how the header customization is stored in the settings file
sheepluva
parents: 6996
diff changeset
   615
    m_gameSettings->setValue("frontend/roomslist_header",
7011
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   616
        QString(roomsList->horizontalHeader()->saveState().toBase64()));
6996
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   617
}