Changeset 6283 for trunk/qt4-gui/src/core/groupmenu.cpp
- Timestamp:
- 06/14/08 03:47:03 (6 months ago)
- Files:
-
- 1 modified
-
trunk/qt4-gui/src/core/groupmenu.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/qt4-gui/src/core/groupmenu.cpp
r6279 r6283 89 89 delete a; 90 90 91 GroupList* g = gUserManager.LockGroupList(LOCK_R); 92 for (unsigned int i = 0; i < g->size(); ++i) 91 FOR_EACH_GROUP_START_SORTED(LOCK_R) 93 92 { 94 QString name = QString::fromLocal8Bit( (*g)[i]);93 QString name = QString::fromLocal8Bit(pGroup->name().c_str()); 95 94 96 95 a = myUserGroupActions->addAction(name); 97 a->setData( i + 1);96 a->setData(pGroup->id()); 98 97 99 98 myGroupsMenu->insertAction(myGroupSeparator, a); 100 99 } 101 gUserManager.UnlockGroupList();100 FOR_EACH_GROUP_END 102 101 103 102 // Add groups to menu … … 118 117 myMoveDownAction->setEnabled(!special && myGroupId < gUserManager.NumGroups()); 119 118 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 } 120 131 } 121 132 … … 133 144 void GroupMenu::moveGroupUp() 134 145 { 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); 137 150 } 138 151 139 152 void GroupMenu::moveGroupDown() 140 153 { 141 // Model uses group+1 so substract one before sending to daemon 142 gUserManager.SwapGroups(myGroupId, myGroupId + 1); 154 gUserManager.ModifyGroupSorting(myGroupId, mySortIndex + 1); 143 155 } 144 156 145 157 void GroupMenu::removeGroup() 146 158 { 147 GroupList* g = gUserManager.LockGroupList(LOCK_R);148 159 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)); 151 161 if (!QueryYesNo(this, warning)) 152 162 return; … … 177 187 gUserManager.SetUserInGroup(id.toLatin1(), ppid, gtype, gid, true, 178 188 gtype == GROUPS_SYSTEM); 179 180 // Daemon doesn't notify us when group memberships change so notify model from here181 LicqGui::instance()->contactList()->updateUser(id, ppid);182 189 } 183 190 }
