-rw-r--r-- | korganizer/kotodoview.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 99402c4..da8b4bc 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -125,218 +125,218 @@ void KOTodoListView::contentsDropEvent(QDropEvent *e) | |||
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 | Incidence *to = destinationEvent; | 142 | Incidence *to = destinationEvent; |
143 | while(to) { | 143 | while(to) { |
144 | if (to->uid() == todo->uid()) { | 144 | if (to->uid() == todo->uid()) { |
145 | KMessageBox::sorry(this, | 145 | KMessageBox::sorry(this, |
146 | i18n("Cannot move To-Do to itself\nor a child of itself"), | 146 | i18n("Cannot move To-Do to itself\nor a child of itself"), |
147 | i18n("Drop To-Do")); | 147 | i18n("Drop To-Do")); |
148 | delete todo; | 148 | delete todo; |
149 | return; | 149 | return; |
150 | } | 150 | } |
151 | to = to->relatedTo(); | 151 | to = to->relatedTo(); |
152 | } | 152 | } |
153 | internalDrop = true; | 153 | internalDrop = true; |
154 | if ( destinationEvent ) | 154 | if ( destinationEvent ) |
155 | reparentTodoSignal( destinationEvent, existingTodo ); | 155 | reparentTodoSignal( destinationEvent, existingTodo ); |
156 | else | 156 | else |
157 | unparentTodoSignal(existingTodo); | 157 | unparentTodoSignal(existingTodo); |
158 | delete todo; | 158 | delete todo; |
159 | } else { | 159 | } else { |
160 | mCalendar->addTodo(todo); | 160 | mCalendar->addTodo(todo); |
161 | emit todoDropped(todo, KOGlobals::EVENTADDED); | 161 | emit todoDropped(todo, KOGlobals::EVENTADDED); |
162 | if ( destinationEvent ) | 162 | if ( destinationEvent ) |
163 | reparentTodoSignal( destinationEvent, todo ); | 163 | reparentTodoSignal( destinationEvent, todo ); |
164 | } | 164 | } |
165 | } | 165 | } |
166 | else { | 166 | else { |
167 | QString text; | 167 | QString text; |
168 | if (QTextDrag::decode(e,text)) { | 168 | if (QTextDrag::decode(e,text)) { |
169 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); | 169 | //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); |
170 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); | 170 | KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); |
171 | qDebug("Dropped : " + text); | 171 | qDebug("Dropped : " + text); |
172 | QStringList emails = QStringList::split(",",text); | 172 | QStringList emails = QStringList::split(",",text); |
173 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { | 173 | for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { |
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 | qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); | 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 | #ifndef KORG_NODND | 192 | #ifndef KORG_NODND |
193 | QPoint p(contentsToViewport(e->pos())); | 193 | QPoint p(contentsToViewport(e->pos())); |
194 | QListViewItem *i = itemAt(p); | 194 | QListViewItem *i = itemAt(p); |
195 | mMousePressed = false; | 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)) + |
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 | QListView::contentsMousePressEvent(e); | 210 | QListView::contentsMousePressEvent(e); |
211 | } | 211 | } |
212 | void KOTodoListView::paintEvent(QPaintEvent* e) | 212 | void KOTodoListView::paintEvent(QPaintEvent* e) |
213 | { | 213 | { |
214 | emit paintNeeded(); | 214 | emit paintNeeded(); |
215 | QListView::paintEvent( e); | 215 | QListView::paintEvent( e); |
216 | } | 216 | } |
217 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) | 217 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) |
218 | { | 218 | { |
219 | 219 | ||
220 | #ifndef KORG_NODND | 220 | #ifndef KORG_NODND |
221 | QListView::contentsMouseMoveEvent(e); | 221 | //QListView::contentsMouseMoveEvent(e); |
222 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > | 222 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > |
223 | QApplication::startDragDistance()) { | 223 | QApplication::startDragDistance()*3) { |
224 | mMousePressed = false; | 224 | mMousePressed = false; |
225 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); | 225 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); |
226 | if (item) { | 226 | if (item) { |
227 | DndFactory factory( mCalendar ); | 227 | DndFactory factory( mCalendar ); |
228 | ICalDrag *vd = factory.createDrag( | 228 | ICalDrag *vd = factory.createDrag( |
229 | ((KOTodoViewItem *)item)->todo(),viewport()); | 229 | ((KOTodoViewItem *)item)->todo(),viewport()); |
230 | internalDrop = false; | 230 | internalDrop = false; |
231 | // we cannot do any senseful here, because the DnD is still broken in Qt | 231 | // we cannot do any senseful here, because the DnD is still broken in Qt |
232 | if (vd->drag()) { | 232 | if (vd->drag()) { |
233 | if ( !internalDrop ) { | 233 | if ( !internalDrop ) { |
234 | //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); | 234 | //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); |
235 | qDebug("Dnd: External move: Delete drag source "); | 235 | qDebug("Dnd: External move: Delete drag source "); |
236 | } else | 236 | } else |
237 | qDebug("Dnd: Internal move "); | 237 | qDebug("Dnd: Internal move "); |
238 | 238 | ||
239 | } else { | 239 | } else { |
240 | if ( !internalDrop ) { | 240 | if ( !internalDrop ) { |
241 | qDebug("Dnd: External Copy"); | 241 | qDebug("Dnd: External Copy"); |
242 | } else | 242 | } else |
243 | qDebug("DnD: Internal copy: Copy pending"); | 243 | qDebug("DnD: Internal copy: Copy pending"); |
244 | } | 244 | } |
245 | } | 245 | } |
246 | } | 246 | } |
247 | #endif | 247 | #endif |
248 | } | 248 | } |
249 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) | 249 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) |
250 | { | 250 | { |
251 | 251 | ||
252 | QListViewItem* cn; | 252 | QListViewItem* cn; |
253 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { | 253 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { |
254 | cn = currentItem(); | 254 | cn = currentItem(); |
255 | if ( cn ) { | 255 | if ( cn ) { |
256 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 256 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
257 | if ( ci ){ | 257 | if ( ci ){ |
258 | if ( e->state() == ShiftButton ) | 258 | if ( e->state() == ShiftButton ) |
259 | ci->setOn( false ); | 259 | ci->setOn( false ); |
260 | else | 260 | else |
261 | ci->setOn( true ); | 261 | ci->setOn( true ); |
262 | cn = cn->itemBelow(); | 262 | cn = cn->itemBelow(); |
263 | if ( cn ) { | 263 | if ( cn ) { |
264 | setCurrentItem ( cn ); | 264 | setCurrentItem ( cn ); |
265 | ensureItemVisible ( cn ); | 265 | ensureItemVisible ( cn ); |
266 | } | 266 | } |
267 | 267 | ||
268 | } | 268 | } |
269 | } | 269 | } |
270 | 270 | ||
271 | return; | 271 | return; |
272 | } | 272 | } |
273 | 273 | ||
274 | // qDebug("KOTodoListView::keyPressEvent "); | 274 | // qDebug("KOTodoListView::keyPressEvent "); |
275 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { | 275 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { |
276 | switch ( e->key() ) { | 276 | switch ( e->key() ) { |
277 | case Qt::Key_Down: | 277 | case Qt::Key_Down: |
278 | case Qt::Key_Up: | 278 | case Qt::Key_Up: |
279 | QListView::keyPressEvent ( e ); | 279 | QListView::keyPressEvent ( e ); |
280 | break; | 280 | break; |
281 | case Qt::Key_Left: | 281 | case Qt::Key_Left: |
282 | case Qt::Key_Right: | 282 | case Qt::Key_Right: |
283 | QListView::keyPressEvent ( e ); | 283 | QListView::keyPressEvent ( e ); |
284 | e->accept(); | 284 | e->accept(); |
285 | return; | 285 | return; |
286 | break; | 286 | break; |
287 | default: | 287 | default: |
288 | e->ignore(); | 288 | e->ignore(); |
289 | break; | 289 | break; |
290 | } | 290 | } |
291 | return; | 291 | return; |
292 | } | 292 | } |
293 | e->ignore(); | 293 | e->ignore(); |
294 | } | 294 | } |
295 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) | 295 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) |
296 | { | 296 | { |
297 | QListView::contentsMouseReleaseEvent(e); | 297 | QListView::contentsMouseReleaseEvent(e); |
298 | mMousePressed = false; | 298 | mMousePressed = false; |
299 | } | 299 | } |
300 | 300 | ||
301 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 301 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) |
302 | { | 302 | { |
303 | if (!e) return; | 303 | if (!e) return; |
304 | 304 | ||
305 | QPoint vp = contentsToViewport(e->pos()); | 305 | QPoint vp = contentsToViewport(e->pos()); |
306 | 306 | ||
307 | QListViewItem *item = itemAt(vp); | 307 | QListViewItem *item = itemAt(vp); |
308 | 308 | ||
309 | emit double_Clicked(item); | 309 | emit double_Clicked(item); |
310 | if (!item) return; | 310 | if (!item) return; |
311 | 311 | ||
312 | emit doubleClicked(item,vp,0); | 312 | emit doubleClicked(item,vp,0); |
313 | } | 313 | } |
314 | 314 | ||
315 | ///////////////////////////////////////////////////////////////////////////// | 315 | ///////////////////////////////////////////////////////////////////////////// |
316 | 316 | ||
317 | KOQuickTodo::KOQuickTodo(QWidget *parent) : | 317 | KOQuickTodo::KOQuickTodo(QWidget *parent) : |
318 | QLineEdit(parent) | 318 | QLineEdit(parent) |
319 | { | 319 | { |
320 | setText(i18n("Click to add a new Todo")); | 320 | setText(i18n("Click to add a new Todo")); |
321 | } | 321 | } |
322 | 322 | ||
323 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) | 323 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) |
324 | { | 324 | { |
325 | if ( text()==i18n("Click to add a new Todo") ) | 325 | if ( text()==i18n("Click to add a new Todo") ) |
326 | setText(""); | 326 | setText(""); |
327 | QLineEdit::focusInEvent(ev); | 327 | QLineEdit::focusInEvent(ev); |
328 | } | 328 | } |
329 | 329 | ||
330 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) | 330 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) |
331 | { | 331 | { |
332 | setText(i18n("Click to add a new Todo")); | 332 | setText(i18n("Click to add a new Todo")); |
333 | QLineEdit::focusOutEvent(ev); | 333 | QLineEdit::focusOutEvent(ev); |
334 | } | 334 | } |
335 | 335 | ||
336 | ///////////////////////////////////////////////////////////////////////////// | 336 | ///////////////////////////////////////////////////////////////////////////// |
337 | 337 | ||
338 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | 338 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : |
339 | KOrg::BaseView(calendar,parent,name) | 339 | KOrg::BaseView(calendar,parent,name) |
340 | { | 340 | { |
341 | mPendingUpdateBeforeRepaint = false; | 341 | mPendingUpdateBeforeRepaint = false; |
342 | isFlatDisplay = false; | 342 | isFlatDisplay = false; |