Changeset 6283 for trunk/qt4-gui/src/contactlist
- Timestamp:
- 06/14/08 03:47:03 (6 months ago)
- Location:
- trunk/qt4-gui/src/contactlist
- Files:
-
- 4 modified
-
contactgroup.cpp (modified) (3 diffs)
-
contactgroup.h (modified) (4 diffs)
-
contactlist.cpp (modified) (4 diffs)
-
contactlist.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/qt4-gui/src/contactlist/contactgroup.cpp
r6200 r6283 36 36 { 37 37 if (myGroupId != 0) 38 { 39 mySortKey.sprintf("%10i", myGroupId); 40 } 38 mySortKey = myGroupId; 41 39 else 42 {43 40 // Put "Other Users" last when sorting 44 mySortKey = QString("9999999999"); 45 } 46 41 mySortKey = 65535; 42 43 update(); 44 45 for (int i = 0; i < 3; ++i) 46 myBars[i] = new ContactBar(static_cast<ContactListModel::SubGroupType>(i), this); 47 } 48 49 ContactGroup::ContactGroup(const LicqGroup* group) 50 : ContactItem(ContactListModel::GroupItem), 51 myGroupId(group->id()), 52 myName(group->name().c_str()), 53 mySortKey(group->sortIndex()), 54 myEvents(0), 55 myVisibleContacts(0) 56 { 47 57 for (int i = 0; i < 3; ++i) 48 58 myBars[i] = new ContactBar(static_cast<ContactListModel::SubGroupType>(i), this); … … 61 71 void ContactGroup::update() 62 72 { 63 GroupList* g = gUserManager.LockGroupList(LOCK_R); 64 myName = QString::fromLocal8Bit((*g)[myGroupId-1]); 65 gUserManager.UnlockGroupList(); 66 67 emit dataChanged(this); 73 // System groups and "Other users" aren't present in daemon group list 74 if (myGroupId == 0 || myGroupId >= ContactListModel::SystemGroupOffset) 75 return; 76 77 LicqGroup* g = gUserManager.FetchGroup(myGroupId, LOCK_R); 78 if (g == NULL) 79 return; 80 81 myName = QString::fromLocal8Bit(g->name().c_str()); 82 mySortKey = g->sortIndex(); 83 gUserManager.DropGroup(g); 84 85 emit dataChanged(this); 86 } 87 88 void ContactGroup::updateSortKey() 89 { 90 // System groups and "Other users" aren't present in daemon group list 91 if (myGroupId == 0 || myGroupId >= ContactListModel::SystemGroupOffset) 92 return; 93 94 LicqGroup* g = gUserManager.FetchGroup(myGroupId, LOCK_R); 95 if (g == NULL) 96 return; 97 98 mySortKey = g->sortIndex(); 99 gUserManager.DropGroup(g); 68 100 } 69 101 … … 214 246 215 247 // Don't save new name here, daemon will signal us when name has changed 216 gUserManager.RenameGroup(myGroupId, newName.toLocal8Bit() );248 gUserManager.RenameGroup(myGroupId, newName.toLocal8Bit().data()); 217 249 218 250 return true; -
trunk/qt4-gui/src/contactlist/contactgroup.h
r6200 r6283 29 29 #include "contactlist.h" 30 30 31 class LicqGroup; 32 31 33 namespace LicqQtGui 32 34 { … … 50 52 * @param name Group name 51 53 */ 52 ContactGroup(unsigned short id, QString name); 54 ContactGroup(unsigned short id, QString name = QString()); 55 56 /** 57 * Constructor, creates an empty group 58 * 59 * @param group Group object from daemon 60 */ 61 ContactGroup(const LicqGroup* group); 53 62 54 63 /** … … 157 166 virtual bool setData(const QVariant& value, int role = ContactListModel::NameRole); 158 167 168 /** 169 * Update sort key for this group from daemon 170 */ 171 void updateSortKey(); 172 159 173 signals: 160 174 /** … … 171 185 unsigned short myGroupId; 172 186 QString myName; 173 QStringmySortKey;187 unsigned short mySortKey; 174 188 int myEvents; 175 189 QList<ContactUser*> myUsers; -
trunk/qt4-gui/src/contactlist/contactlist.cpp
r6270 r6283 103 103 { 104 104 unsigned short gid = sig->Argument(); 105 106 GroupList* g = gUserManager.LockGroupList(LOCK_R); 107 ContactGroup* newGroup = createGroup(gid, QString::fromLocal8Bit((*g)[gid-1])); 108 gUserManager.UnlockGroupList(); 105 ContactGroup* newGroup = createGroup(gid); 109 106 110 107 beginInsertRows(QModelIndex(), myUserGroups.size(), myUserGroups.size()); … … 144 141 break; 145 142 } 143 144 case LIST_GROUP_REORDERED: 145 { 146 // Get new sort keys for all groups 147 for (int i = 0; i < myUserGroups.size(); ++i) 148 myUserGroups.at(i)->updateSortKey(); 149 150 // Send one changed signal for all groups 151 emit dataChanged(createIndex(0, 0, myUserGroups.at(0)), 152 createIndex(myUserGroups.size() + NUM_GROUPS_SYSTEM_ALL - 1, myColumnCount - 1, 153 mySystemGroups[NUM_GROUPS_SYSTEM_ALL-1])); 154 155 break; 156 } 146 157 } 147 158 } … … 250 261 251 262 // Add all groups 252 GroupList* g = gUserManager.LockGroupList(LOCK_R); 253 beginInsertRows(QModelIndex(), 0, g->size()); 263 beginInsertRows(QModelIndex(), 0, gUserManager.NumGroups() + 1); 254 264 255 265 ContactGroup* newGroup = createGroup(0, tr("Other Users")); 256 266 myUserGroups.append(newGroup); 257 267 258 for (unsigned short i = 0; i < g->size(); ++i) 259 { 260 newGroup = createGroup(i+1, QString::fromLocal8Bit((*g)[i])); 261 myUserGroups.append(newGroup); 262 } 268 FOR_EACH_GROUP_START(LOCK_R) 269 { 270 ContactGroup* group = new ContactGroup(pGroup); 271 connect(group, SIGNAL(dataChanged(ContactGroup*)), 272 SLOT(groupDataChanged(ContactGroup*))); 273 connect(group, SIGNAL(barDataChanged(ContactBar*, int)), 274 SLOT(barDataChanged(ContactBar*, int))); 275 myUserGroups.append(group); 276 } 277 FOR_EACH_GROUP_END 263 278 264 279 endInsertRows(); 265 gUserManager.UnlockGroupList();266 280 267 281 // Add all users … … 307 321 unsigned short gid = group->groupId(); 308 322 bool shouldBeMember = (gid != 0 && licqUser->GetInGroup(GROUPS_USER, gid)) || 309 (gid == 0 && licqUser->GetGroups( GROUPS_USER) == 0&& !licqUser->IgnoreList());323 (gid == 0 && licqUser->GetGroups().empty() && !licqUser->IgnoreList()); 310 324 updateUserGroup(user, group, i, shouldBeMember); 311 325 } -
trunk/qt4-gui/src/contactlist/contactlist.h
r6197 r6283 74 74 ItemTypeRole = Qt::UserRole, // Type of item (one of enum ItemType) 75 75 NameRole, // Item name (alias for UserItems) 76 SortPrefixRole, // Primary sort index 77 SortRole, // S econdary sort index76 SortPrefixRole, // Primary sort index (UserItems only) 77 SortRole, // Sort index (secondary index for UserItems, only index for GroupItems) 78 78 UnreadEventsRole, // Number of unread events 79 79 EventSubCommandRole, // Type of event (UserItems only) … … 389 389 * 390 390 * @param id Id for the new group 391 * @param name Name for the new group 391 * @param name Name for the new group (only for non standard groups) 392 392 * @return The created group 393 393 */ 394 ContactGroup* createGroup(unsigned short id, QString name );394 ContactGroup* createGroup(unsigned short id, QString name = QString()); 395 395 396 396 /**
