Show
Ignore:
Timestamp:
06/11/08 08:25:24 (6 months ago)
Author:
eugene
Message:

Applied the latest version of flynd's qt4-gui patch.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/qt4-gui_group/src/core/groupmenu.cpp

    r6200 r6259  
    8989    delete a; 
    9090 
    91   GroupList* g = gUserManager.LockGroupList(LOCK_R); 
    92   for (unsigned int i = 0; i < g->size(); ++i) 
    93   { 
    94     QString name = QString::fromLocal8Bit((*g)[i]); 
     91  FOR_EACH_GROUP_START_SORTED(LOCK_R) 
     92  { 
     93    QString name = QString::fromLocal8Bit(pGroup->name().c_str()); 
    9594 
    9695    a = myUserGroupActions->addAction(name); 
    97     a->setData(i + 1); 
     96    a->setData(pGroup->id()); 
    9897 
    9998    myGroupsMenu->insertAction(myGroupSeparator, a); 
    10099  } 
    101   gUserManager.UnlockGroupList(); 
     100  FOR_EACH_GROUP_END 
    102101 
    103102  // Add groups to menu 
     
    118117  myMoveDownAction->setEnabled(!special && myGroupId < gUserManager.NumGroups()); 
    119118  myRemoveGroupAction->setEnabled(!special); 
     119 
     120  mySortIndex = 0; 
     121  if (!special) 
     122  { 
     123    LicqGroup* group = gUserManager.FetchGroup(myGroupId, LOCK_R); 
     124    if (group != NULL) 
     125    { 
     126      mySortIndex = group->sortIndex(); 
     127      myGroupName = QString::fromLocal8Bit(group->name().c_str()); 
     128      gUserManager.DropGroup(group); 
     129    } 
     130  } 
    120131} 
    121132 
     
    133144void GroupMenu::moveGroupUp() 
    134145{ 
    135   // Model uses group+1 so substract one before sending to daemon 
    136   gUserManager.SwapGroups(myGroupId, myGroupId - 1); 
     146  if (mySortIndex == 0) 
     147    return; 
     148 
     149  gUserManager.ModifyGroupSorting(myGroupId, mySortIndex - 1); 
    137150} 
    138151 
    139152void GroupMenu::moveGroupDown() 
    140153{ 
    141   // Model uses group+1 so substract one before sending to daemon 
    142   gUserManager.SwapGroups(myGroupId, myGroupId + 1); 
     154  gUserManager.ModifyGroupSorting(myGroupId, mySortIndex + 1); 
    143155} 
    144156 
    145157void GroupMenu::removeGroup() 
    146158{ 
    147   GroupList* g = gUserManager.LockGroupList(LOCK_R); 
    148159  QString warning(tr("Are you sure you want to remove the group '%1'?") 
    149       .arg(QString::fromLocal8Bit((*g)[myGroupId-1]))); 
    150   gUserManager.UnlockGroupList(); 
     160      .arg(myGroupName)); 
    151161  if (!QueryYesNo(this, warning)) 
    152162    return;