Changeset View
Changeset View
Standalone View
Standalone View
src/drive/drivessearchquery.h
- This file was copied from src/drive/teamdrivemodifyjob.h.
1 | /* | 1 | /* | ||
---|---|---|---|---|---|
2 | * This file is part of LibKGAPI library | | |||
3 | * | | |||
4 | * Copyright (C) 2019 David Barchiesi <david@barchie.si> | 2 | * Copyright (C) 2019 David Barchiesi <david@barchie.si> | ||
5 | * | 3 | * | ||
6 | * This library is free software; you can redistribute it and/or | 4 | * This library is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU Lesser General Public | 5 | * modify it under the terms of the GNU Lesser General Public | ||
8 | * License as published by the Free Software Foundation; either | 6 | * License as published by the Free Software Foundation; either | ||
9 | * version 2.1 of the License, or (at your option) version 3, or any | 7 | * version 2.1 of the License, or (at your option) version 3, or any | ||
10 | * later version accepted by the membership of KDE e.V. (or its | 8 | * later version accepted by the membership of KDE e.V. (or its | ||
11 | * successor approved by the membership of KDE e.V.), which shall | 9 | * successor approved by the membership of KDE e.V.), which shall | ||
12 | * act as a proxy defined in Section 6 of version 3 of the license. | 10 | * act as a proxy defined in Section 6 of version 3 of the license. | ||
13 | * | 11 | * | ||
14 | * This library is distributed in the hope that it will be useful, | 12 | * This library is distributed in the hope that it will be useful, | ||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
17 | * GNU Lesser General Public License for more details. | 15 | * GNU Lesser General Public License for more details. | ||
18 | * | 16 | * | ||
19 | * You should have received a copy of the GNU Lesser General Public | 17 | * You should have received a copy of the GNU Lesser General Public | ||
20 | * License along with this library. If not, see <https://www.gnu.org/licenses/>. | 18 | * License along with this library. If not, see <https://www.gnu.org/licenses/>. | ||
21 | */ | 19 | */ | ||
22 | 20 | | |||
21 | #ifndef KGAPI2_DRIVE_DRIVESSEARCHQUERY_H | ||||
22 | #define KGAPI2_DRIVE_DRIVESSEARCHQUERY_H | ||||
23 | 23 | | |||
24 | #ifndef KGAPI2_DRIVETEAMDRIVEMODIFYJOB_H | | |||
25 | #define KGAPI2_DRIVETEAMDRIVEMODIFYJOB_H | | |||
26 | | ||||
27 | #include "modifyjob.h" | | |||
28 | #include "kgapidrive_export.h" | 24 | #include "kgapidrive_export.h" | ||
29 | 25 | | |||
26 | #include "searchquery.h" | ||||
27 | | ||||
28 | #include <QVariant> | ||||
29 | #include <QSharedDataPointer> | ||||
30 | | ||||
30 | namespace KGAPI2 | 31 | namespace KGAPI2 | ||
31 | { | 32 | { | ||
32 | | ||||
33 | namespace Drive | 33 | namespace Drive | ||
34 | { | 34 | { | ||
35 | 35 | | |||
36 | class KGAPIDRIVE_EXPORT TeamdriveModifyJob : public KGAPI2::ModifyJob | 36 | /** | ||
37 | * DrivesSearchQuery class allows simply building even complex shared drive search queries | ||||
38 | * for DrivesFetchJob. | ||||
39 | * | ||||
40 | * See https://developers.google.com/drive/api/v2/search-shareddrives for allowed | ||||
41 | * combinations of fields, compare operators, and value types. | ||||
42 | */ | ||||
43 | class KGAPIDRIVE_EXPORT DrivesSearchQuery : public SearchQuery | ||||
37 | { | 44 | { | ||
38 | Q_OBJECT | | |||
39 | | ||||
40 | public: | 45 | public: | ||
41 | explicit TeamdriveModifyJob(const TeamdrivePtr &teamdrive, | 46 | enum Field { | ||
42 | const AccountPtr &account, QObject *parent = nullptr); | 47 | Name, | ||
43 | explicit TeamdriveModifyJob(const TeamdrivesList &teamdrives, | 48 | Hidden, | ||
44 | const AccountPtr &account, QObject *parent = nullptr); | 49 | CreatedDate, | ||
45 | ~TeamdriveModifyJob() override; | 50 | MemberCount, | ||
46 | 51 | OrganizerCount | |||
47 | protected: | | |||
48 | void start() override; | | |||
49 | KGAPI2::ObjectsList handleReplyWithItems(const QNetworkReply *reply, | | |||
50 | const QByteArray &rawData) override; | | |||
51 | | ||||
52 | private: | | |||
53 | class Private; | | |||
54 | QScopedPointer<Private> d; | | |||
55 | friend class Private; | | |||
56 | }; | 52 | }; | ||
57 | 53 | | |||
58 | } // namespace Drive | 54 | using SearchQuery::SearchQuery; | ||
59 | 55 | | |||
60 | } // namespace KGAPI2 | 56 | using SearchQuery::addQuery; | ||
57 | void addQuery(Field field, CompareOperator op, const QVariant &value); | ||||
58 | | ||||
59 | private: | ||||
60 | QString fieldToString(Field field); | ||||
61 | QString valueToString(DrivesSearchQuery::Field field, const QVariant &var); | ||||
62 | }; | ||||
63 | } | ||||
64 | } | ||||
61 | 65 | | |||
62 | #endif // KGAPI2_DRIVETEAMDRIVEMODIFYJOB_H | 66 | #endif // KGAPI2_DRIVE_DRIVESSEARCHQUERY_H |