QTfrontend/ui/page/pageroomslist.cpp
author unc0rr
Sun, 02 Dec 2012 01:26:00 +0400
changeset 8179 a1ffcb559f99
parent 7794 ab7b94c03bc9
child 8453 06541556df53
permissions -rw-r--r--
Refactor: get rid of excessive QSettings instances on the same poor hedgewars.ini file
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
8179
a1ffcb559f99 Refactor: get rid of excessive QSettings instances on the same poor hedgewars.ini file
unc0rr
parents: 7794
diff changeset
    98
    chatWidget = new HWChatWidget(this, 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
8179
a1ffcb559f99 Refactor: get rid of excessive QSettings instances on the same poor hedgewars.ini file
unc0rr
parents: 7794
diff changeset
   159
PageRoomsList::PageRoomsList(QWidget* parent) :
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
{
6995
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   162
    roomsModel = NULL;
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   163
    stateFilteredModel = NULL;
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   164
    schemeFilteredModel = NULL;
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   165
    weaponsFilteredModel = NULL;
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   166
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
   167
    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
   168
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
    // 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
   170
    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
   171
    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
   172
        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
   173
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
    CBWeapons->addItem(QComboBox::tr("Any"));
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   175
    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
   176
    {
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
   177
        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
   178
        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
   179
    }
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   180
}
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   181
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
   182
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
   183
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
   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
    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
   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
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
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
   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
    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
   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
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
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
   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
    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
   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
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
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   200
void PageRoomsList::setAdmin(bool flag)
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   201
{
5283
koda
parents: 5281
diff changeset
   202
    BtnAdmin->setVisible(flag);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   203
}
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   204
6732
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents: 6700
diff changeset
   205
/*
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   206
void PageRoomsList::setRoomsList(const QStringList & list)
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   207
{
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   208
    QBrush red(QColor(255, 0, 0));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   209
    QBrush orange(QColor(127, 127, 0));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   210
    QBrush yellow(QColor(255, 255, 0));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   211
    QBrush green(QColor(0, 255, 0));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   212
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   213
    listFromServer = list;
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   214
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   215
    QString selection = "";
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
    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
   218
        selection = item->text();
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   219
5283
koda
parents: 5281
diff changeset
   220
    roomsList->clear();
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   221
    roomsList->setColumnCount(7);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   222
    roomsList->setHorizontalHeaderLabels(
6732
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents: 6700
diff changeset
   223
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   224
    );
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   225
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   226
    // set minimum sizes
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   227
//  roomsList->horizontalHeader()->resizeSection(0, 200);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   228
//  roomsList->horizontalHeader()->resizeSection(1, 50);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   229
//  roomsList->horizontalHeader()->resizeSection(2, 50);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   230
//  roomsList->horizontalHeader()->resizeSection(3, 100);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   231
//  roomsList->horizontalHeader()->resizeSection(4, 100);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   232
//  roomsList->horizontalHeader()->resizeSection(5, 100);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   233
//  roomsList->horizontalHeader()->resizeSection(6, 100);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   234
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   235
    // set resize modes
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   236
//  roomsList->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   237
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   238
    bool gameCanBeJoined = true;
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
    if (list.size() % 8)
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   241
        return;
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   242
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   243
    roomsList->setRowCount(list.size() / 8);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   244
    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
   245
    {
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   246
        // if we are joining a game
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   247
        // 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
   248
        if (gameInLobby)
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   249
        {
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   250
            if (gameInLobbyName == list[i + 1])
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   251
            {
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   252
                gameCanBeJoined = list[i].compare("True");
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   253
            }
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   254
        }
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   255
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   256
        // check filter settings
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   257
#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
   258
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   259
        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
   260
        {
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   261
            NO_FILTER_MATCH;
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
        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
   264
        {
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   265
            NO_FILTER_MATCH;
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
        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
   268
        {
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   269
            NO_FILTER_MATCH;
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
        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
   272
        {
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   273
            NO_FILTER_MATCH;
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   274
        }
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   275
        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
   276
        if (!found)
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   277
        {
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   278
            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
   279
            {
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   280
                QString compString = list[i + a];
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   281
                if (a == 5 && compString == "+rnd+")
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   282
                {
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   283
                    compString = "Random Map";
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   284
                }
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   285
                else if (a == 5 && compString == "+maze+")
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   286
                {
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   287
                    compString = "Random Maze";
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   288
                }
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   289
                else if (a == 5 && compString == "+drawn+")
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   290
                {
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   291
                    compString = "Drawn Map";
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   292
                }
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   293
                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
   294
                {
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   295
                    found = true;
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   296
                    break;
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   297
                }
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   298
            }
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   299
        }
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   300
        if (!searchText->text().isEmpty() && !found)
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   301
        {
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   302
            NO_FILTER_MATCH;
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
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   305
        QTableWidgetItem * item;
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   306
        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
   307
        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
   308
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   309
        // 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
   310
        if(list[i].compare("True"))
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   311
        {
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   312
            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
   313
            item->setToolTip(tr("Waiting..."));
83dd3447a212 exploit the new setWhatsThis feature in our desktop frontend
koda
parents: 6616
diff changeset
   314
            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
   315
        }
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   316
        else
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
            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
   319
            item->setToolTip(tr("In progress..."));
83dd3447a212 exploit the new setWhatsThis feature in our desktop frontend
koda
parents: 6616
diff changeset
   320
            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
   321
        }
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   322
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   323
        roomsList->setItem(r, 0, item);
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
        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
   326
        item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   327
        item->setTextAlignment(Qt::AlignCenter);
6699
83dd3447a212 exploit the new setWhatsThis feature in our desktop frontend
koda
parents: 6616
diff changeset
   328
        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
   329
        roomsList->setItem(r, 1, item);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   330
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   331
        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
   332
        item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   333
        item->setTextAlignment(Qt::AlignCenter);
6699
83dd3447a212 exploit the new setWhatsThis feature in our desktop frontend
koda
parents: 6616
diff changeset
   334
        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
   335
        //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
   336
        //if(list[i + 3].toInt() >= cMaxTeams)
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   337
        //    item->setForeground(red);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   338
        roomsList->setItem(r, 2, item);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   339
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   340
        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
   341
        item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
6699
83dd3447a212 exploit the new setWhatsThis feature in our desktop frontend
koda
parents: 6616
diff changeset
   342
        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
   343
        roomsList->setItem(r, 3, item);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   344
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   345
        if(list[i + 5] == "+rnd+")
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
            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
   348
// 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
   349
//            item->setIcon(QIcon(":/res/mapRandom.png"));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   350
        }
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   351
        else if (list[i+5] == "+maze+")
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
            item = new QTableWidgetItem(tr("Random Maze"));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   354
// 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
   355
//            item->setIcon(QIcon(":/res/mapMaze.png"));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   356
        }
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   357
        else
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
            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
   360
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   361
            // 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
   362
            // not perfect but a start
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   363
            if(!mapList->contains(list[i + 5]))
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   364
            {
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   365
                item->setForeground(red);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   366
                item->setIcon(QIcon(":/res/mapMissing.png"));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   367
            }
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   368
            else
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   369
            {
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   370
                // todo: mission icon?
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   371
// 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
   372
//               item->setIcon(QIcon(":/res/mapCustom.png"));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   373
            }
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   374
        }
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   375
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   376
        item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
6699
83dd3447a212 exploit the new setWhatsThis feature in our desktop frontend
koda
parents: 6616
diff changeset
   377
        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
   378
        roomsList->setItem(r, 4, item);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   379
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   380
        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
   381
        item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
6699
83dd3447a212 exploit the new setWhatsThis feature in our desktop frontend
koda
parents: 6616
diff changeset
   382
        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
   383
        roomsList->setItem(r, 5, item);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   384
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   385
        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
   386
        item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
6699
83dd3447a212 exploit the new setWhatsThis feature in our desktop frontend
koda
parents: 6616
diff changeset
   387
        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
   388
        roomsList->setItem(r, 6, item);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   389
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   390
        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
   391
            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
   392
    }
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   393
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   394
    roomsList->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   395
    roomsList->horizontalHeader()->setResizeMode(1, QHeaderView::ResizeToContents);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   396
    roomsList->horizontalHeader()->setResizeMode(2, QHeaderView::ResizeToContents);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   397
    roomsList->horizontalHeader()->setResizeMode(3, QHeaderView::ResizeToContents);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   398
    roomsList->horizontalHeader()->setResizeMode(4, QHeaderView::ResizeToContents);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   399
    roomsList->horizontalHeader()->setResizeMode(5, QHeaderView::ResizeToContents);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   400
    roomsList->horizontalHeader()->setResizeMode(6, QHeaderView::ResizeToContents);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   401
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   402
    // 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
   403
    if (gameInLobby)
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   404
    {
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   405
        gameInLobby = false;
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   406
        if (gameCanBeJoined)
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   407
        {
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   408
            emit askForJoinRoom(gameInLobbyName);
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   409
        }
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   410
        else
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   411
        {
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   412
            emit askJoinConfirmation(gameInLobbyName);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   413
        }
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   414
    }
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
//  roomsList->resizeColumnsToContents();
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   417
}
6732
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents: 6700
diff changeset
   418
*/
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   419
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   420
void PageRoomsList::onCreateClick()
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
    if (roomName->text().size())
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   423
        emit askForCreateRoom(roomName->text());
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   424
    else
7794
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7769
diff changeset
   425
    {
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7769
diff changeset
   426
        QMessageBox roomNameMsg(this);
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7769
diff changeset
   427
        roomNameMsg.setIcon(QMessageBox::Warning);
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7769
diff changeset
   428
        roomNameMsg.setWindowTitle(QMessageBox::tr("Room Name - Error"));
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7769
diff changeset
   429
        roomNameMsg.setText(QMessageBox::tr("Please enter room name"));
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7769
diff changeset
   430
        roomNameMsg.setWindowModality(Qt::WindowModal);
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7769
diff changeset
   431
        roomNameMsg.exec();
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7769
diff changeset
   432
    }
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   433
}
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   434
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   435
void PageRoomsList::onJoinClick()
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   436
{
6736
efad396abee9 Bring back functionality to "Join" button
unc0rr
parents: 6735
diff changeset
   437
    QModelIndexList mdl = roomsList->selectionModel()->selectedRows();
efad396abee9 Bring back functionality to "Join" button
unc0rr
parents: 6735
diff changeset
   438
efad396abee9 Bring back functionality to "Join" button
unc0rr
parents: 6735
diff changeset
   439
    if(mdl.size() != 1)
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   440
    {
7794
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7769
diff changeset
   441
        QMessageBox roomNameMsg(this);
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7769
diff changeset
   442
        roomNameMsg.setIcon(QMessageBox::Warning);
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7769
diff changeset
   443
        roomNameMsg.setWindowTitle(QMessageBox::tr("Room Name - Error"));
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7769
diff changeset
   444
        roomNameMsg.setText(QMessageBox::tr("Please select room from the list"));
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7769
diff changeset
   445
        roomNameMsg.setWindowModality(Qt::WindowModal);
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7769
diff changeset
   446
        roomNameMsg.exec();
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   447
        return;
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   448
    }
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   449
6736
efad396abee9 Bring back functionality to "Join" button
unc0rr
parents: 6735
diff changeset
   450
    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
   451
    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
   452
6736
efad396abee9 Bring back functionality to "Join" button
unc0rr
parents: 6735
diff changeset
   453
    if (!gameInLobby)
efad396abee9 Bring back functionality to "Join" button
unc0rr
parents: 6735
diff changeset
   454
        emit askJoinConfirmation(roomName);
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   455
    else
6736
efad396abee9 Bring back functionality to "Join" button
unc0rr
parents: 6735
diff changeset
   456
        emit askForJoinRoom(roomName);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   457
}
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
void PageRoomsList::onRefreshClick()
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   460
{
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   461
    emit askForRoomList();
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   462
}
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   463
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   464
void PageRoomsList::onClearClick()
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   465
{
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   466
    CBState->setCurrentIndex(0);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   467
    CBRules->setCurrentIndex(0);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   468
    CBWeapons->setCurrentIndex(0);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   469
    searchText->clear();
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   470
}
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   471
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   472
void PageRoomsList::onJoinConfirmation(const QString & room)
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   473
{
7794
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7769
diff changeset
   474
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7769
diff changeset
   475
    QMessageBox reallyJoinMsg(this);
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7769
diff changeset
   476
    reallyJoinMsg.setIcon(QMessageBox::Question);
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7769
diff changeset
   477
    reallyJoinMsg.setWindowTitle(QMessageBox::tr("Room Name - Are you sure?"));
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7769
diff changeset
   478
    reallyJoinMsg.setText(QMessageBox::tr("The game you are trying to join has started.\nDo you still want to join the room?"));
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7769
diff changeset
   479
    reallyJoinMsg.setWindowModality(Qt::WindowModal);
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7769
diff changeset
   480
    reallyJoinMsg.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7769
diff changeset
   481
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7769
diff changeset
   482
    if (reallyJoinMsg.exec() == QMessageBox::Ok)
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   483
    {
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   484
        emit askForJoinRoom(room);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   485
    }
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   486
}
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
   487
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
   488
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
   489
{
5602
c89b81817ee4 - Update russian translation
unc0rr
parents: 5283
diff changeset
   490
    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
   491
}
6227
ce60b734fff1 update name autocompletion after nick change (since own nick isn't suggested)
sheepluva
parents: 6180
diff changeset
   492
ce60b734fff1 update name autocompletion after nick change (since own nick isn't suggested)
sheepluva
parents: 6180
diff changeset
   493
void PageRoomsList::setUser(const QString & nickname)
ce60b734fff1 update name autocompletion after nick change (since own nick isn't suggested)
sheepluva
parents: 6180
diff changeset
   494
{
ce60b734fff1 update name autocompletion after nick change (since own nick isn't suggested)
sheepluva
parents: 6180
diff changeset
   495
    chatWidget->setUser(nickname);
ce60b734fff1 update name autocompletion after nick change (since own nick isn't suggested)
sheepluva
parents: 6180
diff changeset
   496
}
6735
050237b1500f Setup rooms list headers
unc0rr
parents: 6732
diff changeset
   497
6995
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   498
void PageRoomsList::setModel(RoomsListModel * model)
6735
050237b1500f Setup rooms list headers
unc0rr
parents: 6732
diff changeset
   499
{
6996
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   500
    // filter chain:
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   501
    // model -> stateFilteredModel -> schemeFilteredModel ->
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   502
    // -> weaponsFilteredModel -> roomsModel (search filter+sorting)
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   503
6995
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   504
    if (roomsModel == NULL)
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   505
    {
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   506
        roomsModel = new QSortFilterProxyModel(this);
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   507
        roomsModel->setDynamicSortFilter(true);
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   508
        roomsModel->setSortCaseSensitivity(Qt::CaseInsensitive);
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   509
        roomsModel->sort(RoomsListModel::StateColumn, Qt::AscendingOrder);
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   510
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   511
        stateFilteredModel = new QSortFilterProxyModel(this);
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   512
        schemeFilteredModel = new QSortFilterProxyModel(this);
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   513
        weaponsFilteredModel = new QSortFilterProxyModel(this);
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   514
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   515
        stateFilteredModel->setDynamicSortFilter(true);
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   516
        schemeFilteredModel->setDynamicSortFilter(true);
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   517
        weaponsFilteredModel->setDynamicSortFilter(true);
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   518
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   519
        roomsModel->setFilterKeyColumn(-1); // search in all columns
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   520
        stateFilteredModel->setFilterKeyColumn(RoomsListModel::StateColumn);
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   521
        schemeFilteredModel->setFilterKeyColumn(RoomsListModel::SchemeColumn);
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   522
        weaponsFilteredModel->setFilterKeyColumn(RoomsListModel::WeaponsColumn);
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   523
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   524
        roomsModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   525
        schemeFilteredModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   526
        weaponsFilteredModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   527
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   528
        schemeFilteredModel->setSourceModel(stateFilteredModel);
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   529
        weaponsFilteredModel->setSourceModel(schemeFilteredModel);
6996
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   530
        roomsModel->setSourceModel(weaponsFilteredModel);
6995
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   531
6996
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   532
        // let the table view display the last model in the filter chain
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   533
        roomsList->setModel(roomsModel);
6995
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   534
    }
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   535
6996
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   536
    stateFilteredModel->setSourceModel(model);
6735
050237b1500f Setup rooms list headers
unc0rr
parents: 6732
diff changeset
   537
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
   538
    roomsList->hideColumn(RoomsListModel::StateColumn);
6736
efad396abee9 Bring back functionality to "Join" button
unc0rr
parents: 6735
diff changeset
   539
6735
050237b1500f Setup rooms list headers
unc0rr
parents: 6732
diff changeset
   540
    QHeaderView * h = roomsList->horizontalHeader();
6987
e34415c77342 allow custom sorting of roomslist (by clicking on header sections)
sheepluva
parents: 6977
diff changeset
   541
7011
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   542
    h->setSortIndicatorShown(true);
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   543
    h->setSortIndicator(RoomsListModel::StateColumn, Qt::AscendingOrder);
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   544
    h->setResizeMode(RoomsListModel::NameColumn, QHeaderView::Stretch);
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   545
6996
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   546
    if (!restoreHeaderState())
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   547
    {
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   548
        h->resizeSection(RoomsListModel::PlayerCountColumn, 32);
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   549
        h->resizeSection(RoomsListModel::TeamCountColumn, 32);
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   550
        h->resizeSection(RoomsListModel::OwnerColumn, 100);
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   551
        h->resizeSection(RoomsListModel::MapColumn, 100);
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   552
        h->resizeSection(RoomsListModel::SchemeColumn, 100);
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   553
        h->resizeSection(RoomsListModel::WeaponsColumn, 100);
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   554
    }
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   555
7011
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   556
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   557
    // save header state on change
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   558
    connect(roomsList->horizontalHeader(), SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)),
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   559
            this, SLOT(saveHeaderState()));
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   560
    connect(roomsList->horizontalHeader(), SIGNAL(sectionResized(int, int, int)),
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   561
            this, SLOT(saveHeaderState()));
6995
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   562
}
6977
6a2ecad333da adjust column widths
sheepluva
parents: 6952
diff changeset
   563
6987
e34415c77342 allow custom sorting of roomslist (by clicking on header sections)
sheepluva
parents: 6977
diff changeset
   564
e34415c77342 allow custom sorting of roomslist (by clicking on header sections)
sheepluva
parents: 6977
diff changeset
   565
void PageRoomsList::onSortIndicatorChanged(int logicalIndex, Qt::SortOrder order)
e34415c77342 allow custom sorting of roomslist (by clicking on header sections)
sheepluva
parents: 6977
diff changeset
   566
{
6995
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   567
    if (roomsModel == NULL)
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   568
        return;
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   569
7011
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   570
    if (logicalIndex == 0)
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   571
    {
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   572
        roomsModel->sort(0, Qt::AscendingOrder);
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   573
        return;
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   574
    }
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   575
6989
4c35e9cf6057 make column sorting three-state: asc -> dsc -> off/default (= by room state)
sheepluva
parents: 6988
diff changeset
   576
    // 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
   577
    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
   578
        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
   579
            RoomsListModel::StateColumn, Qt::AscendingOrder);
6989
4c35e9cf6057 make column sorting three-state: asc -> dsc -> off/default (= by room state)
sheepluva
parents: 6988
diff changeset
   580
    else
4c35e9cf6057 make column sorting three-state: asc -> dsc -> off/default (= by room state)
sheepluva
parents: 6988
diff changeset
   581
        roomsModel->sort(logicalIndex, order);
6987
e34415c77342 allow custom sorting of roomslist (by clicking on header sections)
sheepluva
parents: 6977
diff changeset
   582
}
6995
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   583
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   584
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   585
void PageRoomsList::onFilterChanged()
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   586
{
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   587
    if (roomsModel == NULL)
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   588
        return;
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   589
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   590
    roomsModel->setFilterWildcard(QString("*%1*").arg(searchText->text()));
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   591
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   592
    int stateIdx = CBState->currentIndex();
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   593
    // any = 0, in lobby/false = 1, in progress/true = 2
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   594
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   595
    if (stateIdx == 0)
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   596
        stateFilteredModel->setFilterWildcard("*"); // "any"
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   597
    else
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   598
        stateFilteredModel->setFilterFixedString(QString(stateIdx == 2));
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   599
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   600
    if (CBRules->currentIndex() == 0)
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   601
        schemeFilteredModel->setFilterWildcard("*"); // "any"
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   602
    else
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   603
        schemeFilteredModel->setFilterWildcard(
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   604
            QString("*%1*").arg(CBRules->currentText()));
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   605
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   606
    if (CBWeapons->currentIndex() == 0)
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   607
        weaponsFilteredModel->setFilterWildcard("*"); // "any"
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   608
    else
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   609
        weaponsFilteredModel->setFilterWildcard(
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   610
            QString("*%1*").arg(CBWeapons->currentText()));
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   611
}
6996
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   612
8179
a1ffcb559f99 Refactor: get rid of excessive QSettings instances on the same poor hedgewars.ini file
unc0rr
parents: 7794
diff changeset
   613
void PageRoomsList::setSettings(QSettings *settings)
a1ffcb559f99 Refactor: get rid of excessive QSettings instances on the same poor hedgewars.ini file
unc0rr
parents: 7794
diff changeset
   614
{
a1ffcb559f99 Refactor: get rid of excessive QSettings instances on the same poor hedgewars.ini file
unc0rr
parents: 7794
diff changeset
   615
    m_gameSettings = settings;
a1ffcb559f99 Refactor: get rid of excessive QSettings instances on the same poor hedgewars.ini file
unc0rr
parents: 7794
diff changeset
   616
}
6996
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   617
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   618
bool PageRoomsList::restoreHeaderState()
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   619
{
7003
e118ee168577 tweak how the header customization is stored in the settings file
sheepluva
parents: 6996
diff changeset
   620
    if (!m_gameSettings->contains("frontend/roomslist_header"))
6996
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   621
        return false;
7011
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   622
    return roomsList->horizontalHeader()->restoreState(QByteArray::fromBase64(
8179
a1ffcb559f99 Refactor: get rid of excessive QSettings instances on the same poor hedgewars.ini file
unc0rr
parents: 7794
diff changeset
   623
        (m_gameSettings->value("frontend/roomslist_header").toByteArray())));
6996
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   624
}
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   625
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   626
void PageRoomsList::saveHeaderState()
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   627
{
7003
e118ee168577 tweak how the header customization is stored in the settings file
sheepluva
parents: 6996
diff changeset
   628
    m_gameSettings->setValue("frontend/roomslist_header",
7011
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   629
        QString(roomsList->horizontalHeader()->saveState().toBase64()));
6996
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   630
}