31#include <tqdatetime.h>
33#include <kiconloader.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 )
60KOTodoEditor::~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() ) );
78 connect(
this, TQ_SIGNAL( updateCategoryConfig() ),
79 mGeneral, TQ_SIGNAL( updateCategoryConfig() ) );
81 connect( mDetails, TQ_SIGNAL(updateAttendeeSummary(
int)),
82 mGeneral, TQ_SLOT(updateAttendeeSummary(
int)) );
84 connect( mGeneral, TQ_SIGNAL(editRecurrence()),
85 mRecurrenceDialog, TQ_SLOT(show()) );
86 connect( mRecurrenceDialog, TQ_SIGNAL(okClicked()),
87 TQ_SLOT(updateRecurrenceSummary()) );
90void KOTodoEditor::reload()
93 readTodo( mTodo, mCalendar, TQDate() );
97void KOTodoEditor::setupGeneral()
99 mGeneral =
new KOEditorGeneralTodo(
this);
101 if (KOPrefs::instance()->mCompactDialogs) {
102 TQFrame *topFrame = addPage(i18n(
"General"));
104 TQBoxLayout *topLayout =
new TQVBoxLayout(topFrame);
105 topLayout->setMargin(marginHint());
106 topLayout->setSpacing(spacingHint());
108 mGeneral->initHeader( topFrame, topLayout );
109 mGeneral->initTime(topFrame,topLayout);
110 TQHBoxLayout *priorityLayout =
new TQHBoxLayout( topLayout );
111 mGeneral->initPriority(topFrame,priorityLayout);
112 topLayout->addStretch(1);
114 TQFrame *topFrame2 = addPage(i18n(
"Details"));
116 TQBoxLayout *topLayout2 =
new TQVBoxLayout(topFrame2);
117 topLayout2->setMargin(marginHint());
118 topLayout2->setSpacing(spacingHint());
120 TQHBoxLayout *completionLayout =
new TQHBoxLayout( topLayout2 );
121 mGeneral->initCompletion(topFrame2,completionLayout);
123 mGeneral->initSecrecy( topFrame2, topLayout2 );
124 mGeneral->initDescription(topFrame2,topLayout2);
126 TQFrame *topFrame = addPage(i18n(
"&General"));
128 TQBoxLayout *topLayout =
new TQVBoxLayout(topFrame);
129 topLayout->setSpacing(spacingHint());
131 mGeneral->initHeader( topFrame, topLayout );
132 mGeneral->initTime(topFrame,topLayout);
133 mGeneral->iniStatus(topFrame,topLayout);
134 mGeneral->initDescription(topFrame,topLayout);
135 mGeneral->initAttachments(topFrame,topLayout);
136 connect( mGeneral, TQ_SIGNAL( openURL(
const KURL& ) ),
137 this, TQ_SLOT( openURL(
const KURL& ) ) );
138 connect(
this, TQ_SIGNAL( signalAddAttachments(
const TQStringList&,
const TQStringList&,
bool ) ),
139 mGeneral, TQ_SLOT(
addAttachments(
const TQStringList&,
const TQStringList&,
bool ) ) );
141 mGeneral->finishSetup();
144void KOTodoEditor::setupRecurrence()
146 mRecurrenceDialog =
new KOEditorRecurrenceDialog(
this );
147 mRecurrenceDialog->hide();
148 mRecurrence = mRecurrenceDialog->editor();
153 kdDebug(5850) << k_funcinfo << endl;
154 Todo *todo =
dynamic_cast<Todo*
>( incidence );
158 mCalendar = calendar;
162 setCaption( i18n(
"Edit To-do") );
167 kdDebug(5850) << k_funcinfo << endl;
171 setCaption( i18n(
"New To-do") );
177 if ( description.isEmpty() && summary.contains(
"\n") ) {
178 mGeneral->setDescription( summary );
179 int pos = summary.find(
"\n" );
180 mGeneral->setSummary( summary.left( pos ) );
182 mGeneral->setSummary( summary );
183 mGeneral->setDescription( description );
187void KOTodoEditor::loadDefaults()
189 kdDebug(5850) << k_funcinfo << endl;
190 setDates( TQDateTime::currentDateTime().addDays( 7 ),
true, 0 );
191 mGeneral->toggleAlarm( KOPrefs::instance()->defaultTodoReminders() );
205 kdDebug(5850) <<
"KOTodoEditor::processInput() write event." << endl;
207 kdDebug(5850) <<
"KOTodoEditor::processInput() event written." << endl;
209 if ( *mTodo == *todo ) {
211 kdDebug(5850) <<
"Todo not changed\n";
213 kdDebug(5850) <<
"Todo changed\n";
217 KOGlobals::WhatChanged whatChanged;
220 whatChanged = KOGlobals::COMPLETION_MODIFIED;
222 whatChanged = KOGlobals::NOTHING_MODIFIED;
225 mChanger->changeIncidence( oldTodo, mTodo, whatChanged,
this );
234 KOPrefs::instance()->email() ) );
238 if ( !mChanger->addIncidence( mTodo, mResource, mSubResource,
this ) ) {
249void KOTodoEditor::deleteTodo()
252 emit deleteIncidenceSignal( mTodo );
254 emit dialogClose( mTodo );
260 mRelatedTodo = relatedEvent;
263 if ( mRelatedTodo ) {
264 mGeneral->setCategories( mRelatedTodo->
categories() );
266 if ( !due.isValid() && mRelatedTodo && mRelatedTodo->
hasDueDate() ) {
267 mGeneral->setDefaults( mRelatedTodo->
dtDue(), allDay );
269 mGeneral->setDefaults( due, allDay );
272 mDetails->setDefaults();
274 mRecurrence->setDefaults( mTodo->
dtStart(), due,
false );
276 mRecurrence->setDefaults( TQDateTime::currentDateTime(), due,
false );
287 mGeneral->readTodo( todo, calendar, date );
288 mDetails->readEvent( todo );
289 mRecurrence->readIncidence( todo );
291 createEmbeddedURLPages( todo );
292 readDesignerFields( todo );
299 mRecurrence->writeIncidence( todo );
300 mGeneral->writeTodo( todo );
301 mDetails->writeEvent( todo );
309 writeDesignerFields( todo );
312 if ( mRelatedTodo ) {
316 cancelRemovedAttendees( todo );
321 if ( !mGeneral->validateInput() )
return false;
322 if ( !mRecurrence->validateInput() )
return false;
323 if ( !mDetails->validateInput() )
return false;
327int KOTodoEditor::msgItemDelete()
329 return KMessageBox::warningContinueCancel(
this,
330 i18n(
"This item will be permanently deleted."),
331 i18n(
"KOrganizer Confirmation"), KStdGuiItem::del() );
343 Todo::List todos = cal.
todos();
344 if ( todos.count() == 0 ) {
345 KMessageBox::error(
this,
346 i18n(
"Template does not contain a valid to-do.") );
348 readTodo( todos.first(), 0, TQDate() );
352void KOTodoEditor::slotSaveTemplate(
const TQString &templateName )
356 saveAsTemplate( todo, templateName );
359TQStringList& KOTodoEditor::templates()
const
361 return KOPrefs::instance()->mTodoTemplates;
364void KOTodoEditor::updateRecurrenceSummary()
368 mGeneral->updateRecurrenceSummary( todo );
372#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.