author | zautrix <zautrix> | 2005-01-29 23:23:11 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-29 23:23:11 (UTC) |
commit | d94b52aa95cc52aa1bef7c9cd99f43c725ed8042 (patch) (side-by-side diff) | |
tree | 9443dfbc790a76e5d707ce762e075cdb21096f50 /korganizer/kotodoview.cpp | |
parent | 74c808f288bf81bc68c92a377ce64953603c2d40 (diff) | |
download | kdepimpi-d94b52aa95cc52aa1bef7c9cd99f43c725ed8042.zip kdepimpi-d94b52aa95cc52aa1bef7c9cd99f43c725ed8042.tar.gz kdepimpi-d94b52aa95cc52aa1bef7c9cd99f43c725ed8042.tar.bz2 |
todo dnd
-rw-r--r-- | korganizer/kotodoview.cpp | 61 |
1 files changed, 35 insertions, 26 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 1fb480d..8c1953d 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp @@ -139,27 +139,28 @@ void KOTodoListView::contentsDropEvent(QDropEvent *e) Todo *existingTodo = mCalendar->todo(todo->uid()); if(existingTodo) { -// kdDebug() << "Drop existing Todo" << endl; Incidence *to = destinationEvent; while(to) { if (to->uid() == todo->uid()) { KMessageBox::sorry(this, - i18n("Cannot move To-Do to itself or a child of itself"), + i18n("Cannot move To-Do to itself\nor a child of itself"), i18n("Drop To-Do")); delete todo; return; } to = to->relatedTo(); } - existingTodo->setRelatedTo(destinationEvent); - emit todoDropped(todo); + internalDrop = true; + if ( destinationEvent ) + reparentTodoSignal( destinationEvent, existingTodo ); + else + unparentTodoSignal(existingTodo); delete todo; } else { -// kdDebug() << "Drop new Todo" << endl; - todo->setRelatedTo(destinationEvent); mCalendar->addTodo(todo); - - emit todoDropped(todo); + emit todoDropped(todo, KOGlobals::EVENTADDED); + if ( destinationEvent ) + reparentTodoSignal( destinationEvent, todo ); } } else { @@ -167,10 +168,9 @@ void KOTodoListView::contentsDropEvent(QDropEvent *e) if (QTextDrag::decode(e,text)) { //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); - kdDebug() << "Dropped : " << text << endl; + qDebug("Dropped : " + text); QStringList emails = QStringList::split(",",text); for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { - kdDebug() << " Email: " << (*it) << endl; int pos = (*it).find("<"); QString name = (*it).left(pos); QString email = (*it).mid(pos); @@ -180,7 +180,7 @@ void KOTodoListView::contentsDropEvent(QDropEvent *e) } } else { - kdDebug() << "KOTodoListView::contentsDropEvent(): Todo from drop not decodable" << endl; + qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); e->ignore(); } } @@ -189,10 +189,10 @@ void KOTodoListView::contentsDropEvent(QDropEvent *e) void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) { - QListView::contentsMousePressEvent(e); #ifndef KORG_NODND QPoint p(contentsToViewport(e->pos())); QListViewItem *i = itemAt(p); + mMousePressed = false; if (i) { // if the user clicked into the root decoration of the item, don't // try to start a drag! @@ -207,35 +207,37 @@ void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) } } #endif + QListView::contentsMousePressEvent(e); } void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) { #ifndef KORG_NODND -// kdDebug() << "KOTodoListView::contentsMouseMoveEvent()" << endl; QListView::contentsMouseMoveEvent(e); if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > QApplication::startDragDistance()) { mMousePressed = false; QListViewItem *item = itemAt(contentsToViewport(mPressPos)); if (item) { -// kdDebug() << "Start Drag for item " << item->text(0) << endl; DndFactory factory( mCalendar ); - ICalDrag *vd = factory.createDragTodo( + ICalDrag *vd = factory.createDrag( ((KOTodoViewItem *)item)->todo(),viewport()); + internalDrop = false; + // we cannot do any senseful here, because the DnD is still broken in Qt if (vd->drag()) { - kdDebug() << "KOTodoListView::contentsMouseMoveEvent(): Delete drag source" << endl; + if ( !internalDrop ) { + //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); + qDebug("Dnd: External move: Delete drag source "); + } else + qDebug("Dnd: Internal move "); + + } else { + if ( !internalDrop ) { + qDebug("Dnd: External Copy"); + } else + qDebug("DnD: Internal copy: Copy pending"); } -/* - QString source = fullPath(item); - if ( QFile::exists(source) ) { - QUriDrag* ud = new QUriDrag(viewport()); - ud->setFilenames( source ); - if ( ud->drag() ) - QMessageBox::information( this, "Drag source", - QString("Delete ")+source, "Not implemented" ); -*/ } } #endif @@ -489,8 +491,10 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : SLOT( itemClicked( QListViewItem * ) ) ); connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), SLOT( itemDoubleClicked( QListViewItem * ) ) ); - connect( mTodoListView, SIGNAL( todoDropped( Todo * ) ), + connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), SLOT( updateView() ) ); + connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), + SLOT( todoModified(Todo *, int) ) ); connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), SLOT( itemStateChanged( QListViewItem * ) ) ); connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), @@ -504,6 +508,11 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), SLOT(selectionChanged(QListViewItem *))); #endif + + connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); + connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); + connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); + connect( mTodoListView, SIGNAL(selectionChanged() ), SLOT( processSelectionChange() ) ); connect( mQuickAdd, SIGNAL( returnPressed () ), |