KCalUtils

vcaldrag.cpp
1/*
2 This file is part of the kcalutils library.
3
4 SPDX-FileCopyrightText: 1998 Preston Brown <pbrown@kde.org>
5 SPDX-FileCopyrightText: 2001 Cornelius Schumacher <schumacher@kde.org>
6
7 SPDX-License-Identifier: LGPL-2.0-or-later
8*/
9#include "vcaldrag.h"
10
11#include <KCalendarCore/VCalFormat>
12using namespace KCalendarCore;
13
14#include <QMimeData>
15#include <QString>
16
17using namespace KCalUtils;
18using namespace VCalDrag;
19
21{
22 return QStringLiteral("text/x-vCalendar");
23}
24
26{
27 if (me) {
28 return me->hasFormat(mimeType());
29 } else {
30 return false;
31 }
32}
33
35{
36 if (!canDecode(de)) {
37 return false;
38 }
39
40 bool success = false;
41 const QByteArray payload = de->data(mimeType());
42 if (!payload.isEmpty()) {
43 const QString txt = QString::fromUtf8(payload.data());
44
45 VCalFormat format;
46 success = format.fromString(cal, txt);
47 }
48
49 return success;
50}
bool fromString(const Calendar::Ptr &calendar, const QString &string)
KCALUTILS_EXPORT bool fromMimeData(const QMimeData *e, const KCalendarCore::Calendar::Ptr &cal)
Decode drag&drop object to vCalendar component vcal.
Definition vcaldrag.cpp:34
KCALUTILS_EXPORT QString mimeType()
Mime-type of iCalendar.
Definition vcaldrag.cpp:20
KCALUTILS_EXPORT bool canDecode(const QMimeData *)
Return, if drag&drop object can be decode to vCalendar.
Definition vcaldrag.cpp:25
char * data()
bool isEmpty() const const
QByteArray data(const QString &mimeType) const const
virtual bool hasFormat(const QString &mimeType) const const
QString fromUtf8(QByteArrayView str)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:20:39 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.