From: Marcus Eggenberger Date: Tue, 29 Jan 2008 01:00:12 +0000 (+0000) Subject: Reenabled Activity levels X-Git-Tag: 0.2.0-alpha1~179 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=770b7ef54b03f3ebd1e29a58b4757505e1809b2d;ds=sidebyside Reenabled Activity levels --- diff --git a/src/client/buffermodel.cpp b/src/client/buffermodel.cpp index 78d39605..2fc222ed 100644 --- a/src/client/buffermodel.cpp +++ b/src/client/buffermodel.cpp @@ -35,6 +35,8 @@ BufferModel::BufferModel(NetworkModel *parent) // 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() { @@ -68,3 +70,8 @@ void BufferModel::mapProperty(int column, int role, QObject *target, const QByte 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); +} diff --git a/src/client/buffermodel.h b/src/client/buffermodel.h index 2d6f4b47..80f1ec0a 100644 --- a/src/client/buffermodel.h +++ b/src/client/buffermodel.h @@ -51,6 +51,9 @@ public: QModelIndex currentIndex(); +private slots: + void currentChanged(const QModelIndex ¤t, const QModelIndex &previous); + private: SelectionModelSynchronizer _selectionModelSynchronizer; ModelPropertyMapper _propertyMapper; diff --git a/src/client/client.cpp b/src/client/client.cpp index 8cc87e41..de43a0b6 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -404,17 +404,8 @@ void Client::networkDestroyed() { 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*/) { @@ -426,6 +417,7 @@ void Client::recvBacklogData(BufferInfo id, QVariantList msgs, bool /*done*/) { foreach(QVariant v, msgs) { Message msg = v.value(); b->prependMsg(msg); + // networkModel()->updateBufferActivity(msg); if(!layoutQueue.contains(b)) layoutQueue.append(b); } if(layoutQueue.count() && !layoutTimer->isActive()) layoutTimer->start(); diff --git a/src/client/networkmodel.cpp b/src/client/networkmodel.cpp index f2fc6da3..4ccb5b5d 100644 --- a/src/client/networkmodel.cpp +++ b/src/client/networkmodel.cpp @@ -83,10 +83,12 @@ BufferItem::ActivityLevel BufferItem::activity() const { 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 { @@ -103,11 +105,24 @@ 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; @@ -617,13 +632,14 @@ void NetworkModel::bufferUpdated(BufferInfo bufferInfo) { 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); } diff --git a/src/client/networkmodel.h b/src/client/networkmodel.h index 82136484..5326a4b3 100644 --- a/src/client/networkmodel.h +++ b/src/client/networkmodel.h @@ -53,6 +53,7 @@ public: 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); @@ -81,7 +82,7 @@ public: 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); @@ -202,6 +203,7 @@ public: enum myRoles { BufferTypeRole = Qt::UserRole, ItemActiveRole, + BufferActivityRole, BufferIdRole, NetworkIdRole, BufferInfoRole, @@ -233,7 +235,7 @@ public: public slots: void bufferUpdated(BufferInfo bufferInfo); - void bufferActivity(BufferItem::ActivityLevel, BufferInfo bufferInfo); + void updateBufferActivity(const Message &msg); private: QModelIndex networkIndex(NetworkId networkId); diff --git a/src/uisupport/bufferviewfilter.cpp b/src/uisupport/bufferviewfilter.cpp index b8a1975c..ac4bae5d 100644 --- a/src/uisupport/bufferviewfilter.cpp +++ b/src/uisupport/bufferviewfilter.cpp @@ -34,18 +34,6 @@ BufferViewFilter::BufferViewFilter(QAbstractItemModel *model, const Modes &filte { 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 { @@ -176,6 +164,17 @@ QVariant BufferViewFilter::foreground(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; + } diff --git a/src/uisupport/bufferviewfilter.h b/src/uisupport/bufferviewfilter.h index 5e874f2e..f27352e7 100644 --- a/src/uisupport/bufferviewfilter.h +++ b/src/uisupport/bufferviewfilter.h @@ -57,7 +57,6 @@ public: public slots: void removeBuffer(const QModelIndex &); - void invalidateFilter_(); protected: bool filterAcceptsRow(int source_row, const QModelIndex &source_parent) const; diff --git a/version.inc b/version.inc index 9922abbf..a0cd5833 100644 --- a/version.inc +++ b/version.inc @@ -5,7 +5,7 @@ quasselVersion = "0.2.0-pre"; quasselDate = "2008-01-28"; - quasselBuild = 399; + quasselBuild = 401; //! Minimum client build number the core needs clientBuildNeeded = 358;