+
+QVariant NickViewFilter::data(const QModelIndex &index, int role) const {
+ switch(role) {
+ case Qt::DecorationRole:
+ return icon(index);
+ default:
+ return QSortFilterProxyModel::data(index, role);
+ }
+}
+
+QVariant NickViewFilter::icon(const QModelIndex &index) const {
+ if(!_showUserStateIcons)
+ return QVariant();
+
+ if(index.column() != 0)
+ return QVariant();
+
+ QModelIndex source_index = mapToSource(index);
+ NetworkModel::ItemType itemType = (NetworkModel::ItemType)sourceModel()->data(source_index, NetworkModel::ItemTypeRole).toInt();
+ switch(itemType) {
+ case NetworkModel::UserCategoryItemType:
+ {
+ int categoryId = sourceModel()->data(source_index, TreeModel::SortRole).toInt();
+ if(categoryId <= _opIconLimit)
+ return _categoryOpIcon;
+ if(categoryId <= _voiceIconLimit)
+ return _categoryVoiceIcon;
+ return _userOnlineIcon;
+ }
+ case NetworkModel::IrcUserItemType:
+ if(sourceModel()->data(source_index, NetworkModel::ItemActiveRole).toBool())
+ return _userOnlineIcon;
+ else
+ return _userAwayIcon;
+ break;
+ default:
+ return QVariant();
+ };
+}
+
+void NickViewFilter::showUserStateIconsChanged() {
+ BufferSettings bufferSettings;
+ _showUserStateIcons = bufferSettings.showUserStateIcons();
+}