• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepimlibs API Reference
  • KDE Home
  • Contact Us
 

KCal Library

  • sources
  • kde-4.12
  • kdepimlibs
  • kcal
icaldrag.cpp
1 /*
2  This file is part of the kcal library.
3 
4  Copyright (c) 1998 Preston Brown <pbrown@kde.org>
5  Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Library General Public
9  License as published by the Free Software Foundation; either
10  version 2 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Library General Public License for more details.
16 
17  You should have received a copy of the GNU Library General Public License
18  along with this library; see the file COPYING.LIB. If not, write to
19  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  Boston, MA 02110-1301, USA.
21 */
22 
23 #include "icaldrag.h"
24 #include "icalformat.h"
25 #include "calendar.h"
26 #include "kcal_export.h"
27 
28 #include <kdebug.h>
29 
30 #include <QtCore/QMimeData>
31 
32 using namespace KCal;
33 
34 QString ICalDrag::mimeType()
35 {
36  return "text/calendar";
37 }
38 
39 bool ICalDrag::populateMimeData( QMimeData *me, Calendar *cal )
40 {
41  ICalFormat icf;
42  QString scal = icf.toString( cal );
43 
44  if ( scal.length()>0 ){
45  me->setData( mimeType(), scal.toUtf8() );
46  }
47  return canDecode( me );
48 }
49 
50 bool ICalDrag::canDecode( const QMimeData *me )
51 {
52  return me->hasFormat( mimeType() );
53 }
54 
55 bool ICalDrag::fromMimeData( const QMimeData *de, Calendar *cal )
56 {
57  if (!canDecode( de ) ) {
58  return false;
59  }
60  bool success = false;
61 
62  QByteArray payload = de->data( mimeType() );
63  if ( payload.size() ) {
64  QString txt = QString::fromUtf8( payload.data() );
65 
66  ICalFormat icf;
67  success = icf.fromString( cal, txt );
68  }
69 
70  return success;
71 }
72 
KCal::ICalDrag::mimeType
KCAL_DEPRECATED_EXPORT QString mimeType()
Mime-type of iCalendar.
Definition: icaldrag.cpp:34
KCal::Calendar
Represents the main calendar class.
Definition: calendar.h:119
KCal::ICalFormat::fromString
bool fromString(Calendar *calendar, const QString &string)
Definition: icalformat.cpp:146
KCal::ICalFormat
iCalendar format implementation.
Definition: icalformat.h:52
KCal::ICalDrag::fromMimeData
KCAL_DEPRECATED_EXPORT bool fromMimeData(const QMimeData *e, Calendar *cal)
Decode drag&drop object to iCalendar component cal.
Definition: icaldrag.cpp:55
calendar.h
This file is part of the API for handling calendar data and defines the Calendar class.
KCal::ICalFormat::toString
QString toString(Calendar *calendar)
Definition: icalformat.cpp:229
KCal::ICalDrag::canDecode
KCAL_DEPRECATED_EXPORT bool canDecode(const QMimeData *)
Return, if drag&drop object can be decode to iCalendar.
Definition: icaldrag.cpp:50
KCal::ICalDrag::populateMimeData
KCAL_DEPRECATED_EXPORT bool populateMimeData(QMimeData *e, Calendar *cal)
Sets the iCalendar representation as data of the drag object.
Definition: icaldrag.cpp:39
icalformat.h
This file is part of the API for handling calendar data and defines the ICalFormat class...
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:00:57 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KCal Library

Skip menu "KCal Library"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdepimlibs API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kldap
  • kmbox
  • kmime
  • kpimidentities
  • kpimtextedit
  • kresources
  • ktnef
  • kxmlrpcclient
  • microblog

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal