Changeset 6148 for trunk/qt4-gui/src/contactlist
- Timestamp:
- 04/13/08 23:18:08 (8 months ago)
- Location:
- trunk/qt4-gui/src/contactlist
- Files:
-
- 10 modified
-
contactgroup.cpp (modified) (2 diffs)
-
contactgroup.h (modified) (1 diff)
-
contactitem.cpp (modified) (1 diff)
-
contactitem.h (modified) (1 diff)
-
contactlist.cpp (modified) (2 diffs)
-
contactlist.h (modified) (1 diff)
-
contactuser.cpp (modified) (1 diff)
-
contactuser.h (modified) (1 diff)
-
contactuserdata.cpp (modified) (4 diffs)
-
contactuserdata.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/qt4-gui/src/contactlist/contactgroup.cpp
r5885 r6148 161 161 break; 162 162 163 case Qt::EditRole: 164 return myName; 165 163 166 case ContactListModel::ItemTypeRole: 164 167 return ContactListModel::GroupItem; … … 185 188 return QVariant(); 186 189 } 190 191 bool ContactGroup::setData(const QVariant& value, int role) 192 { 193 if (role != Qt::EditRole || !value.isValid()) 194 return false; 195 196 // Don't allow system groups or "Other users" to be renamed this way 197 if (myGroupId == 0 || myGroupId >= ContactListModel::SystemGroupOffset) 198 return false; 199 200 if (value.toString() == myName) 201 return true; 202 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); 208 209 return true; 210 } -
trunk/qt4-gui/src/contactlist/contactgroup.h
r5885 r6148 143 143 QVariant data(int column, int role) const; 144 144 145 /** 146 * Set data for this group 147 * 148 * @param value New value to set 149 * @param role Role to set 150 * @return True if any data was changed 151 */ 152 virtual bool setData(const QVariant& value, int role = Qt::EditRole); 153 145 154 signals: 146 155 /** -
trunk/qt4-gui/src/contactlist/contactitem.cpp
r5837 r6148 27 27 { 28 28 } 29 30 bool ContactItem::setData(const QVariant& /* value */, int /* role */) 31 { 32 return false; 33 } -
trunk/qt4-gui/src/contactlist/contactitem.h
r5837 r6148 66 66 virtual QVariant data(int column, int role) const = 0; 67 67 68 /** 69 * Set data for this item 70 * 71 * @param value New value to set 72 * @param role Role to set 73 * @return True if any data was changed 74 */ 75 virtual bool setData(const QVariant& value, int role = Qt::EditRole); 76 68 77 private: 69 78 ContactListModel::ItemType myItemType; -
trunk/qt4-gui/src/contactlist/contactlist.cpp
r5892 r6148 402 402 return Qt::ItemIsEnabled; 403 403 404 return Qt::ItemIsEnabled | Qt::ItemIsSelectable; 404 Qt::ItemFlags f = Qt::ItemIsEnabled | Qt::ItemIsSelectable; 405 406 ItemType itemType = static_cast<ContactItem*>(index.internalPointer())->itemType(); 407 408 // Only editing of alias for contacts 409 if (itemType == UserItem && Config::ContactList::instance()->columnFormat(index.column()) == "%a") 410 f |= Qt::ItemIsEditable; 411 412 // Group names are editable in first column unless it's a system group 413 if (itemType == GroupItem && index.column() == 0 && index.row() != 0 && index.row() < myUserGroups.size()) 414 f |= Qt::ItemIsEditable; 415 416 return f; 405 417 } 406 418 … … 449 461 return QModelIndex(); 450 462 } 463 464 bool ContactListModel::setData(const QModelIndex& index, const QVariant& value, int role) 465 { 466 return static_cast<ContactItem*>(index.internalPointer())->setData(value, role); 467 } -
trunk/qt4-gui/src/contactlist/contactlist.h
r5885 r6148 291 291 292 292 /** 293 * Set item data 294 * 295 * @param index Index for the item to update 296 * @param value Value to set 297 * @param role Role to update 298 */ 299 virtual bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole); 300 301 /** 293 302 * Get index for a specific user 294 303 * -
trunk/qt4-gui/src/contactlist/contactuser.cpp
r5837 r6148 52 52 return myUserData->data(column, role); 53 53 } 54 55 bool ContactUser::setData(const QVariant& value, int role) 56 { 57 return myUserData->setData(value, role); 58 } -
trunk/qt4-gui/src/contactlist/contactuser.h
r5885 r6148 99 99 QVariant data(int column, int role) const; 100 100 101 /** 102 * Set data for this user 103 * 104 * @param value New value to set 105 * @param role Role to set 106 * @return True if any data was changed 107 */ 108 virtual bool setData(const QVariant& value, int role = Qt::EditRole); 109 101 110 private: 102 111 ContactUserData* myUserData; -
trunk/qt4-gui/src/contactlist/contactuserdata.cpp
r6132 r6148 400 400 bool hasChanged = false; 401 401 402 myAlias = QString::fromUtf8(licqUser->GetAlias()); 403 402 404 for (unsigned short i = 0; i < Config::ContactList::instance()->columnCount(); i++) 403 405 { … … 410 412 free(temp); 411 413 412 temp = licqUser->usprintf("%a"); 413 QString alias = QString::fromUtf8(temp); 414 free(temp); 415 416 newStr.replace("@_USER_ALIAS_@", alias); 414 newStr.replace("@_USER_ALIAS_@", myAlias); 417 415 418 416 if (newStr != myText[i]) … … 471 469 } 472 470 471 bool ContactUserData::setData(const QVariant& value, int role) 472 { 473 if (role != Qt::EditRole || !value.isValid()) 474 return false; 475 476 if (value.toString() == myAlias) 477 return true; 478 479 ICQUser* u = gUserManager.FetchUser(myId.toLatin1(), myPpid, LOCK_R); 480 if (u == NULL) 481 return false; 482 483 myAlias = value.toString(); 484 u->SetAlias(myAlias.toUtf8()); 485 u->SetKeepAliasOnUpdate(true); 486 487 // Daemon dosen't send signal when alias is changed so trigger update from here 488 updateText(u); 489 updateSorting(); 490 491 gUserManager.DropUser(u); 492 493 emit dataChanged(this); 494 return true; 495 } 496 473 497 void ContactUserData::refresh() 474 498 { … … 558 582 return myText[column]; 559 583 break; 584 585 case Qt::EditRole: 586 return myAlias; 560 587 561 588 case Qt::ToolTipRole: -
trunk/qt4-gui/src/contactlist/contactuserdata.h
r5955 r6148 148 148 */ 149 149 QVariant data(int column, int role) const; 150 151 /** 152 * Set data for this user 153 * Currently only alias may be change this way 154 * 155 * @param value New value to set 156 * @param role Must be Qt::EditRole 157 * @return True if alias was changed 158 */ 159 virtual bool setData(const QVariant& value, int role = Qt::EditRole); 150 160 151 161 signals: … … 241 251 bool myUrgent; 242 252 QString myText[4]; 253 QString myAlias; 243 254 QList<ContactUser*> myUserInstances; 244 255
