Changeset 6200
- Timestamp:
- 05/25/08 06:25:18 (8 months ago)
- Location:
- trunk/qt4-gui/src
- Files:
-
- 8 modified
-
contactlist/contactgroup.cpp (modified) (3 diffs)
-
contactlist/contactgroup.h (modified) (1 diff)
-
contactlist/contactlist.cpp (modified) (3 diffs)
-
core/groupmenu.cpp (modified) (4 diffs)
-
core/licqgui.cpp (modified) (2 diffs)
-
core/mainwin.cpp (modified) (1 diff)
-
dialogs/editgrpdlg.cpp (modified) (2 diffs)
-
dialogs/editgrpdlg.h (modified) (1 diff)
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 } -
trunk/qt4-gui/src/core/groupmenu.cpp
r6154 r6200 89 89 delete a; 90 90 91 ContactListModel* list = LicqGui::instance()->contactList(); 92 int groupCount = list->rowCount(QModelIndex()); 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]); 93 95 94 for (int i = 0; i < groupCount; ++i) 95 { 96 QModelIndex groupIndex = list->index(i, 0, QModelIndex()); 97 unsigned int groupId = groupIndex.data(ContactListModel::GroupIdRole).toUInt(); 96 a = myUserGroupActions->addAction(name); 97 a->setData(i + 1); 98 98 99 // Don't add system groups or other users group 100 if (groupId == 0 || groupId >= ContactListModel::SystemGroupOffset) 101 continue; 102 103 a = myUserGroupActions->addAction(groupIndex.data(ContactListModel::NameRole).toString()); 104 a->setData(groupId); 99 myGroupsMenu->insertAction(myGroupSeparator, a); 105 100 } 101 gUserManager.UnlockGroupList(); 106 102 107 103 // Add groups to menu … … 139 135 // Model uses group+1 so substract one before sending to daemon 140 136 gUserManager.SwapGroups(myGroupId, myGroupId - 1); 141 142 // Daemon doesn't notify us when groups change so notify model from here143 LicqGui::instance()->contactList()->reloadAll();144 LicqGui::instance()->mainWindow()->updateGroups();145 137 } 146 138 … … 149 141 // Model uses group+1 so substract one before sending to daemon 150 142 gUserManager.SwapGroups(myGroupId, myGroupId + 1); 151 152 // Daemon doesn't notify us when groups change so notify model from here153 LicqGui::instance()->contactList()->reloadAll();154 LicqGui::instance()->mainWindow()->updateGroups();155 143 } 156 144 … … 165 153 166 154 gUserManager.RemoveGroup(myGroupId); 167 168 // Daemon doesn't notify us when groups change so notify model from here169 LicqGui::instance()->contactList()->reloadAll();170 LicqGui::instance()->mainWindow()->updateGroups();171 155 } 172 156 -
trunk/qt4-gui/src/core/licqgui.cpp
r6190 r6200 1389 1389 switch (sig->SubSignal()) 1390 1390 { 1391 case LIST_ALL:1392 // Handled by ContactListModel1393 break;1394 1395 1391 case LIST_ADD: 1396 1392 { … … 1459 1455 } 1460 1456 1457 case LIST_ALL: 1458 case LIST_GROUP_ADDED: 1459 case LIST_GROUP_REMOVED: 1460 case LIST_GROUP_CHANGED: 1461 myMainWindow->updateGroups(); 1462 myUserMenu->updateGroups(); 1463 myGroupMenu->updateGroups(); 1464 break; 1461 1465 } 1462 1466 } -
trunk/qt4-gui/src/core/mainwin.cpp
r6188 r6200 765 765 if (!initial) 766 766 { 767 // Daemon does not send an update when groups change so tell contactList it768 // needs to update769 LicqGui::instance()->contactList()->reloadAll();770 771 767 // update group list in user and system menus 772 LicqGui::instance()->userMenu()->updateGroups();773 768 mySystemMenu->updateGroups(); 774 769 } -
trunk/qt4-gui/src/dialogs/editgrpdlg.cpp
r5892 r6200 115 115 connect(btnNewUser, SIGNAL(clicked()), SLOT(slot_newuser())); 116 116 connect(btnEdit, SIGNAL(clicked()), SLOT(slot_edit())); 117 connect(btnDone, SIGNAL(clicked()), SLOT( slot_done()));117 connect(btnDone, SIGNAL(clicked()), SLOT(close())); 118 118 connect(edtName, SIGNAL(returnPressed()), SLOT(slot_editok())); 119 119 connect(btnSave, SIGNAL(clicked()), SLOT(slot_editok())); … … 269 269 connect(btnEdit, SIGNAL(clicked()), SLOT(slot_edit())); 270 270 } 271 272 273 void EditGrpDlg::slot_done()274 {275 // Daemon doesn't notify when groups change so tell mainwin to update276 gMainWindow->updateGroups();277 278 close();279 } -
trunk/qt4-gui/src/dialogs/editgrpdlg.h
r5837 r6200 70 70 void slot_default(); 71 71 void slot_newuser(); 72 void slot_done();73 72 }; 74 73
