void SimpleTray::onUnreadChanged(qutim_sdk_0_3::MessageList unread) { ChatSession *session = sender_cast<ChatSession*>(sender()); MessageList::iterator itr = unread.begin(); while (itr != unread.end()) { if (itr->property("silent", false)) itr = unread.erase(itr); else ++itr; } if (unread.isEmpty()) m_sessions.remove(session); else m_sessions.insert(session, unread.count()); updateGeneratedIcon(); }
void IndicatorService::onUnreadChanged(const qutim_sdk_0_3::MessageList &messages) { qutim_sdk_0_3::debug() << "onUnreadChanged"; if (messages.isEmpty()) return; qutim_sdk_0_3::debug() << "Message list isn't empty. Looking for session."; qutim_sdk_0_3::ChatSession* session = qobject_cast<qutim_sdk_0_3::ChatSession*>(sender()); if (!session || session->isActive()) return; qutim_sdk_0_3::debug() << "session exists and not active."; QIndicate::Indicator *indicator = sessionIndicators.value(session); if (!indicator) return; QDateTime time = messages.last().time(); indicator->setTimeProperty(time); indicator->setDrawAttentionProperty(true); QImage icon = qutim_sdk_0_3::Icon("mail-unread-new").pixmap(64).toImage(); indicator->setIconProperty(icon); indicator->setCountProperty(session->unread().count()); // TODO: ->setIconProperty(QImage) indicator->show(); }
void SessionListWidget::onUnreadChanged(const qutim_sdk_0_3::MessageList &unread) { ChatSessionImpl *session = static_cast<ChatSessionImpl*>(sender()); int index = indexOf(session); QIcon icon; QString title = session->getUnit()->title(); if (unread.isEmpty()) { ChatUnit::ChatState state = static_cast<ChatUnit::ChatState>(session->property("currentChatState").toInt());//FIXME remove in future icon = ChatLayerImpl::iconForState(state,session->getUnit()); if(Buddy *b = qobject_cast<Buddy*>(session->unit())) icon = AvatarFilter::icon(b->avatar(),icon); } else { icon = Icon("mail-unread-new"); title.insert(0,QChar('*')); } QListWidgetItem *i = item(index); i->setIcon(icon); i->setText(title); }