void MainWin::registerNetView(NetworkView *view) {
connect(this, SIGNAL(bufferSelected(Buffer *)), view, SLOT(selectBuffer(Buffer *)));
connect(this, SIGNAL(bufferUpdated(Buffer *)), view, SLOT(bufferUpdated(Buffer *)));
+ connect(this, SIGNAL(bufferActivity(uint, Buffer *)), view, SLOT(bufferActivity(uint, Buffer *)));
connect(this, SIGNAL(bufferDestroyed(Buffer *)), view, SLOT(bufferDestroyed(Buffer *)));
connect(view, SIGNAL(bufferSelected(Buffer *)), this, SLOT(showBuffer(Buffer *)));
view->setBuffers(buffers.values());
}
*/
Buffer *b = getBuffer(msg.buffer);
+
+ uint level = NetworkView::OtherActivity;
+ if(msg.type == Message::Plain or msg.type == Message::Notice){
+ level |= NetworkView::NewMessage;
+ }
+ if(msg.flags & Message::Highlight){
+ level |= NetworkView::Highlight;
+ }
+
+ emit bufferActivity(level, b);
//b->displayMsg(msg);
b->appendChatLine(new ChatLine(msg));
}
void sendInput(BufferId, QString message);
void bufferSelected(Buffer *);
void bufferUpdated(Buffer *);
+ void bufferActivity(uint, Buffer *);
void bufferDestroyed(Buffer *);
void backlogReceived(Buffer *, QList<Message>);
void requestBacklog(BufferId, QVariant, QVariant);
}
}
+void NetworkView::bufferActivity(uint level, Buffer *b) {
+ QColor c;
+ if(bufitems.contains(b) and b != currentBuffer) {
+ if(level & Highlight) {
+ c = QColor(Qt::red);
+ } else if(level & NewMessage) {
+ c = QColor(Qt::darkYellow);
+ } else if(level & OtherActivity) {
+ c = QColor(Qt::darkGreen);
+ }
+ bufitems[b]->setForeground(0, c);
+ }
+}
+
+void NetworkView::clearActivity(Buffer *b) {
+ QColor c;
+ // it should be sane not to check if b is in bufitems since we just checked before calling this function
+ if(b->isActive()) {
+ c = QColor(Qt::black);
+ } else {
+ c = QColor(Qt::gray);
+ }
+ bufitems[b]->setForeground(0, c);
+}
+
bool NetworkView::shouldShow(Buffer *b) {
// bool f = false;
if((mode & NoActive) && b->isActive()) return false;
foreach(QTreeWidgetItem *i, sel) { if(i != item) i->setSelected(false); }
if(item) {
item->setSelected(true);
+ clearActivity(b);
currentBuffer = b;
} else {
currentBuffer = 0;
SomeNets = 0x04, AllNets = 0x08,
NoChannels = 0x10, NoQueries = 0x20, NoServers = 0x40
};
-
+
+ enum ActivityLevel {
+ NoActivity = 0x00, OtherActivity = 0x01,
+ NewMessage = 0x02, Highlight = 0x40
+ };
+
NetworkView(QString name, int mode, QStringList nets = QStringList(), QWidget *parent = 0);
void setMode(int mode, QStringList nets = QStringList());
void setName(QString name);
public slots:
void bufferUpdated(Buffer *);
+ void bufferActivity(uint, Buffer *);
void bufferDestroyed(Buffer *);
void setBuffers(QList<Buffer *>);
void selectBuffer(Buffer *);
QTreeWidget *tree;
bool shouldShow(Buffer *);
+ void clearActivity(Buffer *);
};