LeechCraft  0.6.70-13729-g7046a9d2a7
Modular cross-platform feature rich live environment.
ianemitter.h
Go to the documentation of this file.
1 /**********************************************************************
2  * LeechCraft - modular cross-platform feature rich internet client.
3  * Copyright (C) 2006-2014 Georg Rudoy
4  *
5  * Boost Software License - Version 1.0 - August 17th, 2003
6  *
7  * Permission is hereby granted, free of charge, to any person or organization
8  * obtaining a copy of the software and accompanying documentation covered by
9  * this license (the "Software") to use, reproduce, display, distribute,
10  * execute, and transmit the Software, and to prepare derivative works of the
11  * Software, and to permit third-parties to whom the Software is furnished to
12  * do so, all subject to the following:
13  *
14  * The copyright notices in the Software and this entire statement, including
15  * the above license grant, this restriction and the following disclaimer,
16  * must be included in all copies of the Software, in whole or in part, and
17  * all derivative works of the Software, unless such copies or derivative
18  * works are solely in the form of machine-executable object code generated by
19  * a source language processor.
20  *
21  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23  * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
24  * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
25  * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
26  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27  * DEALINGS IN THE SOFTWARE.
28  **********************************************************************/
29 
30 #pragma once
31 
32 #include <variant>
33 #include <QtPlugin>
34 #include <QVariant>
35 #include <QStringList>
36 
37 namespace LC
38 {
49  struct ANFieldData
50  {
56  QString ID_;
57 
62  QString Name_;
63 
69  QString Description_;
70 
81 
88  QStringList EventTypes_;
89 
99  QVariantList AllowedValues_;
100 
107  : Type_ (QVariant::Invalid)
108  {
109  }
110 
120  ANFieldData (const QString& id,
121  const QString& name,
122  const QString& description,
123  QVariant::Type type,
124  const QStringList& events,
125  const QVariantList& values = {})
126  : ID_ (id)
127  , Name_ (name)
128  , Description_ (description)
129  , Type_ (type)
130  , EventTypes_ (events)
131  , AllowedValues_ (values)
132  {
133  }
134  };
135 
139  {
142  bool IsSet_;
143  };
144 
152  inline bool operator== (const ANBoolFieldValue& left, const ANBoolFieldValue& right)
153  {
154  return left.IsSet_ == right.IsSet_;
155  }
156 
160  {
164 
168  {
171  OGreater = 0x01,
172 
175  OLess = 0x02,
176 
179  OEqual = 0x04
180  };
181 
182  Q_DECLARE_FLAGS (Operations, Operation)
183 
184 
188  Operations Ops_;
189  };
190 
198  inline bool operator== (const ANIntFieldValue& left, const ANIntFieldValue& right)
199  {
200  return left.Boundary_ == right.Boundary_ &&
201  left.Ops_ == right.Ops_;
202  }
203 
207  {
210  QRegExp Rx_;
211 
217  bool Contains_;
218 
225  ANStringFieldValue (const QRegExp& rx, bool contains)
226  : Rx_ { rx }
227  , Contains_ { contains }
228  {
229  }
230 
243  ANStringFieldValue (const QString& str, bool contains = true)
244  : Rx_ { str, Qt::CaseSensitive, QRegExp::FixedString }
245  , Contains_ { contains }
246  {
247  }
248  };
249 
257  inline bool operator== (const ANStringFieldValue& left, const ANStringFieldValue& right)
258  {
259  return left.Contains_ == right.Contains_ &&
260  left.Rx_ == right.Rx_;
261  }
262 
265  typedef std::variant<ANBoolFieldValue, ANIntFieldValue, ANStringFieldValue> ANFieldValue;
266 }
267 
282 class Q_DECL_EXPORT IANEmitter
283 {
284 public:
285  virtual ~IANEmitter () {}
286 
302  virtual QList<LC::ANFieldData> GetANFields () const = 0;
303 };
304 
305 Q_DECLARE_INTERFACE (IANEmitter, "org.Deviant.LeechCraft.IANEmitter/1.0")
306 Q_DECLARE_METATYPE (LC::ANFieldData)
309 
310 Q_DECLARE_OPERATORS_FOR_FLAGS (LC::ANIntFieldValue::Operations)
Describes a field with boolean values.
Definition: ianemitter.h:138
std::variant< ANBoolFieldValue, ANIntFieldValue, ANStringFieldValue > ANFieldValue
A combination of all possible descriptions.
Definition: ianemitter.h:265
ANFieldData(const QString &id, const QString &name, const QString &description, QVariant::Type type, const QStringList &events, const QVariantList &values={})
Constructs field with the given info variables.
Definition: ianemitter.h:120
The value should be greater than Boundary_.
Definition: ianemitter.h:171
QString Name_
The name of the field.
Definition: ianemitter.h:62
Operation
Describes the elementary semantics of Boundary_.
Definition: ianemitter.h:167
ANStringFieldValue(const QString &str, bool contains=true)
Constructs the field matcher for the given str.
Definition: ianemitter.h:243
The value should be equal to Boundary_.
Definition: ianemitter.h:179
QVariant::Type Type_
The type of this field.
Definition: ianemitter.h:80
Operations Ops_
Describe the semantics of Boundary_.
Definition: ianemitter.h:188
QRegExp Rx_
The regular expression the values should (not) match.
Definition: ianemitter.h:210
A single additional AdvancedNotifications field.
Definition: ianemitter.h:49
ANFieldData()
Constructs an empty field info.
Definition: ianemitter.h:106
ANStringFieldValue(const QRegExp &rx, bool contains)
Constructs the field matcher.
Definition: ianemitter.h:225
Type
Describes the various types of XDG .desktop files.
Definition: itemtypes.h:48
Describes a field with integer values.
Definition: ianemitter.h:159
Describes a field with QString values.
Definition: ianemitter.h:206
Interface for plugins emitting AdvancedNotifications entries.
Definition: ianemitter.h:282
Q_DECLARE_METATYPE(QVariantList *)
bool IsSet_
Whether the field should be set.
Definition: ianemitter.h:142
bool Contains_
Whether the values should match or not match Rx_.
Definition: ianemitter.h:217
The value should be less than Boundary_.
Definition: ianemitter.h:175
bool operator==(const ANBoolFieldValue &left, const ANBoolFieldValue &right)
Compares two fields with boolean values.
Definition: ianemitter.h:152
virtual ~IANEmitter()
Definition: ianemitter.h:285
QVariantList AllowedValues_
The allowed values of this field.
Definition: ianemitter.h:99
QStringList EventTypes_
The types of the event that contain this field.
Definition: ianemitter.h:88
Definition: constants.h:35
Q_DECLARE_FLAGS(TabFeatures, LC::TabFeature)
QString ID_
The field ID.
Definition: ianemitter.h:56
QString Description_
The description of the field.
Definition: ianemitter.h:69
int Boundary_
The boundary of the field.
Definition: ianemitter.h:163