author | zautrix <zautrix> | 2004-10-16 13:36:11 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-16 13:36:11 (UTC) |
commit | c3325ebbb92a2814fcb622caaf71316cfa0c2908 (patch) (unidiff) | |
tree | b53545c39f84fc6ce694f371509b4a9fe2ddd743 /korganizer/kotodoview.cpp | |
parent | 023b3c542a6dd4d1c4b53dba6bb2c68f605a7917 (diff) | |
download | kdepimpi-c3325ebbb92a2814fcb622caaf71316cfa0c2908.zip kdepimpi-c3325ebbb92a2814fcb622caaf71316cfa0c2908.tar.gz kdepimpi-c3325ebbb92a2814fcb622caaf71316cfa0c2908.tar.bz2 |
made todos reparentable
-rw-r--r-- | korganizer/kotodoview.cpp | 88 |
1 files changed, 84 insertions, 4 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index ca5eadd..a8143a0 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -118,423 +118,433 @@ void KOTodoListView::contentsDropEvent(QDropEvent *e) | |||
118 | { | 118 | { |
119 | #ifndef KORG_NODND | 119 | #ifndef KORG_NODND |
120 | // kdDebug() << "KOTodoListView::contentsDropEvent" << endl; | 120 | // kdDebug() << "KOTodoListView::contentsDropEvent" << endl; |
121 | 121 | ||
122 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && | 122 | if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) && |
123 | !QTextDrag::canDecode( e ) ) { | 123 | !QTextDrag::canDecode( e ) ) { |
124 | e->ignore(); | 124 | e->ignore(); |
125 | return; | 125 | return; |
126 | } | 126 | } |
127 | 127 | ||
128 | DndFactory factory( mCalendar ); | 128 | DndFactory factory( mCalendar ); |
129 | Todo *todo = factory.createDropTodo(e); | 129 | Todo *todo = factory.createDropTodo(e); |
130 | 130 | ||
131 | if (todo) { | 131 | if (todo) { |
132 | e->acceptAction(); | 132 | e->acceptAction(); |
133 | 133 | ||
134 | KOTodoViewItem *destination = | 134 | KOTodoViewItem *destination = |
135 | (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); | 135 | (KOTodoViewItem *)itemAt(contentsToViewport(e->pos())); |
136 | Todo *destinationEvent = 0; | 136 | Todo *destinationEvent = 0; |
137 | if (destination) destinationEvent = destination->todo(); | 137 | if (destination) destinationEvent = destination->todo(); |
138 | 138 | ||
139 | Todo *existingTodo = mCalendar->todo(todo->uid()); | 139 | Todo *existingTodo = mCalendar->todo(todo->uid()); |
140 | 140 | ||
141 | if(existingTodo) { | 141 | if(existingTodo) { |
142 | // kdDebug() << "Drop existing Todo" << endl; | 142 | // kdDebug() << "Drop existing Todo" << endl; |
143 | Incidence *to = destinationEvent; | 143 | Incidence *to = destinationEvent; |
144 | while(to) { | 144 | while(to) { |
145 | if (to->uid() == todo->uid()) { | 145 | if (to->uid() == todo->uid()) { |
146 | KMessageBox::sorry(this, | 146 | KMessageBox::sorry(this, |
147 | i18n("Cannot move To-Do to itself or a child of itself"), | 147 | i18n("Cannot move To-Do to itself or a child of itself"), |
148 | i18n("Drop To-Do")); | 148 | i18n("Drop To-Do")); |
149 | delete todo; | 149 | delete todo; |
150 | return; | 150 | return; |
151 | } | 151 | } |
152 | to = to->relatedTo(); | 152 | to = to->relatedTo(); |
153 | } | 153 | } |
154 | existingTodo->setRelatedTo(destinationEvent); | 154 | existingTodo->setRelatedTo(destinationEvent); |
155 | emit todoDropped(todo); | 155 | emit todoDropped(todo); |
156 | delete todo; | 156 | delete todo; |
157 | } else { | 157 | } else { |
158 | // kdDebug() << "Drop new Todo" << endl; | 158 | // kdDebug() << "Drop new Todo" << endl; |
159 | todo->setRelatedTo(destinationEvent); | 159 | todo->setRelatedTo(destinationEvent); |
160 | mCalendar->addTodo(todo); | 160 | mCalendar->addTodo(todo); |
161 | 161 | ||
162 | emit todoDropped(todo); | 162 | emit todoDropped(todo); |
163 | } | 163 | } |
164 | } | 164 | } |
165 | else { | 165 | else { |
166 | QString text; | 166 | QString text; |
167 | if (QTextDrag::decode(e,text)) { | 167 | if (QTextDrag::decode(e,text)) { |
168 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); | 168 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); |
169 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); | 169 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); |
170 | kdDebug() << "Dropped : " << text << endl; | 170 | kdDebug() << "Dropped : " << text << endl; |
171 | QStringList emails = QStringList::split(",",text); | 171 | QStringList emails = QStringList::split(",",text); |
172 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { | 172 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { |
173 | kdDebug() << " Email: " << (*it) << endl; | 173 | kdDebug() << " Email: " << (*it) << endl; |
174 | int pos = (*it).find("<"); | 174 | int pos = (*it).find("<"); |
175 | QString name = (*it).left(pos); | 175 | QString name = (*it).left(pos); |
176 | QString email = (*it).mid(pos); | 176 | QString email = (*it).mid(pos); |
177 | if (!email.isEmpty() && todoi) { | 177 | if (!email.isEmpty() && todoi) { |
178 | todoi->todo()->addAttendee(new Attendee(name,email)); | 178 | todoi->todo()->addAttendee(new Attendee(name,email)); |
179 | } | 179 | } |
180 | } | 180 | } |
181 | } | 181 | } |
182 | else { | 182 | else { |
183 | kdDebug() << "KOTodoListView::contentsDropEvent(): Todo from drop not decodable" << endl; | 183 | kdDebug() << "KOTodoListView::contentsDropEvent(): Todo from drop not decodable" << endl; |
184 | e->ignore(); | 184 | e->ignore(); |
185 | } | 185 | } |
186 | } | 186 | } |
187 | #endif | 187 | #endif |
188 | } | 188 | } |
189 | 189 | ||
190 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) | 190 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) |
191 | { | 191 | { |
192 | QListView::contentsMousePressEvent(e); | 192 | QListView::contentsMousePressEvent(e); |
193 | #ifndef KORG_NODND | 193 | #ifndef KORG_NODND |
194 | QPoint p(contentsToViewport(e->pos())); | 194 | QPoint p(contentsToViewport(e->pos())); |
195 | QListViewItem *i = itemAt(p); | 195 | QListViewItem *i = itemAt(p); |
196 | if (i) { | 196 | if (i) { |
197 | // if the user clicked into the root decoration of the item, don't | 197 | // if the user clicked into the root decoration of the item, don't |
198 | // try to start a drag! | 198 | // try to start a drag! |
199 | if (p.x() > header()->sectionPos(header()->mapToIndex(0)) + | 199 | if (p.x() > header()->sectionPos(header()->mapToIndex(0)) + |
200 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + | 200 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + |
201 | itemMargin() || | 201 | itemMargin() || |
202 | p.x() < header()->sectionPos(header()->mapToIndex(0))) { | 202 | p.x() < header()->sectionPos(header()->mapToIndex(0))) { |
203 | if (e->button()==Qt::LeftButton) { | 203 | if (e->button()==Qt::LeftButton) { |
204 | mPressPos = e->pos(); | 204 | mPressPos = e->pos(); |
205 | mMousePressed = true; | 205 | mMousePressed = true; |
206 | } | 206 | } |
207 | } | 207 | } |
208 | } | 208 | } |
209 | #endif | 209 | #endif |
210 | } | 210 | } |
211 | 211 | ||
212 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) | 212 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) |
213 | { | 213 | { |
214 | |||
214 | #ifndef KORG_NODND | 215 | #ifndef KORG_NODND |
215 | // kdDebug() << "KOTodoListView::contentsMouseMoveEvent()" << endl; | 216 | // kdDebug() << "KOTodoListView::contentsMouseMoveEvent()" << endl; |
216 | QListView::contentsMouseMoveEvent(e); | 217 | QListView::contentsMouseMoveEvent(e); |
217 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > | 218 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > |
218 | QApplication::startDragDistance()) { | 219 | QApplication::startDragDistance()) { |
219 | mMousePressed = false; | 220 | mMousePressed = false; |
220 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); | 221 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); |
221 | if (item) { | 222 | if (item) { |
222 | // kdDebug() << "Start Drag for item " << item->text(0) << endl; | 223 | // kdDebug() << "Start Drag for item " << item->text(0) << endl; |
223 | DndFactory factory( mCalendar ); | 224 | DndFactory factory( mCalendar ); |
224 | ICalDrag *vd = factory.createDragTodo( | 225 | ICalDrag *vd = factory.createDragTodo( |
225 | ((KOTodoViewItem *)item)->todo(),viewport()); | 226 | ((KOTodoViewItem *)item)->todo(),viewport()); |
226 | if (vd->drag()) { | 227 | if (vd->drag()) { |
227 | kdDebug() << "KOTodoListView::contentsMouseMoveEvent(): Delete drag source" << endl; | 228 | kdDebug() << "KOTodoListView::contentsMouseMoveEvent(): Delete drag source" << endl; |
228 | } | 229 | } |
229 | /* | 230 | /* |
230 | QString source = fullPath(item); | 231 | QString source = fullPath(item); |
231 | if ( QFile::exists(source) ) { | 232 | if ( QFile::exists(source) ) { |
232 | QUriDrag* ud = new QUriDrag(viewport()); | 233 | QUriDrag* ud = new QUriDrag(viewport()); |
233 | ud->setFilenames( source ); | 234 | ud->setFilenames( source ); |
234 | if ( ud->drag() ) | 235 | if ( ud->drag() ) |
235 | QMessageBox::information( this, "Drag source", | 236 | QMessageBox::information( this, "Drag source", |
236 | QString("Delete ")+source, "Not implemented" ); | 237 | QString("Delete ")+source, "Not implemented" ); |
237 | */ | 238 | */ |
238 | } | 239 | } |
239 | } | 240 | } |
240 | #endif | 241 | #endif |
241 | } | 242 | } |
242 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) | 243 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) |
243 | { | 244 | { |
244 | 245 | ||
245 | QListViewItem* cn; | 246 | QListViewItem* cn; |
246 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { | 247 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { |
247 | cn = currentItem(); | 248 | cn = currentItem(); |
248 | if ( cn ) { | 249 | if ( cn ) { |
249 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 250 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
250 | if ( ci ){ | 251 | if ( ci ){ |
251 | if ( e->state() == ShiftButton ) | 252 | if ( e->state() == ShiftButton ) |
252 | ci->setOn( false ); | 253 | ci->setOn( false ); |
253 | else | 254 | else |
254 | ci->setOn( true ); | 255 | ci->setOn( true ); |
255 | cn = cn->nextSibling(); | 256 | cn = cn->nextSibling(); |
256 | if ( cn ) { | 257 | if ( cn ) { |
257 | setCurrentItem ( cn ); | 258 | setCurrentItem ( cn ); |
258 | ensureItemVisible ( cn ); | 259 | ensureItemVisible ( cn ); |
259 | } | 260 | } |
260 | 261 | ||
261 | } | 262 | } |
262 | } | 263 | } |
263 | 264 | ||
264 | return; | 265 | return; |
265 | } | 266 | } |
266 | 267 | ||
267 | // qDebug("KOTodoListView::keyPressEvent "); | 268 | // qDebug("KOTodoListView::keyPressEvent "); |
268 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { | 269 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { |
269 | switch ( e->key() ) { | 270 | switch ( e->key() ) { |
270 | case Qt::Key_Down: | 271 | case Qt::Key_Down: |
271 | case Qt::Key_Up: | 272 | case Qt::Key_Up: |
272 | QListView::keyPressEvent ( e ); | 273 | QListView::keyPressEvent ( e ); |
273 | break; | 274 | break; |
274 | case Qt::Key_Left: | 275 | case Qt::Key_Left: |
275 | case Qt::Key_Right: | 276 | case Qt::Key_Right: |
276 | QListView::keyPressEvent ( e ); | 277 | QListView::keyPressEvent ( e ); |
278 | e->accept(); | ||
279 | return; | ||
277 | break; | 280 | break; |
278 | default: | 281 | default: |
279 | e->ignore(); | 282 | e->ignore(); |
280 | break; | 283 | break; |
281 | } | 284 | } |
282 | return; | 285 | return; |
283 | } | 286 | } |
284 | e->ignore(); | 287 | e->ignore(); |
285 | } | 288 | } |
286 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) | 289 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) |
287 | { | 290 | { |
288 | QListView::contentsMouseReleaseEvent(e); | 291 | QListView::contentsMouseReleaseEvent(e); |
289 | mMousePressed = false; | 292 | mMousePressed = false; |
290 | } | 293 | } |
291 | 294 | ||
292 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 295 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) |
293 | { | 296 | { |
294 | if (!e) return; | 297 | if (!e) return; |
295 | 298 | ||
296 | QPoint vp = contentsToViewport(e->pos()); | 299 | QPoint vp = contentsToViewport(e->pos()); |
297 | 300 | ||
298 | QListViewItem *item = itemAt(vp); | 301 | QListViewItem *item = itemAt(vp); |
299 | 302 | ||
300 | emit double_Clicked(item); | 303 | emit double_Clicked(item); |
301 | if (!item) return; | 304 | if (!item) return; |
302 | 305 | ||
303 | emit doubleClicked(item,vp,0); | 306 | emit doubleClicked(item,vp,0); |
304 | } | 307 | } |
305 | 308 | ||
306 | ///////////////////////////////////////////////////////////////////////////// | 309 | ///////////////////////////////////////////////////////////////////////////// |
307 | 310 | ||
308 | KOQuickTodo::KOQuickTodo(QWidget *parent) : | 311 | KOQuickTodo::KOQuickTodo(QWidget *parent) : |
309 | QLineEdit(parent) | 312 | QLineEdit(parent) |
310 | { | 313 | { |
311 | setText(i18n("Click to add a new Todo")); | 314 | setText(i18n("Click to add a new Todo")); |
312 | } | 315 | } |
313 | 316 | ||
314 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) | 317 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) |
315 | { | 318 | { |
316 | if ( text()==i18n("Click to add a new Todo") ) | 319 | if ( text()==i18n("Click to add a new Todo") ) |
317 | setText(""); | 320 | setText(""); |
318 | QLineEdit::focusInEvent(ev); | 321 | QLineEdit::focusInEvent(ev); |
319 | } | 322 | } |
320 | 323 | ||
321 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) | 324 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) |
322 | { | 325 | { |
323 | setText(i18n("Click to add a new Todo")); | 326 | setText(i18n("Click to add a new Todo")); |
324 | QLineEdit::focusOutEvent(ev); | 327 | QLineEdit::focusOutEvent(ev); |
325 | } | 328 | } |
326 | 329 | ||
327 | ///////////////////////////////////////////////////////////////////////////// | 330 | ///////////////////////////////////////////////////////////////////////////// |
328 | 331 | ||
329 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | 332 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : |
330 | KOrg::BaseView(calendar,parent,name) | 333 | KOrg::BaseView(calendar,parent,name) |
331 | { | 334 | { |
332 | QBoxLayout *topLayout = new QVBoxLayout(this); | 335 | QBoxLayout *topLayout = new QVBoxLayout(this); |
333 | mName = QString ( name ); | 336 | mName = QString ( name ); |
334 | mBlockUpdate = false; | 337 | mBlockUpdate = false; |
335 | mQuickAdd = new KOQuickTodo(this); | 338 | mQuickAdd = new KOQuickTodo(this); |
336 | topLayout->addWidget(mQuickAdd); | 339 | topLayout->addWidget(mQuickAdd); |
337 | 340 | ||
338 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); | 341 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); |
339 | 342 | ||
340 | mTodoListView = new KOTodoListView(calendar,this, name ); | 343 | mTodoListView = new KOTodoListView(calendar,this, name ); |
341 | topLayout->addWidget(mTodoListView); | 344 | topLayout->addWidget(mTodoListView); |
342 | //mTodoListView->header()->setMaximumHeight(30); | 345 | //mTodoListView->header()->setMaximumHeight(30); |
343 | mTodoListView->setRootIsDecorated(true); | 346 | mTodoListView->setRootIsDecorated(true); |
344 | mTodoListView->setAllColumnsShowFocus(true); | 347 | mTodoListView->setAllColumnsShowFocus(true); |
345 | 348 | ||
346 | mTodoListView->setShowSortIndicator(true); | 349 | mTodoListView->setShowSortIndicator(true); |
347 | 350 | ||
348 | mTodoListView->addColumn(i18n("Todo")); | 351 | mTodoListView->addColumn(i18n("Todo")); |
349 | mTodoListView->addColumn(i18n("Prio")); | 352 | mTodoListView->addColumn(i18n("Prio")); |
350 | mTodoListView->setColumnAlignment(1,AlignHCenter); | 353 | mTodoListView->setColumnAlignment(1,AlignHCenter); |
351 | mTodoListView->addColumn(i18n("Complete")); | 354 | mTodoListView->addColumn(i18n("Complete")); |
352 | mTodoListView->setColumnAlignment(2,AlignHCenter); | 355 | mTodoListView->setColumnAlignment(2,AlignHCenter); |
353 | mTodoListView->addColumn(i18n("Due Date")); | 356 | mTodoListView->addColumn(i18n("Due Date")); |
354 | mTodoListView->setColumnAlignment(3,AlignLeft); | 357 | mTodoListView->setColumnAlignment(3,AlignLeft); |
355 | mTodoListView->addColumn(i18n("Due Time")); | 358 | mTodoListView->addColumn(i18n("Due Time")); |
356 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 359 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
357 | mTodoListView->addColumn(i18n("Cancelled")); | 360 | mTodoListView->addColumn(i18n("Cancelled")); |
358 | mTodoListView->addColumn(i18n("Categories")); | 361 | mTodoListView->addColumn(i18n("Categories")); |
359 | #if 0 | 362 | #if 0 |
360 | mTodoListView->addColumn(i18n("Sort Id")); | 363 | mTodoListView->addColumn(i18n("Sort Id")); |
361 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 364 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
362 | #endif | 365 | #endif |
363 | 366 | ||
364 | mTodoListView->setMinimumHeight( 60 ); | 367 | mTodoListView->setMinimumHeight( 60 ); |
365 | mTodoListView->setItemsRenameable( true ); | 368 | mTodoListView->setItemsRenameable( true ); |
366 | mTodoListView->setRenameable( 0 ); | 369 | mTodoListView->setRenameable( 0 ); |
367 | mTodoListView->setColumnWidth( 0, 120 ); | 370 | mTodoListView->setColumnWidth( 0, 120 ); |
368 | mTodoListView->setColumnWidthMode(0, QListView::Manual); | 371 | mTodoListView->setColumnWidthMode(0, QListView::Manual); |
369 | mTodoListView->setColumnWidthMode(1, QListView::Manual); | 372 | mTodoListView->setColumnWidthMode(1, QListView::Manual); |
370 | mTodoListView->setColumnWidthMode(2, QListView::Manual); | 373 | mTodoListView->setColumnWidthMode(2, QListView::Manual); |
371 | mTodoListView->setColumnWidthMode(3, QListView::Manual); | 374 | mTodoListView->setColumnWidthMode(3, QListView::Manual); |
372 | mTodoListView->setColumnWidthMode(4, QListView::Manual); | 375 | mTodoListView->setColumnWidthMode(4, QListView::Manual); |
373 | mTodoListView->setColumnWidthMode(5, QListView::Manual); | 376 | mTodoListView->setColumnWidthMode(5, QListView::Manual); |
374 | mTodoListView->setColumnAlignment( 2, AlignCenter ); | 377 | mTodoListView->setColumnAlignment( 2, AlignCenter ); |
375 | #if 0 | 378 | #if 0 |
376 | mTodoListView->setColumnWidthMode(6, QListView::Manual); | 379 | mTodoListView->setColumnWidthMode(6, QListView::Manual); |
377 | #endif | 380 | #endif |
378 | 381 | ||
379 | mPriorityPopupMenu = new QPopupMenu(this); | 382 | mPriorityPopupMenu = new QPopupMenu(this); |
380 | for (int i = 1; i <= 5; i++) { | 383 | for (int i = 1; i <= 5; i++) { |
381 | QString label = QString ("%1").arg (i); | 384 | QString label = QString ("%1").arg (i); |
382 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; | 385 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; |
383 | } | 386 | } |
384 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); | 387 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); |
385 | 388 | ||
386 | mPercentageCompletedPopupMenu = new QPopupMenu(this); | 389 | mPercentageCompletedPopupMenu = new QPopupMenu(this); |
387 | for (int i = 0; i <= 100; i+=20) { | 390 | for (int i = 0; i <= 100; i+=20) { |
388 | QString label = QString ("%1 %").arg (i); | 391 | QString label = QString ("%1 %").arg (i); |
389 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; | 392 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; |
390 | } | 393 | } |
391 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); | 394 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); |
392 | 395 | ||
393 | 396 | ||
394 | 397 | ||
395 | mItemPopupMenu = new QPopupMenu(this); | 398 | mItemPopupMenu = new QPopupMenu(this); |
396 | mItemPopupMenu->insertItem(i18n("Show..."), this, | 399 | mItemPopupMenu->insertItem(i18n("Show..."), this, |
397 | SLOT (showTodo())); | 400 | SLOT (showTodo())); |
398 | mItemPopupMenu->insertItem(i18n("Edit..."), this, | 401 | mItemPopupMenu->insertItem(i18n("Edit..."), this, |
399 | SLOT (editTodo())); | 402 | SLOT (editTodo())); |
400 | mItemPopupMenu->insertItem( i18n("Delete"), this, | 403 | mItemPopupMenu->insertItem( i18n("Delete"), this, |
401 | SLOT (deleteTodo())); | 404 | SLOT (deleteTodo())); |
402 | mItemPopupMenu->insertItem( i18n("Clone..."), this, | 405 | mItemPopupMenu->insertItem( i18n("Clone..."), this, |
403 | SLOT (cloneTodo())); | 406 | SLOT (cloneTodo())); |
404 | mItemPopupMenu->insertItem( i18n("Move..."), this, | 407 | mItemPopupMenu->insertItem( i18n("Move..."), this, |
405 | SLOT (moveTodo())); | 408 | SLOT (moveTodo())); |
406 | mItemPopupMenu->insertItem( i18n("Beam..."), this, | 409 | mItemPopupMenu->insertItem( i18n("Beam..."), this, |
407 | SLOT (beamTodo())); | 410 | SLOT (beamTodo())); |
408 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, | 411 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, |
409 | SLOT (cancelTodo())); | 412 | SLOT (cancelTodo())); |
410 | mItemPopupMenu->insertSeparator(); | 413 | mItemPopupMenu->insertSeparator(); |
411 | 414 | ||
412 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, | 415 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, |
413 | SLOT (newTodo())); | 416 | SLOT (newTodo())); |
414 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, | 417 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, |
415 | SLOT (newSubTodo())); | 418 | SLOT (newSubTodo())); |
416 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, | 419 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, |
417 | SLOT (unparentTodo())); | 420 | SLOT (unparentTodo()),0,21); |
421 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, | ||
422 | SLOT (reparentTodo()),0,22); | ||
418 | mItemPopupMenu->insertSeparator(); | 423 | mItemPopupMenu->insertSeparator(); |
419 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), | 424 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), |
420 | this, SLOT( purgeCompleted() ) ); | 425 | this, SLOT( purgeCompleted() ) ); |
421 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), | 426 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), |
422 | this, SLOT( toggleCompleted() ),0, 33 ); | 427 | this, SLOT( toggleCompleted() ),0, 33 ); |
423 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 428 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
424 | this, SLOT( toggleQuickTodo() ),0, 34 ); | 429 | this, SLOT( toggleQuickTodo() ),0, 34 ); |
425 | 430 | ||
426 | mPopupMenu = new QPopupMenu(this); | 431 | mPopupMenu = new QPopupMenu(this); |
427 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, | 432 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, |
428 | SLOT (newTodo()),0,1); | 433 | SLOT (newTodo()),0,1); |
429 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), | 434 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), |
430 | this, SLOT(purgeCompleted()),0,2); | 435 | this, SLOT(purgeCompleted()),0,2); |
431 | mPopupMenu->insertItem(i18n("Show Completed"), | 436 | mPopupMenu->insertItem(i18n("Show Completed"), |
432 | this, SLOT( toggleCompleted() ),0,3 ); | 437 | this, SLOT( toggleCompleted() ),0,3 ); |
433 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 438 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
434 | this, SLOT( toggleQuickTodo() ),0,4 ); | 439 | this, SLOT( toggleQuickTodo() ),0,4 ); |
435 | mDocPrefs = new DocPrefs( name ); | 440 | mDocPrefs = new DocPrefs( name ); |
436 | 441 | ||
437 | mPopupMenu->setCheckable( true ); | 442 | mPopupMenu->setCheckable( true ); |
438 | mItemPopupMenu->setCheckable( true ); | 443 | mItemPopupMenu->setCheckable( true ); |
439 | // Double clicking conflicts with opening/closing the subtree | 444 | // Double clicking conflicts with opening/closing the subtree |
440 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), | 445 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), |
441 | SLOT( editItem( QListViewItem *) ) ); | 446 | SLOT( editItem( QListViewItem *) ) ); |
447 | /* | ||
442 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, | 448 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, |
443 | const QPoint &,int ) ), | 449 | const QPoint &,int ) ), |
444 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 450 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
451 | */ | ||
452 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, | ||
453 | const QPoint &,int ) ), | ||
454 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | ||
445 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), | 455 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), |
446 | SLOT( itemClicked( QListViewItem * ) ) ); | 456 | SLOT( itemClicked( QListViewItem * ) ) ); |
447 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), | 457 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), |
448 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); | 458 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); |
449 | connect( mTodoListView, SIGNAL( todoDropped( Todo * ) ), | 459 | connect( mTodoListView, SIGNAL( todoDropped( Todo * ) ), |
450 | SLOT( updateView() ) ); | 460 | SLOT( updateView() ) ); |
451 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), | 461 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), |
452 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 462 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
453 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), | 463 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), |
454 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 464 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
455 | 465 | ||
456 | #if 0 | 466 | #if 0 |
457 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), | 467 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), |
458 | SLOT(selectionChanged(QListViewItem *))); | 468 | SLOT(selectionChanged(QListViewItem *))); |
459 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), | 469 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), |
460 | SLOT(selectionChanged(QListViewItem *))); | 470 | SLOT(selectionChanged(QListViewItem *))); |
461 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), | 471 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), |
462 | SLOT(selectionChanged(QListViewItem *))); | 472 | SLOT(selectionChanged(QListViewItem *))); |
463 | #endif | 473 | #endif |
464 | connect( mTodoListView, SIGNAL(selectionChanged() ), | 474 | connect( mTodoListView, SIGNAL(selectionChanged() ), |
465 | SLOT( processSelectionChange() ) ); | 475 | SLOT( processSelectionChange() ) ); |
466 | connect( mQuickAdd, SIGNAL( returnPressed () ), | 476 | connect( mQuickAdd, SIGNAL( returnPressed () ), |
467 | SLOT( addQuickTodo() ) ); | 477 | SLOT( addQuickTodo() ) ); |
468 | // if ( QApplication::desktop()->width() < 480 ) { | 478 | // if ( QApplication::desktop()->width() < 480 ) { |
469 | // setNarrow(); | 479 | // setNarrow(); |
470 | // mTodoListView->setColumnWidth( 0, 100 ); | 480 | // mTodoListView->setColumnWidth( 0, 100 ); |
471 | 481 | ||
472 | // } | 482 | // } |
473 | 483 | ||
474 | } | 484 | } |
475 | 485 | ||
476 | KOTodoView::~KOTodoView() | 486 | KOTodoView::~KOTodoView() |
477 | { | 487 | { |
478 | delete mDocPrefs; | 488 | delete mDocPrefs; |
479 | } | 489 | } |
480 | 490 | ||
481 | void KOTodoView::jumpToDate () | 491 | void KOTodoView::jumpToDate () |
482 | { | 492 | { |
483 | // if (mActiveItem) { | 493 | // if (mActiveItem) { |
484 | // mActiveItem->todo()); | 494 | // mActiveItem->todo()); |
485 | // if ( mActiveItem->todo()->hasDueDate() ) | 495 | // if ( mActiveItem->todo()->hasDueDate() ) |
486 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); | 496 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); |
487 | } | 497 | } |
488 | 498 | ||
489 | void KOTodoView::setNarrow() | 499 | void KOTodoView::setNarrow() |
490 | { | 500 | { |
491 | //mTodoListView->setColumnWidth( 0, 120 ); | 501 | //mTodoListView->setColumnWidth( 0, 120 ); |
492 | mTodoListView->setColumnWidth( 1, 35 ); | 502 | mTodoListView->setColumnWidth( 1, 35 ); |
493 | mTodoListView->setColumnWidth( 2, 40 ); | 503 | mTodoListView->setColumnWidth( 2, 40 ); |
494 | mTodoListView->setColumnWidth( 3, 80 ); | 504 | mTodoListView->setColumnWidth( 3, 80 ); |
495 | mTodoListView->setColumnWidth( 4, 40 ); | 505 | mTodoListView->setColumnWidth( 4, 40 ); |
496 | mTodoListView->setColumnWidth( 5, 90 ); | 506 | mTodoListView->setColumnWidth( 5, 90 ); |
497 | 507 | ||
498 | } | 508 | } |
499 | void KOTodoView::updateView() | 509 | void KOTodoView::updateView() |
500 | { | 510 | { |
501 | 511 | ||
502 | if ( mBlockUpdate ) { | 512 | if ( mBlockUpdate ) { |
503 | //qDebug("blocked "); | 513 | //qDebug("blocked "); |
504 | return; | 514 | return; |
505 | } | 515 | } |
506 | //qDebug("update "); | 516 | //qDebug("update "); |
507 | // kdDebug() << "KOTodoView::updateView()" << endl; | 517 | // kdDebug() << "KOTodoView::updateView()" << endl; |
508 | QFont fo = KOPrefs::instance()->mTodoViewFont; | 518 | QFont fo = KOPrefs::instance()->mTodoViewFont; |
509 | mTodoListView->clear(); | 519 | mTodoListView->clear(); |
510 | if ( mName == "todolistsmall" ) { | 520 | if ( mName == "todolistsmall" ) { |
511 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { | 521 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { |
512 | int ps = fo.pointSize() -2; | 522 | int ps = fo.pointSize() -2; |
513 | if ( ps > 12 ) | 523 | if ( ps > 12 ) |
514 | ps -= 2; | 524 | ps -= 2; |
515 | fo.setPointSize( ps ); | 525 | fo.setPointSize( ps ); |
516 | } | 526 | } |
517 | } | 527 | } |
518 | 528 | ||
519 | mTodoListView->setFont( fo ); | 529 | mTodoListView->setFont( fo ); |
520 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); | 530 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); |
521 | //mTodoListView->header()->setMaximumHeight(fm.height()); | 531 | //mTodoListView->header()->setMaximumHeight(fm.height()); |
522 | QPtrList<Todo> todoList = calendar()->todos(); | 532 | QPtrList<Todo> todoList = calendar()->todos(); |
523 | 533 | ||
524 | /* | 534 | /* |
525 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; | 535 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; |
526 | Event *t; | 536 | Event *t; |
527 | for(t = todoList.first(); t; t = todoList.next()) { | 537 | for(t = todoList.first(); t; t = todoList.next()) { |
528 | kdDebug() << " " << t->getSummary() << endl; | 538 | kdDebug() << " " << t->getSummary() << endl; |
529 | 539 | ||
530 | if (t->getRelatedTo()) { | 540 | if (t->getRelatedTo()) { |
531 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; | 541 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; |
532 | } | 542 | } |
533 | 543 | ||
534 | QPtrList<Event> l = t->getRelations(); | 544 | QPtrList<Event> l = t->getRelations(); |
535 | Event *c; | 545 | Event *c; |
536 | for(c=l.first();c;c=l.next()) { | 546 | for(c=l.first();c;c=l.next()) { |
537 | kdDebug() << " - relation: " << c->getSummary() << endl; | 547 | kdDebug() << " - relation: " << c->getSummary() << endl; |
538 | } | 548 | } |
539 | } | 549 | } |
540 | */ | 550 | */ |
@@ -602,435 +612,505 @@ void KOTodoView::restoreItemState( QListViewItem *item ) | |||
602 | 612 | ||
603 | 613 | ||
604 | QMap<Todo *,KOTodoViewItem *>::ConstIterator | 614 | QMap<Todo *,KOTodoViewItem *>::ConstIterator |
605 | KOTodoView::insertTodoItem(Todo *todo) | 615 | KOTodoView::insertTodoItem(Todo *todo) |
606 | { | 616 | { |
607 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; | 617 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; |
608 | // TODO: Check, if dynmaic cast is necessary | 618 | // TODO: Check, if dynmaic cast is necessary |
609 | 619 | ||
610 | 620 | ||
611 | Incidence *incidence = todo->relatedTo(); | 621 | Incidence *incidence = todo->relatedTo(); |
612 | if (incidence && incidence->type() == "Todo") { | 622 | if (incidence && incidence->type() == "Todo") { |
613 | Todo *relatedTodo = static_cast<Todo *>(incidence); | 623 | Todo *relatedTodo = static_cast<Todo *>(incidence); |
614 | 624 | ||
615 | // kdDebug() << " has Related" << endl; | 625 | // kdDebug() << " has Related" << endl; |
616 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 626 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
617 | itemIterator = mTodoMap.find(relatedTodo); | 627 | itemIterator = mTodoMap.find(relatedTodo); |
618 | if (itemIterator == mTodoMap.end()) { | 628 | if (itemIterator == mTodoMap.end()) { |
619 | // kdDebug() << " related not yet in list" << endl; | 629 | // kdDebug() << " related not yet in list" << endl; |
620 | itemIterator = insertTodoItem (relatedTodo); | 630 | itemIterator = insertTodoItem (relatedTodo); |
621 | } | 631 | } |
622 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem | 632 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem |
623 | // and one into the map. Sure finding is more easy but why? -zecke | 633 | // and one into the map. Sure finding is more easy but why? -zecke |
624 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); | 634 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); |
625 | return mTodoMap.insert(todo,todoItem); | 635 | return mTodoMap.insert(todo,todoItem); |
626 | } else { | 636 | } else { |
627 | // kdDebug() << " no Related" << endl; | 637 | // kdDebug() << " no Related" << endl; |
628 | // see above -zecke | 638 | // see above -zecke |
629 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); | 639 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); |
630 | return mTodoMap.insert(todo,todoItem); | 640 | return mTodoMap.insert(todo,todoItem); |
631 | } | 641 | } |
632 | } | 642 | } |
633 | 643 | ||
634 | 644 | ||
635 | void KOTodoView::updateConfig() | 645 | void KOTodoView::updateConfig() |
636 | { | 646 | { |
637 | updateView(); | 647 | updateView(); |
638 | mTodoListView->repaintContents(); | 648 | mTodoListView->repaintContents(); |
639 | } | 649 | } |
640 | 650 | ||
641 | QPtrList<Incidence> KOTodoView::selectedIncidences() | 651 | QPtrList<Incidence> KOTodoView::selectedIncidences() |
642 | { | 652 | { |
643 | QPtrList<Incidence> selected; | 653 | QPtrList<Incidence> selected; |
644 | 654 | ||
645 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 655 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
646 | // if (!item) item = mActiveItem; | 656 | // if (!item) item = mActiveItem; |
647 | if (item) selected.append(item->todo()); | 657 | if (item) selected.append(item->todo()); |
648 | 658 | ||
649 | return selected; | 659 | return selected; |
650 | } | 660 | } |
651 | 661 | ||
652 | QPtrList<Todo> KOTodoView::selectedTodos() | 662 | QPtrList<Todo> KOTodoView::selectedTodos() |
653 | { | 663 | { |
654 | QPtrList<Todo> selected; | 664 | QPtrList<Todo> selected; |
655 | 665 | ||
656 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 666 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
657 | // if (!item) item = mActiveItem; | 667 | // if (!item) item = mActiveItem; |
658 | if (item) selected.append(item->todo()); | 668 | if (item) selected.append(item->todo()); |
659 | 669 | ||
660 | return selected; | 670 | return selected; |
661 | } | 671 | } |
662 | 672 | ||
663 | void KOTodoView::changeEventDisplay(Event *, int) | 673 | void KOTodoView::changeEventDisplay(Event *, int) |
664 | { | 674 | { |
665 | updateView(); | 675 | updateView(); |
666 | } | 676 | } |
667 | 677 | ||
668 | void KOTodoView::showDates(const QDate &, const QDate &) | 678 | void KOTodoView::showDates(const QDate &, const QDate &) |
669 | { | 679 | { |
670 | } | 680 | } |
671 | 681 | ||
672 | void KOTodoView::showEvents(QPtrList<Event>) | 682 | void KOTodoView::showEvents(QPtrList<Event>) |
673 | { | 683 | { |
674 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; | 684 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; |
675 | } | 685 | } |
676 | 686 | ||
677 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 687 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
678 | const QDate &td) | 688 | const QDate &td) |
679 | { | 689 | { |
680 | #ifndef KORG_NOPRINTER | 690 | #ifndef KORG_NOPRINTER |
681 | calPrinter->preview(CalPrinter::Todolist, fd, td); | 691 | calPrinter->preview(CalPrinter::Todolist, fd, td); |
682 | #endif | 692 | #endif |
683 | } | 693 | } |
684 | 694 | ||
685 | void KOTodoView::editItem(QListViewItem *item ) | 695 | void KOTodoView::editItem(QListViewItem *item ) |
686 | { | 696 | { |
687 | // qDebug("editItem(QListViewItem *item ) "); | 697 | // qDebug("editItem(QListViewItem *item ) "); |
688 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); | 698 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); |
689 | } | 699 | } |
690 | 700 | ||
691 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) | 701 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) |
692 | { | 702 | { |
693 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); | 703 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); |
694 | } | 704 | } |
695 | 705 | ||
696 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &,int column) | 706 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &,int column) |
697 | { | 707 | { |
698 | |||
699 | mActiveItem = (KOTodoViewItem *)item; | 708 | mActiveItem = (KOTodoViewItem *)item; |
700 | if (item) { | 709 | if (item) { |
701 | switch (column){ | 710 | switch (column){ |
702 | case 1: | 711 | case 1: |
703 | mPriorityPopupMenu->popup(QCursor::pos ()); break; | 712 | mPriorityPopupMenu->popup(QCursor::pos ()); break; |
704 | case 2: | 713 | case 2: |
705 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; | 714 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; |
706 | case 3: | 715 | case 3: |
707 | moveTodo(); | 716 | moveTodo(); |
708 | break; | 717 | break; |
709 | case 6: | 718 | case 6: |
710 | getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; | 719 | getCategoryPopupMenu((KOTodoViewItem *)item)->popup(QCursor::pos ()); break; |
711 | default: | 720 | default: |
712 | mItemPopupMenu->popup(QCursor::pos()); | 721 | mItemPopupMenu->popup(QCursor::pos()); |
713 | } | 722 | } |
714 | } else mPopupMenu->popup(QCursor::pos()); | 723 | } else mPopupMenu->popup(QCursor::pos()); |
715 | } | 724 | } |
716 | void KOTodoView::newTodo() | 725 | void KOTodoView::newTodo() |
717 | { | 726 | { |
718 | emit newTodoSignal(); | 727 | emit newTodoSignal(); |
719 | } | 728 | } |
720 | 729 | ||
721 | void KOTodoView::newSubTodo() | 730 | void KOTodoView::newSubTodo() |
722 | { | 731 | { |
723 | if (mActiveItem) { | 732 | if (mActiveItem) { |
724 | emit newSubTodoSignal(mActiveItem->todo()); | 733 | emit newSubTodoSignal(mActiveItem->todo()); |
725 | } | 734 | } |
726 | } | 735 | } |
727 | void KOTodoView::unparentTodo() | 736 | void KOTodoView::unparentTodo() |
728 | { | 737 | { |
729 | if (mActiveItem) { | 738 | if (mActiveItem) { |
730 | emit unparentTodoSignal(mActiveItem->todo()); | 739 | emit unparentTodoSignal(mActiveItem->todo()); |
731 | } | 740 | } |
732 | } | 741 | } |
742 | |||
743 | void KOTodoView::reparentTodo() | ||
744 | { | ||
745 | if (mActiveItem) { | ||
746 | qDebug("KOTodoView::reparentTodo() "); | ||
747 | topLevelWidget()->setCaption(i18n("Click on new parent item")); | ||
748 | pendingSubtodo = mActiveItem; | ||
749 | } | ||
750 | } | ||
733 | void KOTodoView::editTodo() | 751 | void KOTodoView::editTodo() |
734 | { | 752 | { |
735 | if (mActiveItem) { | 753 | if (mActiveItem) { |
736 | emit editTodoSignal(mActiveItem->todo()); | 754 | emit editTodoSignal(mActiveItem->todo()); |
737 | } | 755 | } |
738 | } | 756 | } |
739 | void KOTodoView::cloneTodo() | 757 | void KOTodoView::cloneTodo() |
740 | { | 758 | { |
741 | if (mActiveItem) { | 759 | if (mActiveItem) { |
742 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); | 760 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); |
743 | } | 761 | } |
744 | } | 762 | } |
745 | void KOTodoView::cancelTodo() | 763 | void KOTodoView::cancelTodo() |
746 | { | 764 | { |
747 | if (mActiveItem) { | 765 | if (mActiveItem) { |
748 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); | 766 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); |
749 | } | 767 | } |
750 | } | 768 | } |
751 | void KOTodoView::moveTodo() | 769 | void KOTodoView::moveTodo() |
752 | { | 770 | { |
753 | if (mActiveItem) { | 771 | if (mActiveItem) { |
754 | emit moveTodoSignal((Incidence*)mActiveItem->todo()); | 772 | emit moveTodoSignal((Incidence*)mActiveItem->todo()); |
755 | } | 773 | } |
756 | } | 774 | } |
757 | void KOTodoView::beamTodo() | 775 | void KOTodoView::beamTodo() |
758 | { | 776 | { |
759 | if (mActiveItem) { | 777 | if (mActiveItem) { |
760 | emit beamTodoSignal((Incidence*)mActiveItem->todo()); | 778 | emit beamTodoSignal((Incidence*)mActiveItem->todo()); |
761 | } | 779 | } |
762 | } | 780 | } |
763 | 781 | ||
764 | 782 | ||
765 | void KOTodoView::showTodo() | 783 | void KOTodoView::showTodo() |
766 | { | 784 | { |
767 | if (mActiveItem) { | 785 | if (mActiveItem) { |
768 | emit showTodoSignal(mActiveItem->todo()); | 786 | emit showTodoSignal(mActiveItem->todo()); |
769 | } | 787 | } |
770 | } | 788 | } |
771 | 789 | ||
772 | void KOTodoView::deleteTodo() | 790 | void KOTodoView::deleteTodo() |
773 | { | 791 | { |
774 | if (mActiveItem) { | 792 | if (mActiveItem) { |
775 | if (mActiveItem->childCount()) { | 793 | if (mActiveItem->childCount()) { |
776 | KMessageBox::sorry(this,i18n("Cannot delete To-Do which has children."), | 794 | KMessageBox::sorry(this,i18n("Cannot delete To-Do which has children."), |
777 | i18n("Delete To-Do")); | 795 | i18n("Delete To-Do")); |
778 | } else { | 796 | } else { |
779 | emit deleteTodoSignal(mActiveItem->todo()); | 797 | emit deleteTodoSignal(mActiveItem->todo()); |
780 | } | 798 | } |
781 | } | 799 | } |
782 | } | 800 | } |
783 | 801 | ||
784 | void KOTodoView::setNewPriority(int index) | 802 | void KOTodoView::setNewPriority(int index) |
785 | { | 803 | { |
786 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 804 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
787 | mActiveItem->todo()->setPriority(mPriority[index]); | 805 | mActiveItem->todo()->setPriority(mPriority[index]); |
788 | mActiveItem->construct(); | 806 | mActiveItem->construct(); |
789 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); | 807 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); |
790 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 808 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
791 | } | 809 | } |
792 | } | 810 | } |
793 | 811 | ||
794 | void KOTodoView::setNewPercentage(int index) | 812 | void KOTodoView::setNewPercentage(int index) |
795 | { | 813 | { |
796 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 814 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
797 | if (mPercentage[index] == 100) { | 815 | if (mPercentage[index] == 100) { |
798 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); | 816 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); |
799 | } else { | 817 | } else { |
800 | mActiveItem->todo()->setCompleted(false); | 818 | mActiveItem->todo()->setCompleted(false); |
801 | } | 819 | } |
802 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); | 820 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); |
803 | mActiveItem->construct(); | 821 | mActiveItem->construct(); |
804 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); | 822 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); |
805 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 823 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
806 | } | 824 | } |
807 | } | 825 | } |
808 | 826 | ||
809 | 827 | ||
810 | QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) | 828 | QPopupMenu * KOTodoView::getCategoryPopupMenu (KOTodoViewItem *todoItem) |
811 | { | 829 | { |
812 | QPopupMenu* tempMenu = new QPopupMenu (this); | 830 | QPopupMenu* tempMenu = new QPopupMenu (this); |
813 | QStringList checkedCategories = todoItem->todo()->categories (); | 831 | QStringList checkedCategories = todoItem->todo()->categories (); |
814 | 832 | ||
815 | tempMenu->setCheckable (true); | 833 | tempMenu->setCheckable (true); |
816 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); | 834 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); |
817 | it != KOPrefs::instance()->mCustomCategories.end (); | 835 | it != KOPrefs::instance()->mCustomCategories.end (); |
818 | ++it) { | 836 | ++it) { |
819 | int index = tempMenu->insertItem (*it); | 837 | int index = tempMenu->insertItem (*it); |
820 | mCategory[index] = *it; | 838 | mCategory[index] = *it; |
821 | if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); | 839 | if (checkedCategories.find (*it) != checkedCategories.end ()) tempMenu->setItemChecked (index, true); |
822 | } | 840 | } |
823 | 841 | ||
824 | connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); | 842 | connect (tempMenu, SIGNAL (activated (int)), SLOT (changedCategories (int))); |
825 | return tempMenu; | 843 | return tempMenu; |
826 | 844 | ||
827 | 845 | ||
828 | } | 846 | } |
829 | void KOTodoView::changedCategories(int index) | 847 | void KOTodoView::changedCategories(int index) |
830 | { | 848 | { |
831 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 849 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
832 | QStringList categories = mActiveItem->todo()->categories (); | 850 | QStringList categories = mActiveItem->todo()->categories (); |
833 | if (categories.find (mCategory[index]) != categories.end ()) | 851 | if (categories.find (mCategory[index]) != categories.end ()) |
834 | categories.remove (mCategory[index]); | 852 | categories.remove (mCategory[index]); |
835 | else | 853 | else |
836 | categories.insert (categories.end(), mCategory[index]); | 854 | categories.insert (categories.end(), mCategory[index]); |
837 | categories.sort (); | 855 | categories.sort (); |
838 | mActiveItem->todo()->setCategories (categories); | 856 | mActiveItem->todo()->setCategories (categories); |
839 | mActiveItem->construct(); | 857 | mActiveItem->construct(); |
840 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 858 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
841 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); | 859 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); |
842 | } | 860 | } |
843 | } | 861 | } |
844 | void KOTodoView::itemDoubleClicked(QListViewItem *item) | 862 | void KOTodoView::itemDoubleClicked(QListViewItem *item) |
845 | { | 863 | { |
864 | if ( pendingSubtodo != 0 ) { | ||
865 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | ||
866 | } | ||
867 | pendingSubtodo = 0; | ||
846 | if (!item) { | 868 | if (!item) { |
847 | newTodo(); | 869 | newTodo(); |
848 | return; | 870 | return; |
849 | } | 871 | } |
850 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 872 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
851 | editItem( item ); | 873 | editItem( item ); |
852 | else | 874 | else |
853 | showItem( item , QPoint(), 0 ); | 875 | showItem( item , QPoint(), 0 ); |
854 | } | 876 | } |
855 | void KOTodoView::itemClicked(QListViewItem *item) | 877 | void KOTodoView::itemClicked(QListViewItem *item) |
856 | { | 878 | { |
879 | |||
857 | if (!item) { | 880 | if (!item) { |
881 | if ( pendingSubtodo != 0 ) { | ||
882 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | ||
883 | } | ||
884 | pendingSubtodo = 0; | ||
858 | return; | 885 | return; |
859 | } | 886 | } |
860 | |||
861 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 887 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
888 | if ( pendingSubtodo != 0 ) { | ||
889 | bool allowReparent = true; | ||
890 | QListViewItem *par = item; | ||
891 | while ( par ) { | ||
892 | if ( par == pendingSubtodo ) { | ||
893 | allowReparent = false; | ||
894 | break; | ||
895 | } | ||
896 | par = par->parent(); | ||
897 | } | ||
898 | if ( !allowReparent ) { | ||
899 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); | ||
900 | qDebug("Recursive reparenting not possible "); | ||
901 | pendingSubtodo = 0; | ||
902 | } else { | ||
903 | Todo* newParent = todoItem->todo(); | ||
904 | Todo* newSub = pendingSubtodo->todo(); | ||
905 | pendingSubtodo = 0; | ||
906 | emit reparentTodoSignal( newParent,newSub ); | ||
907 | return; | ||
908 | } | ||
909 | } | ||
862 | int completed = todoItem->todo()->isCompleted(); // Completed or not? | 910 | int completed = todoItem->todo()->isCompleted(); // Completed or not? |
863 | 911 | ||
864 | if (todoItem->isOn()) { | 912 | if (todoItem->isOn()) { |
865 | if (!completed) { | 913 | if (!completed) { |
866 | todoItem->todo()->setCompleted(QDateTime::currentDateTime()); | 914 | todoItem->todo()->setCompleted(QDateTime::currentDateTime()); |
867 | } | 915 | } |
868 | } else { | 916 | } else { |
869 | if (completed) { | 917 | if (completed) { |
870 | todoItem->todo()->setCompleted(false); | 918 | todoItem->todo()->setCompleted(false); |
871 | } | 919 | } |
872 | } | 920 | } |
873 | } | 921 | } |
874 | 922 | ||
875 | void KOTodoView::setDocumentId( const QString &id ) | 923 | void KOTodoView::setDocumentId( const QString &id ) |
876 | { | 924 | { |
877 | kdDebug() << "KOTodoView::setDocumentId()" << endl; | 925 | kdDebug() << "KOTodoView::setDocumentId()" << endl; |
878 | 926 | ||
879 | mDocPrefs->setDoc( id ); | 927 | mDocPrefs->setDoc( id ); |
880 | } | 928 | } |
881 | 929 | ||
882 | void KOTodoView::itemStateChanged( QListViewItem *item ) | 930 | void KOTodoView::itemStateChanged( QListViewItem *item ) |
883 | { | 931 | { |
884 | if (!item) return; | 932 | if (!item) return; |
885 | 933 | ||
886 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 934 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
887 | 935 | ||
888 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; | 936 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; |
889 | 937 | ||
890 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); | 938 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); |
891 | } | 939 | } |
892 | 940 | ||
893 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const | 941 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const |
894 | { | 942 | { |
895 | mTodoListView->saveLayout(config,group); | 943 | mTodoListView->saveLayout(config,group); |
896 | } | 944 | } |
897 | 945 | ||
898 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) | 946 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) |
899 | { | 947 | { |
900 | mTodoListView->restoreLayout(config,group); | 948 | mTodoListView->restoreLayout(config,group); |
901 | } | 949 | } |
902 | 950 | ||
903 | void KOTodoView::processSelectionChange() | 951 | void KOTodoView::processSelectionChange() |
904 | { | 952 | { |
905 | // kdDebug() << "KOTodoView::processSelectionChange()" << endl; | 953 | // kdDebug() << "KOTodoView::processSelectionChange()" << endl; |
906 | 954 | ||
907 | KOTodoViewItem *item = | 955 | KOTodoViewItem *item = |
908 | static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); | 956 | static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); |
909 | 957 | ||
910 | if ( !item ) { | 958 | if ( !item ) { |
911 | emit incidenceSelected( 0 ); | 959 | emit incidenceSelected( 0 ); |
912 | } else { | 960 | } else { |
913 | emit incidenceSelected( item->todo() ); | 961 | emit incidenceSelected( item->todo() ); |
914 | } | 962 | } |
915 | } | 963 | } |
916 | 964 | ||
917 | void KOTodoView::modified(bool b) | 965 | void KOTodoView::modified(bool b) |
918 | { | 966 | { |
919 | emit isModified(b); | 967 | emit isModified(b); |
920 | } | 968 | } |
921 | void KOTodoView::setTodoModified( Todo* todo ) | 969 | void KOTodoView::setTodoModified( Todo* todo ) |
922 | { | 970 | { |
923 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); | 971 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); |
924 | } | 972 | } |
925 | void KOTodoView::clearSelection() | 973 | void KOTodoView::clearSelection() |
926 | { | 974 | { |
927 | mTodoListView->selectAll( false ); | 975 | mTodoListView->selectAll( false ); |
928 | } | 976 | } |
929 | 977 | ||
930 | void KOTodoView::purgeCompleted() | 978 | void KOTodoView::purgeCompleted() |
931 | { | 979 | { |
932 | emit purgeCompletedSignal(); | 980 | emit purgeCompletedSignal(); |
933 | } | 981 | } |
934 | void KOTodoView::toggleQuickTodo() | 982 | void KOTodoView::toggleQuickTodo() |
935 | { | 983 | { |
936 | if ( mQuickAdd->isVisible() ) { | 984 | if ( mQuickAdd->isVisible() ) { |
937 | mQuickAdd->hide(); | 985 | mQuickAdd->hide(); |
938 | KOPrefs::instance()->mEnableQuickTodo = false; | 986 | KOPrefs::instance()->mEnableQuickTodo = false; |
939 | } | 987 | } |
940 | else { | 988 | else { |
941 | mQuickAdd->show(); | 989 | mQuickAdd->show(); |
942 | KOPrefs::instance()->mEnableQuickTodo = true; | 990 | KOPrefs::instance()->mEnableQuickTodo = true; |
943 | } | 991 | } |
944 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 992 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
945 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 993 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
946 | } | 994 | } |
947 | void KOTodoView::toggleCompleted() | 995 | void KOTodoView::toggleCompleted() |
948 | { | 996 | { |
949 | KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; | 997 | KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; |
950 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 998 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
951 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 999 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
952 | updateView(); | 1000 | updateView(); |
953 | } | 1001 | } |
954 | 1002 | ||
955 | void KOTodoView::addQuickTodo() | 1003 | void KOTodoView::addQuickTodo() |
956 | { | 1004 | { |
957 | Todo *todo = new Todo(); | 1005 | Todo *todo = new Todo(); |
958 | todo->setSummary(mQuickAdd->text()); | 1006 | todo->setSummary(mQuickAdd->text()); |
959 | todo->setOrganizer(KOPrefs::instance()->email()); | 1007 | todo->setOrganizer(KOPrefs::instance()->email()); |
960 | CalFilter * cf = mCalendar->filter(); | 1008 | CalFilter * cf = mCalendar->filter(); |
961 | if ( cf ) { | 1009 | if ( cf ) { |
962 | if ( cf->isEnabled()&& cf->showCategories()) { | 1010 | if ( cf->isEnabled()&& cf->showCategories()) { |
963 | todo->setCategories(cf->categoryList()); | 1011 | todo->setCategories(cf->categoryList()); |
964 | } | 1012 | } |
965 | if ( cf->isEnabled() ) | 1013 | if ( cf->isEnabled() ) |
966 | todo->setSecrecy( cf->getSecrecy()); | 1014 | todo->setSecrecy( cf->getSecrecy()); |
967 | } | 1015 | } |
968 | mCalendar->addTodo(todo); | 1016 | mCalendar->addTodo(todo); |
969 | mQuickAdd->setText(""); | 1017 | mQuickAdd->setText(""); |
970 | todoModified (todo, KOGlobals::EVENTADDED ); | 1018 | todoModified (todo, KOGlobals::EVENTADDED ); |
971 | updateView(); | 1019 | updateView(); |
972 | } | 1020 | } |
973 | void KOTodoView::keyPressEvent ( QKeyEvent * e ) | 1021 | void KOTodoView::keyPressEvent ( QKeyEvent * e ) |
974 | { | 1022 | { |
975 | // e->ignore(); | 1023 | // e->ignore(); |
976 | //return; | 1024 | //return; |
1025 | //qDebug("KOTodoView::keyPressEvent "); | ||
977 | switch ( e->key() ) { | 1026 | switch ( e->key() ) { |
978 | case Qt::Key_Down: | 1027 | case Qt::Key_Down: |
979 | case Qt::Key_Up: | 1028 | case Qt::Key_Up: |
980 | QWidget::keyPressEvent ( e ); | 1029 | QWidget::keyPressEvent ( e ); |
981 | break; | 1030 | break; |
982 | 1031 | ||
983 | case Qt::Key_Q: | 1032 | case Qt::Key_Q: |
984 | toggleQuickTodo(); | 1033 | toggleQuickTodo(); |
985 | break; | 1034 | break; |
986 | 1035 | case Qt::Key_U: | |
1036 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | ||
1037 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | ||
1038 | unparentTodo(); | ||
1039 | e->accept(); | ||
1040 | } else | ||
1041 | e->ignore(); | ||
1042 | break; | ||
1043 | case Qt::Key_S: | ||
1044 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | ||
1045 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | ||
1046 | reparentTodo(); | ||
1047 | e->accept(); | ||
1048 | } else | ||
1049 | e->ignore(); | ||
1050 | break; | ||
1051 | case Qt::Key_P: | ||
1052 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | ||
1053 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | ||
1054 | if ( pendingSubtodo ) | ||
1055 | itemClicked(mActiveItem); | ||
1056 | e->accept(); | ||
1057 | } else | ||
1058 | e->ignore(); | ||
1059 | break; | ||
1060 | case Qt::Key_Escape: | ||
1061 | if ( pendingSubtodo ) { | ||
1062 | itemClicked(0); | ||
1063 | e->accept(); | ||
1064 | } else | ||
1065 | e->ignore(); | ||
1066 | break; | ||
987 | default: | 1067 | default: |
988 | e->ignore(); | 1068 | e->ignore(); |
989 | } | 1069 | } |
990 | 1070 | ||
991 | if ( true ) { | 1071 | if ( true ) { |
992 | if ( e->key() == Qt::Key_I ) { | 1072 | if ( e->key() == Qt::Key_I ) { |
993 | KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); | 1073 | KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); |
994 | if ( cn ) { | 1074 | if ( cn ) { |
995 | mActiveItem = cn; | 1075 | mActiveItem = cn; |
996 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 1076 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
997 | if ( ci ){ | 1077 | if ( ci ){ |
998 | showTodo(); | 1078 | showTodo(); |
999 | cn = (KOTodoViewItem*)cn->itemBelow(); | 1079 | cn = (KOTodoViewItem*)cn->itemBelow(); |
1000 | if ( cn ) { | 1080 | if ( cn ) { |
1001 | mTodoListView->setCurrentItem ( cn ); | 1081 | mTodoListView->setCurrentItem ( cn ); |
1002 | mTodoListView->ensureItemVisible ( cn ); | 1082 | mTodoListView->ensureItemVisible ( cn ); |
1003 | } | 1083 | } |
1004 | 1084 | ||
1005 | } | 1085 | } |
1006 | } | 1086 | } |
1007 | e->accept(); | 1087 | e->accept(); |
1008 | 1088 | ||
1009 | } | 1089 | } |
1010 | 1090 | ||
1011 | } | 1091 | } |
1012 | 1092 | ||
1013 | } | 1093 | } |
1014 | void KOTodoView::updateTodo( Todo * t, int type ) | 1094 | void KOTodoView::updateTodo( Todo * t, int type ) |
1015 | { | 1095 | { |
1016 | if ( mBlockUpdate) | 1096 | if ( mBlockUpdate) |
1017 | return; | 1097 | return; |
1018 | 1098 | ||
1019 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 1099 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
1020 | itemIterator = mTodoMap.find(t); | 1100 | itemIterator = mTodoMap.find(t); |
1021 | if (itemIterator != mTodoMap.end()) { | 1101 | if (itemIterator != mTodoMap.end()) { |
1022 | (*itemIterator)->construct(); | 1102 | (*itemIterator)->construct(); |
1023 | } else { | 1103 | } else { |
1024 | if ( type == KOGlobals::EVENTADDED ) { | 1104 | if ( type == KOGlobals::EVENTADDED ) { |
1025 | insertTodoItem( t ); | 1105 | insertTodoItem( t ); |
1026 | } | 1106 | } |
1027 | } | 1107 | } |
1028 | 1108 | ||
1029 | } | 1109 | } |
1030 | 1110 | ||
1031 | void KOTodoView::todoModified(Todo * t , int p ) | 1111 | void KOTodoView::todoModified(Todo * t , int p ) |
1032 | { | 1112 | { |
1033 | mBlockUpdate = true; | 1113 | mBlockUpdate = true; |
1034 | emit todoModifiedSignal ( t, p ); | 1114 | emit todoModifiedSignal ( t, p ); |
1035 | mBlockUpdate = false; | 1115 | mBlockUpdate = false; |
1036 | } | 1116 | } |