Show
Ignore:
Timestamp:
06/14/08 04:06:02 (6 months ago)
Author:
eugene
Message:

Merged r6260:6264 from SVNROOT/branches/qt4-gui_group

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/qt4-gui/src/dialogs/adduserdlg.cpp

    r6252 r6287  
    3131#include "helpers/support.h" 
    3232 
     33#include "widgets/groupcombobox.h" 
    3334#include "widgets/protocombobox.h" 
    3435 
     
    5556  layDialog->addWidget(myProtocol, line++, 1); 
    5657 
    57   QLabel* lblUin = new QLabel(tr("New &User ID:")); 
    58   myUin = new QLineEdit(); 
     58  QLabel* lblGroup = new QLabel(tr("&Group:")); 
     59  myGroup = new GroupComboBox(); 
     60  myGroup->setCurrentGroupId(gUserManager.NewUserGroup()); 
     61  lblGroup->setBuddy(myGroup); 
     62 
     63  layDialog->addWidget(lblGroup, line, 0); 
     64  layDialog->addWidget(myGroup, line++, 1); 
     65 
     66  QLabel* lblId = new QLabel(tr("New &User ID:")); 
     67  myId = new QLineEdit(); 
    5968  if (!id.isEmpty()) 
    60     myUin->setText(id); 
    61   connect(myUin, SIGNAL(returnPressed()), SLOT(ok())); 
    62   lblUin->setBuddy(myUin); 
     69    myId->setText(id); 
     70  connect(myId, SIGNAL(returnPressed()), SLOT(ok())); 
     71  lblId->setBuddy(myId); 
    6372 
    64   layDialog->addWidget(lblUin, line, 0); 
    65   layDialog->addWidget(myUin, line++, 1); 
     73  layDialog->addWidget(lblId, line, 0); 
     74  layDialog->addWidget(myId, line++, 1); 
    6675 
    6776  myNotify = new QCheckBox(tr("&Notify User")); 
     
    7786  layDialog->addWidget(buttons, line++, 0, 1, 2); 
    7887 
    79   myUin->setFocus(); 
     88  myId->setFocus(); 
    8089  show(); 
    8190} 
     
    8392void AddUserDlg::ok() 
    8493{ 
    85   QString uin = myUin->text(); 
     94  QByteArray id = myId->text().trimmed().toLatin1(); 
     95  unsigned long ppid = myProtocol->currentPpid(); 
     96  unsigned short group = myGroup->currentGroupId(); 
     97  bool notify = myNotify->isChecked(); 
    8698 
    87   if (!uin.isEmpty()) 
    88     gLicqDaemon->AddUserToList(uin.toLatin1(), myProtocol->currentPpid(), 
    89         myNotify->isChecked()); 
     99  if (!id.isEmpty()) 
     100  { 
     101    ICQUser* u = gUserManager.FetchUser(id, ppid, LOCK_W); 
     102 
     103    if (u == NULL) 
     104    { 
     105      unsigned short currentNewGroup = gUserManager.NewUserGroup(); 
     106      gUserManager.SetNewUserGroup(group); 
     107      gLicqDaemon->AddUserToList(id, ppid, notify); 
     108      gUserManager.SetNewUserGroup(currentNewGroup); 
     109    } 
     110    else 
     111    { 
     112      if (u->NotInList()) 
     113      { 
     114        u->SetPermanent(); 
     115        gUserManager.DropUser(u); 
     116        gUserManager.AddUserToGroup(id.toLatin1()); 
     117        if (notify && ppid == LICQ_PPID) 
     118          gLicqDaemon->icqAlertUser(id.toULong()); 
     119      } 
     120      else 
     121        gUserManager.DropUser(u); 
     122    } 
     123  } 
    90124 
    91125  close();