QTfrontend/ui/page/pageroomslist.cpp
author sheepluva
Fri, 17 Jan 2014 01:06:54 +0100
changeset 9998 736015b847e3
parent 9997 879fc2f86c36
child 9999 8f2dc49262c3
permissions -rw-r--r--
update copyright to 2014
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
9998
736015b847e3 update copyright to 2014
sheepluva
parents: 9997
diff changeset
     3
 * Copyright (c) 2004-2014 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
8453
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
    19
#include <QVBoxLayout>
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
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 <QGridLayout>
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    22
#include <QPushButton>
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    23
#include <QComboBox>
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    24
#include <QLabel>
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    25
#include <QLineEdit>
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    26
#include <QMessageBox>
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    27
#include <QHeaderView>
8453
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
    28
#include <QGroupBox>
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
    29
#include <QMenu>
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
    30
#include <QDebug>
9031
9477443dd583 Rooms list/chat splitter from issue 612
unc0rr
parents: 8731
diff changeset
    31
#include <QSplitter>
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    32
6987
e34415c77342 allow custom sorting of roomslist (by clicking on header sections)
sheepluva
parents: 6977
diff changeset
    33
#include <QSortFilterProxyModel>
e34415c77342 allow custom sorting of roomslist (by clicking on header sections)
sheepluva
parents: 6977
diff changeset
    34
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
    35
#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
    36
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    37
#include "ammoSchemeModel.h"
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    38
#include "hwconsts.h"
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    39
#include "chatwidget.h"
8453
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
    40
#include "roomnameprompt.h"
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
    41
#include "lineeditcursor.h"
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
    42
#include "pageroomslist.h"
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    43
8731
924840dad6a0 fix compilation with clang. fixes issue 553 - thanks to julien for reporting and to drew for the first part of the fix
sheepluva
parents: 8729
diff changeset
    44
void RoomTableView::moveDown()
924840dad6a0 fix compilation with clang. fixes issue 553 - thanks to julien for reporting and to drew for the first part of the fix
sheepluva
parents: 8729
diff changeset
    45
{
924840dad6a0 fix compilation with clang. fixes issue 553 - thanks to julien for reporting and to drew for the first part of the fix
sheepluva
parents: 8729
diff changeset
    46
    setCurrentIndex(moveCursor(QAbstractItemView::MoveDown, Qt::NoModifier));
924840dad6a0 fix compilation with clang. fixes issue 553 - thanks to julien for reporting and to drew for the first part of the fix
sheepluva
parents: 8729
diff changeset
    47
}
924840dad6a0 fix compilation with clang. fixes issue 553 - thanks to julien for reporting and to drew for the first part of the fix
sheepluva
parents: 8729
diff changeset
    48
924840dad6a0 fix compilation with clang. fixes issue 553 - thanks to julien for reporting and to drew for the first part of the fix
sheepluva
parents: 8729
diff changeset
    49
void RoomTableView::moveUp()
924840dad6a0 fix compilation with clang. fixes issue 553 - thanks to julien for reporting and to drew for the first part of the fix
sheepluva
parents: 8729
diff changeset
    50
{
924840dad6a0 fix compilation with clang. fixes issue 553 - thanks to julien for reporting and to drew for the first part of the fix
sheepluva
parents: 8729
diff changeset
    51
    setCurrentIndex(moveCursor(QAbstractItemView::MoveUp, Qt::NoModifier));
924840dad6a0 fix compilation with clang. fixes issue 553 - thanks to julien for reporting and to drew for the first part of the fix
sheepluva
parents: 8729
diff changeset
    52
}
924840dad6a0 fix compilation with clang. fixes issue 553 - thanks to julien for reporting and to drew for the first part of the fix
sheepluva
parents: 8729
diff changeset
    53
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
    54
