26 #include <tqtooltip.h>
30 #include <tqwidgetstack.h>
31 #include <tqwhatsthis.h>
33 #include <kiconloader.h>
35 #include <tdelocale.h>
36 #include <tdemessagebox.h>
38 #include <libkcal/resourcecalendar.h>
39 #include <libkcal/incidenceformatter.h>
40 #include <libkcal/calendarlocal.h>
43 #include "koeditorgeneralevent.h"
44 #include "koeditorrecurrence.h"
45 #include "koeditordetails.h"
46 #include "koeditorfreebusy.h"
47 #include "kogroupware.h"
48 #include "kodialogmanager.h"
49 #include "incidencechanger.h"
51 #include "koeventeditor.h"
55 mEvent( 0 ), mCalendar( 0 ), mGeneral( 0 ), mRecurrence( 0 ), mFreeBusy( 0 )
59 KOEventEditor::~KOEventEditor()
62 emit dialogClose( mEvent );
70 setupDesignerTabs(
"event" );
73 connect( mGeneral, TQ_SIGNAL( dateTimesChanged(
const TQDateTime &,
const TQDateTime & ) ),
74 mRecurrence, TQ_SLOT( setDateTimes(
const TQDateTime &,
const TQDateTime &) ) );
75 connect( mGeneral, TQ_SIGNAL( dateTimeStrChanged(
const TQString & ) ),
76 mRecurrence, TQ_SLOT( setDateTimeStr(
const TQString & ) ) );
77 connect( mFreeBusy, TQ_SIGNAL( dateTimesChanged(
const TQDateTime &,
const TQDateTime & ) ),
78 mRecurrence, TQ_SLOT( setDateTimes(
const TQDateTime &,
const TQDateTime & ) ) );
81 connect( mGeneral, TQ_SIGNAL( dateTimesChanged(
const TQDateTime &,
const TQDateTime & ) ),
82 mFreeBusy, TQ_SLOT( slotUpdateGanttView(
const TQDateTime &,
const TQDateTime & ) ) );
83 connect( mFreeBusy, TQ_SIGNAL( dateTimesChanged(
const TQDateTime &,
const TQDateTime & ) ),
84 mGeneral, TQ_SLOT( setDateTimes(
const TQDateTime &,
const TQDateTime & ) ) );
86 connect( mGeneral, TQ_SIGNAL( focusReceivedSignal() ),
87 TQ_SIGNAL( focusReceivedSignal() ) );
89 connect( mGeneral, TQ_SIGNAL( openCategoryDialog() ),
90 TQ_SIGNAL( editCategories() ) );
91 connect(
this, TQ_SIGNAL( updateCategoryConfig() ),
92 mGeneral, TQ_SIGNAL( updateCategoryConfig() ) );
94 connect( mFreeBusy, TQ_SIGNAL(updateAttendeeSummary(
int)),
95 mGeneral, TQ_SLOT(updateAttendeeSummary(
int)) );
97 connect( mGeneral, TQ_SIGNAL(editRecurrence()),
98 mRecurrenceDialog, TQ_SLOT(show()) );
99 connect( mRecurrenceDialog, TQ_SIGNAL(okClicked()),
100 TQ_SLOT(updateRecurrenceSummary()) );
102 connect( mGeneral, TQ_SIGNAL(acceptInvitation()),
103 mFreeBusy, TQ_SLOT(acceptForMe()) );
104 connect( mGeneral, TQ_SIGNAL(declineInvitation()),
105 mFreeBusy, TQ_SLOT(declineForMe()) );
108 void KOEventEditor::reload()
110 kdDebug(5850) <<
"KOEventEditor::reload()" << endl;
113 readEvent( mEvent, mCalendar, TQDate() );
117 void KOEventEditor::setupGeneral()
119 mGeneral =
new KOEditorGeneralEvent(
this );
121 if( KOPrefs::instance()->mCompactDialogs ) {
122 TQFrame *topFrame = addPage(i18n(
"General"));
123 TQWhatsThis::add( topFrame,
124 i18n(
"The General tab allows you to set the most common "
125 "options for the event.") );
127 TQBoxLayout *topLayout =
new TQVBoxLayout(topFrame);
128 topLayout->setSpacing(spacingHint());
130 mGeneral->initHeader( topFrame, topLayout );
131 mGeneral->initTime(topFrame,topLayout);
133 topLayout->addStretch( 1 );
135 TQFrame *topFrame2 = addPage(i18n(
"Details"));
137 TQBoxLayout *topLayout2 =
new TQVBoxLayout(topFrame2);
138 topLayout2->setSpacing(spacingHint());
140 mGeneral->initClass(topFrame2,topLayout2);
141 mGeneral->initSecrecy( topFrame2, topLayout2 );
142 mGeneral->initDescription(topFrame2,topLayout2);
144 TQFrame *topFrame = addPage(i18n(
"&General"));
145 TQWhatsThis::add( topFrame,
146 i18n(
"The General tab allows you to set the most common "
147 "options for the event.") );
149 TQBoxLayout *topLayout =
new TQVBoxLayout(topFrame);
150 topLayout->setSpacing(spacingHint());
152 mGeneral->initInvitationBar( topFrame, topLayout );
153 mGeneral->initHeader( topFrame, topLayout );
154 mGeneral->initTime(topFrame,topLayout);
155 mGeneral->initDescription(topFrame,topLayout);
156 mGeneral->initAttachments(topFrame,topLayout);
157 connect( mGeneral, TQ_SIGNAL( openURL(
const KURL& ) ),
158 this, TQ_SLOT( openURL(
const KURL& ) ) );
159 connect(
this, TQ_SIGNAL( signalAddAttachments(
const TQStringList&,
const TQStringList&,
bool ) ),
160 mGeneral, TQ_SLOT(
addAttachments(
const TQStringList&,
const TQStringList&,
bool ) ) );
163 mGeneral->finishSetup();
173 void KOEventEditor::setupRecurrence()
175 mRecurrenceDialog =
new KOEditorRecurrenceDialog(
this );
176 mRecurrenceDialog->hide();
177 mRecurrence = mRecurrenceDialog->editor();
180 void KOEventEditor::setupFreeBusy()
182 TQFrame *freeBusyPage = addPage( i18n(
"&Attendees") );
183 TQWhatsThis::add( freeBusyPage,
184 i18n(
"The Free/Busy tab allows you to see whether "
185 "other attendees are free or busy during your event.") );
187 TQBoxLayout *topLayout =
new TQVBoxLayout( freeBusyPage );
189 mAttendeeEditor = mFreeBusy =
new KOEditorFreeBusy( spacingHint(), freeBusyPage );
190 topLayout->addWidget( mFreeBusy );
197 Event*
event =
dynamic_cast<Event*
>(incidence);
202 mCalendar = calendar;
204 const TQDate &dt = mRecurIncidence && date.isValid() ? date : incidence->
dtStart().date();
208 setCaption( i18n(
"Edit Event") );
216 setCaption( i18n(
"New Event") );
221 mGeneral->setDefaults( from, to, allDay );
222 mRecurrence->setDefaults( from, to, allDay );
225 mFreeBusy->setDateTimes( from, to.addDays( 1 ) );
227 mFreeBusy->setDateTimes( from, to );
233 if ( description.isEmpty() && summary.contains(
"\n") ) {
234 mGeneral->setDescription( summary );
235 int pos = summary.find(
"\n" );
236 mGeneral->setSummary( summary.left( pos ) );
238 mGeneral->setSummary( summary );
239 mGeneral->setDescription( description );
243 void KOEventEditor::loadDefaults()
245 TQDateTime from( TQDate::currentDate(), KOPrefs::instance()->mStartTime.time() );
246 int addSecs = ( KOPrefs::instance()->mDefaultDuration.time().hour()*3600 ) +
247 ( KOPrefs::instance()->mDefaultDuration.time().minute()*60 );
248 TQDateTime to( from.addSecs( addSecs ) );
255 kdDebug(5850) <<
"KOEventEditor::processInput(); event is " << mEvent << endl;
258 kdDebug(5850) <<
" mChanger is " << mChanger << endl;
262 TQGuardedPtr<KOEditorFreeBusy> freeBusy( mFreeBusy );
269 kdDebug(5850) <<
"KOEventEditor::processInput() write event." << endl;
271 kdDebug(5850) <<
"KOEventEditor::processInput() event written." << endl;
273 if( *event == *mEvent ) {
275 kdDebug(5850) <<
"Event not changed" << endl;
277 KMessageBox::information(
this, i18n(
"You didn't change the event, thus no counter proposal has been sent to the organizer."), i18n(
"No changes") );
280 kdDebug(5850) <<
"Event changed" << endl;
284 KOGroupware::instance()->sendCounterProposal( mCalendar, oldEvent, mEvent );
288 event->setSummary( i18n(
"My counter proposal for: %1").arg( mEvent->
summary() ) );
289 mChanger->addIncidence( event, mResource, mSubResource,
this );
291 if ( mRecurIncidence && mRecurIncidenceAfterDissoc ) {
292 mChanger->addIncidence( mEvent, mResource, mSubResource,
this );
294 mChanger->changeIncidence( mRecurIncidence, mRecurIncidenceAfterDissoc,
295 KOGlobals::RECURRENCE_MODIFIED_ALL_FUTURE,
this );
298 mChanger->changeIncidence( oldEvent, mEvent, KOGlobals::NOTHING_MODIFIED,
this );
308 KOPrefs::instance()->email() ) );
311 if ( !mChanger->addIncidence( mEvent, mResource, mSubResource,
this ) ) {
319 freeBusy->cancelReload();
325 void KOEventEditor::processCancel()
327 kdDebug(5850) <<
"KOEventEditor::processCancel()" << endl;
329 if ( mFreeBusy ) mFreeBusy->cancelReload();
331 if ( mRecurIncidence && mRecurIncidenceAfterDissoc ) {
332 *mRecurIncidenceAfterDissoc = *mRecurIncidence;
337 void KOEventEditor::deleteEvent()
339 kdDebug(5850) <<
"Delete event" << endl;
342 emit deleteIncidenceSignal( mEvent );
343 emit dialogClose( mEvent );
349 mGeneral->readEvent( event, calendar, date, tmpl );
350 mRecurrence->readIncidence( event );
353 mFreeBusy->readEvent( event );
354 mFreeBusy->triggerReload();
357 createEmbeddedURLPages( event );
358 readDesignerFields( event );
361 mGeneral->invitationBar()->hide();
366 mGeneral->writeEvent( event );
368 mFreeBusy->writeEvent( event );
370 cancelRemovedAttendees( event );
372 mRecurrence->writeIncidence( event );
374 writeDesignerFields( event );
379 if ( !mGeneral->validateInput() ||
380 !mDetails->validateInput() ||
381 !mRecurrence->validateInput() ) {
382 kdDebug(5850) <<
"ValidateInput returns false" << endl;
389 int KOEventEditor::msgItemDelete()
391 return KMessageBox::warningContinueCancel(
this,
392 i18n(
"This item will be permanently deleted."),
393 i18n(
"KOrganizer Confirmation"),KGuiItem(i18n(
"Delete"),
"edit-delete"));
398 const Event::List events = cal.
events();
399 if ( events.count() == 0 ) {
400 KMessageBox::error(
this,
401 i18n(
"Template does not contain a valid event.") );
403 kdDebug(5850) <<
"KOEventEditor::slotLoadTemplate(): readTemplate" << endl;
404 readEvent( events.first(), 0, TQDate(),
true );
408 TQStringList& KOEventEditor::templates()
const
410 return KOPrefs::instance()->mEventTemplates;
413 void KOEventEditor::slotSaveTemplate(
const TQString &templateName )
415 kdDebug(5006) <<
"SlotSaveTemplate" << endl;
418 saveAsTemplate( event, templateName );
421 TQObject *KOEventEditor::typeAheadReceiver()
const
423 return mGeneral->typeAheadReceiver();
426 void KOEventEditor::updateRecurrenceSummary()
430 mGeneral->updateRecurrenceSummary( ev );
434 void KOEventEditor::selectInvitationCounterProposal(
bool enable)
436 KOIncidenceEditor::selectInvitationCounterProposal( enable );
438 mGeneral->invitationBar()->hide();
441 #include "koeventeditor.moc"
virtual Event::List events(EventSortField sortField=EventSortUnsorted, SortDirection sortDirection=SortDirectionAscending)
void setOrganizer(const Person &o)
virtual TQDateTime dtStart() const
bool validateInput()
Check if the input is valid.
void modified()
This event has been modified externally.
void setDates(const TQDateTime &from, const TQDateTime &to, bool allDay)
Set widgets to the given date/time values.
void writeEvent(Event *)
Write event settings to event object.
void init()
Initialize editor.
void setTexts(const TQString &summary, const TQString &description=TQString())
Sets the given summary and description.
bool processInput()
Process user input and create or update event.
void readEvent(Event *event, Calendar *calendar, const TQDate &date, bool tmpl=false)
Read event object and setup widgets accordingly.
KOEventEditor(Calendar *calendar, TQWidget *parent)
Construct new event editor.
void newEvent()
Clear event win for new event.
void editIncidence(Incidence *incidence, const TQDate &date, Calendar *calendar)
Edit an existing event.
This is the base class for the calendar component editors.
void addAttachments(const TQStringList &attachments, const TQStringList &mimeTypes=TQStringList(), bool inlineAttachment=false)
Adds attachments to the editor.