summaryrefslogtreecommitdiffabout
path: root/korganizer/kotodoview.cpp
Unidiff
Diffstat (limited to 'korganizer/kotodoview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kotodoview.cpp49
1 files changed, 34 insertions, 15 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index ccc4b01..0a315cb 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -114,211 +114,222 @@ void KOTodoListView::contentsDragMoveEvent(QDragMoveEvent *e)
114 114
115 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 115 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
116 !QTextDrag::canDecode( e ) ) { 116 !QTextDrag::canDecode( e ) ) {
117 e->ignore(); 117 e->ignore();
118 return; 118 return;
119 } 119 }
120 120
121 e->accept(); 121 e->accept();
122#endif 122#endif
123} 123}
124 124
125void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *) 125void KOTodoListView::contentsDragLeaveEvent(QDragLeaveEvent *)
126{ 126{
127#ifndef KORG_NODND 127#ifndef KORG_NODND
128// kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl; 128// kdDebug() << "KOTodoListView::contentsDragLeaveEvent" << endl;
129 129
130 setCurrentItem(mOldCurrent); 130 setCurrentItem(mOldCurrent);
131 setSelected(mOldCurrent,true); 131 setSelected(mOldCurrent,true);
132#endif 132#endif
133} 133}
134 134
135void KOTodoListView::contentsDropEvent(QDropEvent *e) 135void KOTodoListView::contentsDropEvent(QDropEvent *e)
136{ 136{
137#ifndef KORG_NODND 137#ifndef KORG_NODND
138// kdDebug() << "KOTodoListView::contentsDropEvent" << endl; 138// kdDebug() << "KOTodoListView::contentsDropEvent" << endl;
139 139
140 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && 140 if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) &&
141 !QTextDrag::canDecode( e ) ) { 141 !QTextDrag::canDecode( e ) ) {
142 e->ignore(); 142 e->ignore();
143 return; 143 return;
144 } 144 }
145 145
146 DndFactory factory( mCalendar ); 146 DndFactory factory( mCalendar );
147 Todo *todo = factory.createDropTodo(e); 147 Todo *todo = factory.createDropTodo(e);
148 148
149 if (todo) { 149 if (todo) {
150 e->acceptAction(); 150 e->acceptAction();
151 151
152 KOTodoViewItem *destination = 152 KOTodoViewItem *destination =
153 (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); 153 (KOTodoViewItem *)itemAt(contentsToViewport(e->pos()));
154 Todo *destinationEvent = 0; 154 Todo *destinationEvent = 0;
155 if (destination) destinationEvent = destination->todo(); 155 if (destination) destinationEvent = destination->todo();
156 156
157 Todo *existingTodo = mCalendar->todo(todo->uid()); 157 Todo *existingTodo = mCalendar->todo(todo->uid());
158 158
159 if(existingTodo) { 159 if(existingTodo) {
160 Incidence *to = destinationEvent; 160 Incidence *to = destinationEvent;
161 while(to) { 161 while(to) {
162 if (to->uid() == todo->uid()) { 162 if (to->uid() == todo->uid()) {
163 KMessageBox::sorry(this, 163 KMessageBox::sorry(this,
164 i18n("Cannot move To-Do to itself\nor a child of itself"), 164 i18n("Cannot move To-Do to itself\nor a child of itself"),
165 i18n("Drop To-Do")); 165 i18n("Drop To-Do"));
166 delete todo; 166 delete todo;
167 return; 167 return;
168 } 168 }
169 to = to->relatedTo(); 169 to = to->relatedTo();
170 } 170 }
171 internalDrop = true; 171 internalDrop = true;
172 if ( destinationEvent ) 172 if ( destinationEvent )
173 reparentTodoSignal( destinationEvent, existingTodo ); 173 reparentTodoSignal( destinationEvent, existingTodo );
174 else 174 else
175 unparentTodoSignal(existingTodo); 175 unparentTodoSignal(existingTodo);
176 delete todo; 176 delete todo;
177 } else { 177 } else {
178 mCalendar->addTodo(todo); 178 mCalendar->addTodo(todo);
179 emit todoDropped(todo, KOGlobals::EVENTADDED); 179 emit todoDropped(todo, KOGlobals::EVENTADDED);
180 if ( destinationEvent ) 180 if ( destinationEvent )
181 reparentTodoSignal( destinationEvent, todo ); 181 reparentTodoSignal( destinationEvent, todo );
182 } 182 }
183 } 183 }
184 else { 184 else {
185 QString text; 185 QString text;
186 if (QTextDrag::decode(e,text)) { 186 if (QTextDrag::decode(e,text)) {
187 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); 187 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) );
188 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); 188 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) ));
189 qDebug("Dropped : " + text); 189 qDebug("Dropped : " + text);
190 QStringList emails = QStringList::split(",",text); 190 QStringList emails = QStringList::split(",",text);
191 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { 191 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
192 int pos = (*it).find("<"); 192 int pos = (*it).find("<");
193 QString name = (*it).left(pos); 193 QString name = (*it).left(pos);
194 QString email = (*it).mid(pos); 194 QString email = (*it).mid(pos);
195 if (!email.isEmpty() && todoi) { 195 if (!email.isEmpty() && todoi) {
196 todoi->todo()->addAttendee(new Attendee(name,email)); 196 todoi->todo()->addAttendee(new Attendee(name,email));
197 } 197 }
198 } 198 }
199 } 199 }
200 else { 200 else {
201 qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); 201 qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable ");
202 e->ignore(); 202 e->ignore();
203 } 203 }
204 } 204 }
205#endif 205#endif
206} 206}
207 207
208void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) 208void KOTodoListView::contentsMousePressEvent(QMouseEvent* e)
209{ 209{
210
211 QPoint p(contentsToViewport(e->pos()));
212 QListViewItem *i = itemAt(p);
213 bool rootClicked = true;
214 if (i) {
215 // if the user clicked into the root decoration of the item, don't
216 // try to start a drag!
217 int X = p.x();
218 //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() );
219 if (X > header()->sectionPos(0) +
220 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) +
221 itemMargin() ||
222 X < header()->sectionPos(0)) {
223 rootClicked = false;
224 }
225 }
210#ifndef KORG_NODND 226#ifndef KORG_NODND
211 QPoint p(contentsToViewport(e->pos())); 227 mMousePressed = false;
212 QListViewItem *i = itemAt(p); 228 if (! rootClicked ) {
213 mMousePressed = false;
214 if (i) {
215 // if the user clicked into the root decoration of the item, don't
216 // try to start a drag!
217 if (p.x() > header()->sectionPos(header()->mapToIndex(0)) +
218 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) +
219 itemMargin() ||
220 p.x() < header()->sectionPos(header()->mapToIndex(0))) {
221 if (e->button()==Qt::LeftButton) {
222 mPressPos = e->pos(); 229 mPressPos = e->pos();
223 mMousePressed = true; 230 mMousePressed = true;
224 }
225 } 231 }
226 }
227#endif 232#endif
228 QListView::contentsMousePressEvent(e); 233 //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked);
234#ifndef DESKTOP_VERSION
235 if (!( e->button() == RightButton && rootClicked) )
236 QListView::contentsMousePressEvent(e);
237#else
238 QListView::contentsMousePressEvent(e);
239#endif
229} 240}
230void KOTodoListView::paintEvent(QPaintEvent* e) 241void KOTodoListView::paintEvent(QPaintEvent* e)
231{ 242{
232 emit paintNeeded(); 243 emit paintNeeded();
233 QListView::paintEvent( e); 244 QListView::paintEvent( e);
234} 245}
235void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) 246void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e)
236{ 247{
237 248
238#ifndef KORG_NODND 249#ifndef KORG_NODND
239 //QListView::contentsMouseMoveEvent(e); 250 //QListView::contentsMouseMoveEvent(e);
240 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > 251 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() >
241 QApplication::startDragDistance()*3) { 252 QApplication::startDragDistance()*3) {
242 mMousePressed = false; 253 mMousePressed = false;
243 QListViewItem *item = itemAt(contentsToViewport(mPressPos)); 254 QListViewItem *item = itemAt(contentsToViewport(mPressPos));
244 if (item) { 255 if (item) {
245 DndFactory factory( mCalendar ); 256 DndFactory factory( mCalendar );
246 ICalDrag *vd = factory.createDrag( 257 ICalDrag *vd = factory.createDrag(
247 ((KOTodoViewItem *)item)->todo(),viewport()); 258 ((KOTodoViewItem *)item)->todo(),viewport());
248 internalDrop = false; 259 internalDrop = false;
249 // we cannot do any senseful here, because the DnD is still broken in Qt 260 // we cannot do any senseful here, because the DnD is still broken in Qt
250 if (vd->drag()) { 261 if (vd->drag()) {
251 if ( !internalDrop ) { 262 if ( !internalDrop ) {
252 //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); 263 //emit deleteTodo( ((KOTodoViewItem *)item)->todo() );
253 qDebug("Dnd: External move: Delete drag source "); 264 qDebug("Dnd: External move: Delete drag source ");
254 } else 265 } else
255 qDebug("Dnd: Internal move "); 266 qDebug("Dnd: Internal move ");
256 267
257 } else { 268 } else {
258 if ( !internalDrop ) { 269 if ( !internalDrop ) {
259 qDebug("Dnd: External Copy"); 270 qDebug("Dnd: External Copy");
260 } else 271 } else
261 qDebug("DnD: Internal copy: Copy pending"); 272 qDebug("DnD: Internal copy: Copy pending");
262 } 273 }
263 } 274 }
264 } 275 }
265#endif 276#endif
266} 277}
267void KOTodoListView::keyReleaseEvent ( QKeyEvent *e ) 278void KOTodoListView::keyReleaseEvent ( QKeyEvent *e )
268{ 279{
269 if ( !e->isAutoRepeat() ) { 280 if ( !e->isAutoRepeat() ) {
270 mFlagKeyPressed = false; 281 mFlagKeyPressed = false;
271 } 282 }
272} 283}
273 284
274 285
275void KOTodoListView::keyPressEvent ( QKeyEvent * e ) 286void KOTodoListView::keyPressEvent ( QKeyEvent * e )
276{ 287{
277 qApp->processEvents(); 288 qApp->processEvents();
278 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 289 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
279 e->ignore(); 290 e->ignore();
280 // qDebug(" ignore %d",e->isAutoRepeat() ); 291 // qDebug(" ignore %d",e->isAutoRepeat() );
281 return; 292 return;
282 } 293 }
283 if (! e->isAutoRepeat() ) 294 if (! e->isAutoRepeat() )
284 mFlagKeyPressed = true; 295 mFlagKeyPressed = true;
285 QListViewItem* cn; 296 QListViewItem* cn;
286 if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { 297 if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) {
287 cn = currentItem(); 298 cn = currentItem();
288 if ( cn ) { 299 if ( cn ) {
289 KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); 300 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
290 if ( ci ){ 301 if ( ci ){
291 if ( e->state() == ShiftButton ) 302 if ( e->state() == ShiftButton )
292 ci->setOn( false ); 303 ci->setOn( false );
293 else 304 else
294 ci->setOn( true ); 305 ci->setOn( true );
295 cn = cn->itemBelow(); 306 cn = cn->itemBelow();
296 if ( cn ) { 307 if ( cn ) {
297 setCurrentItem ( cn ); 308 setCurrentItem ( cn );
298 ensureItemVisible ( cn ); 309 ensureItemVisible ( cn );
299 } 310 }
300 311
301 } 312 }
302 } 313 }
303 314
304 return; 315 return;
305 } 316 }
306 317
307 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { 318 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) {
308 switch ( e->key() ) { 319 switch ( e->key() ) {
309 case Qt::Key_Down: 320 case Qt::Key_Down:
310 case Qt::Key_Up: 321 case Qt::Key_Up:
311 QListView::keyPressEvent ( e ); 322 QListView::keyPressEvent ( e );
312 break; 323 break;
313 case Qt::Key_Left: 324 case Qt::Key_Left:
314 case Qt::Key_Right: 325 case Qt::Key_Right:
315 QListView::keyPressEvent ( e ); 326 QListView::keyPressEvent ( e );
316 e->accept(); 327 e->accept();
317 return; 328 return;
318 break; 329 break;
319 default: 330 default:
320 e->ignore(); 331 e->ignore();
321 break; 332 break;
322 } 333 }
323 return; 334 return;
324 } 335 }
@@ -970,204 +981,212 @@ void KOTodoView::beamTodo()
970void KOTodoView::showTodo() 981void KOTodoView::showTodo()
971{ 982{
972 if (mActiveItem) { 983 if (mActiveItem) {
973 emit showTodoSignal(mActiveItem->todo()); 984 emit showTodoSignal(mActiveItem->todo());
974 } 985 }
975} 986}
976 987
977void KOTodoView::deleteTodo() 988void KOTodoView::deleteTodo()
978{ 989{
979 if (mActiveItem) { 990 if (mActiveItem) {
980 emit deleteTodoSignal(mActiveItem->todo()); 991 emit deleteTodoSignal(mActiveItem->todo());
981 } 992 }
982} 993}
983 994
984void KOTodoView::setNewPriority(int index) 995void KOTodoView::setNewPriority(int index)
985{ 996{
986 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 997 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
987 mActiveItem->todo()->setPriority(mPriority[index]); 998 mActiveItem->todo()->setPriority(mPriority[index]);
988 mActiveItem->construct(); 999 mActiveItem->construct();
989 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); 1000 todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED);
990 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1001 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
991 } 1002 }
992} 1003}
993 1004
994void KOTodoView::setNewPercentage(int index) 1005void KOTodoView::setNewPercentage(int index)
995{ 1006{
996 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 1007 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
997 1008
998 if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { 1009 if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) {
999 mActiveItem->setOn( true ); 1010 mActiveItem->setOn( true );
1000 return; 1011 return;
1001 } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { 1012 } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) {
1002 KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); 1013 KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent()));
1003 if ( par && par->isOn() ) 1014 if ( par && par->isOn() )
1004 par->setOn( false ); 1015 par->setOn( false );
1005 } 1016 }
1006 if (mPercentage[index] == 100) { 1017 if (mPercentage[index] == 100) {
1007 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); 1018 mActiveItem->todo()->setCompleted(QDateTime::currentDateTime());
1008 } else { 1019 } else {
1009 mActiveItem->todo()->setCompleted(false); 1020 mActiveItem->todo()->setCompleted(false);
1010 } 1021 }
1011 mActiveItem->todo()->setPercentComplete(mPercentage[index]); 1022 mActiveItem->todo()->setPercentComplete(mPercentage[index]);
1012 mActiveItem->construct(); 1023 mActiveItem->construct();
1013 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); 1024 todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED);
1014 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1025 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1015 } 1026 }
1016} 1027}
1017 1028
1018 1029
1019QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) 1030QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem)
1020{ 1031{
1021 QPopupMenu* tempMenu = new QPopupMenu (this); 1032 QPopupMenu* tempMenu = new QPopupMenu (this);
1022 QStringList checkedCategories = todoItem->todo()->categories (); 1033 QStringList checkedCategories = todoItem->todo()->categories ();
1023 1034
1024 tempMenu->setCheckable (true); 1035 tempMenu->setCheckable (true);
1025 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); 1036 for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin ();
1026 it != KOPrefs::instance()->mCustomCategories.end (); 1037 it != KOPrefs::instance()->mCustomCategories.end ();
1027 ++it) { 1038 ++it) {
1028 int index = tempMenu->insertItem (*it); 1039 int index = tempMenu->insertItem (*it);
1029 mCategory[index] = *it; 1040 mCategory[index] = *it;
1030 if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); 1041 if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true);
1031 } 1042 }
1032 1043
1033 connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); 1044 connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int)));
1034 return tempMenu; 1045 return tempMenu;
1035 1046
1036 1047
1037} 1048}
1038void KOTodoView::changedCategories(int index) 1049void KOTodoView::changedCategories(int index)
1039{ 1050{
1040 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { 1051 if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) {
1041 QStringList categories = mActiveItem->todo()->categories (); 1052 QStringList categories = mActiveItem->todo()->categories ();
1042 QString colcat = categories.first(); 1053 QString colcat = categories.first();
1043 if (categories.find (mCategory[index]) != categories.end ()) 1054 if (categories.find (mCategory[index]) != categories.end ())
1044 categories.remove (mCategory[index]); 1055 categories.remove (mCategory[index]);
1045 else 1056 else
1046 categories.insert (categories.end(), mCategory[index]); 1057 categories.insert (categories.end(), mCategory[index]);
1047 categories.sort (); 1058 categories.sort ();
1048 if ( !colcat.isEmpty() ) { 1059 if ( !colcat.isEmpty() ) {
1049 if ( categories.find ( colcat ) != categories.end () ) { 1060 if ( categories.find ( colcat ) != categories.end () ) {
1050 categories.remove( colcat ); 1061 categories.remove( colcat );
1051 categories.prepend( colcat ); 1062 categories.prepend( colcat );
1052 } 1063 }
1053 } 1064 }
1054 mActiveItem->todo()->setCategories (categories); 1065 mActiveItem->todo()->setCategories (categories);
1055 mActiveItem->construct(); 1066 mActiveItem->construct();
1056 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); 1067 mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 );
1057 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); 1068 todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED);
1058 } 1069 }
1059} 1070}
1060void KOTodoView::itemDoubleClicked(QListViewItem *item) 1071void KOTodoView::itemDoubleClicked(QListViewItem *item)
1061{ 1072{
1062 if ( pendingSubtodo != 0 ) { 1073 if ( pendingSubtodo != 0 ) {
1063 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 1074 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
1064 } 1075 }
1065 pendingSubtodo = 0; 1076 pendingSubtodo = 0;
1077 int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() );
1078 //qDebug("ROW %d ", row);
1066 if (!item) { 1079 if (!item) {
1067 newTodo(); 1080 newTodo();
1068 return; 1081 return;
1082 } else {
1083 if ( row == 1 ) {
1084 mActiveItem = (KOTodoViewItem *) item;
1085 newSubTodo();
1086 return;
1087 }
1069 } 1088 }
1070 if ( KOPrefs::instance()->mEditOnDoubleClick ) 1089 if ( KOPrefs::instance()->mEditOnDoubleClick )
1071 editItem( item ); 1090 editItem( item );
1072 else 1091 else
1073 showItem( item , QPoint(), 0 ); 1092 showItem( item , QPoint(), 0 );
1074} 1093}
1075void KOTodoView::itemClicked(QListViewItem *item) 1094void KOTodoView::itemClicked(QListViewItem *item)
1076{ 1095{
1077 1096 //qDebug("KOTodoView::itemClicked %d", item);
1078 if (!item) { 1097 if (!item) {
1079 if ( pendingSubtodo != 0 ) { 1098 if ( pendingSubtodo != 0 ) {
1080 topLevelWidget()->setCaption(i18n("Reparenting aborted!")); 1099 topLevelWidget()->setCaption(i18n("Reparenting aborted!"));
1081 } 1100 }
1082 pendingSubtodo = 0; 1101 pendingSubtodo = 0;
1083 return; 1102 return;
1084 } 1103 }
1085 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 1104 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
1086 if ( pendingSubtodo != 0 ) { 1105 if ( pendingSubtodo != 0 ) {
1087 bool allowReparent = true; 1106 bool allowReparent = true;
1088 QListViewItem *par = item; 1107 QListViewItem *par = item;
1089 while ( par ) { 1108 while ( par ) {
1090 if ( par == pendingSubtodo ) { 1109 if ( par == pendingSubtodo ) {
1091 allowReparent = false; 1110 allowReparent = false;
1092 break; 1111 break;
1093 } 1112 }
1094 par = par->parent(); 1113 par = par->parent();
1095 } 1114 }
1096 if ( !allowReparent ) { 1115 if ( !allowReparent ) {
1097 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); 1116 topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!"));
1098 qDebug("Recursive reparenting not possible "); 1117 qDebug("Recursive reparenting not possible ");
1099 pendingSubtodo = 0; 1118 pendingSubtodo = 0;
1100 } else { 1119 } else {
1101 Todo* newParent = todoItem->todo(); 1120 Todo* newParent = todoItem->todo();
1102 Todo* newSub = pendingSubtodo->todo(); 1121 Todo* newSub = pendingSubtodo->todo();
1103 pendingSubtodo = 0; 1122 pendingSubtodo = 0;
1104 emit reparentTodoSignal( newParent,newSub ); 1123 emit reparentTodoSignal( newParent,newSub );
1105 return; 1124 return;
1106 } 1125 }
1107 } 1126 }
1108#if 0 1127#if 0
1109 // handled by the item itself 1128 // handled by the item itself
1110 bool completed = todoItem->todo()->isCompleted(); // Completed or not? 1129 bool completed = todoItem->todo()->isCompleted(); // Completed or not?
1111 qDebug("com %d ",completed ); 1130 qDebug("com %d ",completed );
1112 qDebug("itemclicked "); 1131 qDebug("itemclicked ");
1113 if (todoItem->isOn()) { 1132 if (todoItem->isOn()) {
1114 qDebug("on "); 1133 qDebug("on ");
1115 if (!completed) { 1134 if (!completed) {
1116 qDebug("set true "); 1135 qDebug("set true ");
1117 todoItem->todo()->setCompleted(QDateTime::currentDateTime()); 1136 todoItem->todo()->setCompleted(QDateTime::currentDateTime());
1118 } 1137 }
1119 } else { 1138 } else {
1120 qDebug("not on "); 1139 qDebug("not on ");
1121 if (completed) { 1140 if (completed) {
1122 qDebug("set false "); 1141 qDebug("set false ");
1123 todoItem->todo()->setCompleted(false); 1142 todoItem->todo()->setCompleted(false);
1124 } 1143 }
1125 } 1144 }
1126#endif 1145#endif
1127} 1146}
1128 1147
1129void KOTodoView::setDocumentId( const QString &id ) 1148void KOTodoView::setDocumentId( const QString &id )
1130{ 1149{
1131 kdDebug() << "KOTodoView::setDocumentId()" << endl; 1150 kdDebug() << "KOTodoView::setDocumentId()" << endl;
1132 1151
1133 mDocPrefs->setDoc( id ); 1152 mDocPrefs->setDoc( id );
1134} 1153}
1135 1154
1136void KOTodoView::itemStateChanged( QListViewItem *item ) 1155void KOTodoView::itemStateChanged( QListViewItem *item )
1137{ 1156{
1138 if (!item) return; 1157 if (!item) return;
1139 1158
1140 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 1159 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
1141 1160
1142// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; 1161// kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl;
1143 1162
1144 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); 1163 if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() );
1145} 1164}
1146 1165
1147void KOTodoView::saveLayout(KConfig *config, const QString &group) const 1166void KOTodoView::saveLayout(KConfig *config, const QString &group) const
1148{ 1167{
1149 mTodoListView->saveLayout(config,group); 1168 mTodoListView->saveLayout(config,group);
1150} 1169}
1151 1170
1152void KOTodoView::restoreLayout(KConfig *config, const QString &group) 1171void KOTodoView::restoreLayout(KConfig *config, const QString &group)
1153{ 1172{
1154 mTodoListView->restoreLayout(config,group); 1173 mTodoListView->restoreLayout(config,group);
1155} 1174}
1156 1175
1157void KOTodoView::processSelectionChange() 1176void KOTodoView::processSelectionChange()
1158{ 1177{
1159// kdDebug() << "KOTodoView::processSelectionChange()" << endl; 1178// kdDebug() << "KOTodoView::processSelectionChange()" << endl;
1160 1179
1161 KOTodoViewItem *item = 1180 KOTodoViewItem *item =
1162 static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); 1181 static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() );
1163 1182
1164 if ( !item ) { 1183 if ( !item ) {
1165 emit incidenceSelected( 0 ); 1184 emit incidenceSelected( 0 );
1166 } else { 1185 } else {
1167 emit incidenceSelected( item->todo() ); 1186 emit incidenceSelected( item->todo() );
1168 } 1187 }
1169} 1188}
1170 1189
1171void KOTodoView::modified(bool b) 1190void KOTodoView::modified(bool b)
1172{ 1191{
1173 emit isModified(b); 1192 emit isModified(b);