void FriendWidget::setAlias(const QString& _alias) { QString alias = _alias.left(128); // same as TOX_MAX_NAME_LENGTH Friend* f = FriendList::findFriend(friendId); f->setAlias(alias); Settings::getInstance().setFriendAlias(f->getToxId(), alias); Settings::getInstance().savePersonal(); }
void FriendListWidget::removeFriendWidget(FriendWidget* w) { Friend* contact = FriendList::findFriend(w->friendId); if (mode == Activity) { QDate activityDate = getDateFriend(contact); Time time = getTime(activityDate); CategoryWidget* categoryWidget = dynamic_cast<CategoryWidget*>(activityLayout->itemAt(time)->widget()); categoryWidget->removeFriendWidget(w, contact->getStatus()); categoryWidget->setVisible(categoryWidget->hasChatrooms()); } else { int id = Settings::getInstance().getFriendCircleID(contact->getToxId()); CircleWidget* circleWidget = CircleWidget::getFromID(id); if (circleWidget != nullptr) { circleWidget->removeFriendWidget(w, contact->getStatus()); Widget::getInstance()->searchCircle(circleWidget); } } }
void FriendListWidget::dropEvent(QDropEvent* event) { if (event->mimeData()->hasFormat("friend")) { int friendId = event->mimeData()->data("friend").toInt(); Friend* f = FriendList::findFriend(friendId); assert(f != nullptr); FriendWidget* widget = f->getFriendWidget(); assert(widget != nullptr); // Update old circle after moved. CircleWidget* circleWidget = CircleWidget::getFromID(Settings::getInstance().getFriendCircleID(f->getToxId())); moveWidget(widget, f->getStatus(), true); if (circleWidget != nullptr) circleWidget->updateStatus(); } }