- IndicatorHash::Iterator
- it = _indicatorHash.begin(),
- end = _indicatorHash.end();
- for (; it != end; ++it) {
- if (it.value()->lastNotificationId == notificationId) {
- break;
+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);
+ connect(indicator, SIGNAL(display(QIndicate::Indicator *)),
+ SLOT(indicatorDisplayed(QIndicate::Indicator *)));
+ }
+ indicator->lastNotificationId = notification.notificationId;
+
+ BufferInfo::Type type = Client::networkModel()->bufferType(bufferId);
+ QString name;
+ if (type == BufferInfo::QueryBuffer) {
+ name = notification.sender;
+ }
+ else {
+ name = QString("%1 (%2)")
+ .arg(Client::networkModel()->bufferName(bufferId))
+ .arg(notification.sender);
+ }
+ indicator->setNameProperty(name);
+
+ indicator->setTimeProperty(QDateTime::currentDateTime());
+
+ QModelIndex index = Client::networkModel()->bufferIndex(bufferId);
+ QVariant icon = QtUi::style()->bufferViewItemData(index, Qt::DecorationRole);
+ if (icon.canConvert<QIcon>()) {
+ QImage image = icon.value<QIcon>().pixmap(16).toImage();
+ indicator->setIconProperty(image);