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 class ResourceLocatorUrlTest;
20 
21 namespace KContacts
22 {
23 class ParameterMap;
24 
25 /** @short Class that holds a Resource Locator
26  * @since 5.0
27  */
28 class KCONTACTS_EXPORT ResourceLocatorUrl
29 {
30  friend KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &, const ResourceLocatorUrl &);
31  friend KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &, ResourceLocatorUrl &);
32  friend class VCardTool;
33  friend class ::ResourceLocatorUrlTest;
34 
35  Q_GADGET
36  Q_PROPERTY(QUrl url READ url WRITE setUrl)
37  Q_PROPERTY(bool isValid READ isValid)
38  Q_PROPERTY(Type type READ type WRITE setType)
39  Q_PROPERTY(bool isPreferred READ isPreferred WRITE setPreferred)
40 
41 public:
44 
46 
48 
49  /** URL types.
50  * @since 5.12
51  * @see Type
52  */
53  enum TypeFlag {
54  Unknown = 0, /**< No or unknown URL type is set. */
55  Home = 1, /**< Personal website. */
56  Work = 2, /**< Work website. */
57  Profile = 4, /**< Profile website. */
58  Other = 8, /**< Other websie. */
59  };
60 
61  /**
62  * Stores a combination of #TypeFlag values.
63  */
64  Q_DECLARE_FLAGS(Type, TypeFlag)
65  Q_FLAG(Type)
66 
67  Q_REQUIRED_RESULT bool isValid() const;
68 
69  void setUrl(const QUrl &url);
70  Q_REQUIRED_RESULT QUrl url() const;
71 
72  /**
73  * Returns the type of the URL.
74  * @since 5.12
75  */
76  Type type() const;
77  /**
78  * Sets the URL type.
79  * @since 5.12
80  */
81  void setType(Type type);
82 
83  /**
84  * Returns whether this is the preferred website.
85  * @since 5.12
86  */
87  bool isPreferred() const;
88  /**
89  * Sets that this is the preferred website.
90  * @since 5.12
91  */
92  void setPreferred(bool preferred);
93 
94 #if KCONTACTS_ENABLE_DEPRECATED_SINCE(5, 88)
95  /**
96  * @deprecated Since 5.88 for lack of usage
97  */
98  KCONTACTS_DEPRECATED_VERSION(5, 88, "For lack of usage.")
99  void setParameters(const QMap<QString, QStringList> &params);
100 #endif
101 
102 #if KCONTACTS_ENABLE_DEPRECATED_SINCE(5, 88)
103  /**
104  * @deprecated Since 5.88 for lack of usage
105  */
106  Q_REQUIRED_RESULT
107  KCONTACTS_DEPRECATED_VERSION(5, 88, "For lack of usage.")
108  QMap<QString, QStringList> parameters() const;
109 #endif
110 
111  Q_REQUIRED_RESULT bool operator==(const ResourceLocatorUrl &other) const;
112  Q_REQUIRED_RESULT bool operator!=(const ResourceLocatorUrl &other) const;
113 
114  ResourceLocatorUrl &operator=(const ResourceLocatorUrl &other);
115 
116  Q_REQUIRED_RESULT QString toString() const;
117 
118 private:
119  // exported for ResourceLocatorUrlTest
120  void setParams(const ParameterMap &params);
121  Q_REQUIRED_RESULT ParameterMap params() const;
122 
123  class Private;
125 };
126 
127 Q_DECLARE_OPERATORS_FOR_FLAGS(ResourceLocatorUrl::Type)
128 
129 KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &stream, const ResourceLocatorUrl &object);
130 
131 KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &stream, ResourceLocatorUrl &object);
132 }
133 Q_DECLARE_METATYPE(KContacts::ResourceLocatorUrl)
134 Q_DECLARE_TYPEINFO(KContacts::ResourceLocatorUrl, Q_MOVABLE_TYPE);
135 
136 #endif // RESOURCELOCATORURL_H
KCALENDARCORE_EXPORT QDataStream & operator<<(QDataStream &out, const KCalendarCore::Alarm::Ptr &)
KCALENDARCORE_EXPORT QDataStream & operator>>(QDataStream &in, const KCalendarCore::Alarm::Ptr &)
Class that holds a Resource Locator.
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Dec 10 2023 03:49:09 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.