24#include <tqapplication.h>
25#include <tqclipboard.h>
28#include <kiconloader.h>
30#include <tdemessagebox.h>
36#include "vcalformat.h"
37#include "icalformat.h"
38#include "calendarlocal.h"
40#include "dndfactory.h"
44class DndFactory::Private
47 Incidence * pasteIncidence( Incidence *inc,
48 const TQDate &newDate,
49 const TQTime *newTime = 0 )
56 if ( inc && newDate.isValid() ) {
57 if ( inc->type() ==
"Event" ) {
58 Event *anEvent =
static_cast<Event*
>( inc );
60 int daysOffset = anEvent->
dtStart().date().daysTo(
61 anEvent->
dtEnd().date() );
63 TQDateTime endDate( newDate.addDays(daysOffset), anEvent->
dtEnd().time() );
67 int addSecsOffset( anEvent->
dtStart().time().secsTo( *newTime ));
68 endDate=endDate.addSecs( addSecsOffset );
69 anEvent->
setDtStart( TQDateTime( newDate, *newTime ) );
74 }
else if ( inc->type() ==
"Todo" ) {
75 Todo *anTodo =
static_cast<Todo*
>( inc );
77 anTodo->
setDtDue( TQDateTime( newDate, *newTime ) );
79 anTodo->
setDtDue( TQDateTime( newDate, anTodo->
dtDue().time() ) );
81 }
else if ( inc->type() ==
"Journal" ) {
82 Journal *anJournal =
static_cast<Journal*
>( inc );
84 anJournal->
setDtStart( TQDateTime( newDate, *newTime ) );
86 anJournal->
setDtStart( TQDateTime( newDate ) );
89 kdDebug(5850) <<
"Trying to paste unknown incidence of type " << inc->type() << endl;
96DndFactory::DndFactory(
Calendar *cal ) :
97 mCalendar( cal ), d( new Private )
101DndFactory::~DndFactory()
113 if ( i->type() ==
"Event" )
114 icd->setPixmap( BarIcon(
"appointment" ) );
115 else if ( i->type() ==
"Todo" )
116 icd->setPixmap( BarIcon(
"todo" ) );
123 kdDebug(5800) <<
"DndFactory::createDrop()" << endl;
130 Event::List events = cal.
events();
131 if ( !events.isEmpty() ) {
142 kdDebug(5800) <<
"VCalFormat::createDropTodo()" << endl;
149 Todo::List todos = cal.
todos();
150 if ( !todos.isEmpty() ) {
151 Todo *todo =
new Todo( *todos.first() );
161 Incidence::List list;
162 list.append( selectedInc );
169 Incidence::List::ConstIterator it;
170 for ( it = incidences.constBegin(); it != incidences.constEnd(); ++it ) {
171 mCalendar->deleteIncidence( *it );
181 TQClipboard *cb = TQApplication::clipboard();
183 Incidence::List::ConstIterator it;
185 for ( it = incidences.constBegin(); it != incidences.constEnd(); ++it ) {
194 cb->setData(
new ICalDrag( &cal ) );
201 Incidence::List list;
202 list.append( selectedInc );
209 TQClipboard *cb = TQApplication::clipboard();
210 Incidence::List list;
214 kdDebug(5800) <<
"Can't parse clipboard" << endl;
220 TQMap<TQString,Incidence*> oldUidToNewInc;
222 Incidence::List::ConstIterator it;
223 const Incidence::List incs = cal.
incidences();
224 for ( it = incs.constBegin(); it != incs.constEnd(); ++it ) {
225 Incidence *inc = d->pasteIncidence( *it, newDate, newTime );
228 oldUidToNewInc[( *it )->uid()] = inc;
233 for ( it = list.constBegin(); it != list.constEnd(); ++it ) {
252 TQClipboard *cb = TQApplication::clipboard();
256 kdDebug(5800) <<
"Can't parse clipboard" << endl;
261 Incidence *inc = incList.isEmpty() ? 0 : incList.first();
263 Incidence *newInc = d->pasteIncidence( inc, newDate, newTime );
Provides the main "calendar" object class.
This class provides a calendar stored as a local file.
This is the main "calendar" object class.
virtual bool addIncidence(Incidence *incidence)
Insert an Incidence into the Calendar.
virtual Incidence::List incidences()
Return a filtered list of all Incidences for this Calendar.
virtual Event::List events(EventSortField sortField=EventSortUnsorted, SortDirection sortDirection=SortDirectionAscending)
Return a sorted, filtered list of all Events for this Calendar.
virtual Todo::List todos(TodoSortField sortField=TodoSortUnsorted, SortDirection sortDirection=SortDirectionAscending)
Return a sorted, filtered list of all Todos for this Calendar.
bool cutIncidences(const Incidence::List &incidences)
cuts a list of incidences to the clipboard
Incidence * pasteIncidence(const TQDate &, const TQTime *newTime=0)
pastes the event or todo and returns a pointer to the new incidence pasted.
bool copyIncidences(const Incidence::List &incidences)
copies a list of incidences to the clipboard
Incidence::List pasteIncidences(const TQDate &newDate=TQDate(), const TQTime *newTime=0)
pastes and returns the incidences from the clipboard If no date and time are given,...
void cutIncidence(Incidence *)
cut incidence to clipboard
bool copyIncidence(Incidence *)
copy the incidence to clipboard
ICalDrag * createDrag(Incidence *incidence, TQWidget *owner)
Create a drag object.
Todo * createDropTodo(TQDropEvent *de)
Create Todo object from drop event.
Event * createDrop(TQDropEvent *de)
Create Event object from drop event.
This class provides an Event in the sense of RFC2445.
virtual TQDateTime dtEnd() const
Return end date and time.
void setDtEnd(const TQDateTime &dtEnd)
Set end date and time.
iCalendar drag&drop class.
static bool decode(TQMimeSource *e, Calendar *cal)
Decode drag&drop object to iCalendar component cal.
TQString uid() const
Return the unique id for the event.
virtual TQDateTime dtStart() const
returns an event's starting date/time as a TQDateTime.
This class provides the base class common to all calendar components.
TQString relatedToUid() const
What event does this one relate to?
void recreate()
Recreate event.
void setRelatedTo(Incidence *relatedTo)
Point at some other event to which the event relates.
void setRelatedToUid(const TQString &)
Point at some other event to which the event relates.
virtual Incidence * clone()=0
Return copy of this object.
virtual void setDtStart(const TQDateTime &dtStart)
Set starting date/time.
This class provides a Todo in the sense of RFC2445.
void setDtDue(const TQDateTime &dtDue, bool first=false)
Sets due date and time.
TQDateTime dtDue(bool first=false) const
Returns due date and time.
static bool decode(TQMimeSource *e, Calendar *cal)
Decode drag&drop object to vCalendar component vcal.
Namespace KCal is for global classes, objects and/or functions in libkcal.