QLayout * PageRoomsList::bodyLayoutDefinition()
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    55
{
8453
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
    56
    QVBoxLayout * pageLayout = new QVBoxLayout();
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
    57
    pageLayout->setSpacing(0);
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
    58
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
    59
    QGridLayout * topLayout = new QGridLayout();
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
    60
    topLayout->setSpacing(0);
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
    61
    pageLayout->addLayout(topLayout, 0);
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
    62
9997
879fc2f86c36 move room state filter
sheepluva
parents: 9738
diff changeset
    63
    // State button
879fc2f86c36 move room state filter
sheepluva
parents: 9738
diff changeset
    64
879fc2f86c36 move room state filter
sheepluva
parents: 9738
diff changeset
    65
    QPushButton * btnState = new QPushButton(tr("Room state"));
879fc2f86c36 move room state filter
sheepluva
parents: 9738
diff changeset
    66
    btnState->setStyleSheet("QPushButton { padding: 2px; margin: 0px; margin-right: 10px; border-bottom: none; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; } QPushButton:pressed { background-color: #ffcc00; border-color: #ffcc00; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; color: #11084A; }");
879fc2f86c36 move room state filter
sheepluva
parents: 9738
diff changeset
    67
    btnState->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
879fc2f86c36 move room state filter
sheepluva
parents: 9738
diff changeset
    68
879fc2f86c36 move room state filter
sheepluva
parents: 9738
diff changeset
    69
    // State menu
879fc2f86c36 move room state filter
sheepluva
parents: 9738
diff changeset
    70
879fc2f86c36 move room state filter
sheepluva
parents: 9738
diff changeset
    71
    QMenu * stateMenu = new QMenu(btnState);
879fc2f86c36 move room state filter
sheepluva
parents: 9738
diff changeset
    72
    showGamesInLobby = new QAction(QAction::tr("Show games in lobby"), stateMenu);
879fc2f86c36 move room state filter
sheepluva
parents: 9738
diff changeset
    73
    showGamesInLobby->setCheckable(true);
879fc2f86c36 move room state filter
sheepluva
parents: 9738
diff changeset
    74
    showGamesInLobby->setChecked(true);
879fc2f86c36 move room state filter
sheepluva
parents: 9738
diff changeset
    75
    showGamesInProgress = new QAction(QAction::tr("Show games in-progress"), stateMenu);
879fc2f86c36 move room state filter
sheepluva
parents: 9738
diff changeset
    76
    showGamesInProgress->setCheckable(true);
879fc2f86c36 move room state filter
sheepluva
parents: 9738
diff changeset
    77
    showGamesInProgress->setChecked(true);
879fc2f86c36 move room state filter
sheepluva
parents: 9738
diff changeset
    78
    stateMenu->addAction(showGamesInLobby);
879fc2f86c36 move room state filter
sheepluva
parents: 9738
diff changeset
    79
    stateMenu->addAction(showGamesInProgress);
879fc2f86c36 move room state filter
sheepluva
parents: 9738
diff changeset
    80
    btnState->setMenu(stateMenu);
879fc2f86c36 move room state filter
sheepluva
parents: 9738
diff changeset
    81
8453
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
    82
    // Help/prompt message at top
8488
e72f3398a28b Removed in-lineedit labels such as "search:" and "room name:" due to size issues with localization and platform differences.
dag10
parents: 8453
diff changeset
    83
    QLabel * lblDesc = new QLabel(tr("Search for a room:"));
8453
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
    84
    lblDesc->setObjectName("lblDesc");
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
    85
    lblDesc->setStyleSheet("#lblDesc { color: #130F2A; background: #F6CB1C; border: solid 4px #F6CB1C; border-top-left-radius: 10px; padding: 4px 10px;}");
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
    86
    lblDesc->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
    87
    lblDesc->setFixedHeight(24);
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
    88
    lblDesc->setMinimumWidth(0);
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
    89
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
    90
    // Search text box
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
    91
    QWidget * searchContainer = new QWidget();
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
    92
    searchContainer->setFixedHeight(24);
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
    93
    searchContainer->setObjectName("searchContainer");
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
    94
    searchContainer->setStyleSheet("#searchContainer { background: #F6CB1C; border-top-right-radius: 10px; padding: 3px; }");
8488
e72f3398a28b Removed in-lineedit labels such as "search:" and "room name:" due to size issues with localization and platform differences.
dag10
parents: 8453
diff changeset
    95
    searchContainer->setFixedWidth(200);
8453
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
    96
    searchText = new LineEditCursor(searchContainer);
8488
e72f3398a28b Removed in-lineedit labels such as "search:" and "room name:" due to size issues with localization and platform differences.
dag10
parents: 8453
diff changeset
    97
    searchText->setFixedWidth(200);
8453
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
    98
    searchText->setMaxLength(60);
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
    99
    searchText->setFixedHeight(22);
8488
e72f3398a28b Removed in-lineedit labels such as "search:" and "room name:" due to size issues with localization and platform differences.
dag10
parents: 8453
diff changeset
   100
    searchText->setStyleSheet("LineEditCursor { border-width: 0px; border-radius: 6px; margin-top: 3px; margin-right: 3px; padding-left: 4px; padding-bottom: 2px; background-color: rgb(23, 11, 54); } LineEditCursor:hover, LineEditCursor:focus { background-color: rgb(13, 5, 68); }");
8453
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   101
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   102
    // Corner widget
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   103
    QLabel * corner = new QLabel();
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   104
    corner->setPixmap(QPixmap(QString::fromUtf8(":/res/inverse-corner-bl.png")));
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   105
    corner->setFixedSize(10, 10);
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   106
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   107
    const QIcon& lp = QIcon(":/res/new.png");
8637
bf63104605fe caught two frontend warnings
koda
parents: 8488
diff changeset
   108
    //QSize sz = lp.actualSize(QSize(65535, 65535));
8453
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   109
    BtnCreate = new QPushButton();
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   110
    BtnCreate->setText(tr("Create room"));
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   111
    BtnCreate->setIcon(lp);
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   112
    BtnCreate->setStyleSheet("padding: 4px 8px; margin-bottom: 6px;");
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   113
8453
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   114
    BtnJoin = new QPushButton(tr("Join room"));
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   115
    BtnJoin->setStyleSheet("padding: 4px 8px; margin-bottom: 6px; margin-left: 6px;");
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   116
    BtnJoin->setEnabled(false);
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   117
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   118
    // Add widgets to top layout
9997
879fc2f86c36 move room state filter
sheepluva
parents: 9738
diff changeset
   119
    topLayout->addWidget(btnState, 1, 0);
879fc2f86c36 move room state filter
sheepluva
parents: 9738
diff changeset
   120
    topLayout->addWidget(lblDesc, 1, 1);
879fc2f86c36 move room state filter
sheepluva
parents: 9738
diff changeset
   121
    topLayout->addWidget(searchContainer, 1, 2);
879fc2f86c36 move room state filter
sheepluva
parents: 9738
diff changeset
   122
    topLayout->addWidget(corner, 1, 3, Qt::AlignBottom);
879fc2f86c36 move room state filter
sheepluva
parents: 9738
diff changeset
   123
    topLayout->addWidget(BtnCreate, 0, 5, 2, 1);
879fc2f86c36 move room state filter
sheepluva
parents: 9738
diff changeset
   124
    topLayout->addWidget(BtnJoin, 0, 6, 2, 1);
8453
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   125
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   126
    // Top layout stretch
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   127
    topLayout->setRowStretch(0, 1);
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   128
    topLayout->setRowStretch(1, 0);
9997
879fc2f86c36 move room state filter
sheepluva
parents: 9738
diff changeset
   129
    topLayout->setColumnStretch(4, 1);
8453
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   130
9031
9477443dd583 Rooms list/chat splitter from issue 612
unc0rr
parents: 8731
diff changeset
   131
    // Rooms list and chat with splitter
9477443dd583 Rooms list/chat splitter from issue 612
unc0rr
parents: 8731
diff changeset
   132
    m_splitter = new QSplitter();
9477443dd583 Rooms list/chat splitter from issue 612
unc0rr
parents: 8731
diff changeset
   133
    m_splitter->setChildrenCollapsible(false);
9477443dd583 Rooms list/chat splitter from issue 612
unc0rr
parents: 8731
diff changeset
   134
    pageLayout->addWidget(m_splitter, 100);
9477443dd583 Rooms list/chat splitter from issue 612
unc0rr
parents: 8731
diff changeset
   135
8453
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   136
    // Room list
9031
9477443dd583 Rooms list/chat splitter from issue 612
unc0rr
parents: 8731
diff changeset
   137
    QWidget * roomsListWidget = new QWidget(this);
9477443dd583 Rooms list/chat splitter from issue 612
unc0rr
parents: 8731
diff changeset
   138
    m_splitter->setOrientation(Qt::Vertical);
9477443dd583 Rooms list/chat splitter from issue 612
unc0rr
parents: 8731
diff changeset
   139
    m_splitter->addWidget(roomsListWidget);
9477443dd583 Rooms list/chat splitter from issue 612
unc0rr
parents: 8731
diff changeset
   140
9477443dd583 Rooms list/chat splitter from issue 612
unc0rr
parents: 8731
diff changeset
   141
    QVBoxLayout * roomsLayout = new QVBoxLayout(roomsListWidget);
9477443dd583 Rooms list/chat splitter from issue 612
unc0rr
parents: 8731
diff changeset
   142
    roomsLayout->setMargin(0);
8453
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   143
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   144
    roomsList = new RoomTableView(this);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   145
    roomsList->setSelectionBehavior(QAbstractItemView::SelectRows);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   146
    roomsList->verticalHeader()->setVisible(false);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   147
    roomsList->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   148
    roomsList->setAlternatingRowColors(true);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   149
    roomsList->setShowGrid(false);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   150
    roomsList->setSelectionMode(QAbstractItemView::SingleSelection);
8453
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   151
    roomsList->setStyleSheet("QTableView { border-top-left-radius: 0px; }");
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   152
    roomsList->setFocusPolicy(Qt::NoFocus);
9031
9477443dd583 Rooms list/chat splitter from issue 612
unc0rr
parents: 8731
diff changeset
   153
    roomsLayout->addWidget(roomsList, 200);
8453
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   154
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   155
    // Lobby chat
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   156
8179
a1ffcb559f99 Refactor: get rid of excessive QSettings instances on the same poor hedgewars.ini file
unc0rr
parents: 7794
diff changeset
   157
    chatWidget = new HWChatWidget(this, false);
9031
9477443dd583 Rooms list/chat splitter from issue 612
unc0rr
parents: 8731
diff changeset
   158
    m_splitter->addWidget(chatWidget);
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
   159
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
   160
    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
   161
}
6009
14f6fc9869f2 code cleanup/etc
sheepluva
parents: 5602
diff changeset
   162
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
   163
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
   164
{
6172
809e1076ffe2 fix lobby layout issues
sheepluva
parents: 6165
diff changeset
   165
    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
   166
8453
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   167
    BtnAdmin = addButton(tr("Admin features"), bottomLayout, 0);
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   168
    BtnAdmin->setStyleSheet("padding: 4px auto;");
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   169
    BtnAdmin->setWhatsThis(tr("Open server administration page"));
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
   170
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
   171
    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
   172
}
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
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
   175
{
8b5345758f62 some more cleanups/refactoring/blahblah, some button positions may are a bit off atm. also I added a new picture for one of the buttons
sheepluva
parents: 6009
diff changeset
   176
    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
   177
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   178
    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
   179
    connect(BtnJoin, SIGNAL(clicked()), this, SLOT(onJoinClick()));
8453
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   180
    connect(searchText, SIGNAL(moveUp()), this, SLOT(moveSelectionUp()));
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   181
    connect(searchText, SIGNAL(moveDown()), this, SLOT(moveSelectionDown()));
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   182
    connect(searchText, SIGNAL(returnPressed()), this, SLOT(onJoinClick()));
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   183
    connect(roomsList, SIGNAL(doubleClicked (const QModelIndex &)), this, SLOT(onJoinClick()));
8453
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   184
    connect(roomsList, SIGNAL(clicked (const QModelIndex &)), searchText, SLOT(setFocus()));
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   185
    connect(showGamesInLobby, SIGNAL(triggered()), this, SLOT(onFilterChanged()));
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   186
    connect(showGamesInProgress, SIGNAL(triggered()), this, SLOT(onFilterChanged()));
6995
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   187
    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
   188
    connect(this, SIGNAL(askJoinConfirmation (const QString &)), this, SLOT(onJoinConfirmation(const QString &)), Qt::QueuedConnection);
6995
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   189
8453
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   190
    // Set focus on search box
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   191
    connect(this, SIGNAL(pageEnter()), searchText, SLOT(setFocus()));
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   192
6996
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   193
    // sorting
6995
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   194
    connect(roomsList->horizontalHeader(), SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)),
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   195
            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
   196
}
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
   197
