summaryrefslogtreecommitdiffabout
path: root/korganizer/kotodoview.cpp
Side-by-side diff
Diffstat (limited to 'korganizer/kotodoview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kotodoview.cpp61
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
@@ -130,121 +130,123 @@ void KOTodoListView::contentsDropEvent(QDropEvent *e)
if (todo) {
e->acceptAction();
KOTodoViewItem *destination =
(KOTodoViewItem *)itemAt(contentsToViewport(e->pos()));
Todo *destinationEvent = 0;
if (destination) destinationEvent = destination->todo();
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 {
QString text;
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);
if (!email.isEmpty() && todoi) {
todoi->todo()->addAttendee(new Attendee(name,email));
}
}
}
else {
- kdDebug() << "KOTodoListView::contentsDropEvent(): Todo from drop not decodable" << endl;
+ qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable ");
e->ignore();
}
}
#endif
}
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!
if (p.x() > header()->sectionPos(header()->mapToIndex(0)) +
treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) +
itemMargin() ||
p.x() < header()->sectionPos(header()->mapToIndex(0))) {
if (e->button()==Qt::LeftButton) {
mPressPos = e->pos();
mMousePressed = true;
}
}
}
#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
}
void KOTodoListView::keyPressEvent ( QKeyEvent * e )
{
QListViewItem* cn;
if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) {
cn = currentItem();
if ( cn ) {
KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
@@ -480,39 +482,46 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
/*
connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *,
const QPoint &,int ) ),
SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
*/
connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *,
const QPoint &,int ) ),
SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ),
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 * ) ),
SLOT( itemStateChanged( QListViewItem * ) ) );
#if 0
connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)),
SLOT(selectionChanged(QListViewItem *)));
connect(mTodoListView,SIGNAL(clicked(QListViewItem *)),
SLOT(selectionChanged(QListViewItem *)));
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 () ),
SLOT( addQuickTodo() ) );
}
KOTodoView::~KOTodoView()
{
delete mDocPrefs;
}