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

KCalUtils Library

  • kcalutils
icaldrag.cpp
1 /*
2  This file is part of the kcalutils 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 #include "icaldrag.h"
23 
24 #include <kcalcore/icalformat.h>
25 using namespace KCalCore;
26 
27 #include <QtCore/QMimeData>
28 #include <QtCore/QString>
29 
30 using namespace KCalUtils;
31 using namespace ICalDrag;
32 
33 QString ICalDrag::mimeType()
34 {
35  return "text/calendar";
36 }
37 
38 bool ICalDrag::populateMimeData( QMimeData *me, const MemoryCalendar::Ptr &cal )
39 {
40  ICalFormat icf;
41  QString scal = icf.toString( cal, QString(), false );
42 
43  if ( scal.length()>0 ){
44  me->setData( mimeType(), scal.toUtf8() );
45  }
46  return canDecode( me );
47 }
48 
49 bool ICalDrag::canDecode( const QMimeData *me )
50 {
51  return me->hasFormat( mimeType() );
52 }
53 
54 bool ICalDrag::fromMimeData( const QMimeData *de, const MemoryCalendar::Ptr &cal )
55 {
56  if ( !canDecode( de ) ) {
57  return false;
58  }
59  bool success = false;
60 
61  QByteArray payload = de->data( mimeType() );
62  if ( payload.size() ) {
63  QString txt = QString::fromUtf8( payload.data() );
64 
65  ICalFormat icf;
66  success = icf.fromString( cal, txt );
67  }
68 
69  return success;
70 }
71 
KCalUtils::ICalDrag::canDecode
KCALUTILS_EXPORT bool canDecode(const QMimeData *)
Return, if drag&amp;drop object can be decode to iCalendar.
Definition: icaldrag.cpp:49
KCalUtils::ICalDrag::mimeType
KCALUTILS_EXPORT QString mimeType()
Mime-type of iCalendar.
Definition: icaldrag.cpp:33
KCalCore::MemoryCalendar::Ptr
QSharedPointer< MemoryCalendar > Ptr
KCalCore::ICalFormat
KCalCore::ICalFormat::fromString
bool fromString(const Calendar::Ptr &calendar, const QString &string, bool deleted=false, const QString &notebook=QString())
KCalCore::ICalFormat::toString
QString toString(const Calendar::Ptr &calendar, const QString &notebook=QString(), bool deleted=false)
icalformat.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Tue Nov 26 2013 09:02:52 by doxygen 1.8.5 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KCalUtils Library

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

kdepimlibs-4.11.3 API Reference

Skip menu "kdepimlibs-4.11.3 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
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