File indexing completed on 2024-11-10 09:36:19

0001 /*
0002     This file is part of the KContacts framework.
0003 
0004     SPDX-FileCopyrightText: 2002-2010 Tobias Koenig <tokoe@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.0-or-later
0007 */
0008 
0009 #ifndef KCONTACTS_VCARDDRAG_H
0010 #define KCONTACTS_VCARDDRAG_H
0011 
0012 #include "kcontacts_export.h"
0013 
0014 #include <QMimeData>
0015 #include <kcontacts/addressee.h>
0016 
0017 namespace KContacts
0018 {
0019 /**
0020   @brief Utility function for implementing drag&drop for vCards
0021 
0022   See the Qt drag'n'drop documentation.
0023 
0024   @since 4.5
0025 */
0026 namespace VCardDrag
0027 {
0028 /**
0029   Adds the vCard representation as data of the drag object.
0030 
0031   @param md the object to set the data on
0032   @param content the vCard data to set
0033 
0034   @return Always @c true
0035 */
0036 KCONTACTS_EXPORT bool populateMimeData(QMimeData *md, const QByteArray &content);
0037 
0038 /**
0039   Adds the vCard representation as data of the drag object.
0040 
0041   @param md the object to set the data on
0042   @param contacts list of Addressee objects to serialize to vCard
0043 
0044   @return @c true if serializing of the given list worked, otherwise @c false
0045 
0046   @see VCardConverter::createVCards()
0047 */
0048 KCONTACTS_EXPORT bool populateMimeData(QMimeData *md, const KContacts::Addressee::List &contacts);
0049 
0050 /**
0051   Returns if drag&drop object can be decoded to vCard.
0052 
0053   @param md the object to check for vCard data
0054 
0055   @return @c true if the given data object contains a vCard MIME type, otherwise @c false
0056 */
0057 KCONTACTS_EXPORT bool canDecode(const QMimeData *md);
0058 
0059 /**
0060   Decodes the drag&drop object to vCard component @p content.
0061 
0062   @param md the object to check for vCard data
0063   @param content where to put the vCard data from @p md
0064 
0065   @return @c true if there was data for the vCard MIME type, otherwise @c false
0066 
0067   @see canDecode()
0068 */
0069 KCONTACTS_EXPORT bool fromMimeData(const QMimeData *md, QByteArray &content);
0070 
0071 /**
0072   Decodes the MIME data @p md and puts the resulting vCard into @p contacts.
0073 
0074   @param md the object to check for vCard data
0075   @param contacts where to put the parsed vCards from @p md
0076 
0077   @return @c true if there was data for the vCard MIME type and it could be parsed successfully,
0078           otherwise @c false
0079 
0080   @see canDecode()
0081 */
0082 KCONTACTS_EXPORT bool fromMimeData(const QMimeData *md, KContacts::Addressee::List &contacts);
0083 }
0084 }
0085 
0086 #endif // VCARDDRAG_H