-void IndicatorNotificationBackend::notify(const Notification ¬ification) {
- if(!_enabled) {
- return;
- }
- if (notification.type != Highlight && notification.type != PrivMsg) {
- return;
- }
- BufferId bufferId = notification.bufferId;
- Indicator *indicator = _indicatorHash.value(bufferId);
- if(!indicator) {
- indicator = new Indicator;
- _indicatorHash.insert(bufferId, indicator);
- }
- indicator->lastNotificationId = notification.notificationId;
-
- BufferInfo::Type type = Client::networkModel()->bufferType(bufferId);
- QString sender;
- if (type == BufferInfo::QueryBuffer) {
- sender = notification.sender;
- } else {
- sender = QString("%1 (%2)")
- .arg(Client::networkModel()->bufferName(bufferId))
- .arg(notification.sender);
- }
- indicator->setProperty("sender", sender);
-
- indicator->setProperty("time", QTime::currentTime());
-
- QModelIndex index = Client::networkModel()->bufferIndex(bufferId);
- QVariant icon = QtUi::style()->bufferViewItemData(index, Qt::DecorationRole);
- if (icon.canConvert<QPixmap>()) {
- QImage image = icon.value<QPixmap>().toImage();
- indicator->setProperty("icon", image);
- }
-
- indicator->show();