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:
36 
39 
41 
43 
44  /** URL types.
45  * @since 5.12
46  * @see Type
47  */
48  enum TypeFlag {
49  Unknown = 0, /**< No or unknown URL type is set. */
50  Home = 1, /**< Personal website. */
51  Work = 2, /**< Work website. */
52  Profile = 4, /**< Profile website. */
53  Other = 8 /**< Other websie. */
54  };
55 
56  /**
57  * Stores a combination of #TypeFlag values.
58  */
59  Q_DECLARE_FLAGS(Type, TypeFlag)
60  Q_FLAG(Type)
61 
62  Q_REQUIRED_RESULT bool isValid() const;
63 
64  void setUrl(const QUrl &url);
65  Q_REQUIRED_RESULT QUrl url() const;
66 
67  /**
68  * Returns the type of the URL.
69  * @since 5.12
70  */
71  Type type() const;
72  /**
73  * Sets the URL type.
74  * @since 5.12
75  */
76  void setType(Type type);
77 
78  /**
79  * Returns whether this is the preferred website.
80  * @since 5.12
81  */
82  bool isPreferred() const;
83  /**
84  * Sets that this is the preferred website.
85  * @since 5.12
86  */
87  void setPreferred(bool preferred);
88 
89  void setParameters(const QMap<QString, QStringList> &params);
90  Q_REQUIRED_RESULT QMap<QString, QStringList> parameters() const;
91 
92  Q_REQUIRED_RESULT bool operator==(const ResourceLocatorUrl &other) const;
93  Q_REQUIRED_RESULT bool operator!=(const ResourceLocatorUrl &other) const;
94 
95  ResourceLocatorUrl &operator=(const ResourceLocatorUrl &other);
96 
97  Q_REQUIRED_RESULT QString toString() const;
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 Thu Mar 4 2021 22:56:02 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.