27 #include <tqtooltip.h>
31 #include <tqdatetime.h>
33 #include <kiconloader.h>
34 #include <tdelocale.h>
35 #include <tdemessagebox.h>
37 #include <libkcal/calendarlocal.h>
39 #include <libkcal/resourcecalendar.h>
42 #include "koeditorattachments.h"
43 #include "kogroupware.h"
44 #include "kodialogmanager.h"
45 #include "incidencechanger.h"
47 #include "koeditorgeneraltodo.h"
48 #include "koeditordetails.h"
49 #include "koeditorrecurrence.h"
51 #include "kotodoeditor.h"
56 mTodo( 0 ), mCalendar( 0 ), mRelatedTodo( 0 ), mGeneral( 0 ), mRecurrence( 0 )
60 KOTodoEditor::~KOTodoEditor()
62 emit dialogClose( mTodo );
71 connect( mGeneral, TQ_SIGNAL( dateTimeStrChanged(
const TQString & ) ),
72 mRecurrence, TQ_SLOT( setDateTimeStr(
const TQString & ) ) );
73 connect( mGeneral, TQ_SIGNAL( signalDateTimeChanged(
const TQDateTime &,
const TQDateTime & ) ),
74 mRecurrence, TQ_SLOT( setDateTimes(
const TQDateTime &,
const TQDateTime & ) ) );
76 connect( mGeneral, TQ_SIGNAL( openCategoryDialog() ),
77 TQ_SIGNAL( editCategories() ) );
79 connect( mDetails, TQ_SIGNAL(updateAttendeeSummary(
int)),
80 mGeneral, TQ_SLOT(updateAttendeeSummary(
int)) );
82 connect( mGeneral, TQ_SIGNAL(editRecurrence()),
83 mRecurrenceDialog, TQ_SLOT(show()) );
84 connect( mRecurrenceDialog, TQ_SIGNAL(okClicked()),
85 TQ_SLOT(updateRecurrenceSummary()) );
88 void KOTodoEditor::reload()
91 readTodo( mTodo, mCalendar, TQDate() );
95 void KOTodoEditor::setupGeneral()
97 mGeneral =
new KOEditorGeneralTodo(
this);
99 if (KOPrefs::instance()->mCompactDialogs) {
100 TQFrame *topFrame = addPage(i18n(
"General"));
102 TQBoxLayout *topLayout =
new TQVBoxLayout(topFrame);
103 topLayout->setMargin(marginHint());
104 topLayout->setSpacing(spacingHint());
106 mGeneral->initHeader( topFrame, topLayout );
107 mGeneral->initTime(topFrame,topLayout);
108 TQHBoxLayout *priorityLayout =
new TQHBoxLayout( topLayout );
109 mGeneral->initPriority(topFrame,priorityLayout);
110 topLayout->addStretch(1);
112 TQFrame *topFrame2 = addPage(i18n(
"Details"));
114 TQBoxLayout *topLayout2 =
new TQVBoxLayout(topFrame2);
115 topLayout2->setMargin(marginHint());
116 topLayout2->setSpacing(spacingHint());
118 TQHBoxLayout *completionLayout =
new TQHBoxLayout( topLayout2 );
119 mGeneral->initCompletion(topFrame2,completionLayout);
121 mGeneral->initSecrecy( topFrame2, topLayout2 );
122 mGeneral->initDescription(topFrame2,topLayout2);
124 TQFrame *topFrame = addPage(i18n(
"&General"));
126 TQBoxLayout *topLayout =
new TQVBoxLayout(topFrame);
127 topLayout->setSpacing(spacingHint());
129 mGeneral->initHeader( topFrame, topLayout );
130 mGeneral->initTime(topFrame,topLayout);
131 mGeneral->iniStatus(topFrame,topLayout);
132 mGeneral->initDescription(topFrame,topLayout);
133 mGeneral->initAttachments(topFrame,topLayout);
134 connect( mGeneral, TQ_SIGNAL( openURL(
const KURL& ) ),
135 this, TQ_SLOT( openURL(
const KURL& ) ) );
136 connect(
this, TQ_SIGNAL( signalAddAttachments(
const TQStringList&,
const TQStringList&,
bool ) ),
137 mGeneral, TQ_SLOT(
addAttachments(
const TQStringList&,
const TQStringList&,
bool ) ) );
139 mGeneral->finishSetup();
142 void KOTodoEditor::setupRecurrence()
144 mRecurrenceDialog =
new KOEditorRecurrenceDialog(
this );
145 mRecurrenceDialog->hide();
146 mRecurrence = mRecurrenceDialog->editor();
151 kdDebug(5850) << k_funcinfo << endl;
152 Todo *todo =
dynamic_cast<Todo*
>( incidence );
156 mCalendar = calendar;
160 setCaption( i18n(
"Edit To-do") );
165 kdDebug(5850) << k_funcinfo << endl;
169 setCaption( i18n(
"New To-do") );
175 if ( description.isEmpty() && summary.contains(
"\n") ) {
176 mGeneral->setDescription( summary );
177 int pos = summary.find(
"\n" );
178 mGeneral->setSummary( summary.left( pos ) );
180 mGeneral->setSummary( summary );
181 mGeneral->setDescription( description );
185 void KOTodoEditor::loadDefaults()
187 kdDebug(5850) << k_funcinfo << endl;
188 setDates( TQDateTime::currentDateTime().addDays( 7 ),
true, 0 );
189 mGeneral->toggleAlarm( KOPrefs::instance()->defaultTodoReminders() );
203 kdDebug(5850) <<
"KOTodoEditor::processInput() write event." << endl;
205 kdDebug(5850) <<
"KOTodoEditor::processInput() event written." << endl;
207 if ( *mTodo == *todo ) {
209 kdDebug(5850) <<
"Todo not changed\n";
211 kdDebug(5850) <<
"Todo changed\n";
215 KOGlobals::WhatChanged whatChanged;
218 whatChanged = KOGlobals::COMPLETION_MODIFIED;
220 whatChanged = KOGlobals::NOTHING_MODIFIED;
223 mChanger->changeIncidence( oldTodo, mTodo, whatChanged,
this );
232 KOPrefs::instance()->email() ) );
236 if ( !mChanger->addIncidence( mTodo, mResource, mSubResource,
this ) ) {
247 void KOTodoEditor::deleteTodo()
250 emit deleteIncidenceSignal( mTodo );
252 emit dialogClose( mTodo );
258 mRelatedTodo = relatedEvent;
261 if ( mRelatedTodo ) {
262 mGeneral->setCategories( mRelatedTodo->
categories() );
264 if ( !due.isValid() && mRelatedTodo && mRelatedTodo->
hasDueDate() ) {
265 mGeneral->setDefaults( mRelatedTodo->
dtDue(), allDay );
267 mGeneral->setDefaults( due, allDay );
270 mDetails->setDefaults();
272 mRecurrence->setDefaults( mTodo->
dtStart(), due,
false );
274 mRecurrence->setDefaults( TQDateTime::currentDateTime(), due,
false );
285 mGeneral->readTodo( todo, calendar, date );
286 mDetails->readEvent( todo );
287 mRecurrence->readIncidence( todo );
289 createEmbeddedURLPages( todo );
290 readDesignerFields( todo );
297 mRecurrence->writeIncidence( todo );
298 mGeneral->writeTodo( todo );
299 mDetails->writeEvent( todo );
307 writeDesignerFields( todo );
310 if ( mRelatedTodo ) {
314 cancelRemovedAttendees( todo );
319 if ( !mGeneral->validateInput() )
return false;
320 if ( !mRecurrence->validateInput() )
return false;
321 if ( !mDetails->validateInput() )
return false;
325 int KOTodoEditor::msgItemDelete()
327 return KMessageBox::warningContinueCancel(
this,
328 i18n(
"This item will be permanently deleted."),
329 i18n(
"KOrganizer Confirmation"), KStdGuiItem::del() );
341 Todo::List todos = cal.
todos();
342 if ( todos.count() == 0 ) {
343 KMessageBox::error(
this,
344 i18n(
"Template does not contain a valid to-do.") );
346 readTodo( todos.first(), 0, TQDate() );
350 void KOTodoEditor::slotSaveTemplate(
const TQString &templateName )
354 saveAsTemplate( todo, templateName );
357 TQStringList& KOTodoEditor::templates()
const
359 return KOPrefs::instance()->mTodoTemplates;
362 void KOTodoEditor::updateRecurrenceSummary()
366 mGeneral->updateRecurrenceSummary( todo );
370 #include "kotodoeditor.moc"
virtual Todo::List todos(TodoSortField sortField=TodoSortUnsorted, SortDirection sortDirection=SortDirectionAscending)
void setOrganizer(const Person &o)
void setRelatedTo(Incidence *relatedTo)
TQStringList categories() const
Recurrence * recurrence() const
bool hasStartDate() const
void setDtDue(const TQDateTime &dtDue, bool first=false)
TQDateTime dtStart(bool first=false) const
void setDtStart(const TQDateTime &dtStart)
TQDateTime dtDue(bool first=false) const
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.
void readTodo(Todo *todo, Calendar *calendar, const TQDate &date)
Read event object and setup widgets accordingly.
void init()
Initialize editor.
void setTexts(const TQString &summary, const TQString &description=TQString())
Sets the given summary and description.
void setDates(const TQDateTime &due, bool allDay=true, Todo *relatedTodo=0)
Set widgets to default values.
void newTodo()
Edit new todo.
KOTodoEditor(Calendar *calendar, TQWidget *parent)
Constructs a new todo editor.
void writeTodo(Todo *)
Write event settings to event object.
bool processInput()
Process user input and create or update event.
bool validateInput()
Check if the input is valid.
void editIncidence(Incidence *incidence, const TQDate &date, Calendar *calendar)
Edit an existing todo.
void modified()
This todo has been modified externally.