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

KCalUtils Library

vcaldrag.cpp
00001 /*
00002   This file is part of the kcalutils library.
00003 
00004   Copyright (c) 1998 Preston Brown <pbrown@kde.org>
00005   Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
00006 
00007   This library is free software; you can redistribute it and/or
00008   modify it under the terms of the GNU Library General Public
00009   License as published by the Free Software Foundation; either
00010   version 2 of the License, or (at your option) any later version.
00011 
00012   This library is distributed in the hope that it will be useful,
00013   but WITHOUT ANY WARRANTY; without even the implied warranty of
00014   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015   Library General Public License for more details.
00016 
00017   You should have received a copy of the GNU Library General Public License
00018   along with this library; see the file COPYING.LIB.  If not, write to
00019   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00020   Boston, MA 02110-1301, USA.
00021 */
00022 #include "vcaldrag.h"
00023 
00024 #include <kcalcore/vcalformat.h>
00025 using namespace KCalCore;
00026 
00027 #include <QtCore/QMimeData>
00028 #include <QtCore/QString>
00029 
00030 using namespace KCalUtils;
00031 using namespace VCalDrag;
00032 
00033 QString VCalDrag::mimeType()
00034 {
00035   return "text/x-vCalendar";
00036 }
00037 
00038 bool VCalDrag::populateMimeData( QMimeData *e,
00039                                  const MemoryCalendar::Ptr &cal )
00040 {
00041   VCalFormat format;
00042   QString calstr( format.toString( cal ) );
00043   if ( calstr.length() > 0 ) {
00044     e->setData( mimeType(), calstr.toUtf8() );
00045   }
00046   return canDecode( e );
00047 }
00048 
00049 bool VCalDrag::canDecode( const QMimeData *me )
00050 {
00051   return me->hasFormat( mimeType() );
00052 }
00053 
00054 bool VCalDrag::fromMimeData( const QMimeData *de,
00055                              const MemoryCalendar::Ptr &cal )
00056 {
00057   if ( !canDecode( de ) ) {
00058     return false;
00059   }
00060 
00061   bool success = false;
00062   QByteArray payload = de->data( mimeType() );
00063   if ( payload.size() ) {
00064     QString txt = QString::fromUtf8( payload.data() );
00065 
00066     VCalFormat format;
00067     success = format.fromString( cal, txt );
00068   }
00069 
00070   return success;
00071 }
00072 
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon May 14 2012 04:49:08 by doxygen 1.7.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.8.3 API Reference

Skip menu "kdepimlibs-4.8.3 API Reference"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • 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