diff -Naur --exclude='*orig' psi-0.10-test3-orig/src/contactview.cpp psi-0.10-test3/src/contactview.cpp --- psi-0.10-test3-orig/src/contactview.cpp 2005-11-08 22:16:14.000000000 +0000 +++ psi-0.10-test3/src/contactview.cpp 2005-11-08 22:19:44.000000000 +0000 @@ -1244,7 +1244,7 @@ str += QString("%1. %2").arg(n+1).arg(*it); gm->insertItem(str, n+base_group); - if(*it == g) + if(u->inGroup(*it)) gm->setItemChecked(n+base_group, true); ++n; } @@ -1370,8 +1370,9 @@ if(online) { // if we have groups, but we are setting to 'none', then remove that particular group if(!u->groups().isEmpty()) { - QString gname = groupNameCache; - actionGroupRemove(u->jid(), gname); + for(QStringList::ConstIterator it = gl.begin(); it != gl.end(); ++it) { + actionGroupRemove(u->jid(), *it); + } } } } @@ -1386,17 +1387,7 @@ continue; // make sure we don't have it already - bool found = false; - const QStringList &groups = u->groups(); - for(QStringList::ConstIterator it = groups.begin(); it != groups.end(); ++it) { - if(*it == newgroup) { - found = true; - break; - } - } - if(!found) { - QString gname = groupNameCache; - actionGroupRemove(u->jid(), gname); + if (!u->inGroup(newgroup)) { actionGroupAdd(u->jid(), newgroup); break; } @@ -1518,16 +1509,40 @@ ++n; } - if(newgroup.isEmpty()) + if(newgroup.isEmpty()) { newgroup = ContactView::tr("Hidden"); + if (!u->inGroup(newgroup)) { + // clicking on 'hidden' when it wasn't previously + // selected will deselect all groups + for(QStringList::ConstIterator it = gl.begin(); it != gl.end(); ++it) { + actionGroupRemove(u->jid(), *it); + } + } + // if hidden group was already selected, it'll + // be deselected only if contact is in other + // groups too + } + else + { + // a specific group was selected; make sure + // this contact isn't in the 'hidden' group. + QString h = ContactView::tr("Hidden"); + if (u->inGroup(h)) + { + actionGroupRemove(u->jid(), h); + } + } - if(n == n2) { - // remove the group of this cvi if there is one - if(!u->groups().isEmpty()) { - //QString gname = ((ContactViewItem *)static_cast(i)->parent())->groupName(); - QString gname = groupNameCache; - actionGroupRemove(u->jid(), gname); + if (u->inGroup(newgroup)) + { + // we're already in this group. If contact is + // in multiple groups, remove it. + if (u->groups().count() > 1) { + actionGroupRemove(u->jid(), newgroup); } + } + else + { // add the group actionGroupAdd(u->jid(), newgroup); } @@ -1697,7 +1712,7 @@ } } -void ContactProfile::dragDrop(const Jid &jid, ContactViewItem *i) +void ContactProfile::dragDrop(const Jid &jid, ContactViewItem *i, ContactViewItem *o = 0) { if(!d->pa->loggedIn()) return; @@ -1720,20 +1735,27 @@ // already in the general group if(gr->groupType() == ContactViewItem::gGeneral && gl.isEmpty()) return; - // already in this user group - if(gr->groupType() == ContactViewItem::gUser && u.inGroup(gr->groupName())) + + if(gr->groupType() != ContactViewItem::gUser) return; - //printf("putting [%s] into group [%s]\n", u.jid().full().latin1(), gr->groupName().latin1()); + if (o) { + Jid j = o->u()->jid(); + // o really can't be a group + if (o->type() != ContactViewItem::Group) + o = (ContactViewItem *) (static_cast(o)->parent()); - // remove all other groups from this contact - for(QStringList::ConstIterator it = gl.begin(); it != gl.end(); ++it) { - actionGroupRemove(u.jid(), *it); + if(gr->groupName() == o->groupName()) + return; + + if (o) { + actionGroupRemove(j, o->groupName()); + } } - if(gr->groupType() == ContactViewItem::gUser) { - // add the new group + + // add the new group + if(!u.inGroup(gr->groupName())) actionGroupAdd(u.jid(), gr->groupName()); - } } void ContactProfile::dragDropFiles(const QStringList &files, ContactViewItem *i) @@ -3460,6 +3482,13 @@ // if(!QTextDrag::decode(m, str)) // return false; + if (QDropEvent* e = const_cast((const QDropEvent*)(m))) + { + QDropEvent::Action a = e->action(); + if ((a == QDropEvent::Copy) || (a == QDropEvent::Move)) + e->acceptAction(); + } + return true; } @@ -3509,6 +3538,22 @@ if(JidDrag::decode(i, jids)) { for_each(jids.begin(), jids.end(), DroppedJidFunk(this)); } + + QString text; + if (QTextDrag::decode(i, text)) { + ContactViewItem* old = 0; + + if (i->action() == QDropEvent::Move) { + if (QListView* src = dynamic_cast(i->source())) { + old = (ContactViewItem*)(src->selectedItem()); + i->acceptAction(); + } + } + + i->accept(); + + d->cp->dragDrop(text, this, old); + } } } diff -Naur --exclude='*orig' psi-0.10-test3-orig/src/contactview.h psi-0.10-test3/src/contactview.h --- psi-0.10-test3-orig/src/contactview.h 2005-11-08 22:16:14.000000000 +0000 +++ psi-0.10-test3/src/contactview.h 2005-11-08 22:19:44.000000000 +0000 @@ -173,7 +173,7 @@ friend class ContactViewItem; friend class DroppedJidFunk; - void dragDrop(const Jid &, ContactViewItem *); + void dragDrop(const Jid &, ContactViewItem *, ContactViewItem *); void dragDropFiles(const QStringList &, ContactViewItem *); };