Esempio n. 1
0
void FriendListWidget::removeFriendWidget(FriendWidget* w)
{
    Friend* contact = FriendList::findFriend(w->friendId);
    if (mode == Activity) {
        QDate activityDate = getDateFriend(contact);
        int time = static_cast<int>(getTime(activityDate));
        QWidget* widget = activityLayout->itemAt(time)->widget();
        CategoryWidget* categoryWidget = qobject_cast<CategoryWidget*>(widget);
        categoryWidget->removeFriendWidget(w, contact->getStatus());
        categoryWidget->setVisible(categoryWidget->hasChatrooms());
    } else {
        int id = Settings::getInstance().getFriendCircleID(contact->getPublicKey());
        CircleWidget* circleWidget = CircleWidget::getFromID(id);
        if (circleWidget != nullptr) {
            circleWidget->removeFriendWidget(w, contact->getStatus());
            Widget::getInstance()->searchCircle(circleWidget);
        }
    }
}
Esempio n. 2
0
void FriendListWidget::onFriendWidgetRenamed(FriendWidget* friendWidget)
{
    const Friend* contact = friendWidget->getFriend();
    auto status = contact->getStatus();
    if (mode == Activity) {
        QDate activityDate = getDateFriend(contact);
        int time = static_cast<int>(getTime(activityDate));
        QWidget* widget = activityLayout->itemAt(time)->widget();
        CategoryWidget* categoryWidget = qobject_cast<CategoryWidget*>(widget);
        categoryWidget->removeFriendWidget(friendWidget, status);
        categoryWidget->addFriendWidget(friendWidget, status);
    } else {
        int id = Settings::getInstance().getFriendCircleID(contact->getPublicKey());
        CircleWidget* circleWidget = CircleWidget::getFromID(id);
        if (circleWidget != nullptr) {
            circleWidget->removeFriendWidget(friendWidget, status);
            circleWidget->addFriendWidget(friendWidget, status);
            Widget::getInstance()->searchCircle(circleWidget);
        } else {
            listLayout->removeFriendWidget(friendWidget, status);
            listLayout->addFriendWidget(friendWidget, status);
        }
    }
}