KContacts

resourcelocatorurl.h
1 /*
2  This file is part of the KContacts framework.
3  SPDX-FileCopyrightText: 2015-2019 Laurent Montel <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7 
8 #ifndef RESOURCELOCATORURL_H
9 #define RESOURCELOCATORURL_H
10 
11 #include "kcontacts_export.h"
12 
13 #include <QMap>
14 #include <QMetaType>
15 #include <QSharedDataPointer>
16 #include <QString>
17 #include <QUrl>
18 
19 namespace KContacts
20 {
21 /** @short Class that holds a Resource Locator
22  * @since 5.0
23  */
24 class KCONTACTS_EXPORT ResourceLocatorUrl
25 {
26  friend KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &, const ResourceLocatorUrl &);
27  friend KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &, ResourceLocatorUrl &);
28 
29  Q_GADGET
30  Q_PROPERTY(QUrl url READ url WRITE setUrl)
31  Q_PROPERTY(bool isValid READ isValid)
32  Q_PROPERTY(Type type READ type WRITE setType)
33  Q_PROPERTY(bool isPreferred READ isPreferred WRITE setPreferred)
34 
35 public:
38 
40 
42 
43  /** URL types.
44  * @since 5.12
45  * @see Type
46  */
47  enum TypeFlag {
48  Unknown = 0, /**< No or unknown URL type is set. */
49  Home = 1, /**< Personal website. */
50  Work = 2, /**< Work website. */
51  Profile = 4, /**< Profile website. */
52  Other = 8, /**< Other websie. */
53  };
54 
55  /**
56  * Stores a combination of #TypeFlag values.
57  */
58  Q_DECLARE_FLAGS(Type, TypeFlag)
59  Q_FLAG(Type)
60 
61  Q_REQUIRED_RESULT bool isValid() const;
62 
63  void setUrl(const QUrl &url);
64  Q_REQUIRED_RESULT QUrl url() const;
65 
66  /**
67  * Returns the type of the URL.
68  * @since 5.12
69  */
70  Type type() const;
71  /**
72  * Sets the URL type.
73  * @since 5.12
74  */
75  void setType(Type type);
76 
77  /**
78  * Returns whether this is the preferred website.
79  * @since 5.12
80  */
81  bool isPreferred() const;
82  /**
83  * Sets that this is the preferred website.
84  * @since 5.12
85  */
86  void setPreferred(bool preferred);
87 
88  void setParameters(const QMap<QString, QStringList> &params);
89  Q_REQUIRED_RESULT QMap<QString, QStringList> parameters() const;
90 
91  Q_REQUIRED_RESULT bool operator==(const ResourceLocatorUrl &other) const;
92  Q_REQUIRED_RESULT bool operator!=(const ResourceLocatorUrl &other) const;
93 
94  ResourceLocatorUrl &operator=(const ResourceLocatorUrl &other);
95 
96  Q_REQUIRED_RESULT QString toString() const;
97 
98 private:
99  class Private;
100  QSharedDataPointer<Private> d;
101 };
102 
103 Q_DECLARE_OPERATORS_FOR_FLAGS(ResourceLocatorUrl::Type)
104 
105 KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &stream, const ResourceLocatorUrl &object);
106 
107 KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &stream, ResourceLocatorUrl &object);
108 }
109 Q_DECLARE_METATYPE(KContacts::ResourceLocatorUrl)
110 Q_DECLARE_TYPEINFO(KContacts::ResourceLocatorUrl, Q_MOVABLE_TYPE);
111 
112 #endif // RESOURCELOCATORURL_H
Class that holds a Resource Locator.
QDataStream & operator>>(QDataStream &in, KDateTime::Spec &spec)
QDataStream & operator<<(QDataStream &out, const KDateTime::Spec &spec)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Jun 12 2021 22:55:11 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.