IrcUser *ircUser = net->ircUser(bufferInfo.bufferName());
if(ircUser)
attachIrcUser(ircUser);
-
}
-bool QueryBufferItem::isActive() const {
- if(_ircUser)
- return !_ircUser->isAway();
- else
- return false;
+QVariant QueryBufferItem::data(int column, int role) const {
+ switch(role) {
+ case NetworkModel::UserAwayRole:
+ return (bool)_ircUser ? _ircUser->isAway() : false;
+ default:
+ return BufferItem::data(column, role);
+ }
}
QString QueryBufferItem::toolTip(int column) const {
public:
QueryBufferItem(const BufferInfo &bufferInfo, NetworkItem *parent);
- virtual bool isActive() const;
+ virtual QVariant data(int column, int role) const;
+ virtual inline bool isActive() const { return (bool)_ircUser; }
virtual QString toolTip(int column) const;
public slots:
BufferIdRole,
NetworkIdRole,
BufferInfoRole,
- ItemTypeRole
+ ItemTypeRole,
+ UserAwayRole
};
enum itemType {
#include "bufferviewfilter.h"
-#include <QCoreApplication>
+#include <QApplication>
+#include <QPalette>
+#include <QBrush>
#include "buffermodel.h"
#include "client.h"
}
QVariant BufferViewFilter::data(const QModelIndex &index, int role) const {
- if(role == Qt::ForegroundRole)
+ switch(role) {
+ case Qt::ForegroundRole:
return foreground(index);
- else
+ case Qt::BackgroundRole:
+ if(index.data(NetworkModel::UserAwayRole).toBool()) {
+ QLinearGradient gradient(0, 0, 0, 18);
+ gradient.setColorAt(0.4, QApplication::palette().color(QPalette::Normal, QPalette::Base));
+ gradient.setColorAt(0.5, QApplication::palette().color(QPalette::Disabled, QPalette::Base));
+ gradient.setColorAt(0.6, QApplication::palette().color(QPalette::Normal, QPalette::Base));
+ return QBrush(gradient);
+ }
+ // else: fallthrough to default
+ default:
return QSortFilterProxyModel::data(index, role);
+ }
}
QVariant BufferViewFilter::foreground(const QModelIndex &index) const {