Huggle  build:^490^dce1e5c
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
hugglequeuefilter.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 "hugglequeuefilter.hpp"
12 
13 using namespace Huggle;
14 
15 HuggleQueueFilter *HuggleQueueFilter::DefaultFilter = new HuggleQueueFilter();
16 QList<HuggleQueueFilter*> HuggleQueueFilter::Filters;
17 
18 HuggleQueueFilter::HuggleQueueFilter()
19 {
20  QueueName = "default";
21  this->IgnoreBots = true;
22  this->IgnoreWL = true;
23  this->IgnoreFriends = true;
24  this->IgnoreIP = false;
25  this->IgnoreMinor = false;
26  this->IgnoreNP = false;
27  this->IgnoreUsers = false;
28  this->IgnoreTalk = true;
29 }
30 
31 bool HuggleQueueFilter::Matches(WikiEdit *edit)
32 {
33  if (edit == NULL)
34  {
35  throw new Exception("WikiEdit *edit must not be NULL in this context", "bool HuggleQueueFilter::Matches(WikiEdit *edit)");
36  }
37  if (edit->Page->IsTalk() && this->IgnoreTalk)
38  {
39  return false;
40  }
41  int i = 0;
42  while (i < Configuration::LocalConfig_IgnorePatterns.count())
43  {
44  if (edit->Page->PageName.contains(Configuration::LocalConfig_IgnorePatterns.at(i)))
45  {
46  return false;
47  }
48  i++;
49  }
50  if (Configuration::LocalConfig_Ignores.contains(edit->Page->PageName))
51  {
52  return false;
53  }
54  if (edit->User->IsWhitelisted() && this->IgnoreWL)
55  {
56  return false;
57  }
58  if (edit->TrustworthEdit && this->IgnoreFriends)
59  {
60  return false;
61  }
62  if (edit->Minor && this->IgnoreMinor)
63  {
64  return false;
65  }
66  if (edit->NewPage && this->IgnoreNP)
67  {
68  return false;
69  }
70  if (edit->Bot && IgnoreBots)
71  {
72  return false;
73  }
74  return true;
75 }
76 
78 {
79  return IgnoreMinor;
80 }
81 
83 {
84  IgnoreMinor = value;
85 }
86 
88 {
89  return IgnoreUsers;
90 }
91 
93 {
94  IgnoreUsers = value;
95 }
96 
98 {
99  return IgnoreWL;
100 }
101 
103 {
104  IgnoreWL = value;
105 }
106 
108 {
109  return IgnoreIP;
110 }
111 
113 {
114  IgnoreIP = value;
115 }
116 
118 {
119  return IgnoreBots;
120 }
121 
123 {
124  IgnoreBots = value;
125 }
126 
128 {
129  return IgnoreNP;
130 }
131 
133 {
134  IgnoreNP = value;
135 }
136 
138 {
139  return IgnoreFriends;
140 }
141 
143 {
144  IgnoreFriends = value;
145 }
146 
147 
148 
149 
150 
151 
152 
153 
Filter that can be applied to edit queue.
bool NewPage
Edit is a new page.
Definition: wikiedit.hpp:95
bool IsTalk()
Return true in case this is a talk page.
Definition: wikipage.cpp:96
bool IsWhitelisted()
Returns true if this user is wl.
Definition: wikiuser.cpp:250
Every exception raised by huggle is defined by this class.
Definition: exception.hpp:20
bool Minor
Edit is a minor edit.
Definition: wikiedit.hpp:91
WikiUser * User
User who changed the page.
Definition: wikiedit.hpp:89
Wiki edit.
Definition: wikiedit.hpp:67
QString PageName
Name of page.
Definition: wikipage.hpp:48
bool Bot
Edit is a bot edit.
Definition: wikiedit.hpp:93
WikiPage * Page
Page that was changed by edit.
Definition: wikiedit.hpp:87