Huggle  build:^490^dce1e5c
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
hugglequeueitemlabel.cpp
1 //This program is free software: you can redistribute it and/or modify
2 //it under the terms of the GNU General Public License as published by
3 //the Free Software Foundation, either version 3 of the License, or
4 //(at your option) any later version.
5 
6 //This program is distributed in the hope that it will be useful,
7 //but WITHOUT ANY WARRANTY; without even the implied warranty of
8 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 //GNU General Public License for more details.
10 
11 #include "hugglequeueitemlabel.hpp"
12 #include "ui_hugglequeueitemlabel.h"
13 
14 using namespace Huggle;
15 
16 int HuggleQueueItemLabel::Count = 0;
17 
18 HuggleQueueItemLabel::HuggleQueueItemLabel(QWidget *parent) : QFrame(parent), ui(new Ui::HuggleQueueItemLabel)
19 {
20  ParentQueue = (HuggleQueue*)parent;
21  ui->setupUi(this);
22 }
23 
24 HuggleQueueItemLabel::~HuggleQueueItemLabel()
25 {
26  delete ui;
27 }
28 
29 void HuggleQueueItemLabel::SetName(QString name)
30 {
31  ui->label_2->setText(name);
32  if (this->page != NULL)
33  {
34  // change the icon according to edit type
35  if (this->page->OwnEdit)
36  {
37  ui->label->setPixmap(QPixmap(":/huggle/pictures/Resources/blob-me.png"));
38  return;
39  }
40 
41  if (this->page->User->IsReported)
42  {
43  ui->label->setPixmap(QPixmap(":/huggle/pictures/Resources/blob-reported.png"));
44  return;
45  }
46 
47  switch (this->page->CurrentUserWarningLevel)
48  {
49  case WarningLevelNone:
50  ui->label->setPixmap(QPixmap(":/huggle/pictures/Resources/blob-none.png"));
51  break;
52  case WarningLevel1:
53  ui->label->setPixmap(QPixmap(":/huggle/pictures/Resources/blob-warn-1.png"));
54  return;
55  case WarningLevel2:
56  ui->label->setPixmap(QPixmap(":/huggle/pictures/Resources/blob-warn-2.png"));
57  return;
58  case WarningLevel3:
59  ui->label->setPixmap(QPixmap(":/huggle/pictures/Resources/blob-warn-3.png"));
60  return;
61  case WarningLevel4:
62  ui->label->setPixmap(QPixmap(":/huggle/pictures/Resources/blob-warn-4.png"));
63  return;
64  }
65 
66  if (this->page->Score > 1000)
67  {
68  ui->label->setPixmap(QPixmap(":/huggle/pictures/Resources/blob-warning.png"));
69  return;
70  }
71 
72  if (this->page->User->IsIP())
73  {
74  ui->label->setPixmap(QPixmap(":/huggle/pictures/Resources/blob-anon.png"));
75  return;
76  }
77  }
78 }
79 
80 QString HuggleQueueItemLabel::GetName()
81 {
82  return ui->label_2->text();
83 }
84 
85 void HuggleQueueItemLabel::Process(QLayoutItem *qi)
86 {
87  HuggleQueueItemLabel::Count--;
88  if (this->ParentQueue->Items.contains(this))
89  {
90  this->ParentQueue->Items.removeOne(this);
91  }
92  Core::ProcessEdit(this->page);
93  this->close();
94  this->page->RegisterConsumer("MainForm");
95  this->page->UnregisterConsumer(HUGGLECONSUMER_QUEUE);
96  ParentQueue->Delete(this, qi);
97 }
98 
99 void HuggleQueueItemLabel::Remove()
100 {
101  HuggleQueueItemLabel::Count--;
102  if (this->ParentQueue->Items.contains(this))
103  {
104  this->ParentQueue->Items.removeOne(this);
105  }
106  this->page->UnregisterConsumer(HUGGLECONSUMER_QUEUE);
107  this->page = NULL;
108  this->close();
109  ParentQueue->Delete(this);
110 }
111 
112 void HuggleQueueItemLabel::mousePressEvent(QMouseEvent *event)
113 {
114  if (event->button() == Qt::LeftButton)
115  {
116  this->Process();
117  delete this;
118  }
119 }
bool IsIP()
Returns true in case the current user is IP user.
Definition: wikiuser.cpp:240
void UnregisterConsumer(const int consumer)
This function will remove a string which prevent the object from being removed.
Definition: collectable.cpp:68
void RegisterConsumer(const int consumer)
Registers a consumer.
Definition: collectable.cpp:57
WarningLevel CurrentUserWarningLevel
Current warning level.
Definition: wikiedit.hpp:108
Queue of edits.
Definition: hugglequeue.hpp:36
WikiUser * User
User who changed the page.
Definition: wikiedit.hpp:89
This is item of queue, it is derived from qt object.
bool OwnEdit
Edit was made by you.
Definition: wikiedit.hpp:119