Changeset 6200 for trunk/qt4-gui/src/contactlist
- Timestamp:
- 05/25/08 06:25:18 (6 months ago)
- Location:
- trunk/qt4-gui/src/contactlist
- Files:
-
- 3 modified
-
contactgroup.cpp (modified) (3 diffs)
-
contactgroup.h (modified) (1 diff)
-
contactlist.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/qt4-gui/src/contactlist/contactgroup.cpp
r6150 r6200 21 21 #include "contactgroup.h" 22 22 23 #include <licq_user.h> 24 23 25 #include "contactbar.h" 24 26 #include "contactuser.h" … … 55 57 for (int i = 0; i < 3; ++i) 56 58 delete myBars[i]; 59 } 60 61 void ContactGroup::update() 62 { 63 GroupList* g = gUserManager.LockGroupList(LOCK_R); 64 myName = QString::fromLocal8Bit((*g)[myGroupId-1]); 65 gUserManager.UnlockGroupList(); 66 67 emit dataChanged(this); 57 68 } 58 69 … … 198 209 return false; 199 210 200 if (value.toString() == myName) 211 QString newName = value.toString(); 212 if (newName == myName) 201 213 return true; 202 214 203 myName = value.toString(); 204 gUserManager.RenameGroup(myGroupId, myName.toLocal8Bit()); 205 206 // Daemon doesn't signal when groups change so trigger update from here 207 emit dataChanged(this); 215 // Don't save new name here, daemon will signal us when name has changed 216 gUserManager.RenameGroup(myGroupId, newName.toLocal8Bit()); 208 217 209 218 return true; -
trunk/qt4-gui/src/contactlist/contactgroup.h
r6150 r6200 56 56 */ 57 57 virtual ~ContactGroup(); 58 59 /** 60 * Group data in daemon has changed and needs to be refetched 61 */ 62 void update(); 58 63 59 64 /** -
trunk/qt4-gui/src/contactlist/contactlist.cpp
r6198 r6200 56 56 } 57 57 58 ContactListModel::~ContactListModel()59 {60 // Delete all users and groups61 clear();62 63 // Delete the system groups64 for (unsigned long i = 0; i < NUM_GROUPS_SYSTEM_ALL; ++i)65 delete mySystemGroups[i];66 }67 68 58 ContactGroup* ContactListModel::createGroup(unsigned short id, QString name) 69 59 { … … 76 66 } 77 67 68 ContactListModel::~ContactListModel() 69 { 70 // Delete all users and groups 71 clear(); 72 73 // Delete the system groups 74 for (unsigned long i = 0; i < NUM_GROUPS_SYSTEM_ALL; ++i) 75 delete mySystemGroups[i]; 76 } 77 78 78 void ContactListModel::listUpdated(CICQSignal* sig) 79 79 { 80 80 switch(sig->SubSignal()) 81 81 { 82 case LIST_ ALL:82 case LIST_INVALIDATE: 83 83 reloadAll(); 84 84 break; 85 85 86 case LIST_ ADD:86 case LIST_CONTACT_ADDED: 87 87 { 88 88 ICQUser* u = gUserManager.FetchUser(sig->Id(), sig->PPID(), LOCK_R); … … 96 96 break; 97 97 } 98 case LIST_ REMOVE:98 case LIST_CONTACT_REMOVED: 99 99 removeUser(sig->Id(), sig->PPID()); 100 100 break; 101 102 case LIST_GROUP_ADDED: 103 { 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(); 109 110 beginInsertRows(QModelIndex(), myUserGroups.size(), myUserGroups.size()); 111 myUserGroups.append(newGroup); 112 endInsertRows(); 113 break; 114 } 115 116 case LIST_GROUP_REMOVED: 117 { 118 unsigned short gid = sig->Argument(); 119 120 for (int i = 0; i < myUserGroups.size(); ++i) 121 { 122 ContactGroup* group = myUserGroups.at(i); 123 if (group->groupId() == gid) 124 { 125 beginRemoveRows(QModelIndex(), i, i); 126 myUserGroups.removeAll(group); 127 endRemoveRows(); 128 delete group; 129 } 130 } 131 break; 132 } 133 134 case LIST_GROUP_CHANGED: 135 { 136 unsigned short gid = sig->Argument(); 137 138 for (int i = 0; i < myUserGroups.size(); ++i) 139 { 140 ContactGroup* group = myUserGroups.at(i); 141 if (group->groupId() == gid) 142 group->update(); 143 } 144 break; 145 } 101 146 } 102 147 }
