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" ) {
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" ) {
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 );
163 cutIncidences( list );
168 if ( copyIncidences( incidences ) ) {
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 ) {
191 if ( cal.incidences().isEmpty() ) {
194 cb->setData(
new ICalDrag( &cal ) );
202 list.append( selectedInc );
203 return copyIncidences( list );
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 );
iCalendar drag&drop class.
virtual TQDateTime dtStart() const
returns an event's starting date/time as a TQDateTime.
void setDtEnd(const TQDateTime &dtEnd)
Set end date and time.
static bool decode(TQMimeSource *e, Calendar *cal)
Decode drag&drop object to iCalendar component cal.
void setDtDue(const TQDateTime &dtDue, bool first=false)
Sets due date and time.
This class provides a Todo in the sense of RFC2445.
This is the main "calendar" object class.
void recreate()
Recreate event.
void setRelatedToUid(const TQString &)
Point at some other event to which the event relates.
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, the incidences will be pasted at their original time
This class provides an Event in the sense of RFC2445.
TQString relatedToUid() const
What event does this one relate to? This function should only be used when constructing a calendar be...
bool copyIncidences(const Incidence::List &incidences)
copies a list of incidences to the clipboard
This class provides a calendar stored as a local file.
void setRelatedTo(Incidence *relatedTo)
Point at some other event to which the event relates.
bool cutIncidences(const Incidence::List &incidences)
cuts a list of incidences to the clipboard
TQString uid() const
Return the unique id for the event.
Todo * createDropTodo(TQDropEvent *de)
Create Todo object from drop event.
Incidence * pasteIncidence(const TQDate &, const TQTime *newTime=0)
pastes the event or todo and returns a pointer to the new incidence pasted.
Provides the main "calendar" object class.
This class provides the base class common to all calendar components.
This class provides a Journal in the sense of RFC2445.
ICalDrag * createDrag(Incidence *incidence, TQWidget *owner)
Create a drag object.
void cutIncidence(Incidence *)
cut incidence to clipboard
bool copyIncidence(Incidence *)
copy the incidence to clipboard
Namespace KCal is for global classes, objects and/or functions in libkcal.
virtual bool addIncidence(Incidence *incidence)
Insert an Incidence into the Calendar.
Event * createDrop(TQDropEvent *de)
Create Event object from drop event.
static bool decode(TQMimeSource *e, Calendar *cal)
Decode drag&drop object to vCalendar component vcal.
TQDateTime dtDue(bool first=false) const
Returns due date and time.
virtual TQDateTime dtEnd() const
Return end date and time.
virtual Incidence * clone()=0
Return copy of this object.
virtual void setDtStart(const TQDateTime &dtStart)
Set starting date/time.