From d94b52aa95cc52aa1bef7c9cd99f43c725ed8042 Mon Sep 17 00:00:00 2001 From: zautrix Date: Sat, 29 Jan 2005 23:23:11 +0000 Subject: todo dnd --- (limited to 'korganizer') diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 0c39590..74aefb7 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -1531,7 +1531,7 @@ bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a kind = i18n( "Anniversary" ); ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); } - ev->setOrganizer(a->email()); + //ev->setOrganizer(a->email()); ev->setCategories( kind ); ev->setDtStart( QDateTime(date) ); ev->setDtEnd( QDateTime(date) ); @@ -2214,7 +2214,7 @@ void CalendarView::edit_cut() return; } DndFactory factory( mCalendar ); - factory.cutEvent(anEvent); + factory.cutIncidence(anEvent); changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); } @@ -2235,7 +2235,7 @@ void CalendarView::edit_copy() return; } DndFactory factory( mCalendar ); - factory.copyEvent(anEvent); + factory.copyIncidence(anEvent); } void CalendarView::edit_paste() @@ -2243,7 +2243,7 @@ void CalendarView::edit_paste() QDate date = mNavigator->selectedDates().first(); DndFactory factory( mCalendar ); - Event *pastedEvent = factory.pasteEvent( date ); + Event *pastedEvent = (Event *)factory.pasteIncidence( date ); changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); } diff --git a/korganizer/korganizer.pro b/korganizer/korganizer.pro index 4d67dca..3c7a1fb 100644 --- a/korganizer/korganizer.pro +++ b/korganizer/korganizer.pro @@ -9,9 +9,9 @@ include( ../variables.pri ) INCLUDEPATH += ../microkde ../ interfaces ../microkde/kdecore ../microkde/kdeui ../microkde/kio/kfile ../microkde/kio/kio ../libkdepim #../qtcompat -DEFINES += KORG_NODND KORG_NOPLUGINS KORG_NOARCHIVE KORG_NOMAIL +DEFINES += KORG_NOPLUGINS KORG_NOARCHIVE KORG_NOMAIL DEFINES += KORG_NODCOP KORG_NOKALARMD KORG_NORESOURCEVIEW KORG_NOSPLITTER -#KORG_NOPRINTER KORG_NOKABC +#KORG_NOPRINTER KORG_NOKABC KORG_NODND DEFINES += KORG_NOLVALTERNATION DEFINES += DESKTOP_VERSION unix : { 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(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 () ), diff --git a/korganizer/kotodoview.h b/korganizer/kotodoview.h index f11518d..68e29bb 100644 --- a/korganizer/kotodoview.h +++ b/korganizer/kotodoview.h @@ -60,9 +60,11 @@ class KOTodoListView : public KListView virtual ~KOTodoListView() {} signals: - void todoDropped(Todo *); + void todoDropped(Todo *, int); void double_Clicked(QListViewItem *item); - + void reparentTodoSignal( Todo *,Todo * ); + void unparentTodoSignal(Todo *); + void deleteTodo( Todo * ); protected: void contentsDragEnterEvent(QDragEnterEvent *); void contentsDragMoveEvent(QDragMoveEvent *); @@ -75,6 +77,7 @@ class KOTodoListView : public KListView void contentsMouseDoubleClickEvent(QMouseEvent *); private: + bool internalDrop; QString mName; Calendar *mCalendar; QPoint mPressPos; @@ -197,6 +200,8 @@ class KOTodoView : public KOrg::BaseView protected slots: void processSelectionChange(); void addQuickTodo(); + void setTodoModified( Todo* ); + void todoModified(Todo *, int ); private: /* @@ -209,7 +214,6 @@ class KOTodoView : public KOrg::BaseView * -- zecke 2002-07-08 */ friend class KOTodoViewItem; - void setTodoModified( Todo* ); QMap::ConstIterator insertTodoItem(Todo *todo); void restoreItemState( QListViewItem * ); @@ -235,7 +239,6 @@ class KOTodoView : public KOrg::BaseView QString mCurrentDoc; KOQuickTodo *mQuickAdd; bool mBlockUpdate; - void todoModified(Todo *, int ); void keyPressEvent ( QKeyEvent * ) ; KOTodoViewItem * pendingSubtodo; DateNavigator* mNavigator; -- cgit v0.9.0.2