24 #include <tqapplication.h>
25 #include <tqclipboard.h>
28 #include <kiconloader.h>
30 #include <tdemessagebox.h>
31 #include <tdelocale.h>
36 #include "vcalformat.h"
37 #include "icalformat.h"
38 #include "calendarlocal.h"
40 #include "dndfactory.h"
44 class DndFactory::Private
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;
96 DndFactory::DndFactory(
Calendar *cal ) :
97 mCalendar( cal ), d( new Private )
101 DndFactory::~DndFactory()
110 cal.addIncidence( i );
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;
131 if ( !events.isEmpty() ) {
142 kdDebug(5800) <<
"VCalFormat::createDropTodo()" << endl;
150 if ( !todos.isEmpty() ) {
151 Todo *todo =
new Todo( *todos.first() );
162 list.append( selectedInc );
169 Incidence::List::ConstIterator it;
170 for ( it = incidences.constBegin(); it != incidences.constEnd(); ++it ) {
181 TQClipboard *cb = TQApplication::clipboard();
183 Incidence::List::ConstIterator it;
185 for ( it = incidences.constBegin(); it != incidences.constEnd(); ++it ) {
191 if ( cal.incidences().isEmpty() ) {
194 cb->setData(
new ICalDrag( &cal ) );
202 list.append( selectedInc );
209 TQClipboard *cb = TQApplication::clipboard();
214 kdDebug(5800) <<
"Can't parse clipboard" << endl;
220 TQMap<TQString,Incidence*> oldUidToNewInc;
222 Incidence::List::ConstIterator it;
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 );
void recreate()
Recreate event.
TQString relatedToUid() const
What event does this one relate to? This function should only be used when constructing a calendar be...
virtual bool deleteIncidence(Incidence *incidence)
Remove an Incidence from the Calendar.
bool copyIncidence(Incidence *)
copy the incidence to clipboard
virtual Incidence * clone()=0
Return copy of this object.
TQString timeZoneId() const
Get the Time Zone ID for the Calendar.
void setDtDue(const TQDateTime &dtDue, bool first=false)
Sets due date and time.
ICalDrag * createDrag(Incidence *incidence, TQWidget *owner)
Create a drag object.
virtual bool addIncidence(Incidence *incidence)
Insert an Incidence into the Calendar.
Todo * createDropTodo(TQDropEvent *de)
Create Todo object from drop event.
static bool decode(TQMimeSource *e, Calendar *cal)
Decode drag&drop object to vCalendar component vcal.
Event * createDrop(TQDropEvent *de)
Create Event object from drop event.
This class provides an Event in the sense of RFC2445.
bool copyIncidences(const Incidence::List &incidences)
copies a list of incidences to the clipboard
This class provides a Todo in the sense of RFC2445.
This class provides a calendar stored as a local file.
void setRelatedTo(Incidence *relatedTo)
Point at some other event to which the event relates.
Incidence * pasteIncidence(const TQDate &, const TQTime *newTime=0)
pastes the event or todo and returns a pointer to the new incidence pasted.
iCalendar drag&drop class.
void cutIncidence(Incidence *)
cut incidence to clipboard
This class provides the base class common to all calendar components.
static bool decode(TQMimeSource *e, Calendar *cal)
Decode drag&drop object to iCalendar component cal.
virtual void setDtStart(const TQDateTime &dtStart)
Set starting date/time.
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,...
bool cutIncidences(const Incidence::List &incidences)
cuts a list of incidences to the clipboard
This class provides a Journal in the sense of RFC2445.
TQString uid() const
Return the unique id for the event.
virtual TQDateTime dtStart() const
returns an event's starting date/time as a TQDateTime.
TQDateTime dtDue(bool first=false) const
Returns due date and time.
void setDtEnd(const TQDateTime &dtEnd)
Set end date and time.
void setRelatedToUid(const TQString &)
Point at some other event to which the event relates.
virtual TQDateTime dtEnd() const
Return end date and time.