1 /* 2 * Copyright 2018 Arjen Hiemstra <ahiemstra@heimr.nl> 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License as 6 * published by the Free Software Foundation; either version 2 of 7 * the License or (at your option) version 3 or any later version 8 * accepted by the membership of KDE e.V. (or its successor approved 9 * by the membership of KDE e.V.), which shall act as a proxy 10 * defined in Section 14 of version 3 of the license. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 21 #ifndef CONTENTQUERY_H 22 #define CONTENTQUERY_H 23 24 #include <memory> 25 26 #include <QObject> 27 28 /** 29 * Encapsulates searching parameters for files on the file system. 30 * 31 * 32 */ 33 class ContentQuery : public QObject 34 { 35 Q_OBJECT 36 /** 37 * The type of files to search for. 38 */ 39 Q_PROPERTY(Type type READ type WRITE setType NOTIFY typeChanged) 40 /** 41 * A string that should be included in the file's file name. 42 */ 43 Q_PROPERTY(QString searchString READ searchString WRITE setSearchString NOTIFY searchStringChanged) 44 /** 45 * A list of directories. Only these directories and their subdirectories will be searched. 46 */ 47 Q_PROPERTY(QStringList locations READ locations WRITE setLocations NOTIFY locationsChanged) 48 /** 49 * A list of mime type names to search for. 50 * 51 * Note that if this property has not explicitly been set, the list of mime types 52 * is based on the type property. 53 */ 54 Q_PROPERTY(QStringList mimeTypes READ mimeTypes WRITE setMimeTypes NOTIFY mimeTypesChanged) 55 56 public: 57 /** 58 * The type of files to search for. 59 */ 60 enum Type { 61 Any, ///< Do not limit results by any type. 62 Video, ///< Only search for videos. 63 Audio, ///< Only search for audio files. 64 Documents, ///< Only search for documents. 65 Images, ///< Only search for images. 66 Comics, ///< Only search for comic books. 67 }; 68 Q_ENUM(Type) 69 70 /** 71 * Constructor 72 * 73 * @param parent The QObject parent. 74 */ 75 explicit ContentQuery(QObject* parent = nullptr); 76 77 /** 78 * Destructor 79 */ 80 ~ContentQuery(); 81 82 /** 83 * Get the type property. 84 */ 85 Type type() const; 86 /** 87 * Get the searchString property. 88 */ 89 QString searchString() const; 90 /** 91 * Get the locations property. 92 */ 93 QStringList locations() const; 94 /** 95 * Get the mimeTypes property. 96 */ 97 QStringList mimeTypes() const; 98 99 public Q_SLOTS: 100 /** 101 * Set the type property. 102 * 103 * \param type The new type. 104 */ 105 void setType(Type type); 106 /** 107 * Set the searchString property. 108 * 109 * \param searchString The new search string. 110 */ 111 void setSearchString(const QString& searchString); 112 /** 113 * Set the location property. 114 * 115 * \param location The new location. 116 */ 117 void setLocations(const QStringList& location); 118 /** 119 * Set the mimeTypes property. 120 * 121 * \param mimeTypes The new list of mime types. 122 */ 123 void setMimeTypes(const QStringList& mimeTypes); 124 125 Q_SIGNALS: 126 /** 127 * Emitted whenever the type property changes. 128 */ 129 void typeChanged(); 130 /** 131 * Emitted whenever the searchString property changes. 132 */ 133 void searchStringChanged(); 134 /** 135 * Emitted whenever the location property changes. 136 */ 137 void locationsChanged(); 138 /** 139 * Emitted whenever the mimeTypes property changes. 140 */ 141 void mimeTypesChanged(); 142 143 private: 144 class Private; 145 const std::unique_ptr<Private> d; 146 }; 147 148 #endif // CONTENTQUERY_H 149