libkcal

vcaldrag.cpp
1 /*
2  This file is part of libkcal.
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 "vcaldrag.h"
24 
25 #include "vcalformat.h"
26 
27 using namespace KCal;
28 
29 VCalDrag::VCalDrag( Calendar *cal, TQWidget *parent, const char *name )
30  : TQStoredDrag( "text/x-vCalendar", parent, name )
31 {
32  VCalFormat format;
33  setEncodedData( format.toString( cal ).utf8() );
34 }
35 
36 bool VCalDrag::canDecode( TQMimeSource *me )
37 {
38  return me->provides( "text/x-vCalendar" );
39 }
40 
41 bool VCalDrag::decode( TQMimeSource *de, Calendar *cal )
42 {
43  bool success = false;
44 
45  TQByteArray payload = de->encodedData( "text/x-vCalendar" );
46  if ( payload.size() ) {
47  TQString txt = TQString::fromUtf8( payload.data() );
48 
49  VCalFormat format;
50  success = format.fromString( cal, txt );
51  }
52 
53  return success;
54 }
55 
This is the main "calendar" object class.
Definition: calendar.h:171
VCalDrag(Calendar *vcal, TQWidget *parent=0, const char *name=0)
Create a drag&drop object for vCalendar component vcal.
Definition: vcaldrag.cpp:29
static bool canDecode(TQMimeSource *)
Return, if drag&drop object can be decode to vCalendar.
Definition: vcaldrag.cpp:36
static bool decode(TQMimeSource *e, Calendar *cal)
Decode drag&drop object to vCalendar component vcal.
Definition: vcaldrag.cpp:41
This class implements the vCalendar format.
Definition: vcalformat.h:45
bool fromString(Calendar *, const TQString &)
Parse string and populate calendar with that information.
Definition: vcalformat.cpp:136
TQString toString(Calendar *)
Return calendar information as string.
Definition: vcalformat.cpp:172
Namespace KCal is for global classes, objects and/or functions in libkcal.
Definition: alarm.h:38