LeechCraft  0.6.70-15082-g543737046d
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  * Distributed under the Boost Software License, Version 1.0.
6  * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7  **********************************************************************/
8 
9 #pragma once
10 
11 #include <variant>
12 #include <QtPlugin>
13 #include <QVariant>
14 #include <QStringList>
15 
16 namespace LC
17 {
28  struct ANFieldData
29  {
35  QString ID_;
36 
41  QString Name_;
42 
48  QString Description_;
49 
59  QVariant::Type Type_ = QVariant::Invalid;
60 
67  QStringList EventTypes_;
68 
78  QVariantList AllowedValues_ = {};
79  };
80 
83  struct ANBoolFieldValue
84  {
87  bool IsSet_;
88 
89  auto operator<=> (const ANBoolFieldValue&) const = default;
90  };
91 
94  struct ANIntFieldValue
95  {
98  int Boundary_;
99 
102  enum Operation
103  {
106  OGreater = 0x01,
107 
110  OLess = 0x02,
111 
114  OEqual = 0x04
115  };
116 
117  Q_DECLARE_FLAGS (Operations, Operation)
118 
119 
123  Operations Ops_;
124 
125  bool operator== (const ANIntFieldValue&) const = default;
126  };
127 
130  struct ANStringFieldValue
131  {
134  QRegExp Rx_;
135 
141  bool Contains_;
142 
149  ANStringFieldValue (const QRegExp& rx, bool contains)
150  : Rx_ { rx }
151  , Contains_ { contains }
152  {
153  }
154 
167  ANStringFieldValue (const QString& str, bool contains = true)
168  : Rx_ { str, Qt::CaseSensitive, QRegExp::FixedString }
169  , Contains_ { contains }
170  {
171  }
172 
173  bool operator== (const ANStringFieldValue&) const = default;
174  };
175 
178  using ANFieldValue = std::variant<ANBoolFieldValue, ANIntFieldValue, ANStringFieldValue>;
179 }
180 
195 class Q_DECL_EXPORT IANEmitter
196 {
197 public:
198  virtual ~IANEmitter () = default;
199 
215  virtual QList<LC::ANFieldData> GetANFields () const = 0;
216 };
217 
218 Q_DECLARE_INTERFACE (IANEmitter, "org.Deviant.LeechCraft.IANEmitter/1.0")
219 Q_DECLARE_METATYPE (LC::ANFieldData)
222 
223 Q_DECLARE_OPERATORS_FOR_FLAGS (LC::ANIntFieldValue::Operations)
LC::ANIntFieldValue::Boundary_
int Boundary_
The boundary of the field.
Definition: ianemitter.h:104
LC::Q_DECLARE_FLAGS
Q_DECLARE_FLAGS(TabFeatures, LC::TabFeature)
LC::ANStringFieldValue
Describes a field with QString values.
Definition: ianemitter.h:136
LC::ANStringFieldValue::operator==
bool operator==(const ANStringFieldValue &) const =default
QList
Definition: ianrulesstorage.h:14
LC::ANBoolFieldValue
Describes a field with boolean values.
Definition: ianemitter.h:89
LC::ANIntFieldValue::Operation
Operation
Describes the elementary semantics of Boundary_.
Definition: ianemitter.h:108
LC::ANStringFieldValue::ANStringFieldValue
ANStringFieldValue(const QRegExp &rx, bool contains)
Constructs the field matcher.
Definition: ianemitter.h:155
LC::ANFieldData::Name_
QString Name_
The name of the field.
Definition: ianemitter.h:53
IANEmitter
Interface for plugins emitting AdvancedNotifications entries.
Definition: ianemitter.h:195
LC::ANIntFieldValue::Ops_
Operations Ops_
Describe the semantics of Boundary_.
Definition: ianemitter.h:129
LC::ANFieldData::ID_
QString ID_
The field ID.
Definition: ianemitter.h:47
LC::Util::XDG::Type
Type
Describes the various types of XDG .desktop files.
Definition: itemtypes.h:23
LC::ANFieldData::Type_
QVariant::Type Type_
The type of this field.
Definition: ianemitter.h:71
LC::ANIntFieldValue::OEqual
@ OEqual
The value should be equal to Boundary_.
Definition: ianemitter.h:120
LC::ANFieldData::AllowedValues_
QVariantList AllowedValues_
The allowed values of this field.
Definition: ianemitter.h:90
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(QVariantList *)
LC::ANStringFieldValue::Rx_
QRegExp Rx_
The regular expression the values should (not) match.
Definition: ianemitter.h:140
LC::ANIntFieldValue
Describes a field with integer values.
Definition: ianemitter.h:100
LC::ANBoolFieldValue::IsSet_
bool IsSet_
Whether the field should be set.
Definition: ianemitter.h:93
LC
Definition: constants.h:14
LC::ANFieldData::EventTypes_
QStringList EventTypes_
The types of the event that contain this field.
Definition: ianemitter.h:79
LC::ANFieldValue
std::variant< ANBoolFieldValue, ANIntFieldValue, ANStringFieldValue > ANFieldValue
A combination of all possible descriptions.
Definition: ianemitter.h:184
LC::ANIntFieldValue::OGreater
@ OGreater
The value should be greater than Boundary_.
Definition: ianemitter.h:112
LC::ANIntFieldValue::operator==
bool operator==(const ANIntFieldValue &) const =default
LC::ANFieldData::Description_
QString Description_
The description of the field.
Definition: ianemitter.h:60
LC::ANIntFieldValue::OLess
@ OLess
The value should be less than Boundary_.
Definition: ianemitter.h:116
LC::ANStringFieldValue::Contains_
bool Contains_
Whether the values should match or not match Rx_.
Definition: ianemitter.h:147