libkcal

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