1/*
2 This file is part of the KContacts framework.
3
4 SPDX-FileCopyrightText: 2002-2010 Tobias Koenig <tokoe@kde.org>
5
6 SPDX-License-Identifier: LGPL-2.0-or-later
7*/
8
9#ifndef KCONTACTS_VCARDDRAG_H
10#define KCONTACTS_VCARDDRAG_H
11
12#include "kcontacts_export.h"
13
14#include <QMimeData>
15#include <kcontacts/addressee.h>
16
17namespace KContacts
18{
19/*!
20 \namespace KContacts::VCardDrag
21 \inheaderfile KContacts/VCardDrag
22 \inmodule KContacts
23
24 \brief Utility function for implementing drag&drop for vCards.
25
26 See the Qt drag'n'drop documentation.
27
28 \since 4.5
29*/
30namespace VCardDrag
31{
32/*!
33 Adds the vCard representation as data of the drag object.
34
35 \a md the object to set the data on
36
37 \a content the vCard data to set
38
39 Always returns true
40*/
41KCONTACTS_EXPORT bool populateMimeData(QMimeData *md, const QByteArray &content);
42
43/*!
44 Adds the vCard representation as data of the drag object.
45
46 \a md the object to set the data on
47
48 \a contacts list of Addressee objects to serialize to vCard
49
50 Returns \c true if serializing of the given list worked, otherwise \c false
51
52 \sa VCardConverter::createVCards()
53*/
54KCONTACTS_EXPORT bool populateMimeData(QMimeData *md, const KContacts::Addressee::List &contacts);
55
56/*!
57 Returns if drag&drop object can be decoded to vCard.
58
59 \a md the object to check for vCard data
60
61 Returns \c true if the given data object contains a vCard MIME type, otherwise \c false
62*/
63KCONTACTS_EXPORT bool canDecode(const QMimeData *md);
64
65/*!
66 Decodes the drag&drop object to vCard component \a content.
67
68 \a md the object to check for vCard data
69
70 \a content where to put the vCard data from \a md
71
72 Returns \c true if there was data for the vCard MIME type, otherwise \c false
73
74 \sa canDecode()
75*/
76KCONTACTS_EXPORT bool fromMimeData(const QMimeData *md, QByteArray &content);
77
78/*!
79 Decodes the MIME data \a md and puts the resulting vCard into \a contacts.
80
81 \a md the object to check for vCard data
82
83 \a contacts where to put the parsed vCards from @p md
84
85 Returns \c true if there was data for the vCard MIME type and it could be parsed successfully,
86 otherwise \c false
87
88 \sa canDecode()
89*/
90KCONTACTS_EXPORT bool fromMimeData(const QMimeData *md, KContacts::Addressee::List &contacts);
91}
92}
93
94#endif // VCARDDRAG_H
95

source code of kcontacts/src/vcarddrag.h