11 #include "huggletool.hpp"
12 #include "ui_huggletool.h"
14 using namespace Huggle;
16 HuggleTool::HuggleTool(QWidget *parent) : QDockWidget(parent), ui(new Ui::
HuggleTool)
20 this->tick =
new QTimer(
this);
21 connect(this->tick, SIGNAL(timeout()),
this, SLOT(onTick()));
25 HuggleTool::~HuggleTool()
31 void HuggleTool::SetTitle(QString title)
33 ui->lineEdit->setText(title);
34 ui->comboBox_2->lineEdit()->setText(title);
37 void HuggleTool::SetInfo(QString info)
39 ui->lineEdit->setText(info);
42 void HuggleTool::SetUser(QString user)
44 ui->comboBox->lineEdit()->setText(user);
47 void HuggleTool::SetPage(
WikiPage *page)
51 throw new Exception(
"HuggleTool::SetPage(WikiPage* page) page must not be null");
53 this->ui->comboBox_2->lineEdit()->setText(page->
PageName);
56 this->ui->pushButton->setEnabled(
true);
58 this->ui->comboBox_2->lineEdit()->setStyleSheet(
"color: black;");
61 void Huggle::HuggleTool::on_pushButton_clicked()
63 if (this->ui->comboBox_2->lineEdit()->text() ==
"")
67 ui->pushButton->setEnabled(
false);
68 this->ui->comboBox_2->lineEdit()->setStyleSheet(
"color: green;");
72 this->query->SetAction(ActionQuery);
73 this->query->Parameters =
"prop=revisions&rvprop=ids%7Cflags%7Ctimestamp%7Cuser%7Cuserid%7Csize%7Csha1%7Ccomment&rvlimit=1&titles="
74 + QUrl::toPercentEncoding(this->ui->comboBox_2->lineEdit()->text());
75 this->query->RegisterConsumer(HUGGLECONSUMER_HUGGLETOOL);
76 this->query->Process();
77 this->tick->start(200);
80 void HuggleTool::onTick()
98 if (this->query == NULL)
112 QDomNodeList l = d.elementsByTagName(
"rev");
115 QDomElement e = l.at(0).toElement();
116 if (e.attributes().contains(
"missing"))
120 this->ui->comboBox_2->lineEdit()->setStyleSheet(
"color: red;");
122 Core::Log(
"There is no page " + ui->comboBox_2->lineEdit()->text() +
" on wiki");
126 if (e.attributes().contains(
"user"))
130 if (e.attributes().contains(
"revid"))
132 edit->
RevID = e.attribute(
"revid").toInt();
144 void HuggleTool::FinishEdit()
146 if (this->
edit == NULL)
158 void HuggleTool::DeleteQuery()
160 if (this->query == NULL)
static void Log(QString Message)
Write text to terminal as well as ring log.
static void PostProcessEdit(WikiEdit *_e)
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.
void ProcessEdit(WikiEdit *e, bool IgnoreHistory=false)
Recreate interface, should be called everytime you do anything with main form.
bool IsPostProcessed()
Return true in case this edit was post processed already.
Every exception raised by huggle is defined by this class.
WikiUser * User
User who changed the page.
static MainWindow * Main
Pointer to main.
QString PageName
Name of page.
This class can be used to execute any kind of api query on any wiki.
WikiPage * Page
Page that was changed by edit.
QString Data
Data retrieved by query.
QueryResult * Result
Result of query, see documentation of QueryResult for more.