-rw-r--r-- | korganizer/kotodoview.cpp | 49 |
1 files changed, 34 insertions, 15 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index ccc4b01..0a315cb 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -194,51 +194,62 @@ void KOTodoListView::contentsDropEvent(QDropEvent *e) | |||
194 | QString email = (*it).mid(pos); | 194 | QString email = (*it).mid(pos); |
195 | if (!email.isEmpty() && todoi) { | 195 | if (!email.isEmpty() && todoi) { |
196 | todoi->todo()->addAttendee(new Attendee(name,email)); | 196 | todoi->todo()->addAttendee(new Attendee(name,email)); |
197 | } | 197 | } |
198 | } | 198 | } |
199 | } | 199 | } |
200 | else { | 200 | else { |
201 | qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); | 201 | qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); |
202 | e->ignore(); | 202 | e->ignore(); |
203 | } | 203 | } |
204 | } | 204 | } |
205 | #endif | 205 | #endif |
206 | } | 206 | } |
207 | 207 | ||
208 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) | 208 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) |
209 | { | 209 | { |
210 | |||
211 | QPoint p(contentsToViewport(e->pos())); | ||
212 | QListViewItem *i = itemAt(p); | ||
213 | bool rootClicked = true; | ||
214 | if (i) { | ||
215 | // if the user clicked into the root decoration of the item, don't | ||
216 | // try to start a drag! | ||
217 | int X = p.x(); | ||
218 | //qDebug("%d %d %d", X, header()->sectionPos(0), treeStepSize() ); | ||
219 | if (X > header()->sectionPos(0) + | ||
220 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + | ||
221 | itemMargin() || | ||
222 | X < header()->sectionPos(0)) { | ||
223 | rootClicked = false; | ||
224 | } | ||
225 | } | ||
210 | #ifndef KORG_NODND | 226 | #ifndef KORG_NODND |
211 | QPoint p(contentsToViewport(e->pos())); | 227 | mMousePressed = false; |
212 | QListViewItem *i = itemAt(p); | 228 | if (! rootClicked ) { |
213 | mMousePressed = false; | ||
214 | if (i) { | ||
215 | // if the user clicked into the root decoration of the item, don't | ||
216 | // try to start a drag! | ||
217 | if (p.x() > header()->sectionPos(header()->mapToIndex(0)) + | ||
218 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + | ||
219 | itemMargin() || | ||
220 | p.x() < header()->sectionPos(header()->mapToIndex(0))) { | ||
221 | if (e->button()==Qt::LeftButton) { | ||
222 | mPressPos = e->pos(); | 229 | mPressPos = e->pos(); |
223 | mMousePressed = true; | 230 | mMousePressed = true; |
224 | } | ||
225 | } | 231 | } |
226 | } | ||
227 | #endif | 232 | #endif |
228 | QListView::contentsMousePressEvent(e); | 233 | //qDebug("KOTodoListView::contentsMousePressEvent %d", rootClicked); |
234 | #ifndef DESKTOP_VERSION | ||
235 | if (!( e->button() == RightButton && rootClicked) ) | ||
236 | QListView::contentsMousePressEvent(e); | ||
237 | #else | ||
238 | QListView::contentsMousePressEvent(e); | ||
239 | #endif | ||
229 | } | 240 | } |
230 | void KOTodoListView::paintEvent(QPaintEvent* e) | 241 | void KOTodoListView::paintEvent(QPaintEvent* e) |
231 | { | 242 | { |
232 | emit paintNeeded(); | 243 | emit paintNeeded(); |
233 | QListView::paintEvent( e); | 244 | QListView::paintEvent( e); |
234 | } | 245 | } |
235 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) | 246 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) |
236 | { | 247 | { |
237 | 248 | ||
238 | #ifndef KORG_NODND | 249 | #ifndef KORG_NODND |
239 | //QListView::contentsMouseMoveEvent(e); | 250 | //QListView::contentsMouseMoveEvent(e); |
240 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > | 251 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > |
241 | QApplication::startDragDistance()*3) { | 252 | QApplication::startDragDistance()*3) { |
242 | mMousePressed = false; | 253 | mMousePressed = false; |
243 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); | 254 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); |
244 | if (item) { | 255 | if (item) { |
@@ -1050,44 +1061,52 @@ void KOTodoView::changedCategories(int index) | |||
1050 | categories.remove( colcat ); | 1061 | categories.remove( colcat ); |
1051 | categories.prepend( colcat ); | 1062 | categories.prepend( colcat ); |
1052 | } | 1063 | } |
1053 | } | 1064 | } |
1054 | mActiveItem->todo()->setCategories (categories); | 1065 | mActiveItem->todo()->setCategories (categories); |
1055 | mActiveItem->construct(); | 1066 | mActiveItem->construct(); |
1056 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1067 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1057 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); | 1068 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); |
1058 | } | 1069 | } |
1059 | } | 1070 | } |
1060 | void KOTodoView::itemDoubleClicked(QListViewItem *item) | 1071 | void KOTodoView::itemDoubleClicked(QListViewItem *item) |
1061 | { | 1072 | { |
1062 | if ( pendingSubtodo != 0 ) { | 1073 | if ( pendingSubtodo != 0 ) { |
1063 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 1074 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
1064 | } | 1075 | } |
1065 | pendingSubtodo = 0; | 1076 | pendingSubtodo = 0; |
1077 | int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); | ||
1078 | //qDebug("ROW %d ", row); | ||
1066 | if (!item) { | 1079 | if (!item) { |
1067 | newTodo(); | 1080 | newTodo(); |
1068 | return; | 1081 | return; |
1082 | } else { | ||
1083 | if ( row == 1 ) { | ||
1084 | mActiveItem = (KOTodoViewItem *) item; | ||
1085 | newSubTodo(); | ||
1086 | return; | ||
1087 | } | ||
1069 | } | 1088 | } |
1070 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 1089 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
1071 | editItem( item ); | 1090 | editItem( item ); |
1072 | else | 1091 | else |
1073 | showItem( item , QPoint(), 0 ); | 1092 | showItem( item , QPoint(), 0 ); |
1074 | } | 1093 | } |
1075 | void KOTodoView::itemClicked(QListViewItem *item) | 1094 | void KOTodoView::itemClicked(QListViewItem *item) |
1076 | { | 1095 | { |
1077 | 1096 | //qDebug("KOTodoView::itemClicked %d", item); | |
1078 | if (!item) { | 1097 | if (!item) { |
1079 | if ( pendingSubtodo != 0 ) { | 1098 | if ( pendingSubtodo != 0 ) { |
1080 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 1099 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
1081 | } | 1100 | } |
1082 | pendingSubtodo = 0; | 1101 | pendingSubtodo = 0; |
1083 | return; | 1102 | return; |
1084 | } | 1103 | } |
1085 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 1104 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
1086 | if ( pendingSubtodo != 0 ) { | 1105 | if ( pendingSubtodo != 0 ) { |
1087 | bool allowReparent = true; | 1106 | bool allowReparent = true; |
1088 | QListViewItem *par = item; | 1107 | QListViewItem *par = item; |
1089 | while ( par ) { | 1108 | while ( par ) { |
1090 | if ( par == pendingSubtodo ) { | 1109 | if ( par == pendingSubtodo ) { |
1091 | allowReparent = false; | 1110 | allowReparent = false; |
1092 | break; | 1111 | break; |
1093 | } | 1112 | } |