QTfrontend/ui/page/pageadmin.cpp
author koda
Wed, 20 Apr 2016 14:46:04 -0400
changeset 11659 870f22de388b
parent 11046 47a8c19ecb60
child 12902 fc47fc4af6bd
permissions -rw-r--r--
Add support for compiling C engine with emscripten
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
11046
47a8c19ecb60 more copyright fixes
sheepluva
parents: 10108
diff changeset
     3
 * Copyright (c) 2004-2015 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
10108
c68cf030eded update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents: 9998
diff changeset
    16
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    17
 */
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    18
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    19
#include <QGridLayout>
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    20
#include <QLabel>
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    21
#include <QLineEdit>
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    22
#include <QSpinBox>
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    23
#include <QPushButton>
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    24
#include <QTextBrowser>
8157
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    25
#include <QTableWidget>
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    26
#include <QHeaderView>
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    27
5204
e1a5f4d5d86a split pages.h into several header files
koda
parents: 5078
diff changeset
    28
#include "pageadmin.h"
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    29
#include "chatwidget.h"
8157
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    30
#include "bandialog.h"
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    31
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: 6010
diff changeset
    32
QLayout * PageAdmin::bodyLayoutDefinition()
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    33
{
8157
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    34
    QVBoxLayout * pageLayout = new QVBoxLayout();
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6180
diff changeset
    35
8157
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    36
    QTabWidget * tabs = new QTabWidget(this);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    37
    pageLayout->addWidget(tabs);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    38
    QWidget * page1 = new QWidget(this);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    39
    QWidget * page2 = new QWidget(this);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    40
    tabs->addTab(page1, tr("General"));
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    41
    tabs->addTab(page2, tr("Bans"));
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    42
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    43
    // page 1
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    44
    {
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    45
        QGridLayout * tab1Layout = new QGridLayout(page1);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    46
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    47
        // 0
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    48
        pbAsk = addButton(tr("Fetch data"), tab1Layout, 0, 0, 1, 3);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    49
8157
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    50
        // 1
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    51
        QLabel * lblSMN = new QLabel(this);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    52
        lblSMN->setText(tr("Server message for latest version:"));
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    53
        tab1Layout->addWidget(lblSMN, 1, 0);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    54
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    55
        leServerMessageNew = new QLineEdit(this);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    56
        tab1Layout->addWidget(leServerMessageNew, 1, 1);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    57
8157
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    58
        // 2
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    59
        QLabel * lblSMO = new QLabel(this);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    60
        lblSMO->setText(tr("Server message for previous versions:"));
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    61
        tab1Layout->addWidget(lblSMO, 2, 0);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    62
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    63
        leServerMessageOld = new QLineEdit(this);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    64
        tab1Layout->addWidget(leServerMessageOld, 2, 1);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    65
8157
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    66
        // 3
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    67
        QLabel * lblP = new QLabel(this);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    68
        lblP->setText(tr("Latest version protocol number:"));
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    69
        tab1Layout->addWidget(lblP, 3, 0);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    70
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    71
        sbProtocol = new QSpinBox(this);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    72
        tab1Layout->addWidget(sbProtocol, 3, 1);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    73
8157
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    74
        // 4
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    75
        QLabel * lblPreview = new QLabel(this);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    76
        lblPreview->setText(tr("MOTD preview:"));
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    77
        tab1Layout->addWidget(lblPreview, 4, 0);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    78
8157
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    79
        tb = new QTextBrowser(this);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    80
        tb->setOpenExternalLinks(true);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    81
        tb->document()->setDefaultStyleSheet(HWChatWidget::styleSheet());
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    82
        tab1Layout->addWidget(tb, 4, 1, 1, 2);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    83
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    84
        // 5
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    85
        pbClearAccountsCache = addButton(tr("Clear Accounts Cache"), tab1Layout, 5, 0);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    86
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    87
        // 6
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    88
        pbSetSM = addButton(tr("Set data"), tab1Layout, 6, 0, 1, 3);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    89
    }
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    90
8157
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    91
    // page 2
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    92
    {
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    93
        QGridLayout * tab2Layout = new QGridLayout(page2);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    94
        twBans = new QTableWidget(this);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    95
        twBans->setColumnCount(3);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    96
        twBans->setHorizontalHeaderLabels(QStringList()
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    97
                              << tr("IP/Nick")
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    98
                              << tr("Expiration")
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    99
                              << tr("Reason")
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   100
                    );
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   101
        twBans->horizontalHeader()->setResizeMode(2, QHeaderView::Stretch);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   102
        twBans->setEditTriggers(QAbstractItemView::NoEditTriggers);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   103
        twBans->setSelectionBehavior(QAbstractItemView::SelectRows);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   104
        twBans->setSelectionMode(QAbstractItemView::SingleSelection);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   105
        twBans->setAlternatingRowColors(true);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   106
        tab2Layout->addWidget(twBans, 0, 1, 4, 1);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   107
8157
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   108
        QPushButton * btnRefresh = addButton(tr("Refresh"), tab2Layout, 0, 0);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   109
        QPushButton * btnAdd = addButton(tr("Add"), tab2Layout, 1, 0);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   110
        QPushButton * btnRemove = addButton(tr("Remove"), tab2Layout, 2, 0);
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 6180
diff changeset
   111
8157
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   112
        connect(btnRefresh, SIGNAL(clicked()), this, SIGNAL(bansListRequest()));
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   113
        connect(btnRefresh, SIGNAL(clicked()), this, SLOT(onRefreshClicked()));
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   114
        connect(btnAdd, SIGNAL(clicked()), this, SLOT(onAddClicked()));
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   115
        connect(btnRemove, SIGNAL(clicked()), this, SLOT(onRemoveClicked()));
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   116
    }
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   117
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: 6010
diff changeset
   118
    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: 6010
diff changeset
   119
}
6009
14f6fc9869f2 code cleanup/etc
sheepluva
parents: 5204
diff changeset
   120
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: 6010
diff changeset
   121