8453
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   198
void PageRoomsList::moveSelectionUp()
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   199
{
8731
924840dad6a0 fix compilation with clang. fixes issue 553 - thanks to julien for reporting and to drew for the first part of the fix
sheepluva
parents: 8729
diff changeset
   200
    roomsList->moveUp();
8453
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   201
}
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   202
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   203
void PageRoomsList::moveSelectionDown()
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   204
{
8731
924840dad6a0 fix compilation with clang. fixes issue 553 - thanks to julien for reporting and to drew for the first part of the fix
sheepluva
parents: 8729
diff changeset
   205
    roomsList->moveDown();
8453
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   206
}
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   207
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   208
void PageRoomsList::roomSelectionChanged(const QModelIndex & current, const QModelIndex & previous)
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   209
{
9031
9477443dd583 Rooms list/chat splitter from issue 612
unc0rr
parents: 8731
diff changeset
   210
    Q_UNUSED(previous);
9477443dd583 Rooms list/chat splitter from issue 612
unc0rr
parents: 8731
diff changeset
   211
8453
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   212
    BtnJoin->setEnabled(current.isValid());
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   213
}
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
   214
8179
a1ffcb559f99 Refactor: get rid of excessive QSettings instances on the same poor hedgewars.ini file
unc0rr
parents: 7794
diff changeset
   215
