digiKam
itemquerybuilder.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2007-03-22
7  * Description : Building complex database SQL queries from search descriptions
8  *
9  * Copyright (C) 2005 by Renchi Raju <renchi dot raju at gmail dot com>
10  * Copyright (C) 2007-2012 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
11  * Copyright (C) 2012-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
12  *
13  * This program is free software; you can redistribute it
14  * and/or modify it under the terms of the GNU General
15  * Public License as published by the Free Software Foundation;
16  * either version 2, or (at your option)
17  * any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU General Public License for more details.
23  *
24  * ============================================================ */
25 
26 #ifndef DIGIKAM_ITEM_QUERY_BUILDER_H
27 #define DIGIKAM_ITEM_QUERY_BUILDER_H
28 
29 // Qt includes
30 
31 #include <QVariant>
32 #include <QString>
33 
34 // Local includes
35 
36 #include "coredbsearchxml.h"
37 #include "itemqueryposthooks.h"
38 #include "digikam_export.h"
39 
40 class QUrl;
41 
42 namespace Digikam
43 {
44 
45 class DIGIKAM_DATABASE_EXPORT ItemQueryBuilder
46 {
47 public:
48 
49  explicit ItemQueryBuilder();
50 
51  QString buildQuery(const QString& q, QList<QVariant>* boundValues, ItemQueryPostHooks* const hooks) const;
52  QString buildQueryFromUrl(const QUrl& url, QList<QVariant>* boundValues) const;
53  QString buildQueryFromXml(const QString& xml, QList<QVariant>* boundValues, ItemQueryPostHooks* const hooks) const;
54  QString convertFromUrlToXml(const QUrl& url) const;
55 
60  void setImageTagPropertiesJoined(bool isJoined);
61 
62 public:
63 
64  static void addSqlOperator(QString& sql, SearchXml::Operator op, bool isFirst);
65  static void addSqlRelation(QString& sql, SearchXml::Relation rel);
66  static void addNoEffectContent(QString& sql, SearchXml::Operator op);
67 
68 protected:
69 
70  void buildGroup(QString& sql, SearchXmlCachingReader& reader,
71  QList<QVariant>* boundValues, ItemQueryPostHooks* const hooks) const;
72  bool buildField(QString& sql, SearchXmlCachingReader& reader, const QString& name,
73  QList<QVariant>* boundValues, ItemQueryPostHooks* const hooks) const;
74 
75  QString possibleDate(const QString& str, bool& exact) const;
76 
77 protected:
78 
79  QString m_longMonths[12];
80  QString m_shortMonths[12];
82 };
83 
84 } // namespace Digikam
85 
86 #endif // DIGIKAM_ITEM_QUERY_BUILDER_H
Definition: itemquerybuilder.h:46
bool m_imageTagPropertiesJoined
Definition: itemquerybuilder.h:81
Definition: itemqueryposthooks.h:60
Definition: coredbsearchxml.h:376
Relation
Definition: coredbsearchxml.h:66
Operator
Definition: coredbsearchxml.h:48
Definition: datefolderview.cpp:43