File indexing completed on 2024-05-12 05:22:20

0001 /*
0002  * SPDX-FileCopyrightText: 2014 Daniel Vrátil <dvratil@redhat.com>
0003  * SPDX-FileCopyrightText: 2019 David Barchiesi <david@barchie.si>
0004  *
0005  * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0006  */
0007 
0008 #pragma once
0009 
0010 #include "kgapidrive_export.h"
0011 
0012 #include "searchquery.h"
0013 
0014 #include <QSharedDataPointer>
0015 #include <QVariant>
0016 
0017 namespace KGAPI2
0018 {
0019 namespace Drive
0020 {
0021 
0022 /**
0023  * FileSearchQuery class allows simply building even complex file search queries
0024  * for FileFetchJob.
0025  *
0026  * See https://developers.google.com/drive/web/search-parameters for allowed
0027  * combinations of fields, compare operators, and value types.
0028  *
0029  * @since 2.3
0030  */
0031 class KGAPIDRIVE_EXPORT FileSearchQuery : public SearchQuery
0032 {
0033 public:
0034     enum Field {
0035         Title,
0036         FullText,
0037         MimeType,
0038         ModifiedDate,
0039         LastViewedByMeDate,
0040         Trashed,
0041         Starred,
0042         Parents,
0043         Owners,
0044         Writers,
0045         Readers,
0046         SharedWithMe,
0047         /*Properties            FIXME: Not supported atm */
0048     };
0049 
0050     using SearchQuery::SearchQuery;
0051 
0052     using SearchQuery::addQuery;
0053     void addQuery(Field field, CompareOperator op, const QVariant &value);
0054 
0055 private:
0056     [[nodiscard]] QString fieldToString(Field field);
0057     [[nodiscard]] QString valueToString(FileSearchQuery::Field field, const QVariant &var);
0058 };
0059 }
0060 }