11 #include "hugglequeue.hpp"
12 #include "ui_hugglequeue.h"
14 using namespace Huggle;
16 HuggleQueue::HuggleQueue(QWidget *parent) : QDockWidget(parent), ui(new Ui::
HuggleQueue)
19 CurrentFilter = HuggleQueueFilter::DefaultFilter;
20 this->layout =
new QVBoxLayout(ui->scrollArea);
21 this->layout->setMargin(0);
22 this->layout->setSpacing(0);
23 this->xx =
new QWidget();
24 this->frame =
new QFrame();
25 ui->scrollArea->setWidget(this->xx);
26 xx->setLayout(this->layout);
27 this->layout->addWidget(this->frame);
28 ui->comboBox->addItem(this->CurrentFilter->QueueName);
29 ui->comboBox->setCurrentIndex(0);
32 HuggleQueue::~HuggleQueue()
39 void HuggleQueue::AddItem(
WikiEdit *page)
43 throw new Exception(
"WikiEdit *page must not be NULL",
"void HuggleQueue::AddItem(WikiEdit *page)");
52 if (page->Score <= MINIMAL_SCORE)
54 this->layout->addWidget(label);
60 while (GetScore(
id) > page->Score && GetScore(
id) > MINIMAL_SCORE)
67 while (GetScore(
id) >= page->Score && GetScore(
id) > MINIMAL_SCORE)
72 if (
id >= this->layout->count() && this->layout->count() > 0)
74 id = this->layout->count() - 1;
76 this->layout->insertWidget(
id, label);
78 this->Items.append(label);
79 HuggleQueueItemLabel::Count++;
82 void HuggleQueue::Next()
84 if (HuggleQueueItemLabel::Count < 1)
88 QLayoutItem *i = this->layout->itemAt(0);
91 this->layout->removeItem(i);
95 void HuggleQueue::DeleteByRevID(
int RevID)
98 while (c < this->Items.count())
101 if (item->page->
RevID == RevID)
120 throw new Exception(
"HuggleQueueItemLabel *item must not be NULL in this context",
"void HuggleQueue::Delete(HuggleQueueItemLabel *item, QLayoutItem *qi)");
126 this->layout->removeItem(qi);
130 while(curr<(this->layout->count()-1))
132 QLayoutItem *i = this->layout->itemAt(curr);
136 this->layout->removeItem(i);
137 if (label->page != NULL)
152 throw new Huggle::Exception(
"Parameter i must be greater than 0 in HuggleQueue::Trim(i)");
164 if (HuggleQueueItemLabel::Count < 1)
168 int x = this->layout->count() - 1;
169 QLayoutItem *i = this->layout->itemAt(x);
170 if (i->widget() == this->frame)
173 i = this->layout->itemAt(x);
177 this->layout->removeItem(i);
181 long HuggleQueue::GetScore(
int id)
183 if (this->layout->count() - 1 <= id)
185 return MINIMAL_SCORE;
188 QLayoutItem *i = this->layout->itemAt(
id);
190 if (label->page == NULL)
192 return MINIMAL_SCORE;
194 return label->page->Score;
static bool QueueNewEditsUp
Whether new edits go to top or bottom.
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.
Every exception raised by huggle is defined by this class.
void Trim()
Remove 1 item.
This is item of queue, it is derived from qt object.
static MainWindow * Main
Pointer to main.
QString PageName
Name of page.
WikiPage * Page
Page that was changed by edit.