KContacts

resourcelocatorurl.h
1/*
2 This file is part of the KContacts framework.
3 SPDX-FileCopyrightText: 2015-2019 Laurent Montel <montel@kde.org>
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
19class ResourceLocatorUrlTest;
20
21namespace KContacts
22{
23class ParameterMap;
24
25/** @short Class that holds a Resource Locator
26 * @since 5.0
27 */
28class 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
41public:
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 Ftp = 8, /**< Ftp website. @since 6.0 */
59 Reservation = 16, /**< Reservation website. @since 6.0 */
60 AppInstallPage = 32, /**< Application installation website. @sine 6.0 */
61 Other = 64, /**< Other websie. */
62 };
63
64 /**
65 * Stores a combination of #TypeFlag values.
66 */
67 Q_DECLARE_FLAGS(Type, TypeFlag)
68 Q_FLAG(Type)
69
70 Q_REQUIRED_RESULT bool isValid() const;
71
72 void setUrl(const QUrl &url);
73 Q_REQUIRED_RESULT QUrl url() const;
74
75 /**
76 * Returns the type of the URL.
77 * @since 5.12
78 */
79 Type type() const;
80 /**
81 * Sets the URL type.
82 * @since 5.12
83 */
84 void setType(Type type);
85
86 /**
87 * Returns whether this is the preferred website.
88 * @since 5.12
89 */
90 bool isPreferred() const;
91 /**
92 * Sets that this is the preferred website.
93 * @since 5.12
94 */
95 void setPreferred(bool preferred);
96
97 Q_REQUIRED_RESULT bool operator==(const ResourceLocatorUrl &other) const;
98 Q_REQUIRED_RESULT bool operator!=(const ResourceLocatorUrl &other) const;
99
100 ResourceLocatorUrl &operator=(const ResourceLocatorUrl &other);
101
102 Q_REQUIRED_RESULT QString toString() const;
103
104private:
105 // exported for ResourceLocatorUrlTest
106 void setParams(const ParameterMap &params);
107 Q_REQUIRED_RESULT ParameterMap params() const;
108
109 class Private;
111};
112
113Q_DECLARE_OPERATORS_FOR_FLAGS(ResourceLocatorUrl::Type)
114
115KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &stream, const ResourceLocatorUrl &object);
116
117KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &stream, ResourceLocatorUrl &object);
118}
119
120Q_DECLARE_TYPEINFO(KContacts::ResourceLocatorUrl, Q_RELOCATABLE_TYPE);
121
122#endif // RESOURCELOCATORURL_H
Class that holds a Resource Locator.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jun 14 2024 11:58:05 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.