void PageAdmin::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: 6010
diff changeset
   122
{
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: 6010
diff changeset
   123
    connect(pbAsk, SIGNAL(clicked()), this, SIGNAL(askServerVars()));
6680
907999eff9e9 Show preview immediately on fetch
unc0rr
parents: 6616
diff changeset
   124
    connect(leServerMessageNew, SIGNAL(textChanged(QString)), tb, SLOT(setHtml(const QString &)));
907999eff9e9 Show preview immediately on fetch
unc0rr
parents: 6616
diff changeset
   125
    connect(leServerMessageOld, SIGNAL(textChanged(QString)), tb, SLOT(setHtml(const QString &)));
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: 6010
diff changeset
   126
    connect(pbClearAccountsCache, SIGNAL(clicked()), this, SIGNAL(clearAccountsCache()));
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: 6010
diff changeset
   127
    connect(pbSetSM, SIGNAL(clicked()), this, SLOT(smChanged()));
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: 6010
diff changeset
   128
}
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: 6010
diff changeset
   129
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: 6010
diff changeset
   130
PageAdmin::PageAdmin(QWidget* parent) : AbstractPage(parent)
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: 6010
diff changeset
   131
{
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: 6010
diff changeset
   132
    initPage();
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   133
}
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   134
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   135
void PageAdmin::smChanged()
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   136
{
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   137
    emit setServerMessageNew(leServerMessageNew->text());
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   138
    emit setServerMessageOld(leServerMessageOld->text());
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   139
    emit setProtocol(sbProtocol->value());
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   140
}
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   141
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   142
void PageAdmin::serverMessageNew(const QString & str)
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   143
{
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   144
    leServerMessageNew->setText(str);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   145
}
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   146
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   147
void PageAdmin::serverMessageOld(const QString & str)
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   148
{
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   149
    leServerMessageOld->setText(str);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   150
}
8157
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   151
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   152
void PageAdmin::protocol(int proto)
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   153
{
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   154
    sbProtocol->setValue(proto);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   155
}
8157
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   156
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   157
void PageAdmin::onAddClicked()
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   158
{
8177
1fc36c2168c4 Some fixes
unc0rr
parents: 8157
diff changeset
   159
    BanDialog dialog(this);
8157
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   160
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   161
    if(dialog.exec())
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   162
    {
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   163
        if(dialog.byIP())
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   164
        {
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   165
            emit banIP(dialog.banId(), dialog.reason(), dialog.duration());
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   166
        } else
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   167
        {
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   168
            emit banNick(dialog.banId(), dialog.reason(), dialog.duration());
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   169
        }
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   170
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   171
        emit bansListRequest();
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   172
    }
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   173
}
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   174
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   175
void PageAdmin::onRemoveClicked()
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   176
{
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   177
    QList<QTableWidgetItem *> sel = twBans->selectedItems();
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   178
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   179
    if(sel.size())
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   180
    {
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   181
        emit removeBan(twBans->item(sel[0]->row(), 0)->data(Qt::DisplayRole).toString());
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   182
        emit bansListRequest();
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   183
    }
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   184
}
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   185
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   186
void PageAdmin::setBansList(const QStringList & bans)
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   187
{
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   188
    if(bans.size() % 4)
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   189
        return;
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   190
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   191
    twBans->setRowCount(bans.size() / 4);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   192
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   193
    for(int i = 0; i < bans.size(); i += 4)
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   194
    {
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   195
        if(!twBans->item(i / 4, 0))
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   196
        {
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   197
            twBans->setItem(i / 4, 0, new QTableWidgetItem());
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   198
            twBans->setItem(i / 4, 1, new QTableWidgetItem());
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   199
            twBans->setItem(i / 4, 2, new QTableWidgetItem());
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   200
        }
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   201
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   202
        twBans->item(i / 4, 0)->setData(Qt::DisplayRole, bans[i + 1]);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   203
        twBans->item(i / 4, 1)->setData(Qt::DisplayRole, bans[i + 3]);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   204
        twBans->item(i / 4, 2)->setData(Qt::DisplayRole, bans[i + 2]);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   205
    }
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   206
}
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   207
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   208
void PageAdmin::onRefreshClicked()
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   209
{
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   210
    twBans->setRowCount(0);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   211
}