PageRoomsList::PageRoomsList(QWidget* parent) :
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   216
    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
   217
{
6995
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   218
    roomsModel = NULL;
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   219
    stateFilteredModel = NULL;
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   220
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
   221
    initPage();
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   222
}
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   223
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
   224
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
   225
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
   226
{
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
   227
    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
   228
}
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
   229
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
   230
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
   231
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
   232
{
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
   233
    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
   234
}
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
   235
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
   236
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
   237
{
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
   238
    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
   239
}
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
   240
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
   241
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   242
void PageRoomsList::setAdmin(bool flag)
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   243
{
5283
koda
parents: 5281
diff changeset
   244
    BtnAdmin->setVisible(flag);
5078
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
6732
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents: 6700
diff changeset
   247
/*
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   248
void PageRoomsList::setRoomsList(const QStringList & list)
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   249
{
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   250
    QBrush red(QColor(255, 0, 0));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   251
    QBrush orange(QColor(127, 127, 0));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   252
    QBrush yellow(QColor(255, 255, 0));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   253
    QBrush green(QColor(0, 255, 0));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   254
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   255
    listFromServer = list;
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   256
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   257
    QString selection = "";
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   258
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   259
    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
   260
        selection = item->text();
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   261
5283
koda
parents: 5281
diff changeset
   262
    roomsList->clear();
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   263
    roomsList->setColumnCount(7);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   264
    roomsList->setHorizontalHeaderLabels(
6732
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents: 6700
diff changeset
   265
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   266
    );
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   267
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   268
    // set minimum sizes
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   269
//  roomsList->horizontalHeader()->resizeSection(0, 200);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   270
//  roomsList->horizontalHeader()->resizeSection(1, 50);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   271
//  roomsList->horizontalHeader()->resizeSection(2, 50);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   272
//  roomsList->horizontalHeader()->resizeSection(3, 100);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   273
//  roomsList->horizontalHeader()->resizeSection(4, 100);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   274
//  roomsList->horizontalHeader()->resizeSection(5, 100);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   275
//  roomsList->horizontalHeader()->resizeSection(6, 100);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   276
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   277
    // set resize modes
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   278
//  roomsList->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   279
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   280
    bool gameCanBeJoined = true;
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   281
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   282
    if (list.size() % 8)
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   283
        return;
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   284
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   285
    roomsList->setRowCount(list.size() / 8);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   286
    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
   287
    {
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   288
        // if we are joining a game
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   289
        // 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
   290
        if (gameInLobby)
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   291
        {
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   292
            if (gameInLobbyName == list[i + 1])
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   293
            {
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   294
                gameCanBeJoined = list[i].compare("True");
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   295
            }
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   296
        }
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   297
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   298
        // check filter settings
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   299
#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
   300
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   301
        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
   302
        {
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   303
            NO_FILTER_MATCH;
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   304
        }
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   305
        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
   306
        {
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   307
            NO_FILTER_MATCH;
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   308
        }
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   309
        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
   310
        {
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   311
            NO_FILTER_MATCH;
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   312
        }
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   313
        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
   314
        {
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   315
            NO_FILTER_MATCH;
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   316
        }
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   317
        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
   318
        if (!found)
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   319
        {
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   320
            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
   321
            {
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   322
                QString compString = list[i + a];
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   323
                if (a == 5 && compString == "+rnd+")
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   324
                {
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   325
                    compString = "Random Map";
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   326
                }
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   327
                else if (a == 5 && compString == "+maze+")
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   328
                {
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   329
                    compString = "Random Maze";
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   330
                }
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   331
                else if (a == 5 && compString == "+drawn+")
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   332
                {
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   333
                    compString = "Drawn Map";
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   334
                }
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   335
                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
   336
                {
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   337
                    found = true;
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   338
                    break;
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
            }
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   341
        }
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   342
        if (!searchText->text().isEmpty() && !found)
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   343
        {
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   344
            NO_FILTER_MATCH;
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   345
        }
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   346
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   347
        QTableWidgetItem * item;
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   348
        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
   349
        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
   350
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   351
        // 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
   352
        if(list[i].compare("True"))
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   353
        {
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   354
            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
   355
            item->setToolTip(tr("Waiting..."));
83dd3447a212 exploit the new setWhatsThis feature in our desktop frontend
koda
parents: 6616
diff changeset
   356
            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
   357
        }
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   358
        else
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   359
        {
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   360
            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
   361
            item->setToolTip(tr("In progress..."));
83dd3447a212 exploit the new setWhatsThis feature in our desktop frontend
koda
parents: 6616
diff changeset
   362
            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
   363
        }
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
        roomsList->setItem(r, 0, item);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   366
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   367
        item = 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
   368
        item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   369
        item->setTextAlignment(Qt::AlignCenter);
6699
83dd3447a212 exploit the new setWhatsThis feature in our desktop frontend
koda
parents: 6616
diff changeset
   370
        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
   371
        roomsList->setItem(r, 1, item);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   372
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   373
        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
   374
        item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   375
        item->setTextAlignment(Qt::AlignCenter);
6699
83dd3447a212 exploit the new setWhatsThis feature in our desktop frontend
koda
parents: 6616
diff changeset
   376
        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
   377
        //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
   378
        //if(list[i + 3].toInt() >= cMaxTeams)
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   379
        //    item->setForeground(red);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   380
        roomsList->setItem(r, 2, item);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   381
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   382
        item = new QTableWidgetItem(list[i + 4].left(15)); // name of host
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   383
        item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
6699
83dd3447a212 exploit the new setWhatsThis feature in our desktop frontend
koda
parents: 6616
diff changeset
   384
        item->setWhatsThis(tr("%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
   385
        roomsList->setItem(r, 3, item);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   386
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   387
        if(list[i + 5] == "+rnd+")
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   388
        {
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   389
            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
   390
// 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
   391
//            item->setIcon(QIcon(":/res/mapRandom.png"));
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
        else if (list[i+5] == "+maze+")
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   394
        {
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   395
            item = new QTableWidgetItem(tr("Random Maze"));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   396
// 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
   397
//            item->setIcon(QIcon(":/res/mapMaze.png"));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   398
        }
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   399
        else
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   400
        {
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   401
            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
   402
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   403
            // 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
   404
            // not perfect but a start
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   405
            if(!mapList->contains(list[i + 5]))
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   406
            {
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   407
                item->setForeground(red);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   408
                item->setIcon(QIcon(":/res/mapMissing.png"));
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   409
            }
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   410
            else
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   411
            {
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   412
                // todo: mission icon?
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   413
// 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
   414
//               item->setIcon(QIcon(":/res/mapCustom.png"));
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
        }
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   417
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   418
        item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
6699
83dd3447a212 exploit the new setWhatsThis feature in our desktop frontend
koda
parents: 6616
diff changeset
   419
        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
   420
        roomsList->setItem(r, 4, item);
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
        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
   423
        item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
6699
83dd3447a212 exploit the new setWhatsThis feature in our desktop frontend
koda
parents: 6616
diff changeset
   424
        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
   425
        roomsList->setItem(r, 5, item);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   426
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   427
        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
   428
        item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
6699
83dd3447a212 exploit the new setWhatsThis feature in our desktop frontend
koda
parents: 6616
diff changeset
   429
        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
   430
        roomsList->setItem(r, 6, item);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   431
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   432
        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
   433
            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
   434
    }
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   435
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   436
    roomsList->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   437
    roomsList->horizontalHeader()->setResizeMode(1, QHeaderView::ResizeToContents);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   438
    roomsList->horizontalHeader()->setResizeMode(2, QHeaderView::ResizeToContents);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   439
    roomsList->horizontalHeader()->setResizeMode(3, QHeaderView::ResizeToContents);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   440
    roomsList->horizontalHeader()->setResizeMode(4, QHeaderView::ResizeToContents);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   441
    roomsList->horizontalHeader()->setResizeMode(5, QHeaderView::ResizeToContents);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   442
    roomsList->horizontalHeader()->setResizeMode(6, QHeaderView::ResizeToContents);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   443
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   444
    // 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
   445
    if (gameInLobby)
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   446
    {
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   447
        gameInLobby = false;
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   448
        if (gameCanBeJoined)
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   449
        {
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   450
            emit askForJoinRoom(gameInLobbyName);
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   451
        }
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   452
        else
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   453
        {
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   454
            emit askJoinConfirmation(gameInLobbyName);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   455
        }
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   456
    }
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   457
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   458
//  roomsList->resizeColumnsToContents();
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   459
}
6732
c906dc78091f Start switching to rooms list model. To be continued.
unc0rr
parents: 6700
diff changeset
   460
*/
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   461
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   462
void PageRoomsList::onCreateClick()
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   463
{
9541
312bb4384f33 - Frontend finally learns how to create passworded room
unc0rr
parents: 9080
diff changeset
   464
    RoomNamePrompt prompt(this, m_gameSettings->value("frontend/lastroomname", QString()).toString());
312bb4384f33 - Frontend finally learns how to create passworded room
unc0rr
parents: 9080
diff changeset
   465
    if(prompt.exec())
312bb4384f33 - Frontend finally learns how to create passworded room
unc0rr
parents: 9080
diff changeset
   466
        onRoomNameChosen(prompt.getRoomName(), prompt.getPassword());
8453
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   467
}
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   468
9541
312bb4384f33 - Frontend finally learns how to create passworded room
unc0rr
parents: 9080
diff changeset
   469
void PageRoomsList::onRoomNameChosen(const QString & roomName, const QString & password)
8453
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   470
{
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   471
    if (!roomName.trimmed().isEmpty())
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   472
    {
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   473
        m_gameSettings->setValue("frontend/lastroomname", roomName);
9541
312bb4384f33 - Frontend finally learns how to create passworded room
unc0rr
parents: 9080
diff changeset
   474
        emit askForCreateRoom(roomName, password);
8453
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   475
    }
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   476
    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
   477
    {
8453
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   478
        onCreateClick();
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
   479
    }
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   480
}
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   481
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   482
void PageRoomsList::onJoinClick()
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   483
{
6736
efad396abee9 Bring back functionality to "Join" button
unc0rr
parents: 6735
diff changeset
   484
    QModelIndexList mdl = roomsList->selectionModel()->selectedRows();
efad396abee9 Bring back functionality to "Join" button
unc0rr
parents: 6735
diff changeset
   485
efad396abee9 Bring back functionality to "Join" button
unc0rr
parents: 6735
diff changeset
   486
    if(mdl.size() != 1)
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   487
    {
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
   488
        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
   489
        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
   490
        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
   491
        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
   492
        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
   493
        roomNameMsg.exec();
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   494
        return;
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   495
    }
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   496
6736
efad396abee9 Bring back functionality to "Join" button
unc0rr
parents: 6735
diff changeset
   497
    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
   498
    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
   499
6736
efad396abee9 Bring back functionality to "Join" button
unc0rr
parents: 6735
diff changeset
   500
    if (!gameInLobby)
efad396abee9 Bring back functionality to "Join" button
unc0rr
parents: 6735
diff changeset
   501
        emit askJoinConfirmation(roomName);
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6227
diff changeset
   502
    else
9549
ac5c1f691ce2 Allow user to enter password for the room he joins
unc0rr
parents: 9541
diff changeset
   503
        emit askForJoinRoom(roomName, QString());
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   504
}
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   505
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   506
void PageRoomsList::onRefreshClick()
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   507
{
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   508
    emit askForRoomList();
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   509
}
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   510
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   511
void PageRoomsList::onJoinConfirmation(const QString & room)
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   512
{
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
   513
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
   514
    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
   515
    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
   516
    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
   517
    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
   518
    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
   519
    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
   520
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
   521
    if (reallyJoinMsg.exec() == QMessageBox::Ok)
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   522
    {
9549
ac5c1f691ce2 Allow user to enter password for the room he joins
unc0rr
parents: 9541
diff changeset
   523
        emit askForJoinRoom(room, QString());
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   524
    }
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   525
}
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
   526
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
   527
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
   528
{
8729
b19be476a2fa Call steps on focus instead. fix typo
nemo
parents: 8637
diff changeset
   529
    setDefaultDescription(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
   530
}
6227
ce60b734fff1 update name autocompletion after nick change (since own nick isn't suggested)
sheepluva
parents: 6180
diff changeset
   531
ce60b734fff1 update name autocompletion after nick change (since own nick isn't suggested)
sheepluva
parents: 6180
diff changeset
   532
void PageRoomsList::setUser(const QString & nickname)
ce60b734fff1 update name autocompletion after nick change (since own nick isn't suggested)
sheepluva
parents: 6180
diff changeset
   533
{
ce60b734fff1 update name autocompletion after nick change (since own nick isn't suggested)
sheepluva
parents: 6180
diff changeset
   534
    chatWidget->setUser(nickname);
ce60b734fff1 update name autocompletion after nick change (since own nick isn't suggested)
sheepluva
parents: 6180
diff changeset
   535
}
6735
050237b1500f Setup rooms list headers
unc0rr
parents: 6732
diff changeset
   536
6995
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   537
void PageRoomsList::setModel(RoomsListModel * model)
6735
050237b1500f Setup rooms list headers
unc0rr
parents: 6732
diff changeset
   538
{
6996
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   539
    // filter chain:
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   540
    // model -> stateFilteredModel -> schemeFilteredModel ->
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   541
    // -> weaponsFilteredModel -> roomsModel (search filter+sorting)
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   542
6995
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   543
    if (roomsModel == NULL)
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   544
    {
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   545
        roomsModel = new QSortFilterProxyModel(this);
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   546
        roomsModel->setDynamicSortFilter(true);
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   547
        roomsModel->setSortCaseSensitivity(Qt::CaseInsensitive);
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   548
        roomsModel->sort(RoomsListModel::StateColumn, Qt::AscendingOrder);
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   549
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   550
        stateFilteredModel = new QSortFilterProxyModel(this);
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   551
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   552
        stateFilteredModel->setDynamicSortFilter(true);
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   553
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   554
        roomsModel->setFilterKeyColumn(-1); // search in all columns
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   555
        stateFilteredModel->setFilterKeyColumn(RoomsListModel::StateColumn);
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   556
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   557
        roomsModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   558
9702
27006953d901 - Column for script in rooms list
unc0rr
parents: 9549
diff changeset
   559
        roomsModel->setSourceModel(stateFilteredModel);
6995
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   560
6996
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   561
        // let the table view display the last model in the filter chain
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   562
        roomsList->setModel(roomsModel);
8453
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   563
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   564
        // When the data changes
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   565
        connect(roomsModel, SIGNAL(layoutChanged()), roomsList, SLOT(repaint()));
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   566
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   567
        // When a selection changes
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   568
        connect(roomsList->selectionModel(), SIGNAL(currentRowChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(roomSelectionChanged(const QModelIndex &, const QModelIndex &)));
6995
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   569
    }
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   570
6996
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   571
    stateFilteredModel->setSourceModel(model);
6735
050237b1500f Setup rooms list headers
unc0rr
parents: 6732
diff changeset
   572
050237b1500f Setup rooms list headers
unc0rr
parents: 6732
diff changeset
   573
    QHeaderView * h = roomsList->horizontalHeader();
6987
e34415c77342 allow custom sorting of roomslist (by clicking on header sections)
sheepluva
parents: 6977
diff changeset
   574
7011
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   575
    h->setSortIndicatorShown(true);
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   576
    h->setSortIndicator(RoomsListModel::StateColumn, Qt::AscendingOrder);
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   577
    h->setResizeMode(RoomsListModel::NameColumn, QHeaderView::Stretch);
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   578
6996
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   579
    if (!restoreHeaderState())
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   580
    {
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   581
        h->resizeSection(RoomsListModel::PlayerCountColumn, 32);
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   582
        h->resizeSection(RoomsListModel::TeamCountColumn, 32);
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   583
        h->resizeSection(RoomsListModel::OwnerColumn, 100);
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   584
        h->resizeSection(RoomsListModel::MapColumn, 100);
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   585
        h->resizeSection(RoomsListModel::SchemeColumn, 100);
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   586
        h->resizeSection(RoomsListModel::WeaponsColumn, 100);
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   587
    }
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   588
9702
27006953d901 - Column for script in rooms list
unc0rr
parents: 9549
diff changeset
   589
    // hide column used for filtering
27006953d901 - Column for script in rooms list
unc0rr
parents: 9549
diff changeset
   590
    roomsList->hideColumn(RoomsListModel::StateColumn);
7011
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   591
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   592
    // save header state on change
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   593
    connect(roomsList->horizontalHeader(), SIGNAL(sortIndicatorChanged(int, Qt::SortOrder)),
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   594
            this, SLOT(saveHeaderState()));
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   595
    connect(roomsList->horizontalHeader(), SIGNAL(sectionResized(int, int, int)),
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   596
            this, SLOT(saveHeaderState()));
8453
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   597
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   598
    roomsList->repaint();
6995
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   599
}
6977
6a2ecad333da adjust column widths
sheepluva
parents: 6952
diff changeset
   600
6987
e34415c77342 allow custom sorting of roomslist (by clicking on header sections)
sheepluva
parents: 6977
diff changeset
   601
e34415c77342 allow custom sorting of roomslist (by clicking on header sections)
sheepluva
parents: 6977
diff changeset
   602
void PageRoomsList::onSortIndicatorChanged(int logicalIndex, Qt::SortOrder order)
e34415c77342 allow custom sorting of roomslist (by clicking on header sections)
sheepluva
parents: 6977
diff changeset
   603
{
6995
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   604
    if (roomsModel == NULL)
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   605
        return;
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   606
7011
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   607
    if (logicalIndex == 0)
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   608
    {
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   609
        roomsModel->sort(0, Qt::AscendingOrder);
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   610
        return;
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   611
    }
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   612
6989
4c35e9cf6057 make column sorting three-state: asc -> dsc -> off/default (= by room state)
sheepluva
parents: 6988
diff changeset
   613
    // 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
   614
    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
   615
        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
   616
            RoomsListModel::StateColumn, Qt::AscendingOrder);
6989
4c35e9cf6057 make column sorting three-state: asc -> dsc -> off/default (= by room state)
sheepluva
parents: 6988
diff changeset
   617
    else
4c35e9cf6057 make column sorting three-state: asc -> dsc -> off/default (= by room state)
sheepluva
parents: 6988
diff changeset
   618
        roomsModel->sort(logicalIndex, order);
6987
e34415c77342 allow custom sorting of roomslist (by clicking on header sections)
sheepluva
parents: 6977
diff changeset
   619
}
6995
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   620
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   621
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   622
void PageRoomsList::onFilterChanged()
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   623
{
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   624
    if (roomsModel == NULL)
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   625
        return;
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   626
9702
27006953d901 - Column for script in rooms list
unc0rr
parents: 9549
diff changeset
   627
    roomsModel->setFilterFixedString(searchText->text());
6995
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   628
8453
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   629
    bool stateLobby = showGamesInLobby->isChecked();
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   630
    bool stateProgress = showGamesInProgress->isChecked();
6995
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   631
8453
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   632
    if (stateLobby && stateProgress)
9702
27006953d901 - Column for script in rooms list
unc0rr
parents: 9549
diff changeset
   633
        stateFilteredModel->setFilterFixedString(QString()); // "any"
8453
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   634
    else if (stateLobby != stateProgress)
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   635
        stateFilteredModel->setFilterFixedString(QString(stateProgress));
6995
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   636
    else
8453
06541556df53 Reorganized layout and appearance of rooms list page.
dag10
parents: 8179
diff changeset
   637
        stateFilteredModel->setFilterFixedString(QString("none")); // Basically, none.
6995
6b44c0f11476 roomslist: reimplement filters
sheepluva
parents: 6993
diff changeset
   638
}
6996
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   639
8179
a1ffcb559f99 Refactor: get rid of excessive QSettings instances on the same poor hedgewars.ini file
unc0rr
parents: 7794
diff changeset
   640
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
   641
{
a1ffcb559f99 Refactor: get rid of excessive QSettings instances on the same poor hedgewars.ini file
unc0rr
parents: 7794
diff changeset
   642
    m_gameSettings = settings;
a1ffcb559f99 Refactor: get rid of excessive QSettings instances on the same poor hedgewars.ini file
unc0rr
parents: 7794
diff changeset
   643
}
6996
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   644
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   645
bool PageRoomsList::restoreHeaderState()
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   646
{
9031
9477443dd583 Rooms list/chat splitter from issue 612
unc0rr
parents: 8731
diff changeset
   647
    if (m_gameSettings->contains("frontend/roomslist_splitter"))
9477443dd583 Rooms list/chat splitter from issue 612
unc0rr
parents: 8731
diff changeset
   648
    {
9477443dd583 Rooms list/chat splitter from issue 612
unc0rr
parents: 8731
diff changeset
   649
        m_splitter->restoreState(QByteArray::fromBase64(
9477443dd583 Rooms list/chat splitter from issue 612
unc0rr
parents: 8731
diff changeset
   650
            (m_gameSettings->value("frontend/roomslist_splitter").toByteArray())));
9477443dd583 Rooms list/chat splitter from issue 612
unc0rr
parents: 8731
diff changeset
   651
    }
9477443dd583 Rooms list/chat splitter from issue 612
unc0rr
parents: 8731
diff changeset
   652
9477443dd583 Rooms list/chat splitter from issue 612
unc0rr
parents: 8731
diff changeset
   653
    if (m_gameSettings->contains("frontend/roomslist_header"))
9477443dd583 Rooms list/chat splitter from issue 612
unc0rr
parents: 8731
diff changeset
   654
    {
9477443dd583 Rooms list/chat splitter from issue 612
unc0rr
parents: 8731
diff changeset
   655
        return roomsList->horizontalHeader()->restoreState(QByteArray::fromBase64(
9477443dd583 Rooms list/chat splitter from issue 612
unc0rr
parents: 8731
diff changeset
   656
            (m_gameSettings->value("frontend/roomslist_header").toByteArray())));
9477443dd583 Rooms list/chat splitter from issue 612
unc0rr
parents: 8731
diff changeset
   657
    } else return false;
6996
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   658
}
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   659
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   660
void PageRoomsList::saveHeaderState()
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   661
{
7003
e118ee168577 tweak how the header customization is stored in the settings file
sheepluva
parents: 6996
diff changeset
   662
    m_gameSettings->setValue("frontend/roomslist_header",
7011
f6f09a0954ea small tweaks/fixes to room list header saving and restore...
sheepluva
parents: 7003
diff changeset
   663
        QString(roomsList->horizontalHeader()->saveState().toBase64()));
9031
9477443dd583 Rooms list/chat splitter from issue 612
unc0rr
parents: 8731
diff changeset
   664
9477443dd583 Rooms list/chat splitter from issue 612
unc0rr
parents: 8731
diff changeset
   665
    m_gameSettings->setValue("frontend/roomslist_splitter",
9477443dd583 Rooms list/chat splitter from issue 612
unc0rr
parents: 8731
diff changeset
   666
        QString(m_splitter->saveState().toBase64()));
6996
a0052cd32508 rooms list
sheepluva
parents: 6995
diff changeset
   667
}