-
Notifications
You must be signed in to change notification settings - Fork 0
/
adminpanel.cpp
executable file
·136 lines (118 loc) · 3.6 KB
/
adminpanel.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*
* This file is part of community judge client project developed by Shervin Kh.
* Copyright (C) 2014 Shervin Kh.
* License: GPLv3 Or Later
* Full license could be found in License file shipped with program or at http://www.gnu.org/licenses/
*/
#include "adminpanel.h"
#include "mainwidget.h"
#include "problemmanagement.h"
#include "scoreplanmanager.h"
#include "usermanagement.h"
#include "connection.h"
#include "serverconfig.h"
#include "submissionpurge.h"
#include "contestmanagement.h"
#include "scoreboardconfig.h"
#include <QtGui>
#if QT_VERSION >= 0x050000
#include <QtWidgets>
#endif
AdminPanel::AdminPanel(MainWidget *MW, QWidget *parent) :
QWidget(parent), mw(MW)
{
PM = new ProblemManagement(mw);
CM = new ContestManagement(mw);
UM = new UserManagement(mw);
SPM = new ScorePlanManager(mw);
SC = new ServerConfig(mw);
SP = new SubmissionPurge(mw);
SBC = new ScoreboardConfig(mw);
buttons = new QListWidget;
buttons->addItem("Manage Problems");
buttons->addItem("Manage Contests");
buttons->addItem("Manage Users");
buttons->addItem("Manage Score Plans");
buttons->addItem("Scoreboard Configuration");
buttons->addItem("Server Configurations");
buttons->addItem("Submission Purge");
buttons->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Expanding);
connect(buttons, SIGNAL(currentRowChanged(int)), this, SLOT(selectChanged(int)));
backButton = new QPushButton("&Back To User Panel");
connect(backButton, SIGNAL(clicked()), this, SIGNAL(userPanel()));
connectedToLabel = new QLabel("<b>User: </b>");
QFont fntC;
fntC.setPointSize(12);
connectedToLabel->setFont(fntC);
userLayout = new QHBoxLayout;
userLayout->addWidget(connectedToLabel);
userLayout->addStretch();
userLayout->addWidget(backButton);
sw = new QStackedWidget;
sw->addWidget(PM);
sw->addWidget(CM);
sw->addWidget(UM);
sw->addWidget(SPM);
sw->addWidget(SBC);
sw->addWidget(SC);
sw->addWidget(SP);
rightLayout = new QVBoxLayout;
rightLayout->addLayout(userLayout);
rightLayout->addWidget(sw);
totalLayout = new QHBoxLayout;
totalLayout->addWidget(buttons);
totalLayout->addLayout(rightLayout);
setLayout(totalLayout);
connect(sw, SIGNAL(currentChanged(int)), this, SLOT(onSwitch()));
}
void AdminPanel::init()
{
disconnect(sw, SIGNAL(currentChanged(int)), this, SLOT(onSwitch()));
connectedToLabel->setText(QString("<b>User: </b>%1@%4 %2:%3").arg(mw->currentUsername())
.arg(mw->connection()->currentAddress().host())
.arg(mw->connection()->currentAddress().port())
.arg(mw->connection()->currentAddress().scheme() == "ssl" ? "SSL:" : ""));
PM->init();
UM->init();
SPM->init();
SC->init();
SP->init();
CM->init();
SBC->init();
sw->setCurrentIndex(0);
buttons->setCurrentRow(0);
connect(sw, SIGNAL(currentChanged(int)), this, SLOT(onSwitch()));
}
void AdminPanel::onSwitch()
{
switch (sw->currentIndex())
{
case 0:
PM->onSwitch();
break;
case 1:
CM->onSwitch();
break;
case 2:
UM->onSwitch();
break;
case 3:
SPM->onSwitch();
break;
case 4:
SBC->onSwitch();
break;
case 5:
SC->onSwitch();
break;
case 6:
SP->onSwitch();
break;
default:
break;
}
}
void AdminPanel::selectChanged(int sel)
{
sw->setCurrentIndex(sel);
}