11 #include "deleteform.hpp"
12 #include "ui_deleteform.h"
15 using namespace Huggle;
17 DeleteForm::DeleteForm(QWidget *parent) : QDialog(parent), ui(new Ui::
DeleteForm)
22 this->deletetoken =
"";
23 this->delquery = NULL;
24 this->tokenquery = NULL;
27 DeleteForm::~DeleteForm()
33 void DeleteForm::setPage(
WikiPage *Page)
37 throw new Exception(
"Page must not be NULL",
"void DeleteForm::setPage(WikiPage *Page)");
46 tokenquery->
Parameters =
"action=query&prop=info&intoken=delete&titles=" + QUrl::toPercentEncoding(this->page->
PageName);
48 tokenquery->
Target =
"Getting token to delete " + this->page->
PageName;
53 this->
dt =
new QTimer(
this);
54 connect(this->
dt, SIGNAL(timeout()),
this, SLOT(onTick()));
55 this->delQueryPhase = 0;
59 void DeleteForm::onTick()
61 switch (this->delQueryPhase)
75 if (tokenquery == NULL)
83 if (this->tokenquery->
Result->Failed)
86 Failed(
"ERROR: Retreiving the delete token failed. The reason provided was: " + this->tokenquery->
Result->
ErrorMessage);
91 QDomNodeList l = d.elementsByTagName(
"page");
96 Failed(
"no page info was present in query (are you sysop?)");
99 QDomElement element = l.at(0).toElement();
100 if (!element.attributes().contains(
"deletetoken"))
106 this->deletetoken = element.attribute(
"deletetoken");
107 this->delQueryPhase++;
109 this->tokenquery = NULL;
116 +
"&reason=" + QUrl::toPercentEncoding(ui->comboBox->lineEdit()->text())
117 +
"&token=" + QUrl::toPercentEncoding(deletetoken);
127 if (this->delquery == NULL)
136 if (this->delquery->
Result->Failed)
143 ui->pushButton->setText(
"deleted");
151 QMessageBox *_b =
new QMessageBox();
153 _b->setWindowTitle(
"Unable to delete page");
155 _b->setText(
"Unable to delete the page because " + reason);
161 ui->pushButton->setEnabled(
true);
162 if (this->tokenquery != NULL)
166 if (this->delquery != NULL)
170 this->delquery = NULL;
171 this->tokenquery = NULL;
175 void DeleteForm::on_pushButton_clicked()
178 ui->pushButton->setEnabled(
false);
181 void DeleteForm::on_pushButton_2_clicked()
QString Target
This is optional property which contains a label of target this query is for.
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 SetAction(const Action action)
Change the action type.
Every exception raised by huggle is defined by this class.
bool UsingPOST
Whether the query will submit parameters using POST data.
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 PageName
Name of page.
This class can be used to execute any kind of api query on any wiki.
QString Data
Data retrieved by query.
QueryResult * Result
Result of query, see documentation of QueryResult for more.