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

0001 /*
0002     SPDX-FileCopyrightText: 2012 Andrius da Costa Ribas <andriusmao@gmail.com>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 
0007 #pragma once
0008 
0009 #include "kgapidrive_export.h"
0010 #include "object.h"
0011 #include "types.h"
0012 
0013 #include <QSharedPointer>
0014 #include <QString>
0015 #include <QStringList>
0016 #include <QUrl>
0017 
0018 namespace KGAPI2
0019 {
0020 
0021 namespace Drive
0022 {
0023 
0024 class KGAPIDRIVE_EXPORT App : public KGAPI2::Object
0025 {
0026     class Private;
0027 
0028 public:
0029     class Icon
0030     {
0031     public:
0032         enum Category { UndefinedCategory, ApplicationCategory, DocumentCategory, DocumentSharedCategory };
0033 
0034         explicit Icon();
0035         explicit Icon(const Icon &other);
0036         virtual ~Icon();
0037         bool operator==(const Icon &other) const;
0038         bool operator!=(const Icon &other) const
0039         {
0040             return !operator==(other);
0041         }
0042 
0043         [[nodiscard]] Category category() const;
0044         [[nodiscard]] int size() const;
0045         [[nodiscard]] QUrl iconUrl() const;
0046 
0047     private:
0048         class Private;
0049         Private *const d;
0050         friend class Private;
0051         friend class App::Private;
0052     };
0053 
0054     using IconPtr = QSharedPointer<Icon>;
0055     using IconsList = QList<IconPtr>;
0056 
0057     explicit App();
0058     explicit App(const App &other);
0059     ~App() override;
0060     bool operator==(const App &other) const;
0061     bool operator!=(const App &other) const
0062     {
0063         return !operator==(other);
0064     }
0065 
0066     [[nodiscard]] QString id() const;
0067     [[nodiscard]] QString name() const;
0068     [[nodiscard]] QString objectType() const;
0069     [[nodiscard]] bool supportsCreate() const;
0070     [[nodiscard]] bool supportsImport() const;
0071     [[nodiscard]] bool installed() const;
0072     [[nodiscard]] bool authorized() const;
0073     [[nodiscard]] bool useByDefault() const;
0074     [[nodiscard]] QUrl productUrl() const;
0075     [[nodiscard]] QStringList primaryMimeTypes() const;
0076     [[nodiscard]] QStringList secondaryMimeTypes() const;
0077     [[nodiscard]] QStringList primaryFileExtensions() const;
0078     [[nodiscard]] QStringList secondaryFileExtensions() const;
0079     [[nodiscard]] IconsList icons() const;
0080 
0081     static AppsList fromJSONFeed(const QByteArray &jsonData);
0082     static AppPtr fromJSON(const QByteArray &jsonData);
0083 
0084 private:
0085     Private *const d;
0086     friend class Private;
0087 };
0088 
0089 } /* namespace Drive */
0090 
0091 } /* namespace KGAPI2 */