File indexing completed on 2024-05-12 15:55:37
0001 // SPDX-FileCopyrightText: 2005-2007, 2010, 2012 Jesper K. Pedersen <jesper.pedersen@kdab.com> 0002 // SPDX-FileCopyrightText: 2007 Dirk Mueller <mueller@kde.org> 0003 // SPDX-FileCopyrightText: 2007 Tuomas Suutari <tuomas@nepnep.net> 0004 // SPDX-FileCopyrightText: 2008 Henner Zeller <h.zeller@acm.org> 0005 // SPDX-FileCopyrightText: 2013 Dominik Broj <broj.dominik@gmail.com> 0006 // SPDX-FileCopyrightText: 2013, 2015, 2019-2022 Johannes Zarl-Zierl <johannes@zarl-zierl.at> 0007 // 0008 // SPDX-License-Identifier: GPL-2.0-or-later 0009 0010 #ifndef EXIFSEARCHINFO_H 0011 #define EXIFSEARCHINFO_H 0012 0013 #include "Database.h" 0014 0015 #include <kpabase/FileName.h> 0016 0017 #include <QList> 0018 #include <QPair> 0019 #include <QStringList> 0020 0021 namespace Exif 0022 { 0023 0024 class SearchInfo 0025 { 0026 public: 0027 /** 0028 * @brief SearchInfo creates an invalid SearchInfo. 0029 * Methods such as addSearchKey() or others can be called on an invalid SearchInfo, 0030 * but the searchInfo will not become valid by this and isNull() will always return \c true. 0031 */ 0032 SearchInfo(); 0033 SearchInfo(const Database *db); 0034 0035 typedef Database::CameraList CameraList; 0036 typedef Database::Camera Camera; 0037 typedef Database::LensList LensList; 0038 typedef Database::Lens Lens; 0039 typedef QList<int> IntList; 0040 0041 class Range 0042 { 0043 public: 0044 Range() { } 0045 explicit Range(const QString &key); 0046 bool isLowerMin = false; 0047 bool isLowerMax = false; 0048 bool isUpperMin = false; 0049 bool isUpperMax = false; 0050 double min = 0; 0051 double max = 0; 0052 QString key; 0053 }; 0054 0055 void addSearchKey(const QString &key, const IntList &values); 0056 void addRangeKey(const Range &range); 0057 void addCamera(const CameraList &list); 0058 void addLens(const LensList &list); 0059 0060 void search() const; 0061 bool matches(const DB::FileName &fileName) const; 0062 0063 /** 0064 * @brief isNull 0065 * @return \c false if the SearchInfo is bound to an Exif::Database object, \c true otherwise. 0066 */ 0067 bool isNull() const; 0068 /** 0069 * @brief isEmpty 0070 * @return \c true if the SearchInfo is null or if the query is empty, \c false otherwise. 0071 */ 0072 bool isEmpty() const; 0073 0074 protected: 0075 QString buildQuery() const; 0076 QStringList buildIntKeyQuery() const; 0077 QStringList buildRangeQuery() const; 0078 QString buildCameraSearchQuery() const; 0079 QString buildLensSearchQuery() const; 0080 QString sqlForOneRangeItem(const Range &) const; 0081 0082 private: 0083 const Database *m_exifDB; 0084 typedef QList<QPair<QString, IntList>> IntKeyList; 0085 IntKeyList m_intKeys; 0086 QList<Range> m_rangeKeys; 0087 CameraList m_cameras; 0088 LensList m_lenses; 0089 mutable DB::FileNameSet m_matches; 0090 mutable bool m_emptyQuery = false; 0091 }; 0092 0093 } 0094 0095 #endif /* EXIFSEARCHINFO_H */ 0096 0097 // vi:expandtab:tabstop=4 shiftwidth=4: