mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-08 02:53:25 -08:00
* [DeckList] Apply include-what-you-use to libcockatrice_deck_list * [IWYU] Apply include-what-you-use across the tree Run one whole-tree IWYU pass over the libcockatrice_* libraries, the Cockatrice client, Oracle, Servatrice and the test suite, so each translation unit includes what it uses directly and forward-declares what it does not need. IWYU only analyses real translation units, never the moc code CMake generates from Q_OBJECT headers, so it strips includes that moc output silently relies on. Where a type is passed by value (or nested in a QList/QMap) in a signal or slot signature, the generated moc code needs the complete type; those includes are kept with an explanatory `// IWYU pragma: keep`. The same holds for Q_DECLARE_METATYPE targets such as QSqlDatabase. A handful of includes are added by hand where callers brace-initialize a const-reference parameter, which also requires the complete type. Applied as a single commit on purpose: stripping includes from the libcockatrice_* headers is precisely what breaks the client, test and server translation units, and the fixes for those live in the same translation units. Splitting by component would therefore leave intermediate commits that do not compile. All 426 modified Q_OBJECT/Q_GADGET headers were verified to be moc-self-contained by compiling each generated moc_*.cpp standalone; several built only because of moc include ordering in mocs_compilation.cpp before the keep-includes were added. * [Tooling] Emit public Qt headers and fix IWYU fallout CI found Three problems the local build could not see, all because a green local build only proves the configuration it was run under. Private Qt headers. IWYU emitted private, lowercase Qt headers, and qtypes.h does not exist at all before Qt 6.9, so the Debian 12 and Ubuntu 24.04 jobs on Qt 6.4.2 failed to compile. The generator only emitted a mapping when the capital header name mirrored the private one (QAbstractAnimation for qabstractanimation.h), so qtypes.h, which is wrapped by QtTypes instead, got no mapping and kept the private spelling. Map it explicitly to <QtTypes>, which is public since Qt 5 and provides the same typedefs either way, and rewrite the 100 affected includes. Do not generalize this to "prefer any Qt* wrapper". The table is generated from whichever Qt is installed, and the wrappers are not equally old: QtLogging only appeared in Qt 6.8 and QtMinMax in 6.5, so that heuristic trades one breakage for another. Every other lowercase header still in the tree has shipped publicly since Qt 5, so those are left alone. Platform-guarded includes. IWYU only sees the preprocessor configuration it is handed, so it dropped an include that only the macOS branch of main.cpp needs, and the macOS jobs failed on an undeclared UrlSchemeEventFilter. Restore the include. Force-compiling every file that carries a platform guard under Q_OS_MAC, Q_OS_MACOS and __APPLE__ reports nothing else, so the macOS branches are covered rather than assumed. shellcheck. Drop a leftover variable and stop assigning the include-what-you-use lookup, which was only ever an existence check. * [Tooling] Map Qt 6.5+ split headers to QtGlobal for Qt 6.4 compatibility IWYU emitted QtTypes, QtPreprocessorSupport, QtVersionChecks, QtAssert, QtMinMax, QtClassHelperMacros, QtEnvironmentVariables and QtTranslation. Qt 6.5 split those declarations out of qglobal.h into separate headers, so neither the Qt* wrapper nor the q*.h private name exists on the oldest Qt we support (6.4.2), and Debian 12 / Ubuntu 24.04 fail with "No such file or directory". qtypes.h is worse still: it only appeared in Qt 6.9. QtGlobal is the one spelling that works across the whole supported range. It has been public since Qt 5, defines these declarations itself up to Qt 6.4, and includes the split headers from Qt 6.5 on, so redirect all eight private headers to it and collapse the affected includes in the tree. Curated overrides now take precedence over the name-mirroring rule, which cannot know about Qt version floors because the mapping is generated from whatever Qt is installed. That rule was mapping qtversionchecks.h to <QtVersionChecks> even with an override present, because the override was only consulted as a fallback. A curated key that matches nothing is now a hard error rather than a silent fallback, and the redirected headers are no longer advertised as the home of a symbol. Verified every Qt include in the tree resolves against the real qt6-base-dev 6.4.2 package: 15 distinct includes, 0 missing. * [Tooling] Map QOverload to QtGlobal and drop the QMetaMethodArgument include Two more headers IWYU emitted do not exist on Qt 6.4.2: QOverload was split out of qglobal.h in Qt 6.5, so on 6.4.2 it is declared in qglobal.h directly and the standalone header is a hard error. QtGlobal covers both, so map qoverload.h to it like the other 6.5+ split headers. QMetaMethodArgument is never referenced anywhere in the tree. It is a bare forwarder for qobjectdefs.h that our generator advertised as a class symbol, which is how IWYU came to add the include at all. The symbol mappings are generated from header names, so they cannot tell a forwarder that happens to be capitalised from a real class; removing the unused include is the fix, and the generic case stays a known limitation of the generator. Extending the audit to every Q* header (an earlier pass only matched headers starting with "Qt" or lowercase q*.h, so it missed all of them) against the real qt6-base-dev, qt6-multimedia-dev, qt6-declarative-dev, qt6-svg-dev and qt6-websockets-dev 6.4.2 packages: 341 distinct Qt includes, 0 missing. * [Game] Give moc the complete CardItem type in player_actions.h player_actions.h forward declares CardItem but passes QList<CardItem *> by value in actPlay/actPlayFacedown/actHide. moc instantiates the metatype for those parameters, and on Qt 6.4 that expands to sizeof(CardItem), so Ubuntu 24.04 fails with "invalid application of 'sizeof' to incomplete type 'CardItem'". Newer Qt tolerates the incomplete type, which is why only the 6.4.2 jobs failed. Include the defining header with an IWYU pragma keep, matching how the other MOC-required includes in this area are handled. * [Game] Give moc the complete ServerInfo_Card type player_logic.h, game_scene.h, view_zone.h and view_zone_widget.h forward declare ServerInfo_Card but pass QList<const ServerInfo_Card *> through signal and slot signatures. moc instantiates the metatype for those parameters, which Qt 6.4 expands to sizeof(ServerInfo_Card), so the connect in game_scene.cpp fails on Debian 12 and Ubuntu 24.04 with "invalid application of 'sizeof' to incomplete type 'const ServerInfo_Card'". Newer Qt tolerates it, so only the 6.4.2 jobs failed. Include the generated protobuf header with an IWYU pragma keep, following the pattern already used for ServerInfo_Player and ServerInfo_User in game_event_handler.h. * [Client] Complete the types Qt 6.4 needs for connect and moc Qt 6.4 expands QMetaType::fromType on the normalised argument list of a PMF connect and on moc-generated metatypes, which requires sizeof on every signal and slot parameter. Newer Qt tolerates forward declarations there, so only the Debian 12 and Ubuntu 24.04 jobs failed, with "invalid application of 'sizeof' to incomplete type" for QMouseEvent, QPrinter and GameReplay. Replace the forward declarations with the real includes: - QMouseEvent in the nine widget headers that pass it through signals - QPrinter in abstract_tab_deck_editor.cpp, for the actPrintDeck lambda - game_replay.pb.h in tab_replays.h. GameReplay is a protobuf message, so the project's game/replay.h only forward declares it and cannot supply the complete type. Found by recompiling all 1918 project TUs against the Debian Qt 6.4.2 headers, which reproduces those two CI jobs locally in one pass. * [Client] Complete Release and QMenu for Qt 6.4 moc and connect Continuing the Qt 6.4 complete-type sweep: - window_main.cpp connects ClientUpdateChecker::finishedCheck to MainWindow::checkClientUpdatesFinished, whose Release * parameter made moc 6.4 instantiate the metatype. GameReplay turned out to be a protobuf message, so Release likewise needed release_channel.h in the three headers declaring those signals: window_main.h, dlg_update.h and client_update_checker.h. - moc 6.4 also needs sizeof(QMenu) for the QList<QMenu *> carried by TabSupervisor::setMenu and MainWindow::updateTabMenu. Verified by regenerating moc output with the Debian moc 6.4.2 for all 434 Q_OBJECT/Q_GADGET classes and compiling it, plus recompiling all 1612 source TUs, against the Qt 6.4.2 headers: no remaining failures. --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
937 lines
34 KiB
C++
937 lines
34 KiB
C++
#include "tab_report.h"
|
|
|
|
#include "../utility/report_utils.h"
|
|
#include "abstract_client.h"
|
|
#include "libcockatrice/protocol/pb/response.pb.h"
|
|
#include "tab_supervisor.h"
|
|
|
|
#include <QAbstractItemView>
|
|
#include <QChar>
|
|
#include <QCheckBox>
|
|
#include <QComboBox>
|
|
#include <QDateTime>
|
|
#include <QDebug>
|
|
#include <QFont>
|
|
#include <QFontDatabase>
|
|
#include <QGridLayout>
|
|
#include <QGroupBox>
|
|
#include <QHBoxLayout>
|
|
#include <QHeaderView>
|
|
#include <QInputDialog>
|
|
#include <QLabel>
|
|
#include <QLineEdit>
|
|
#include <QPushButton>
|
|
#include <QSharedPointer>
|
|
#include <QSignalBlocker>
|
|
#include <QSplitter>
|
|
#include <QTableWidget>
|
|
#include <QTableWidgetItem>
|
|
#include <QTextCursor>
|
|
#include <QTextEdit>
|
|
#include <QTimer>
|
|
#include <QVBoxLayout>
|
|
#include <QVariant>
|
|
#include <QWidget>
|
|
#include <QtGlobal>
|
|
#include <libcockatrice/protocol/pb/command_replay_download_by_game_id.pb.h>
|
|
#include <libcockatrice/protocol/pb/command_report_add_comment.pb.h>
|
|
#include <libcockatrice/protocol/pb/command_report_assign.pb.h>
|
|
#include <libcockatrice/protocol/pb/command_report_details.pb.h>
|
|
#include <libcockatrice/protocol/pb/command_report_list.pb.h>
|
|
#include <libcockatrice/protocol/pb/command_report_resolve.pb.h>
|
|
#include <libcockatrice/protocol/pb/command_report_stats.pb.h>
|
|
#include <libcockatrice/protocol/pb/command_report_user_info.pb.h>
|
|
#include <libcockatrice/protocol/pb/game_replay.pb.h>
|
|
#include <libcockatrice/protocol/pb/response_replay_download_by_game_id.pb.h>
|
|
#include <libcockatrice/protocol/pb/response_report_details.pb.h>
|
|
#include <libcockatrice/protocol/pb/response_report_list.pb.h>
|
|
#include <libcockatrice/protocol/pb/response_report_stats.pb.h>
|
|
#include <libcockatrice/protocol/pb/response_report_user_info.pb.h>
|
|
#include <libcockatrice/protocol/pb/serverinfo_report.pb.h>
|
|
#include <libcockatrice/protocol/pending_command.h>
|
|
#include <qnamespace.h>
|
|
#include <string>
|
|
|
|
namespace
|
|
{
|
|
constexpr int COL_ID = 0;
|
|
constexpr int COL_TIME = 1;
|
|
constexpr int COL_REPORTER = 2;
|
|
constexpr int COL_REPORTED = 3;
|
|
constexpr int COL_CATEGORY = 4;
|
|
constexpr int COL_GAMEID = 5;
|
|
constexpr int COL_STATUS = 6;
|
|
constexpr int COL_ASSIGNED = 7;
|
|
constexpr int COL_REPLAY = 8;
|
|
constexpr int COL_ROOM = 9;
|
|
constexpr int COL_COUNT = 10;
|
|
constexpr int REFRESH_INTERVAL_MS = 300000;
|
|
} // namespace
|
|
|
|
TabReport::TabReport(TabSupervisor *_tabSupervisor, AbstractClient *_client) : Tab(_tabSupervisor), client(_client)
|
|
{
|
|
auto *centralWidget = new QWidget(this);
|
|
setCentralWidget(centralWidget);
|
|
|
|
searchEdit = new QLineEdit;
|
|
searchEdit->setClearButtonEnabled(true);
|
|
connect(searchEdit, &QLineEdit::textChanged, this, &TabReport::applyFilters);
|
|
|
|
statusFilter = new QComboBox;
|
|
connect(statusFilter, &QComboBox::currentIndexChanged, this, &TabReport::applyFilters);
|
|
|
|
unresolvedOnlyBox = new QCheckBox;
|
|
unresolvedOnlyBox->setChecked(true);
|
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
|
|
connect(unresolvedOnlyBox, &QCheckBox::checkStateChanged, this, &TabReport::refreshList);
|
|
#else
|
|
connect(unresolvedOnlyBox, &QCheckBox::stateChanged, this, &TabReport::refreshList);
|
|
#endif
|
|
|
|
refreshButton = new QPushButton;
|
|
connect(refreshButton, &QPushButton::clicked, this, &TabReport::refreshList);
|
|
|
|
refreshTimer = new QTimer(this);
|
|
refreshTimer->setInterval(REFRESH_INTERVAL_MS);
|
|
connect(refreshTimer, &QTimer::timeout, this, [this]() {
|
|
if (tabSupervisor->currentWidget() == this) {
|
|
refreshList();
|
|
}
|
|
});
|
|
refreshTimer->start();
|
|
|
|
auto *topBar = new QHBoxLayout;
|
|
topBar->addWidget(searchEdit);
|
|
topBar->addWidget(statusFilter);
|
|
topBar->addWidget(unresolvedOnlyBox);
|
|
topBar->addStretch();
|
|
topBar->addWidget(refreshButton);
|
|
|
|
statsLabel = new QLabel;
|
|
|
|
table = new QTableWidget(0, COL_COUNT);
|
|
table->setSelectionBehavior(QAbstractItemView::SelectRows);
|
|
table->setSelectionMode(QAbstractItemView::SingleSelection);
|
|
table->setEditTriggers(QAbstractItemView::NoEditTriggers);
|
|
table->setSortingEnabled(true);
|
|
table->verticalHeader()->setVisible(false);
|
|
table->setAlternatingRowColors(true);
|
|
table->horizontalHeader()->setSectionResizeMode(COL_TIME, QHeaderView::ResizeToContents);
|
|
table->horizontalHeader()->setSectionResizeMode(COL_REPORTED, QHeaderView::Stretch);
|
|
table->horizontalHeader()->setSectionResizeMode(COL_REPORTER, QHeaderView::ResizeToContents);
|
|
connect(table, &QTableWidget::itemSelectionChanged, this, &TabReport::onSelectionChanged);
|
|
|
|
descGroup = new QGroupBox;
|
|
descriptionEdit = new QTextEdit;
|
|
descriptionEdit->setReadOnly(true);
|
|
auto *descLayout = new QVBoxLayout(descGroup);
|
|
descLayout->setContentsMargins(4, 4, 4, 4);
|
|
descLayout->addWidget(descriptionEdit);
|
|
|
|
chatGroup = new QGroupBox;
|
|
chatLogEdit = new QTextEdit;
|
|
chatLogEdit->setReadOnly(true);
|
|
QFont monoFont("monospace");
|
|
monoFont.setStyleHint(QFont::Monospace);
|
|
const int systemPointSize = QFontDatabase::systemFont(QFontDatabase::GeneralFont).pointSize();
|
|
if (systemPointSize > 0) {
|
|
monoFont.setPointSize(systemPointSize);
|
|
}
|
|
chatLogEdit->setFont(monoFont);
|
|
auto *chatLayout = new QVBoxLayout(chatGroup);
|
|
chatLayout->setContentsMargins(4, 4, 4, 4);
|
|
chatLayout->addWidget(chatLogEdit);
|
|
|
|
commentsGroup = new QGroupBox;
|
|
commentsEdit = new QTextEdit;
|
|
commentsEdit->setReadOnly(true);
|
|
auto *commentInputRow = new QHBoxLayout;
|
|
commentInput = new QLineEdit;
|
|
commentButton = new QPushButton;
|
|
commentButton->setEnabled(false);
|
|
connect(commentButton, &QPushButton::clicked, this, &TabReport::addComment);
|
|
connect(commentInput, &QLineEdit::returnPressed, this, &TabReport::addComment);
|
|
commentInputRow->addWidget(commentInput);
|
|
commentInputRow->addWidget(commentButton);
|
|
auto *commentsLayout = new QVBoxLayout(commentsGroup);
|
|
commentsLayout->setContentsMargins(4, 4, 4, 4);
|
|
commentsLayout->addWidget(commentsEdit);
|
|
commentsLayout->addLayout(commentInputRow);
|
|
|
|
userContextGroup = new QGroupBox;
|
|
userContextName = new QLabel;
|
|
userContextAccountAge = new QLabel;
|
|
userContextReports = new QLabel;
|
|
userContextBans = new QLabel;
|
|
userContextWarns = new QLabel;
|
|
userContextNotes = new QTextEdit;
|
|
userContextNotes->setReadOnly(true);
|
|
userContextNotes->setMaximumHeight(80);
|
|
userContextRecentReports = new QTextEdit;
|
|
userContextRecentReports->setReadOnly(true);
|
|
userContextRecentReports->setMaximumHeight(120);
|
|
userContextUserLabel = new QLabel;
|
|
userContextAgeLabel = new QLabel;
|
|
userContextReportsLabel = new QLabel;
|
|
userContextBansLabel = new QLabel;
|
|
userContextWarnsLabel = new QLabel;
|
|
userContextNotesLabel = new QLabel;
|
|
userContextRecentReportsLabel = new QLabel;
|
|
auto *ucLayout = new QGridLayout(userContextGroup);
|
|
ucLayout->setContentsMargins(8, 8, 8, 8);
|
|
ucLayout->addWidget(userContextUserLabel, 0, 0);
|
|
ucLayout->addWidget(userContextName, 0, 1, 1, 3);
|
|
ucLayout->addWidget(userContextAgeLabel, 1, 0);
|
|
ucLayout->addWidget(userContextAccountAge, 1, 1);
|
|
ucLayout->addWidget(userContextReportsLabel, 1, 2);
|
|
ucLayout->addWidget(userContextReports, 1, 3);
|
|
ucLayout->addWidget(userContextBansLabel, 2, 0);
|
|
ucLayout->addWidget(userContextBans, 2, 1);
|
|
ucLayout->addWidget(userContextWarnsLabel, 2, 2);
|
|
ucLayout->addWidget(userContextWarns, 2, 3);
|
|
ucLayout->addWidget(userContextNotesLabel, 3, 0, Qt::AlignTop);
|
|
ucLayout->addWidget(userContextNotes, 3, 1, 1, 3);
|
|
ucLayout->addWidget(userContextRecentReportsLabel, 4, 0, 1, 4);
|
|
ucLayout->addWidget(userContextRecentReports, 5, 0, 1, 4);
|
|
userContextGroup->setVisible(false);
|
|
|
|
statsGroup = new QGroupBox;
|
|
statsGroup->setCheckable(true);
|
|
statsTotalLabel = new QLabel;
|
|
statsTrendLabel = new QLabel;
|
|
statsCategoriesLabel = new QLabel;
|
|
statsDetailText = new QTextEdit;
|
|
statsDetailText->setReadOnly(true);
|
|
statsDetailText->setMaximumHeight(150);
|
|
auto *statsContent = new QWidget;
|
|
auto *sgLayout = new QVBoxLayout(statsContent);
|
|
sgLayout->setContentsMargins(8, 8, 8, 8);
|
|
sgLayout->addWidget(statsTotalLabel);
|
|
sgLayout->addWidget(statsTrendLabel);
|
|
sgLayout->addWidget(statsCategoriesLabel);
|
|
sgLayout->addWidget(statsDetailText);
|
|
auto *statsGroupLayout = new QVBoxLayout(statsGroup);
|
|
statsGroupLayout->setContentsMargins(0, 0, 0, 0);
|
|
statsGroupLayout->addWidget(statsContent);
|
|
statsGroup->setChecked(true);
|
|
connect(statsGroup, &QGroupBox::toggled, this, [this, statsContent](bool checked) {
|
|
statsContent->setVisible(checked);
|
|
if (checked) {
|
|
requestStats();
|
|
}
|
|
});
|
|
|
|
detailSplitter = new QSplitter(Qt::Vertical);
|
|
detailSplitter->addWidget(descGroup);
|
|
detailSplitter->addWidget(chatGroup);
|
|
detailSplitter->addWidget(commentsGroup);
|
|
detailSplitter->setStretchFactor(0, 1);
|
|
detailSplitter->setStretchFactor(1, 1);
|
|
detailSplitter->setStretchFactor(2, 2);
|
|
|
|
assignButton = new QPushButton;
|
|
resolveButton = new QPushButton;
|
|
resolveWithNoteButton = new QPushButton;
|
|
dismissButton = new QPushButton;
|
|
viewReplayButton = new QPushButton;
|
|
joinGameButton = new QPushButton;
|
|
connect(assignButton, &QPushButton::clicked, this, &TabReport::assignReport);
|
|
connect(resolveButton, &QPushButton::clicked, this, [this]() { resolveReport(false, false); });
|
|
connect(resolveWithNoteButton, &QPushButton::clicked, this, [this]() { resolveReport(false, true); });
|
|
connect(dismissButton, &QPushButton::clicked, this, [this]() { resolveReport(true, true); });
|
|
connect(viewReplayButton, &QPushButton::clicked, this, &TabReport::viewReplay);
|
|
connect(joinGameButton, &QPushButton::clicked, this, &TabReport::joinGame);
|
|
|
|
statusLabel = new QLabel;
|
|
|
|
auto *actionBar = new QHBoxLayout;
|
|
actionBar->addWidget(assignButton);
|
|
actionBar->addWidget(resolveButton);
|
|
actionBar->addWidget(resolveWithNoteButton);
|
|
actionBar->addWidget(dismissButton);
|
|
actionBar->addSpacing(20);
|
|
actionBar->addWidget(viewReplayButton);
|
|
actionBar->addWidget(joinGameButton);
|
|
actionBar->addStretch();
|
|
actionBar->addWidget(statusLabel);
|
|
|
|
auto *layout = new QVBoxLayout(centralWidget);
|
|
layout->addLayout(topBar);
|
|
layout->addWidget(statsLabel);
|
|
layout->addWidget(table, 2);
|
|
layout->addWidget(detailSplitter, 1);
|
|
layout->addWidget(userContextGroup);
|
|
layout->addWidget(statsGroup);
|
|
layout->addLayout(actionBar);
|
|
|
|
retranslateUi();
|
|
|
|
setActionsEnabled(false);
|
|
refreshList();
|
|
}
|
|
|
|
void TabReport::retranslateUi()
|
|
{
|
|
searchEdit->setPlaceholderText(tr("Search by username, category..."));
|
|
statusFilter->clear();
|
|
statusFilter->addItem(tr("All Statuses"), "");
|
|
statusFilter->addItem(tr("Open"), "open");
|
|
statusFilter->addItem(tr("Assigned"), "assigned");
|
|
statusFilter->addItem(tr("Resolved"), "resolved");
|
|
statusFilter->addItem(tr("Dismissed"), "dismissed");
|
|
unresolvedOnlyBox->setText(tr("Unresolved only"));
|
|
refreshButton->setText(tr("Refresh"));
|
|
|
|
table->setHorizontalHeaderLabels({tr("#"), tr("Time"), tr("Reporter"), tr("Reported User"), tr("Category"),
|
|
tr("Game ID"), tr("Status"), tr("Assigned To"), tr("Replay"), tr("Room")});
|
|
|
|
descGroup->setTitle(tr("Description"));
|
|
chatGroup->setTitle(tr("Chat Log Context"));
|
|
chatGroup->setToolTip(
|
|
tr("Chat log attached by the reporter. It is captured from their client and may be incomplete or edited."));
|
|
commentsGroup->setTitle(tr("Comments / Thread"));
|
|
descriptionEdit->setPlaceholderText(tr("No description."));
|
|
chatLogEdit->setPlaceholderText(tr("No chat log attached."));
|
|
commentsEdit->setPlaceholderText(tr("No comments yet."));
|
|
commentInput->setPlaceholderText(tr("Type a reply..."));
|
|
commentButton->setText(tr("Send"));
|
|
|
|
userContextGroup->setTitle(tr("Reported User Context"));
|
|
userContextUserLabel->setText(tr("User:"));
|
|
userContextAgeLabel->setText(tr("Account Age:"));
|
|
userContextReportsLabel->setText(tr("Reports:"));
|
|
userContextBansLabel->setText(tr("Bans:"));
|
|
userContextWarnsLabel->setText(tr("Warns:"));
|
|
userContextNotesLabel->setText(tr("Admin Notes:"));
|
|
userContextRecentReportsLabel->setText(tr("Recent Reports Against User:"));
|
|
userContextAccountAge->setText(QString());
|
|
userContextReports->setText(QString());
|
|
userContextBans->setText(QString());
|
|
userContextWarns->setText(QString());
|
|
|
|
statsGroup->setTitle(tr("Report Statistics"));
|
|
|
|
assignButton->setText(tr("Assign to Me"));
|
|
resolveButton->setText(tr("Resolve"));
|
|
resolveWithNoteButton->setText(tr("Resolve with note..."));
|
|
dismissButton->setText(tr("Dismiss..."));
|
|
viewReplayButton->setText(tr("View Replay"));
|
|
joinGameButton->setText(tr("Join Game"));
|
|
}
|
|
|
|
void TabReport::refreshList()
|
|
{
|
|
selectedReportIdBeforeRefresh = selectedReportId();
|
|
commentDraftBeforeRefresh = commentInput->text();
|
|
previousSelectedReportValid = selectedReportInfo(previousSelectedReport);
|
|
|
|
refreshButton->setEnabled(false);
|
|
statusLabel->setText(tr("Loading..."));
|
|
table->setRowCount(0);
|
|
allReports.clear();
|
|
filteredReports.clear();
|
|
commentButton->setEnabled(false);
|
|
setActionsEnabled(false);
|
|
|
|
Command_ReportList cmd;
|
|
cmd.set_unresolved_only(unresolvedOnlyBox->isChecked());
|
|
|
|
PendingCommand *pend = client->prepareModeratorCommand(cmd);
|
|
connect(pend, &PendingCommand::finished, this, &TabReport::reportListResponse);
|
|
client->sendCommand(pend);
|
|
}
|
|
|
|
void TabReport::reportListResponse(const Response &response)
|
|
{
|
|
refreshButton->setEnabled(true);
|
|
|
|
if (response.response_code() != Response::RespOk) {
|
|
statusLabel->setText(tr("Failed to load reports."));
|
|
return;
|
|
}
|
|
|
|
const Response_ReportList &resp = response.GetExtension(Response_ReportList::ext);
|
|
allReports.clear();
|
|
for (int i = 0; i < resp.reports_size(); ++i) {
|
|
allReports.append(resp.reports(i));
|
|
}
|
|
|
|
applyFilters();
|
|
updateStats();
|
|
|
|
if (selectedReportIdBeforeRefresh >= 0) {
|
|
bool found = false;
|
|
for (int row = 0; row < table->rowCount(); ++row) {
|
|
if (table->item(row, COL_ID) &&
|
|
table->item(row, COL_ID)->data(Qt::UserRole).toInt() == selectedReportIdBeforeRefresh) {
|
|
found = true;
|
|
{
|
|
QSignalBlocker blocker(table);
|
|
table->setCurrentCell(row, 0);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (found) {
|
|
bool dataChanged = false;
|
|
ServerInfo_Report newReport;
|
|
if (!selectedReportInfo(newReport) || !previousSelectedReportValid ||
|
|
previousSelectedReport.description() != newReport.description() ||
|
|
previousSelectedReport.status() != newReport.status() ||
|
|
previousSelectedReport.resolution_note() != newReport.resolution_note() ||
|
|
previousSelectedReport.assigned_mod_name() != newReport.assigned_mod_name()) {
|
|
dataChanged = true;
|
|
}
|
|
|
|
if (dataChanged || detailsRequestedReportId != selectedReportIdBeforeRefresh) {
|
|
loadReportDetails(selectedReportIdBeforeRefresh);
|
|
}
|
|
updateActionStates();
|
|
} else {
|
|
descriptionEdit->clear();
|
|
chatLogEdit->clear();
|
|
commentsEdit->clear();
|
|
setActionsEnabled(false);
|
|
userContextGroup->setVisible(false);
|
|
}
|
|
}
|
|
|
|
if (commentInput->text().isEmpty()) {
|
|
commentInput->setText(commentDraftBeforeRefresh);
|
|
}
|
|
|
|
if (statsGroup->isChecked()) {
|
|
requestStats();
|
|
}
|
|
}
|
|
|
|
void TabReport::applyFilters()
|
|
{
|
|
filteredReports.clear();
|
|
|
|
const QString searchText = searchEdit->text().toLower();
|
|
const QString statusFilterValue = statusFilter->currentData().toString();
|
|
|
|
for (const ServerInfo_Report &r : allReports) {
|
|
bool matchesSearch = searchText.isEmpty() ||
|
|
QString::fromStdString(r.reporter_name()).toLower().contains(searchText) ||
|
|
QString::fromStdString(r.reported_user_name()).toLower().contains(searchText) ||
|
|
QString::fromStdString(r.category()).toLower().contains(searchText) ||
|
|
QString::fromStdString(r.description()).toLower().contains(searchText);
|
|
|
|
bool matchesStatus = statusFilterValue.isEmpty() || QString::fromStdString(r.status()) == statusFilterValue;
|
|
|
|
if (matchesSearch && matchesStatus) {
|
|
filteredReports.append(r);
|
|
}
|
|
}
|
|
|
|
table->setSortingEnabled(false);
|
|
table->setRowCount(filteredReports.size());
|
|
|
|
for (int row = 0; row < filteredReports.size(); ++row) {
|
|
const ServerInfo_Report &r = filteredReports[row];
|
|
|
|
report_utils::fillReportTableRow(table, row, r, COL_ID, COL_TIME, COL_REPORTED, COL_CATEGORY, COL_GAMEID,
|
|
COL_STATUS, COL_ASSIGNED);
|
|
|
|
table->setItem(row, COL_REPORTER, new QTableWidgetItem(QString::fromStdString(r.reporter_name())));
|
|
|
|
table->setItem(row, COL_REPLAY,
|
|
new QTableWidgetItem(r.has_replay_id() && r.replay_id() > 0 ? tr("Yes") : tr("No")));
|
|
|
|
table->setItem(row, COL_ROOM,
|
|
new QTableWidgetItem(r.has_room_id() && r.room_id() > 0 ? QString::number(r.room_id()) : ""));
|
|
}
|
|
|
|
table->setSortingEnabled(true);
|
|
table->resizeColumnsToContents();
|
|
table->horizontalHeader()->setSectionResizeMode(COL_REPORTED, QHeaderView::Stretch);
|
|
|
|
statusLabel->setText(tr("%1 report(s)").arg(filteredReports.size()));
|
|
}
|
|
|
|
void TabReport::updateStats()
|
|
{
|
|
int open = 0, assigned = 0, resolved = 0, dismissed = 0;
|
|
for (const ServerInfo_Report &r : allReports) {
|
|
QString status = QString::fromStdString(r.status());
|
|
if (status == "open") {
|
|
open++;
|
|
} else if (status == "assigned") {
|
|
assigned++;
|
|
} else if (status == "resolved") {
|
|
resolved++;
|
|
} else if (status == "dismissed") {
|
|
dismissed++;
|
|
}
|
|
}
|
|
|
|
statsLabel->setText(tr("%1 open | %2 assigned | %3 resolved | %4 dismissed")
|
|
.arg(open)
|
|
.arg(assigned)
|
|
.arg(resolved)
|
|
.arg(dismissed));
|
|
}
|
|
|
|
void TabReport::onSelectionChanged()
|
|
{
|
|
const int row = table->currentRow();
|
|
if (row < 0 || !table->item(row, COL_ID)) {
|
|
descriptionEdit->clear();
|
|
chatLogEdit->clear();
|
|
commentsEdit->clear();
|
|
commentInput->clear();
|
|
commentButton->setEnabled(false);
|
|
setActionsEnabled(false);
|
|
userContextGroup->setVisible(false);
|
|
return;
|
|
}
|
|
|
|
const int reportId = table->item(row, COL_ID)->data(Qt::UserRole).toInt();
|
|
loadReportDetails(reportId);
|
|
updateActionStates();
|
|
}
|
|
|
|
void TabReport::loadReportDetails(int reportId)
|
|
{
|
|
detailsRequestedReportId = reportId;
|
|
|
|
for (const ServerInfo_Report &r : filteredReports) {
|
|
if (r.report_id() == reportId) {
|
|
descriptionEdit->setPlainText(QString::fromStdString(r.description()));
|
|
|
|
QString reportedUser = QString::fromStdString(r.reported_user_name());
|
|
if (!reportedUser.isEmpty()) {
|
|
requestUserInfo(reportedUser);
|
|
} else {
|
|
userContextGroup->setVisible(false);
|
|
}
|
|
|
|
QString status = QString::fromStdString(r.status());
|
|
bool canComment = (status == "open" || status == "assigned");
|
|
commentButton->setEnabled(canComment);
|
|
commentInput->setEnabled(canComment);
|
|
if (!canComment) {
|
|
commentInput->setPlaceholderText(tr("This report is closed."));
|
|
} else {
|
|
commentInput->setPlaceholderText(tr("Type a reply..."));
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
|
|
chatLogEdit->setPlainText(tr("Loading..."));
|
|
commentsEdit->setPlainText(tr("Loading..."));
|
|
|
|
Command_ReportDetails cmd;
|
|
cmd.set_report_id(reportId);
|
|
|
|
const int seq = ++detailsRequestSeq;
|
|
PendingCommand *pend = client->prepareSessionCommand(cmd);
|
|
connect(pend, &PendingCommand::finished, this, [this, seq](const Response &response) {
|
|
if (seq != detailsRequestSeq) {
|
|
return;
|
|
}
|
|
reportDetailsResponse(response);
|
|
});
|
|
client->sendCommand(pend);
|
|
}
|
|
|
|
void TabReport::reportDetailsResponse(const Response &response)
|
|
{
|
|
if (response.response_code() != Response::RespOk) {
|
|
if (selectedReportId() == detailsRequestedReportId) {
|
|
chatLogEdit->clear();
|
|
commentsEdit->setPlainText(tr("Failed to load report details."));
|
|
}
|
|
return;
|
|
}
|
|
|
|
const Response_ReportDetails &resp = response.GetExtension(Response_ReportDetails::ext);
|
|
const ServerInfo_Report &r = resp.report();
|
|
|
|
if (selectedReportId() != r.report_id()) {
|
|
return;
|
|
}
|
|
|
|
report_utils::renderReportDetails(chatLogEdit, commentsEdit, r, tr("No comments yet."), tr("[Moderator]"),
|
|
tr("[Reporter]"));
|
|
}
|
|
|
|
void TabReport::updateActionStates()
|
|
{
|
|
const int row = table->currentRow();
|
|
if (row < 0 || !table->item(row, COL_STATUS)) {
|
|
setActionsEnabled(false);
|
|
return;
|
|
}
|
|
|
|
ServerInfo_Report report;
|
|
if (!selectedReportInfo(report)) {
|
|
setActionsEnabled(false);
|
|
return;
|
|
}
|
|
|
|
const QString status = QString::fromStdString(report.status());
|
|
assignButton->setEnabled(status == "open");
|
|
resolveButton->setEnabled(status == "open" || status == "assigned");
|
|
resolveWithNoteButton->setEnabled(status == "open" || status == "assigned");
|
|
dismissButton->setEnabled(status == "open" || status == "assigned");
|
|
|
|
const bool hasGameId = report.game_id() > 0;
|
|
const bool hasReplay = hasGameId && report.has_replay_id() && report.replay_id() > 0;
|
|
viewReplayButton->setEnabled(hasReplay);
|
|
joinGameButton->setEnabled(hasGameId && report.has_room_id() && report.room_id() > 0);
|
|
}
|
|
|
|
void TabReport::setActionsEnabled(bool enabled)
|
|
{
|
|
assignButton->setEnabled(enabled);
|
|
resolveButton->setEnabled(enabled);
|
|
resolveWithNoteButton->setEnabled(enabled);
|
|
dismissButton->setEnabled(enabled);
|
|
viewReplayButton->setEnabled(false);
|
|
joinGameButton->setEnabled(false);
|
|
commentButton->setEnabled(enabled);
|
|
commentInput->setEnabled(enabled);
|
|
}
|
|
|
|
int TabReport::selectedReportId() const
|
|
{
|
|
const int row = table->currentRow();
|
|
if (row < 0 || !table->item(row, COL_ID)) {
|
|
return -1;
|
|
}
|
|
return table->item(row, COL_ID)->data(Qt::UserRole).toInt();
|
|
}
|
|
|
|
bool TabReport::selectedReportInfo(ServerInfo_Report &info) const
|
|
{
|
|
const int reportId = selectedReportId();
|
|
if (reportId < 0) {
|
|
return false;
|
|
}
|
|
|
|
for (const ServerInfo_Report &r : filteredReports) {
|
|
if (r.report_id() == reportId) {
|
|
info = r;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
void TabReport::assignReport()
|
|
{
|
|
const int reportId = selectedReportId();
|
|
if (reportId < 0) {
|
|
return;
|
|
}
|
|
|
|
setActionsEnabled(false);
|
|
statusLabel->setText(tr("Assigning..."));
|
|
|
|
Command_ReportAssign cmd;
|
|
cmd.set_report_id(reportId);
|
|
|
|
PendingCommand *pend = client->prepareModeratorCommand(cmd);
|
|
connect(pend, &PendingCommand::finished, this, &TabReport::assignResponse);
|
|
client->sendCommand(pend);
|
|
}
|
|
|
|
void TabReport::assignResponse(const Response &response)
|
|
{
|
|
if (response.response_code() == Response::RespOk) {
|
|
statusLabel->setText(tr("Assigned."));
|
|
refreshList();
|
|
} else {
|
|
statusLabel->setText(tr("Assignment failed."));
|
|
updateActionStates();
|
|
}
|
|
}
|
|
|
|
void TabReport::resolveReport(bool dismissed, bool promptNote)
|
|
{
|
|
const int reportId = selectedReportId();
|
|
if (reportId < 0) {
|
|
return;
|
|
}
|
|
|
|
QString note;
|
|
if (promptNote) {
|
|
bool ok;
|
|
note = QInputDialog::getText(this, dismissed ? tr("Dismiss Report") : tr("Resolve Report"),
|
|
dismissed ? tr("Optional note:") : tr("Resolution note (optional):"),
|
|
QLineEdit::Normal, QString(), &ok);
|
|
if (!ok) {
|
|
return;
|
|
}
|
|
}
|
|
|
|
setActionsEnabled(false);
|
|
statusLabel->setText(dismissed ? tr("Dismissing...") : tr("Resolving..."));
|
|
|
|
Command_ReportResolve cmd;
|
|
cmd.set_report_id(reportId);
|
|
cmd.set_dismissed(dismissed);
|
|
if (!note.isEmpty()) {
|
|
cmd.set_resolution_note(note.toStdString());
|
|
}
|
|
|
|
PendingCommand *pend = client->prepareModeratorCommand(cmd);
|
|
connect(pend, &PendingCommand::finished, this, &TabReport::resolveResponse);
|
|
client->sendCommand(pend);
|
|
}
|
|
|
|
void TabReport::resolveResponse(const Response &response)
|
|
{
|
|
if (response.response_code() == Response::RespOk) {
|
|
statusLabel->setText(tr("Done."));
|
|
refreshList();
|
|
} else {
|
|
statusLabel->setText(tr("Action failed."));
|
|
updateActionStates();
|
|
}
|
|
}
|
|
|
|
void TabReport::viewReplay()
|
|
{
|
|
ServerInfo_Report report;
|
|
if (!selectedReportInfo(report) || report.game_id() <= 0) {
|
|
return;
|
|
}
|
|
|
|
setActionsEnabled(false);
|
|
statusLabel->setText(tr("Loading replay..."));
|
|
|
|
Command_ReplayDownloadByGameId cmd;
|
|
cmd.set_game_id(report.game_id());
|
|
|
|
PendingCommand *pend = client->prepareModeratorCommand(cmd);
|
|
connect(pend, &PendingCommand::finished, this, &TabReport::viewReplayResponse);
|
|
client->sendCommand(pend);
|
|
}
|
|
|
|
void TabReport::viewReplayResponse(const Response &response)
|
|
{
|
|
if (response.response_code() != Response::RespOk) {
|
|
statusLabel->setText(tr("No replay available for this game."));
|
|
updateActionStates();
|
|
return;
|
|
}
|
|
|
|
const Response_ReplayDownloadByGameId &resp = response.GetExtension(Response_ReplayDownloadByGameId::ext);
|
|
GameReplay *replay = new GameReplay;
|
|
if (replay->ParseFromString(resp.replay_data())) {
|
|
emit openReplay(replay);
|
|
statusLabel->setText(tr("Replay opened."));
|
|
} else {
|
|
delete replay;
|
|
statusLabel->setText(tr("Failed to parse replay."));
|
|
}
|
|
|
|
updateActionStates();
|
|
}
|
|
|
|
void TabReport::joinGame()
|
|
{
|
|
ServerInfo_Report report;
|
|
if (!selectedReportInfo(report) || report.game_id() <= 0) {
|
|
return;
|
|
}
|
|
|
|
const int roomId = report.has_room_id() ? report.room_id() : -1;
|
|
if (roomId <= 0) {
|
|
statusLabel->setText(tr("No room recorded for this report, use the replay instead."));
|
|
return;
|
|
}
|
|
|
|
emit requestJoinGame(report.game_id(), roomId);
|
|
statusLabel->setText(tr("Attempting to join game..."));
|
|
}
|
|
|
|
void TabReport::addComment()
|
|
{
|
|
const int reportId = selectedReportId();
|
|
if (reportId < 0) {
|
|
return;
|
|
}
|
|
|
|
QString text = commentInput->text().trimmed();
|
|
if (text.isEmpty()) {
|
|
return;
|
|
}
|
|
|
|
commentButton->setEnabled(false);
|
|
|
|
Command_ReportAddComment cmd;
|
|
cmd.set_report_id(reportId);
|
|
cmd.set_comment(text.toStdString());
|
|
|
|
PendingCommand *pend = client->prepareSessionCommand(cmd);
|
|
connect(pend, &PendingCommand::finished, this, &TabReport::addCommentResponse);
|
|
client->sendCommand(pend);
|
|
}
|
|
|
|
void TabReport::addCommentResponse(const Response &response)
|
|
{
|
|
if (response.response_code() == Response::RespOk) {
|
|
commentInput->clear();
|
|
refreshList();
|
|
} else {
|
|
commentButton->setEnabled(true);
|
|
statusLabel->setText(tr("Failed to send comment."));
|
|
}
|
|
}
|
|
|
|
void TabReport::requestUserInfo(const QString &userName)
|
|
{
|
|
if (userName.isEmpty()) {
|
|
userContextGroup->setVisible(false);
|
|
return;
|
|
}
|
|
|
|
lastRequestedUser = userName;
|
|
userContextGroup->setVisible(true);
|
|
userContextName->setText(userName);
|
|
userContextAccountAge->setText(tr("Loading..."));
|
|
userContextReports->clear();
|
|
userContextBans->clear();
|
|
userContextWarns->clear();
|
|
userContextNotes->clear();
|
|
userContextRecentReports->clear();
|
|
|
|
Command_ReportUserInfo cmd;
|
|
cmd.set_user_name(userName.toStdString());
|
|
|
|
PendingCommand *pend = client->prepareModeratorCommand(cmd);
|
|
connect(pend, &PendingCommand::finished, this, &TabReport::userInfoResponse);
|
|
client->sendCommand(pend);
|
|
}
|
|
|
|
void TabReport::userInfoResponse(const Response &response)
|
|
{
|
|
if (response.response_code() != Response::RespOk) {
|
|
userContextAccountAge->setText(tr("Error loading user info."));
|
|
return;
|
|
}
|
|
|
|
const Response_ReportUserInfo &resp = response.GetExtension(Response_ReportUserInfo::ext);
|
|
|
|
if (resp.has_user_name() && QString::fromStdString(resp.user_name()) != lastRequestedUser) {
|
|
return;
|
|
}
|
|
|
|
QDateTime regTime = QDateTime::fromSecsSinceEpoch(resp.registration_time());
|
|
qint64 daysSinceReg = regTime.daysTo(QDateTime::currentDateTime());
|
|
userContextAccountAge->setText(tr("%1 days (since %2)").arg(daysSinceReg).arg(regTime.toString("yyyy-MM-dd")));
|
|
|
|
userContextReports->setText(QString::number(resp.total_reports()));
|
|
userContextBans->setText(QString::number(resp.total_bans()));
|
|
userContextWarns->setText(QString::number(resp.total_warns()));
|
|
|
|
if (resp.has_admin_notes() && !resp.admin_notes().empty()) {
|
|
userContextNotes->setPlainText(QString::fromStdString(resp.admin_notes()));
|
|
} else {
|
|
userContextNotes->setPlainText(tr("(none)"));
|
|
}
|
|
|
|
userContextRecentReports->clear();
|
|
if (resp.recent_reports_size() == 0) {
|
|
userContextRecentReports->setPlainText(tr("No previous reports against this user."));
|
|
} else {
|
|
for (int i = 0; i < resp.recent_reports_size(); ++i) {
|
|
const ServerInfo_Report &r = resp.recent_reports(i);
|
|
QDateTime dt = QDateTime::fromSecsSinceEpoch(r.report_time());
|
|
userContextRecentReports->moveCursor(QTextCursor::End);
|
|
userContextRecentReports->insertPlainText(QString("[%1] #%2 by %3 [%4]: %5\n")
|
|
.arg(dt.toString("yyyy-MM-dd"))
|
|
.arg(r.report_id())
|
|
.arg(QString::fromStdString(r.reporter_name()))
|
|
.arg(QString::fromStdString(r.status()))
|
|
.arg(QString::fromStdString(r.category())));
|
|
}
|
|
}
|
|
}
|
|
|
|
void TabReport::requestStats()
|
|
{
|
|
statsTotalLabel->setText(tr("Loading statistics..."));
|
|
statsTrendLabel->clear();
|
|
statsCategoriesLabel->clear();
|
|
statsDetailText->clear();
|
|
|
|
Command_ReportStats cmd;
|
|
|
|
PendingCommand *pend = client->prepareModeratorCommand(cmd);
|
|
connect(pend, &PendingCommand::finished, this, &TabReport::statsResponse);
|
|
client->sendCommand(pend);
|
|
}
|
|
|
|
void TabReport::statsResponse(const Response &response)
|
|
{
|
|
if (response.response_code() != Response::RespOk) {
|
|
statsTotalLabel->setText(tr("Error loading statistics."));
|
|
return;
|
|
}
|
|
|
|
const Response_ReportStats &resp = response.GetExtension(Response_ReportStats::ext);
|
|
|
|
statsTotalLabel->setText(tr("Total: %1 reports (%2 open, %3 assigned, %4 resolved/dismissed)")
|
|
.arg(resp.total_reports())
|
|
.arg(resp.total_pending())
|
|
.arg(resp.total_assigned())
|
|
.arg(resp.total_resolved()));
|
|
|
|
statsTrendLabel->setText(tr("Last 24h: %1 | Last 7d: %2 | Last 30d: %3 | Avg resolution: %4h")
|
|
.arg(resp.reports_last_24h())
|
|
.arg(resp.reports_last_7d())
|
|
.arg(resp.reports_last_30d())
|
|
.arg(resp.avg_resolution_hours(), 0, 'f', 1));
|
|
|
|
QString weekCompare =
|
|
tr("This week: %1 vs last week: %2 (%3%)")
|
|
.arg(resp.reports_this_week())
|
|
.arg(resp.reports_last_week())
|
|
.arg(resp.reports_last_week() > 0 ? QString::number(((resp.reports_this_week() - resp.reports_last_week()) *
|
|
100.0 / resp.reports_last_week()),
|
|
'f', 0)
|
|
: resp.reports_this_week() > 0 ? "new"
|
|
: "0");
|
|
statsTrendLabel->setText(statsTrendLabel->text() + " | " + weekCompare);
|
|
|
|
statsCategoriesLabel->setText(tr("By category:"));
|
|
statsDetailText->clear();
|
|
|
|
statsDetailText->moveCursor(QTextCursor::End);
|
|
statsDetailText->insertPlainText(tr("=== Top Categories ===") + "\n");
|
|
for (int i = 0; i < resp.category_counts_size(); ++i) {
|
|
const ReportCategoryCount &cc = resp.category_counts(i);
|
|
QString cat = QString::fromStdString(cc.category());
|
|
cat.replace('_', ' ');
|
|
cat = cat.left(1).toUpper() + cat.mid(1);
|
|
statsDetailText->moveCursor(QTextCursor::End);
|
|
statsDetailText->insertPlainText(QString(" %1: %2\n").arg(cat).arg(cc.count()));
|
|
}
|
|
|
|
statsDetailText->moveCursor(QTextCursor::End);
|
|
statsDetailText->insertPlainText("\n" + tr("=== Most Reported Users ===") + "\n");
|
|
for (int i = 0; i < resp.top_reported_users_size(); ++i) {
|
|
const ReportTopUser &tu = resp.top_reported_users(i);
|
|
statsDetailText->moveCursor(QTextCursor::End);
|
|
statsDetailText->insertPlainText(
|
|
QString(" %1: %2 reports\n").arg(QString::fromStdString(tu.user_name())).arg(tu.count()));
|
|
}
|
|
|
|
statsDetailText->moveCursor(QTextCursor::End);
|
|
statsDetailText->insertPlainText("\n" + tr("=== Top Reporters ===") + "\n");
|
|
for (int i = 0; i < resp.top_reporters_size(); ++i) {
|
|
const ReportTopUser &tu = resp.top_reporters(i);
|
|
statsDetailText->moveCursor(QTextCursor::End);
|
|
statsDetailText->insertPlainText(
|
|
QString(" %1: %2 reports filed\n").arg(QString::fromStdString(tu.user_name())).arg(tu.count()));
|
|
}
|
|
}
|