QTfrontend/ui/page/pageadmin.cpp
author Wuzzy <Wuzzy2@mail.ru>
Mon, 01 Apr 2019 17:35:07 +0200
changeset 14752 3246e5c8cf69
parent 13676 05fde8e30041
child 15276 2dc98f688c65
permissions -rw-r--r--
Update German translation
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);
13676
05fde8e30041 Add a few translator comments for frontend strings
Wuzzy <Wuzzy2@mail.ru>
parents: 12897
diff changeset
    76
        //: MOTD = Message Of The Day, the message which is shown to players joining the server
8157
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    77
        lblPreview->setText(tr("MOTD preview:"));
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    78
        tab1Layout->addWidget(lblPreview, 4, 0);
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    79
8157
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    80
        tb = new QTextBrowser(this);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    81
        tb->setOpenExternalLinks(true);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    82
        tb->document()->setDefaultStyleSheet(HWChatWidget::styleSheet());
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    83
        tab1Layout->addWidget(tb, 4, 1, 1, 2);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    84
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    85
        // 5
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    86
        pbClearAccountsCache = addButton(tr("Clear Accounts Cache"), tab1Layout, 5, 0);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    87
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    88
        // 6
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    89
        pbSetSM = addButton(tr("Set data"), tab1Layout, 6, 0, 1, 3);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    90
    }
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
    91
8157
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    92
    // page 2
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    93
    {
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    94
        QGridLayout * tab2Layout = new QGridLayout(page2);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    95
        twBans = new QTableWidget(this);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    96
        twBans->setColumnCount(3);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    97
        twBans->setHorizontalHeaderLabels(QStringList()
13676
05fde8e30041 Add a few translator comments for frontend strings
Wuzzy <Wuzzy2@mail.ru>
parents: 12897
diff changeset
    98
                              //: IP = short for "IP address" (Internet Protocol). Nick = short for "nick name"
8157
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
    99
                              << tr("IP/Nick")
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   100
                              << tr("Expiration")
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   101
                              << tr("Reason")
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   102
                    );
12897
fc47fc4af6bd Finish porting. Seems to work, but no thorough testing has been performed
unc0rr
parents: 11046
diff changeset
   103
        twBans->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Stretch);
8157
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   104
        twBans->setEditTriggers(QAbstractItemView::NoEditTriggers);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   105
        twBans->setSelectionBehavior(QAbstractItemView::SelectRows);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   106
        twBans->setSelectionMode(QAbstractItemView::SingleSelection);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   107
        twBans->setAlternatingRowColors(true);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   108
        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
   109
8157
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   110
        QPushButton * btnRefresh = addButton(tr("Refresh"), tab2Layout, 0, 0);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   111
        QPushButton * btnAdd = addButton(tr("Add"), tab2Layout, 1, 0);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   112
        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
   113
8157
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   114
        connect(btnRefresh, SIGNAL(clicked()), this, SIGNAL(bansListRequest()));
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   115
        connect(btnRefresh, SIGNAL(clicked()), this, SLOT(onRefreshClicked()));
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   116
        connect(btnAdd, SIGNAL(clicked()), this, SLOT(onAddClicked()));
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   117
        connect(btnRemove, SIGNAL(clicked()), this, SLOT(onRemoveClicked()));
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   118
    }
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   119
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
   120
    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
   121
}
6009
14f6fc9869f2 code cleanup/etc
sheepluva
parents: 5204
diff changeset
   122
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
   123
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
   124
{
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
   125
    connect(pbAsk, SIGNAL(clicked()), this, SIGNAL(askServerVars()));
6680
907999eff9e9 Show preview immediately on fetch
unc0rr
parents: 6616
diff changeset
   126
    connect(leServerMessageNew, SIGNAL(textChanged(QString)), tb, SLOT(setHtml(const QString &)));
907999eff9e9 Show preview immediately on fetch
unc0rr
parents: 6616
diff changeset
   127
    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
   128
    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
   129
    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
   130
}
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
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
   133
{
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
   134
    initPage();
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   135
}
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
void PageAdmin::smChanged()
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   138
{
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   139
    emit setServerMessageNew(leServerMessageNew->text());
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   140
    emit setServerMessageOld(leServerMessageOld->text());
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   141
    emit setProtocol(sbProtocol->value());
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   142
}
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   143
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   144
void PageAdmin::serverMessageNew(const QString & 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
    leServerMessageNew->setText(str);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   147
}
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
void PageAdmin::serverMessageOld(const QString & str)
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   150
{
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   151
    leServerMessageOld->setText(str);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   152
}
8157
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   153
5078
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   154
void PageAdmin::protocol(int proto)
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   155
{
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   156
    sbProtocol->setValue(proto);
3527f0e7bb21 Removing pages.cpp and splitting it up into various files.
Zorg <zorgiepoo@gmail.com>
parents:
diff changeset
   157
}
8157
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   158
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   159
void PageAdmin::onAddClicked()
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   160
{
8177
1fc36c2168c4 Some fixes
unc0rr
parents: 8157
diff changeset
   161
    BanDialog dialog(this);
8157
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   162
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   163
    if(dialog.exec())
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   164
    {
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   165
        if(dialog.byIP())
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   166
        {
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   167
            emit banIP(dialog.banId(), dialog.reason(), dialog.duration());
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   168
        } else
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   169
        {
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   170
            emit banNick(dialog.banId(), dialog.reason(), dialog.duration());
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   171
        }
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   172
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   173
        emit bansListRequest();
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   174
    }
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   175
}
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   176
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   177
void PageAdmin::onRemoveClicked()
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   178
{
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   179
    QList<QTableWidgetItem *> sel = twBans->selectedItems();
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   180
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   181
    if(sel.size())
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   182
    {
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   183
        emit removeBan(twBans->item(sel[0]->row(), 0)->data(Qt::DisplayRole).toString());
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   184
        emit bansListRequest();
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   185
    }
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   186
}
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   187
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   188
void PageAdmin::setBansList(const QStringList & bans)
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   189
{
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   190
    if(bans.size() % 4)
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   191
        return;
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   192
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   193
    twBans->setRowCount(bans.size() / 4);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   194
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   195
    for(int i = 0; i < bans.size(); i += 4)
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   196
    {
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   197
        if(!twBans->item(i / 4, 0))
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   198
        {
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   199
            twBans->setItem(i / 4, 0, new QTableWidgetItem());
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   200
            twBans->setItem(i / 4, 1, new QTableWidgetItem());
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   201
            twBans->setItem(i / 4, 2, new QTableWidgetItem());
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   202
        }
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   203
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   204
        twBans->item(i / 4, 0)->setData(Qt::DisplayRole, bans[i + 1]);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   205
        twBans->item(i / 4, 1)->setData(Qt::DisplayRole, bans[i + 3]);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   206
        twBans->item(i / 4, 2)->setData(Qt::DisplayRole, bans[i + 2]);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   207
    }
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   208
}
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   209
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   210
void PageAdmin::onRefreshClicked()
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   211
{
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   212
    twBans->setRowCount(0);
695f1eef72c8 Bans manager
unc0rr
parents: 6952
diff changeset
   213
}