1 | /* |
2 | This file is part of libkabc. |
3 | |
4 | Copyright (c) 2002-2010 Tobias Koenig <tokoe@kde.org> |
5 | |
6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. |
10 | |
11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. |
15 | |
16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
19 | Boston, MA 02110-1301, USA. |
20 | */ |
21 | |
22 | #ifndef KABC_VCARDDRAG_H |
23 | #define KABC_VCARDDRAG_H |
24 | |
25 | #include "kabc_export.h" |
26 | |
27 | #include <kabc/addressee.h> |
28 | |
29 | namespace KABC { |
30 | |
31 | /** |
32 | @brief Utility function for implementing drag&drop for vCards |
33 | |
34 | See the Qt drag'n'drop documentation. |
35 | |
36 | @since 4.5 |
37 | */ |
38 | namespace VCardDrag { |
39 | |
40 | /** |
41 | Adds the vCard representation as data of the drag object. |
42 | |
43 | @param md the object to set the data on |
44 | @param content the vCard data to set |
45 | |
46 | @return Always @c true |
47 | */ |
48 | KABC_EXPORT bool populateMimeData( QMimeData *md, const QByteArray &content ); |
49 | |
50 | /** |
51 | Adds the vCard representation as data of the drag object. |
52 | |
53 | @param md the object to set the data on |
54 | @param contacts list of Addressee objects to serialize to vCard |
55 | |
56 | @return @c true if serializing of the given list worked, otherwise @c false |
57 | |
58 | @see VCardConverter::createVCards() |
59 | */ |
60 | KABC_EXPORT bool populateMimeData( QMimeData *md, const KABC::Addressee::List &contacts ); |
61 | |
62 | /** |
63 | Returns if drag&drop object can be decoded to vCard. |
64 | |
65 | @param md the object to check for vCard data |
66 | |
67 | @return @c true if the given data object contains a vCard MIME type, otherwise @c false |
68 | */ |
69 | KABC_EXPORT bool canDecode( const QMimeData *md ); |
70 | |
71 | /** |
72 | Decodes the drag&drop object to vCard component @p content. |
73 | |
74 | @param md the object to check for vCard data |
75 | @param content where to put the vCard data from @p md |
76 | |
77 | @return @c true if there was data for the vCard MIME type, otherwise @c false |
78 | |
79 | @see canDecode() |
80 | */ |
81 | KABC_EXPORT bool fromMimeData( const QMimeData *md, QByteArray &content ); |
82 | |
83 | /** |
84 | Decodes the MIME data @p md and puts the resulting vCard into @p contactss. |
85 | |
86 | @param md the object to check for vCard data |
87 | @param contacts where to put the parsed vCards from @p md |
88 | |
89 | @return @c true if there was data for the vCard MIME type and it could be parsed successfully, |
90 | otherwise @c false |
91 | |
92 | @see canDecode() |
93 | */ |
94 | KABC_EXPORT bool fromMimeData( const QMimeData *md, KABC::Addressee::List &contacts ); |
95 | } |
96 | |
97 | } |
98 | |
99 | #endif // VCARDDRAG_H |
100 | |