author | zautrix <zautrix> | 2005-01-29 23:23:11 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-29 23:23:11 (UTC) |
commit | d94b52aa95cc52aa1bef7c9cd99f43c725ed8042 (patch) (unidiff) | |
tree | 9443dfbc790a76e5d707ce762e075cdb21096f50 /korganizer | |
parent | 74c808f288bf81bc68c92a377ce64953603c2d40 (diff) | |
download | kdepimpi-d94b52aa95cc52aa1bef7c9cd99f43c725ed8042.zip kdepimpi-d94b52aa95cc52aa1bef7c9cd99f43c725ed8042.tar.gz kdepimpi-d94b52aa95cc52aa1bef7c9cd99f43c725ed8042.tar.bz2 |
todo dnd
-rw-r--r-- | korganizer/calendarview.cpp | 8 | ||||
-rw-r--r-- | korganizer/korganizer.pro | 4 | ||||
-rw-r--r-- | korganizer/kotodoview.cpp | 61 | ||||
-rw-r--r-- | korganizer/kotodoview.h | 11 |
4 files changed, 48 insertions, 36 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 0c39590..74aefb7 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -1530,9 +1530,9 @@ bool CalendarView::addAnniversary( QDate date, QString name, KCal::Attendee* a | |||
1530 | else { | 1530 | else { |
1531 | kind = i18n( "Anniversary" ); | 1531 | kind = i18n( "Anniversary" ); |
1532 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); | 1532 | ev->setSummary( name + " (" + QString::number(date.year()) +") " + kind ); |
1533 | } | 1533 | } |
1534 | ev->setOrganizer(a->email()); | 1534 | //ev->setOrganizer(a->email()); |
1535 | ev->setCategories( kind ); | 1535 | ev->setCategories( kind ); |
1536 | ev->setDtStart( QDateTime(date) ); | 1536 | ev->setDtStart( QDateTime(date) ); |
1537 | ev->setDtEnd( QDateTime(date) ); | 1537 | ev->setDtEnd( QDateTime(date) ); |
1538 | ev->setFloats( true ); | 1538 | ev->setFloats( true ); |
@@ -2213,9 +2213,9 @@ void CalendarView::edit_cut() | |||
2213 | KNotifyClient::beep(); | 2213 | KNotifyClient::beep(); |
2214 | return; | 2214 | return; |
2215 | } | 2215 | } |
2216 | DndFactory factory( mCalendar ); | 2216 | DndFactory factory( mCalendar ); |
2217 | factory.cutEvent(anEvent); | 2217 | factory.cutIncidence(anEvent); |
2218 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 2218 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
2219 | } | 2219 | } |
2220 | 2220 | ||
2221 | void CalendarView::edit_copy() | 2221 | void CalendarView::edit_copy() |
@@ -2234,17 +2234,17 @@ void CalendarView::edit_copy() | |||
2234 | KNotifyClient::beep(); | 2234 | KNotifyClient::beep(); |
2235 | return; | 2235 | return; |
2236 | } | 2236 | } |
2237 | DndFactory factory( mCalendar ); | 2237 | DndFactory factory( mCalendar ); |
2238 | factory.copyEvent(anEvent); | 2238 | factory.copyIncidence(anEvent); |
2239 | } | 2239 | } |
2240 | 2240 | ||
2241 | void CalendarView::edit_paste() | 2241 | void CalendarView::edit_paste() |
2242 | { | 2242 | { |
2243 | QDate date = mNavigator->selectedDates().first(); | 2243 | QDate date = mNavigator->selectedDates().first(); |
2244 | 2244 | ||
2245 | DndFactory factory( mCalendar ); | 2245 | DndFactory factory( mCalendar ); |
2246 | Event *pastedEvent = factory.pasteEvent( date ); | 2246 | Event *pastedEvent = (Event *)factory.pasteIncidence( date ); |
2247 | 2247 | ||
2248 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); | 2248 | changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); |
2249 | } | 2249 | } |
2250 | 2250 | ||
diff --git a/korganizer/korganizer.pro b/korganizer/korganizer.pro index 4d67dca..3c7a1fb 100644 --- a/korganizer/korganizer.pro +++ b/korganizer/korganizer.pro | |||
@@ -8,11 +8,11 @@ DESTDIR= ../bin | |||
8 | include( ../variables.pri ) | 8 | include( ../variables.pri ) |
9 | 9 | ||
10 | INCLUDEPATH += ../microkde ../ interfaces ../microkde/kdecore ../microkde/kdeui ../microkde/kio/kfile ../microkde/kio/kio ../libkdepim | 10 | INCLUDEPATH += ../microkde ../ interfaces ../microkde/kdecore ../microkde/kdeui ../microkde/kio/kfile ../microkde/kio/kio ../libkdepim |
11 | #../qtcompat | 11 | #../qtcompat |
12 | DEFINES += KORG_NODND KORG_NOPLUGINS KORG_NOARCHIVE KORG_NOMAIL | 12 | DEFINES += KORG_NOPLUGINS KORG_NOARCHIVE KORG_NOMAIL |
13 | DEFINES += KORG_NODCOP KORG_NOKALARMD KORG_NORESOURCEVIEW KORG_NOSPLITTER | 13 | DEFINES += KORG_NODCOP KORG_NOKALARMD KORG_NORESOURCEVIEW KORG_NOSPLITTER |
14 | #KORG_NOPRINTER KORG_NOKABC | 14 | #KORG_NOPRINTER KORG_NOKABC KORG_NODND |
15 | DEFINES += KORG_NOLVALTERNATION | 15 | DEFINES += KORG_NOLVALTERNATION |
16 | DEFINES += DESKTOP_VERSION | 16 | DEFINES += DESKTOP_VERSION |
17 | unix : { | 17 | unix : { |
18 | LIBS += ../bin/libmicrokdepim.so | 18 | LIBS += ../bin/libmicrokdepim.so |
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 1fb480d..8c1953d 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -138,40 +138,40 @@ void KOTodoListView::contentsDropEvent(QDropEvent *e) | |||
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; | ||
143 | Incidence *to = destinationEvent; | 142 | Incidence *to = destinationEvent; |
144 | while(to) { | 143 | while(to) { |
145 | if (to->uid() == todo->uid()) { | 144 | if (to->uid() == todo->uid()) { |
146 | KMessageBox::sorry(this, | 145 | KMessageBox::sorry(this, |
147 | i18n("Cannot move To-Do to itself or a child of itself"), | 146 | i18n("Cannot move To-Do to itself\nor a child of itself"), |
148 | i18n("Drop To-Do")); | 147 | i18n("Drop To-Do")); |
149 | delete todo; | 148 | delete todo; |
150 | return; | 149 | return; |
151 | } | 150 | } |
152 | to = to->relatedTo(); | 151 | to = to->relatedTo(); |
153 | } | 152 | } |
154 | existingTodo->setRelatedTo(destinationEvent); | 153 | internalDrop = true; |
155 | emit todoDropped(todo); | 154 | if ( destinationEvent ) |
155 | reparentTodoSignal( destinationEvent, existingTodo ); | ||
156 | else | ||
157 | unparentTodoSignal(existingTodo); | ||
156 | delete todo; | 158 | delete todo; |
157 | } else { | 159 | } else { |
158 | // kdDebug() << "Drop new Todo" << endl; | ||
159 | todo->setRelatedTo(destinationEvent); | ||
160 | mCalendar->addTodo(todo); | 160 | mCalendar->addTodo(todo); |
161 | 161 | emit todoDropped(todo, KOGlobals::EVENTADDED); | |
162 | emit todoDropped(todo); | 162 | if ( destinationEvent ) |
163 | reparentTodoSignal( destinationEvent, todo ); | ||
163 | } | 164 | } |
164 | } | 165 | } |
165 | else { | 166 | else { |
166 | QString text; | 167 | QString text; |
167 | if (QTextDrag::decode(e,text)) { | 168 | if (QTextDrag::decode(e,text)) { |
168 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); | 169 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); |
169 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); | 170 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); |
170 | kdDebug() << "Dropped : " << text << endl; | 171 | qDebug("Dropped : " + text); |
171 | QStringList emails = QStringList::split(",",text); | 172 | QStringList emails = QStringList::split(",",text); |
172 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { | 173 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { |
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) { |
@@ -179,21 +179,21 @@ void KOTodoListView::contentsDropEvent(QDropEvent *e) | |||
179 | } | 179 | } |
180 | } | 180 | } |
181 | } | 181 | } |
182 | else { | 182 | else { |
183 | kdDebug() << "KOTodoListView::contentsDropEvent(): Todo from drop not decodable" << endl; | 183 | qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); |
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); | ||
193 | #ifndef KORG_NODND | 192 | #ifndef KORG_NODND |
194 | QPoint p(contentsToViewport(e->pos())); | 193 | QPoint p(contentsToViewport(e->pos())); |
195 | QListViewItem *i = itemAt(p); | 194 | QListViewItem *i = itemAt(p); |
195 | mMousePressed = false; | ||
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)) + |
@@ -206,37 +206,39 @@ void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) | |||
206 | } | 206 | } |
207 | } | 207 | } |
208 | } | 208 | } |
209 | #endif | 209 | #endif |
210 | QListView::contentsMousePressEvent(e); | ||
210 | } | 211 | } |
211 | 212 | ||
212 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) | 213 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) |
213 | { | 214 | { |
214 | 215 | ||
215 | #ifndef KORG_NODND | 216 | #ifndef KORG_NODND |
216 | // kdDebug() << "KOTodoListView::contentsMouseMoveEvent()" << endl; | ||
217 | QListView::contentsMouseMoveEvent(e); | 217 | QListView::contentsMouseMoveEvent(e); |
218 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > | 218 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > |
219 | QApplication::startDragDistance()) { | 219 | QApplication::startDragDistance()) { |
220 | mMousePressed = false; | 220 | mMousePressed = false; |
221 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); | 221 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); |
222 | if (item) { | 222 | if (item) { |
223 | // kdDebug() << "Start Drag for item " << item->text(0) << endl; | ||
224 | DndFactory factory( mCalendar ); | 223 | DndFactory factory( mCalendar ); |
225 | ICalDrag *vd = factory.createDragTodo( | 224 | ICalDrag *vd = factory.createDrag( |
226 | ((KOTodoViewItem *)item)->todo(),viewport()); | 225 | ((KOTodoViewItem *)item)->todo(),viewport()); |
226 | internalDrop = false; | ||
227 | // we cannot do any senseful here, because the DnD is still broken in Qt | ||
227 | if (vd->drag()) { | 228 | if (vd->drag()) { |
228 | kdDebug() << "KOTodoListView::contentsMouseMoveEvent(): Delete drag source" << endl; | 229 | if ( !internalDrop ) { |
230 | //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); | ||
231 | qDebug("Dnd: External move: Delete drag source "); | ||
232 | } else | ||
233 | qDebug("Dnd: Internal move "); | ||
234 | |||
235 | } else { | ||
236 | if ( !internalDrop ) { | ||
237 | qDebug("Dnd: External Copy"); | ||
238 | } else | ||
239 | qDebug("DnD: Internal copy: Copy pending"); | ||
229 | } | 240 | } |
230 | /* | ||
231 | QString source = fullPath(item); | ||
232 | if ( QFile::exists(source) ) { | ||
233 | QUriDrag* ud = new QUriDrag(viewport()); | ||
234 | ud->setFilenames( source ); | ||
235 | if ( ud->drag() ) | ||
236 | QMessageBox::information( this, "Drag source", | ||
237 | QString("Delete ")+source, "Not implemented" ); | ||
238 | */ | ||
239 | } | 241 | } |
240 | } | 242 | } |
241 | #endif | 243 | #endif |
242 | } | 244 | } |
@@ -488,10 +490,12 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | |||
488 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), | 490 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), |
489 | SLOT( itemClicked( QListViewItem * ) ) ); | 491 | SLOT( itemClicked( QListViewItem * ) ) ); |
490 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), | 492 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), |
491 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); | 493 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); |
492 | connect( mTodoListView, SIGNAL( todoDropped( Todo * ) ), | 494 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), |
493 | SLOT( updateView() ) ); | 495 | SLOT( updateView() ) ); |
496 | connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), | ||
497 | SLOT( todoModified(Todo *, int) ) ); | ||
494 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), | 498 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), |
495 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 499 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
496 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), | 500 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), |
497 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 501 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
@@ -503,8 +507,13 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | |||
503 | SLOT(selectionChanged(QListViewItem *))); | 507 | SLOT(selectionChanged(QListViewItem *))); |
504 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), | 508 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), |
505 | SLOT(selectionChanged(QListViewItem *))); | 509 | SLOT(selectionChanged(QListViewItem *))); |
506 | #endif | 510 | #endif |
511 | |||
512 | connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); | ||
513 | connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); | ||
514 | connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); | ||
515 | |||
507 | connect( mTodoListView, SIGNAL(selectionChanged() ), | 516 | connect( mTodoListView, SIGNAL(selectionChanged() ), |
508 | SLOT( processSelectionChange() ) ); | 517 | SLOT( processSelectionChange() ) ); |
509 | connect( mQuickAdd, SIGNAL( returnPressed () ), | 518 | connect( mQuickAdd, SIGNAL( returnPressed () ), |
510 | SLOT( addQuickTodo() ) ); | 519 | SLOT( addQuickTodo() ) ); |
diff --git a/korganizer/kotodoview.h b/korganizer/kotodoview.h index f11518d..68e29bb 100644 --- a/korganizer/kotodoview.h +++ b/korganizer/kotodoview.h | |||
@@ -59,11 +59,13 @@ class KOTodoListView : public KListView | |||
59 | KOTodoListView(Calendar *,QWidget *parent=0,const char *name=0); | 59 | KOTodoListView(Calendar *,QWidget *parent=0,const char *name=0); |
60 | virtual ~KOTodoListView() {} | 60 | virtual ~KOTodoListView() {} |
61 | 61 | ||
62 | signals: | 62 | signals: |
63 | void todoDropped(Todo *); | 63 | void todoDropped(Todo *, int); |
64 | void double_Clicked(QListViewItem *item); | 64 | void double_Clicked(QListViewItem *item); |
65 | 65 | void reparentTodoSignal( Todo *,Todo * ); | |
66 | void unparentTodoSignal(Todo *); | ||
67 | void deleteTodo( Todo * ); | ||
66 | protected: | 68 | protected: |
67 | void contentsDragEnterEvent(QDragEnterEvent *); | 69 | void contentsDragEnterEvent(QDragEnterEvent *); |
68 | void contentsDragMoveEvent(QDragMoveEvent *); | 70 | void contentsDragMoveEvent(QDragMoveEvent *); |
69 | void contentsDragLeaveEvent(QDragLeaveEvent *); | 71 | void contentsDragLeaveEvent(QDragLeaveEvent *); |
@@ -74,8 +76,9 @@ class KOTodoListView : public KListView | |||
74 | void contentsMouseReleaseEvent(QMouseEvent *); | 76 | void contentsMouseReleaseEvent(QMouseEvent *); |
75 | void contentsMouseDoubleClickEvent(QMouseEvent *); | 77 | void contentsMouseDoubleClickEvent(QMouseEvent *); |
76 | 78 | ||
77 | private: | 79 | private: |
80 | bool internalDrop; | ||
78 | QString mName; | 81 | QString mName; |
79 | Calendar *mCalendar; | 82 | Calendar *mCalendar; |
80 | QPoint mPressPos; | 83 | QPoint mPressPos; |
81 | bool mMousePressed; | 84 | bool mMousePressed; |
@@ -196,8 +199,10 @@ class KOTodoView : public KOrg::BaseView | |||
196 | 199 | ||
197 | protected slots: | 200 | protected slots: |
198 | void processSelectionChange(); | 201 | void processSelectionChange(); |
199 | void addQuickTodo(); | 202 | void addQuickTodo(); |
203 | void setTodoModified( Todo* ); | ||
204 | void todoModified(Todo *, int ); | ||
200 | 205 | ||
201 | private: | 206 | private: |
202 | /* | 207 | /* |
203 | * the TodoEditor approach is rather unscaling in the long | 208 | * the TodoEditor approach is rather unscaling in the long |
@@ -208,9 +213,8 @@ class KOTodoView : public KOrg::BaseView | |||
208 | * 3. add a private method for setting a todo modified + friend here? | 213 | * 3. add a private method for setting a todo modified + friend here? |
209 | * -- zecke 2002-07-08 | 214 | * -- zecke 2002-07-08 |
210 | */ | 215 | */ |
211 | friend class KOTodoViewItem; | 216 | friend class KOTodoViewItem; |
212 | void setTodoModified( Todo* ); | ||
213 | QMap<Todo *,KOTodoViewItem *>::ConstIterator insertTodoItem(Todo *todo); | 217 | QMap<Todo *,KOTodoViewItem *>::ConstIterator insertTodoItem(Todo *todo); |
214 | void restoreItemState( QListViewItem * ); | 218 | void restoreItemState( QListViewItem * ); |
215 | 219 | ||
216 | bool checkTodo( Todo * ); | 220 | bool checkTodo( Todo * ); |
@@ -234,9 +238,8 @@ class KOTodoView : public KOrg::BaseView | |||
234 | DocPrefs *mDocPrefs; | 238 | DocPrefs *mDocPrefs; |
235 | QString mCurrentDoc; | 239 | QString mCurrentDoc; |
236 | KOQuickTodo *mQuickAdd; | 240 | KOQuickTodo *mQuickAdd; |
237 | bool mBlockUpdate; | 241 | bool mBlockUpdate; |
238 | void todoModified(Todo *, int ); | ||
239 | void keyPressEvent ( QKeyEvent * ) ; | 242 | void keyPressEvent ( QKeyEvent * ) ; |
240 | KOTodoViewItem * pendingSubtodo; | 243 | KOTodoViewItem * pendingSubtodo; |
241 | DateNavigator* mNavigator; | 244 | DateNavigator* mNavigator; |
242 | }; | 245 | }; |