11 #include "uaareport.hpp"
12 #include "ui_uaareport.h"
14 using namespace Huggle;
16 UAAReport::UAAReport(QWidget *parent) : QDialog(parent), ui(new Ui::
UAAReport)
20 this->contentsOfUAA =
"";
21 this->qUAApage = NULL;
24 this->qChUAApage = NULL;
27 this->optionalreason =
"";
29 this->uaaReportReason =
"";
33 UAAReport::~UAAReport()
50 qUAApage->
Parameters =
"prop=revisions&rvprop=content&titles=" + QUrl::toPercentEncoding(Configuration::LocalConfig_UAAPath);
61 this->
uT =
new QTimer(
this);
62 connect(this->
uT, SIGNAL(timeout()),
this, SLOT(
onTick()));
79 QDomNodeList l = r.elementsByTagName(
"rev");
83 this->
failed(
"the query for the page contents returned no data.");
87 QDomElement element = l.at(0).toElement();
89 if (element.text() ==
"")
92 this->
failed(
"the page contents weren't available.");
98 this->
dr = element.text();
110 this->ui->pushButton->setText(
"Reported");
115 ta = Configuration::LocalConfig_UAATemplate;
119 dr =
dr +
"\n" + contentsOfUAA;
125 if (this->ui->checkBox->isChecked())
127 uaaReportReason =
"Username is a policy violation because it is disruptive.";
129 if (this->ui->checkBox_2->isChecked())
131 uaaReportReason =
"Username is a policy violation because it is offensive.";
133 if (this->ui->checkBox_3->isChecked())
135 uaaReportReason =
"Username is a policy violation because it is a promotional username.";
137 if (this->ui->checkBox_4->isChecked())
139 uaaReportReason =
"Username is a policy violation because it is a misleading username.";
146 QMessageBox *_b =
new QMessageBox();
147 _b->setWindowTitle(
"Unable to report user to UAA");
148 _b->setText(
"Unable to report the user because " + reason);
149 _b->setAttribute(Qt::WA_DeleteOnClose);
157 if (!this->ui->checkBox->isChecked() && !this->ui->checkBox_2->isChecked() &&
158 !this->ui->checkBox_3->isChecked() && !this->ui->checkBox_4->isChecked()
159 && this->ui->lineEdit->text().isEmpty())
161 QMessageBox *g =
new QMessageBox();
163 g->setWindowTitle(
"No reason specified");
165 g->setText(
"You didn't specify a reason as to why the username is a policy violation. "\
166 "Please specify a reason.");
167 g->setAttribute(Qt::WA_DeleteOnClose);
172 ui->pushButton->setEnabled(
false);
176 void UAAReport::on_pushButton_2_clicked()
181 void UAAReport::on_pushButton_3_clicked()
185 qChUAApage->
Parameters =
"prop=revisons&rvprop=" + QUrl::toPercentEncoding(
"timestamp|user|comment|content") +
"titles="
186 + QUrl::toPercentEncoding(Configuration::LocalConfig_UAAPath);
191 this->
cuT =
new QTimer(
this);
192 connect(this->
cuT, SIGNAL(timeout()),
this, SLOT(onStartOfSearch()));
198 if (
dr.contains(this->User->Username))
205 void UAAReport::onStartOfSearch()
217 QDomNodeList chkusr = tj.elementsByTagName(
"rev");
218 if (chkusr.count() == 0)
220 QMessageBox *msgb =
new QMessageBox();
221 msgb->setWindowTitle(
"Cannot retrieve page");
222 msgb->setIcon(QMessageBox::Critical);
223 msgb->setText(
"Retrieving the page " + Configuration::LocalConfig_UAAPath +
" failed.");
224 msgb->setAttribute(Qt::WA_DeleteOnClose);
230 QDomElement h = chkusr.at(0).toElement();
234 QMessageBox *msg =
new QMessageBox();
235 msg->setWindowTitle(
"User is already reported");
236 msg->setText(
"This user has already been reported to UAA.");
237 msg->setAttribute(Qt::WA_DeleteOnClose);
244 QMessageBox *msga =
new QMessageBox();
245 msga->setWindowTitle(
"User is not reported");
246 msga->setText(
"This user is not reported to UAA.");
247 msga->setAttribute(Qt::WA_DeleteOnClose);
QString dr
Whole contents of UAA page.
bool checkIfReported()
Check if user is reported.
static void Log(QString Message)
Write text to terminal as well as ring log.
QTimer * uT
Timer pointer that allows us to do magical things.
QString Target
This is optional property which contains a label of target this query is for.
static WikiPage * UAAP
Pointer to UAA page.
void setUserForUAA(WikiUser *user)
I don't have much of a clue why this is here lol, but I know the dialog can't be initialised from mai...
virtual bool Processed()
Returns true in case that query is processed.
void UnregisterConsumer(const int consumer)
This function will remove a string which prevent the object from being removed.
void RegisterConsumer(const int consumer)
Registers a consumer.
static void AppendQuery(Query *item)
Insert a query to internal list of running queries, so that they can be watched This will insert it t...
void failed(QString reason)
Message box, if anything fails.
QString Username
Username.
void on_pushButton_clicked()
QString optionalreason
String that represents what is in the line edit.
ApiQuery * qUAApage
Pointer to get UAA contents (we don't want replace the page with our content, do we?)
void whatToReport()
Function to decide what we are reporting.
QString uaaReportReason
Reason for report.
void SetAction(const Action action)
Change the action type.
void getPageContents()
Get page contents (reason for this is above)
ApiQuery * qChUAApage
Pointer that also gets UAA contents; this time it is used for checking if a user is reported or not...
static QString EditSuffixOfHuggle
Suffix used by huggle.
static void DebugLog(QString Message, unsigned int Verbosity=1)
This log is only shown if verbosity is same or larger than requested verbosity.
QString Parameters
Parameters for action, for example page title.
Form to report users to UAA.
WikiPage * page
Pointer to WikiUser.
This class can be used to execute any kind of api query on any wiki.
QTimer * cuT
Timer that does other magical things.
void insertUsername()
Function to that allows us to properly insert what we need to insert.
QString Data
Data retrieved by query.
QueryResult * Result
Result of query, see documentation of QueryResult for more.