File indexing completed on 2025-01-19 03:53:39

0001 /* ============================================================
0002  *
0003  * This file is a part of digiKam project
0004  * https://www.digikam.org
0005  *
0006  * Date        : 2007-03-22
0007  * Description : database SQL queries helper class
0008  *
0009  * SPDX-FileCopyrightText: 2007-2012 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
0010  * SPDX-FileCopyrightText: 2012-2024 by Gilles Caulier <caulier dot gilles at gmail dot com>
0011  *
0012  * SPDX-License-Identifier: GPL-2.0-or-later
0013  *
0014  * ============================================================ */
0015 
0016 #ifndef DIGIKAM_FIELD_QUERY_BUILDER_H
0017 #define DIGIKAM_FIELD_QUERY_BUILDER_H
0018 
0019 // Qt includes
0020 
0021 #include <QList>
0022 #include <QString>
0023 
0024 // Local includes
0025 
0026 #include "coredbsearchxml.h"
0027 
0028 namespace Digikam
0029 {
0030 
0031 class ItemQueryPostHooks;
0032 
0033 class Q_DECL_HIDDEN FieldQueryBuilder
0034 {
0035 public:
0036 
0037     FieldQueryBuilder(QString& sql,
0038                       SearchXmlCachingReader& reader,
0039                       QList<QVariant>* boundValues,
0040                       ItemQueryPostHooks* const hooks,
0041                       SearchXml::Relation relation);
0042 
0043 public:
0044 
0045     QString&                sql;
0046     SearchXmlCachingReader& reader;
0047     QList<QVariant>*        boundValues;
0048     ItemQueryPostHooks*     hooks;
0049     SearchXml::Relation     relation;
0050 
0051 public:
0052 
0053     QString prepareForLike(const QString& str) const;
0054 
0055     void addIntField(const QString& name);
0056     void addLongField(const QString& name);
0057     void addDoubleField(const QString& name);
0058     void addStringField(const QString& name);
0059     void addDateField(const QString& name);
0060     void addChoiceIntField(const QString& name);
0061     void addLongListField(const QString& name);
0062     void addIntBitmaskField(const QString& name);
0063     void addChoiceStringField(const QString& name);
0064     void addPosition();
0065     void addRectanglePositionSearch(double lon1, double lat1, double lon2, double lat2) const;
0066 };
0067 
0068 } // namespace Digikam
0069 
0070 #endif // DIGIKAM_FIELD_QUERY_BUILDER_H