Changeset 6319 for trunk/qt4-gui/src

Show
Ignore:
Timestamp:
06/17/08 02:19:46 (6 months ago)
Author:
flynd
Message:

Use new group handling when pressing delete key to remove a user from a group.

Location:
trunk/qt4-gui/src/core
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/qt4-gui/src/core/licqgui.cpp

    r6318 r6319  
    736736    return true; 
    737737  } 
    738   return false; 
    739 } 
    740  
    741 bool LicqGui::removeUserFromGroup(GroupType gtype, unsigned long group, 
    742     QString id, unsigned long ppid, QWidget* parent) 
    743 { 
    744   if (parent == NULL) 
    745     parent = myMainWindow; 
    746  
    747   if (gtype == GROUPS_USER) 
    748   { 
    749     if (group == 0) 
    750       return true; 
    751     else 
    752     { 
    753       ICQUser* u = gUserManager.FetchUser(id.toLatin1(), ppid, LOCK_R); 
    754       if (u == NULL) 
    755         return true; 
    756       LicqGroup* g = gUserManager.FetchGroup(group, LOCK_R); 
    757       if (g == NULL) 
    758       { 
    759         gUserManager.DropUser(u); 
    760         return true; 
    761       } 
    762       QString warning(tr("Are you sure you want to remove\n%1 (%2)\nfrom the '%3' group?") 
    763           .arg(QString::fromUtf8(u->GetAlias())) 
    764           .arg(u->IdString()).arg(QString::fromLocal8Bit(g->name().c_str()))); 
    765       gUserManager.DropGroup(g); 
    766       gUserManager.DropUser(u); 
    767       if (QueryYesNo(parent, warning)) 
    768       { 
    769         gUserManager.RemoveUserFromGroup(id.toLatin1(), ppid, group); 
    770         return true; 
    771       } 
    772     } 
    773   } 
    774   else if (gtype == GROUPS_SYSTEM) 
    775   { 
    776     if (group == 0) 
    777       return removeUserFromList(id, ppid, parent); 
    778     ICQUser* u = gUserManager.FetchUser(id.toLatin1(), ppid, LOCK_W); 
    779     if (u == NULL) 
    780       return true; 
    781     u->RemoveFromGroup(GROUPS_SYSTEM, group); 
    782     gUserManager.DropUser(u); 
    783  
    784     // The daemon does not send an update when group membership changes 
    785     // so tell the contactList it needs to update 
    786     myContactList->updateUser(id, ppid); 
    787     return true; 
    788   } 
    789  
    790738  return false; 
    791739} 
  • trunk/qt4-gui/src/core/licqgui.h

    r6185 r6319  
    109109 
    110110  /** 
    111    * Remove a contact from a group 
    112    * 
    113    * @param gtype Group type 
    114    * @param group Group id 
    115    * @param id Contact id 
    116    * @param ppid Contact protocol id 
    117    * @param parent Parent window to use for confirmation box or NULL to use mainwin 
    118    * @return true if contact was removed from group 
    119    */ 
    120   bool removeUserFromGroup(GroupType gtype, unsigned long group, 
    121       QString id, unsigned long ppid, QWidget* parent = NULL); 
    122  
    123   /** 
    124111   * Show contact info dialog 
    125112   * 
  • trunk/qt4-gui/src/core/mainwin.cpp

    r6283 r6319  
    502502void MainWindow::removeUserFromGroup() 
    503503{ 
     504  GroupType gtype = Config::ContactList::instance()->groupType(); 
     505  unsigned short gid = Config::ContactList::instance()->groupId(); 
     506 
     507  // Removing "All users" is the same as removing user from the list 
     508  if (gtype == GROUPS_SYSTEM && gid == 0) 
     509  { 
     510    removeUserFromList(); 
     511    return; 
     512  } 
     513 
     514  // Removing user from "Other users" is not allowed 
     515  if (gtype == GROUPS_USER && gid == 0) 
     516    return; 
     517 
     518  // Get currently selected user 
    504519  QString id; 
    505520  unsigned long ppid = 0; 
    506521  myUserView->MainWindowSelectedItemUser(id, ppid); 
    507522 
    508   LicqGui::instance()->removeUserFromGroup( 
    509       Config::ContactList::instance()->groupType(), 
    510       Config::ContactList::instance()->groupId(), 
    511       id, ppid, this); 
     523  gUserManager.SetUserInGroup(id.toLatin1(), ppid, GROUPS_USER, gid, false); 
    512524} 
    513525 
     
    728740void MainWindow::setCurrentGroup(int groupId) 
    729741{ 
     742//TODO: This is bugged 
    730743  GroupType groupType = GROUPS_USER; 
    731744  unsigned short nNumGroups = gUserManager.NumGroups();