11 #include "reportuser.hpp"
12 #include "ui_reportuser.h"
13 using namespace Huggle;
20 ui->tableWidget->horizontalHeader()->setSelectionBehavior(QAbstractItemView::SelectRows);
21 ui->pushButton->setEnabled(
false);
23 ui->pushButton->setText(
"Retrieving history...");
25 ui->tableWidget->setColumnCount(5);
26 this->diff =
new QTimer(
this);
27 connect(this->diff, SIGNAL(timeout()),
this, SLOT(
On_DiffTick()));
29 header <<
"Page" <<
"Time" <<
"Link" <<
"DiffID" <<
"Include in report";
30 ui->tableWidget->setHorizontalHeaderLabels(header);
32 ui->tableWidget->verticalHeader()->setVisible(
false);
33 ui->tableWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);
38 #if QT_VERSION >= 0x050000
40 ui->tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
43 ui->tableWidget->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);
46 ui->tableWidget->setShowGrid(
false);
50 ui->webView->setHtml(
"Please select a diff in list in order to open preview");
64 "&rcprop=user%7Ccomment%7Ctimestamp%7Ctitle%7Cids%7Csizes&rclimit=20&rctype=edit%7Cnew";
67 this->timer =
new QTimer(
this);
68 connect(this->timer, SIGNAL(timeout()),
this, SLOT(
Tick()));
69 this->timer->start(200);
73 ReportUser::~ReportUser()
104 QDomNodeList results = d.elementsByTagName(
"rev");
105 if (results.count() == 0)
108 ui->pushButton->setText(
"Error unable to retrieve report page at " + Configuration::LocalConfig_ReportPath);
112 QDomElement e = results.at(0).toElement();
114 if (!this->CheckUser())
117 ui->pushButton->setText(
"This user is already reported");
127 ui->pushButton->setText(
"Reported");
138 QDomNodeList results = d.elementsByTagName(
"rc");
140 if (results.count() > 0)
142 while (results.count() > xx)
144 QDomElement edit = results.at(xx).toElement();
145 if (!edit.attributes().contains(
"type"))
149 QString page =
"unknown page";
150 if (edit.attributes().contains(
"title"))
152 page = edit.attribute(
"title");
154 QString time =
"unknown time";
155 if (edit.attributes().contains(
"timestamp"))
157 time = edit.attribute(
"timestamp");
160 if (edit.attributes().contains(
"revid"))
162 diff = edit.attribute(
"revid");
165 ui->tableWidget->insertRow(0);
166 ui->tableWidget->setItem(0, 0,
new QTableWidgetItem(page));
167 ui->tableWidget->setItem(0, 1,
new QTableWidgetItem(time));
168 ui->tableWidget->setItem(0, 2,
new QTableWidgetItem(link));
169 ui->tableWidget->setItem(0, 3,
new QTableWidgetItem(diff));
170 QCheckBox *Item =
new QCheckBox(
this);
171 this->CheckBoxes.insert(0, Item);
172 ui->tableWidget->setCellWidget(0, 4, Item);
177 ui->pushButton->setEnabled(
true);
178 ui->pushButton->setText(
"Report");
184 if (this->qd == NULL)
192 if (this->qd->
Result->Failed)
205 QDomNodeList l = d.elementsByTagName(
"rev");
206 QDomNodeList diff = d.elementsByTagName(
"diff");
207 if (diff.count() > 0)
209 QDomElement e = diff.at(0).toElement();
210 if (e.nodeName() ==
"diff")
218 ui->webView->setHtml(
"Unable to retrieve diff because api returned no data for it, debug information:<br><hr>" +
226 QDomElement e = l.at(0).toElement();
227 if (e.nodeName() ==
"rev")
229 if (e.attributes().contains(
"comment"))
231 Summary = e.attribute(
"comment");
239 Summary =
"<font color=red>No summary was provided</font>";
242 Summary = HuggleWeb::Encode(Summary);
245 ui->webView->setHtml(
Core::HtmlHeader +
"<tr></td colspan=2><b>Summary:</b> "
252 if (this->tq == NULL)
265 QDomNodeList results = d.elementsByTagName(
"rev");
266 ui->pushButton_3->setEnabled(
true);
267 if (results.count() == 0)
271 mb.setText(
"Error unable to retrieve report page at " + Configuration::LocalConfig_ReportPath);
278 QDomElement e = results.at(0).toElement();
280 if (!this->CheckUser())
284 mb.setText(
"This user is already reported");
296 mb.setText(
"This user is not reported now");
306 ui->pushButton->setEnabled(
false);
308 QString reports =
"";
311 while (xx < ui->tableWidget->rowCount())
313 if (this->CheckBoxes.count() > xx)
315 if (this->CheckBoxes.at(xx)->isChecked())
319 QUrl::toPercentEncoding(ui->tableWidget->item(xx, 0)->text()) +
"&diff="
320 + ui->tableWidget->item(xx, 3)->text()).toUtf8() +
" #" + QString::number(EvidenceID) +
"] ";
327 QMessageBox::StandardButton mb;
329 mb = QMessageBox::question(
this,
"Question",
"You didn't provide any diffs as evidence, this will make it extremery hard for administrators to figure out if this "\
330 "user is vandal or not. Are you sure you want to continue?", QMessageBox::Yes|QMessageBox::No);
331 if (mb == QMessageBox::No)
333 ui->pushButton->setEnabled(
true);
340 ui->pushButton->setText(
"Retrieving current report page");
348 q->
Parameters =
"prop=revisions&rvprop=" + QUrl::toPercentEncoding(
"timestamp|user|comment|content") +
"&titles=" +
349 QUrl::toPercentEncoding(Configuration::LocalConfig_ReportPath);
351 this->report = reports;
352 this->timer->start(800);
356 void ReportUser::on_pushButton_2_clicked()
359 (this->user->
GetTalk()) +
"?action=render").toUtf8());
360 ui->webView->load(u);
366 ui->webView->setHtml(
"Please wait...");
368 if (this->qd != NULL)
374 this->qd->
Parameters =
"prop=revisions&rvprop=" + QUrl::toPercentEncoding(
"ids|user|timestamp|comment" ) +
"&rvlimit=1&rvtoken=rollback&rvstartid=" +
375 ui->tableWidget->item(index.row(), 3)->text() +
"&rvendid=" + ui->tableWidget->item(index.row(), 3)->text() +
"&rvdiffto=prev&titles=" +
376 QUrl::toPercentEncoding(ui->tableWidget->item(index.row(), 0)->text());
379 this->diff->start(200);
382 bool ReportUser::CheckUser()
384 if (
_p.contains(this->user->Username))
391 void ReportUser::InsertUser()
394 if (!this->user->
IsIP())
398 xx = xx.replace(
"$1", this->user->
Username);
399 xx = xx.replace(
"$2", report);
400 xx = xx.replace(
"$3", ui->lineEdit->text());
404 void ReportUser::on_pushButton_3_clicked()
406 if (this->tq != NULL)
413 this->tq->
Parameters =
"prop=revisions&rvprop=" + QUrl::toPercentEncoding(
"timestamp|user|comment|content") +
"&titles=" +
414 QUrl::toPercentEncoding(Configuration::LocalConfig_ReportPath);
416 if (this->t2 == NULL)
418 this->t2 =
new QTimer(
this);
420 connect(this->t2, SIGNAL(timeout()),
this, SLOT(
Test()));
421 this->t2->start(100);
static QString GetProjectScriptURL()
Return a script url like http://en.wikipedia.org/w/.
virtual bool SafeDelete()
Use this if you are not sure if you can delete this object in this moment.
static QString GetProjectWikiURL()
Return a full url like http://en.wikipedia.org/wiki/.
static WikiPage * AIVP
Pointer to AIV page.
void on_tableWidget_clicked(const QModelIndex &index)
QString _p
Content of report.
static QString HtmlHeader
This string contains a html header.
void Kill()
Terminate the query.
static QString HtmlFooter
This string contains a html footer.
virtual bool Processed()
Returns true in case that query is processed.
bool IsIP()
Returns true in case the current user is IP user.
bool SetUser(WikiUser *u)
Set a user.
void on_pushButton_clicked()
QString Username
Username.
static QString LocalConfig_RUTemplateReport
Regular users.
ReportUser(QWidget *parent=0)
void SetAction(const Action action)
Change the action type.
static void DebugLog(QString Message, unsigned int Verbosity=1)
This log is only shown if verbosity is same or larger than requested verbosity.
QString ErrorMessage
If query is in error the reason for error is stored here.
QString Parameters
Parameters for action, for example page title.
QString GetTalk()
Return a link to talk page of this user (like User talk:Jimbo)
static QString LocalConfig_IPVTemplateReport
IP vandals.
This class can be used to execute any kind of api query on any wiki.
static void UpdateUser(WikiUser *us)
Update a list of problematic users.
QString Data
Data retrieved by query.
QueryResult * Result
Result of query, see documentation of QueryResult for more.