Ananas Library  0.9.5
afilter.h
1 /****************************************************************************
2 ** $Id: afilter.h,v 1.3 2007/03/17 11:34:09 gr Exp $
3 **
4 ** Filter declaration file of
5 ** Ananas application library
6 **
7 ** Created : 20070315
8 **
9 ** Copyright (C) 2007 Ananas Project.
10 ** Copyright (C) 2007 Grigory Panov <grigory.panov at gmail.com>, Moscow
11 **
12 ** This file is part of the Library of the Ananas
13 ** automation accounting system.
14 **
15 ** This file may be distributed and/or modified under the terms of the
16 ** GNU General Public License version 2 as published by the Free Software
17 ** Foundation and appearing in the file LICENSE.GPL included in the
18 ** packaging of this file.
19 **
20 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
21 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22 **
23 ** See http://www.leaderit.ru/page=ananas or email sales@leaderit.ru
24 ** See http://www.leaderit.ru/gpl/ for GPL licensing information.
25 **
26 ** Contact org@leaderit.ru if any conditions of this licensing are
27 ** not clear to you.
28 **
29 **********************************************************************/
30 
31 #ifndef afilter_h
32 #define afilter_h
33 
34 #include <qstring.h>
35 #include <qvaluelist.h>
36 #include <qdatetime.h>
37 #include "ananasglobal.h"
38 
39 ANANAS_EXPORT enum OperationEnum{
40  OperationEnumEquals,
41  OperationEnumNotEquals,
42  OperationEnumGreaterThen,
43  OperationEnumLessThen,
44  OperationEnumGreaterOrEquals,
45  OperationEnumLessOrEquals,
46  OperationEnumLike
47  };
48 
49 class ANANAS_EXPORT aFilter
50 {
51 public:
52  aFilter();
53  virtual ~aFilter();
54  void Dump() const;
55 
56  void Add(const QString& fname, const char* value, OperationEnum op, bool AndOp = true, bool replace = true);
57  void Add(const QString& fname, const Q_INT64 value, OperationEnum op, bool AndOp = true, bool replace = true);
58  void Add(const QString& fname, const int value, OperationEnum op, bool AndOp = true, bool replace = true);
59  void Add(const QString& fname, const double value, OperationEnum op, bool AndOp = true, bool replace = true);
60  //void Add(const QString& fname, bool value, OperationEnum op, bool AndOp = true, bool replace = true);
61  void Add(const QString& fname, const QString& value, OperationEnum op, bool AndOp = true, bool replace = true);
62  void Add(const QString& fname, const QDateTime& value, OperationEnum op, bool AndOp = true, bool replace = true);
63  void Add(const QString& fname, const QDate& value, OperationEnum op, bool AndOp = true, bool replace = true);
64  QString toString(bool removeFirst = true) const;
65  void Clear();
66 protected:
67  void AddHelper(const QString& fname, const QString& value, OperationEnum op, bool And, bool replace);
68  QString Escape(const QString& val);
69 private:
70  struct filterCondition
71  {
72  QString fname;
73  QString value;
74  QString operation;
75  QString AndOr;
76  }f;
77  //typedef struct filterCondition FilterCondition;
78  QValueList<filterCondition> conditions;
79 };
80 
81 #endif
Definition: afilter.h:49