// initialize the Property Mapper
_propertyMapper.setModel(this);
_selectionModelSynchronizer.addRegularSelectionModel(_propertyMapper.selectionModel());
+ connect(_propertyMapper.selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)),
+ this, SLOT(currentChanged(QModelIndex, QModelIndex)));
}
BufferModel::~BufferModel() {
QModelIndex BufferModel::currentIndex() {
return propertyMapper()->selectionModel()->currentIndex();
}
+
+void BufferModel::currentChanged(const QModelIndex ¤t, const QModelIndex &previous) {
+ Q_UNUSED(current);
+ setData(previous, qVariantFromValue((int)BufferItem::NoActivity), NetworkModel::BufferActivityRole);
+}
QModelIndex currentIndex();
+private slots:
+ void currentChanged(const QModelIndex ¤t, const QModelIndex &previous);
+
private:
SelectionModelSynchronizer _selectionModelSynchronizer;
ModelPropertyMapper _propertyMapper;
void Client::recvMessage(const Message &msg) {
Buffer *b = buffer(msg.buffer());
-
-// Buffer::ActivityLevel level = Buffer::OtherActivity;
-// if(msg.type() == Message::Plain || msg.type() == Message::Notice){
-// level |= Buffer::NewMessage;
-// }
-// if(msg.flags() & Message::Highlight){
-// level |= Buffer::Highlight;
-// }
-// emit bufferActivity(level, b);
-
b->appendMsg(msg);
+ networkModel()->updateBufferActivity(msg);
}
void Client::recvStatusMsg(QString /*net*/, QString /*msg*/) {
foreach(QVariant v, msgs) {
Message msg = v.value<Message>();
b->prependMsg(msg);
+ // networkModel()->updateBufferActivity(msg);
if(!layoutQueue.contains(b)) layoutQueue.append(b);
}
if(layoutQueue.count() && !layoutTimer->isActive()) layoutTimer->start();
void BufferItem::setActivity(const ActivityLevel &level) {
_activity = level;
+ emit dataChanged();
}
-void BufferItem::addActivity(const ActivityLevel &level) {
+void BufferItem::updateActivity(const ActivityLevel &level) {
_activity |= level;
+ emit dataChanged();
}
QVariant BufferItem::data(int column, int role) const {
return int(bufferType());
case NetworkModel::ItemActiveRole:
return isActive();
+ case NetworkModel::BufferActivityRole:
+ return qVariantFromValue((int)activity());
default:
return PropertyMapItem::data(column, role);
}
}
+bool BufferItem::setData(int column, const QVariant &value, int role) {
+ switch(role) {
+ case NetworkModel::BufferActivityRole:
+ setActivity((ActivityLevel)value.toInt());
+ default:
+ return PropertyMapItem::setData(column, value, role);
+ }
+ return true;
+}
+
+
void BufferItem::attachIrcChannel(IrcChannel *ircChannel) {
if(!ircChannel)
return;
emit dataChanged(itemindex, itemindex);
}
-void NetworkModel::bufferActivity(BufferItem::ActivityLevel level, BufferInfo bufferInfo) {
-// BufferItem *bufferItem = buffer(buf->bufferInfo());
-// if(!bufferItem) {
-// qWarning() << "NetworkModel::bufferActivity(): received Activity Info for uknown Buffer";
-// return;
-// }
-// bufferItem->setActivity(level);
-// bufferUpdated(buf);
+void NetworkModel::updateBufferActivity(const Message &msg) {
+ BufferItem::ActivityLevel level = BufferItem::OtherActivity;
+ if(msg.type() == Message::Plain || msg.type() == Message::Notice)
+ level |= BufferItem::NewMessage;
+
+ if(msg.flags() & Message::Highlight)
+ level |= BufferItem::Highlight;
+
+ bufferItem(msg.buffer())->updateActivity(level);
}
const BufferInfo &bufferInfo() const;
virtual quint64 id() const;
virtual QVariant data(int column, int role) const;
+ virtual bool setData(int column, const QVariant &value, int role);
void attachIrcChannel(IrcChannel *ircChannel);
ActivityLevel activity() const;
void setActivity(const ActivityLevel &level);
- void addActivity(const ActivityLevel &level);
+ void updateActivity(const ActivityLevel &level);
public slots:
void setTopic(const QString &topic);
enum myRoles {
BufferTypeRole = Qt::UserRole,
ItemActiveRole,
+ BufferActivityRole,
BufferIdRole,
NetworkIdRole,
BufferInfoRole,
public slots:
void bufferUpdated(BufferInfo bufferInfo);
- void bufferActivity(BufferItem::ActivityLevel, BufferInfo bufferInfo);
+ void updateBufferActivity(const Message &msg);
private:
QModelIndex networkIndex(NetworkId networkId);
{
setSourceModel(model);
setSortCaseSensitivity(Qt::CaseInsensitive);
-
- // FIXME
- // ok the following basically sucks. therfore it's commented out. Justice served.
- // a better solution would use dataChanged()
-
- // I have this feeling that this resulted in a fuckup once... no clue though right now and invalidateFilter isn't a slot -.-
- //connect(model, SIGNAL(invalidateFilter()), this, SLOT(invalidate()));
- // connect(model, SIGNAL(invalidateFilter()), this, SLOT(invalidateFilter_()));
-}
-
-void BufferViewFilter::invalidateFilter_() {
- QSortFilterProxyModel::invalidateFilter();
}
Qt::ItemFlags BufferViewFilter::flags(const QModelIndex &index) const {
if(!index.data(NetworkModel::ItemActiveRole).toBool())
return QColor(Qt::gray);
- // FIXME:: show colors depending on activity level
+ BufferItem::ActivityLevel activity = (BufferItem::ActivityLevel)index.data(NetworkModel::BufferActivityRole).toInt();
+
+ if(activity & BufferItem::Highlight)
+ return QColor(Qt::magenta);
+ if(activity & BufferItem::NewMessage)
+ return QColor(Qt::green);
+ if(activity & BufferItem::OtherActivity)
+ return QColor(Qt::darkGreen);
+
return QColor(Qt::black);
+
+ // FIXME:: make colors configurable;
+
}
public slots:
void removeBuffer(const QModelIndex &);
- void invalidateFilter_();
protected:
bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const;
quasselVersion = "0.2.0-pre";
quasselDate = "2008-01-28";
- quasselBuild = 399;
+ quasselBuild = 401;
//! Minimum client build number the core needs
clientBuildNeeded = 358;