X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fchatline-old.cpp;h=c26da15a7dc3067e1a75689fde407e19c359a4f0;hp=4146db97c1710e0c5da1946be6300998385b84c6;hb=cab361607b686847ee0df2e605f8f05598b65f99;hpb=8699dd758516d0ded076811e8ea656adc95e69d0 diff --git a/src/qtui/chatline-old.cpp b/src/qtui/chatline-old.cpp index 4146db97..c26da15a 100644 --- a/src/qtui/chatline-old.cpp +++ b/src/qtui/chatline-old.cpp @@ -19,13 +19,13 @@ ***************************************************************************/ #include "chatline-old.h" +#include "client.h" +#include "network.h" #include "qtui.h" -//!\brief Construct a ChatLine object from a message. +//! Construct a ChatLine object from a message. /** * \param m The message to be layouted and rendered - * \param net The network name - * \param buf The buffer name */ ChatLine::ChatLine(Message m) { hght = 0; @@ -33,6 +33,7 @@ ChatLine::ChatLine(Message m) { //bufferName = m.buffer.buffer(); msg = m; selectionMode = None; + isHighlight = false; formatMsg(msg); } @@ -41,6 +42,12 @@ ChatLine::~ChatLine() { } void ChatLine::formatMsg(Message msg) { + const Network *net = Client::network(msg.bufferInfo().networkId()); + if(net) { + QRegExp nickRegExp("^(.*\\W)?"+net->myNick()+"(\\W.*)?$"); + if((msg.type() == Message::Plain || msg.type() == Message::Notice || msg.type() == Message::Action) && nickRegExp.exactMatch(msg.text())) + isHighlight = true; + } QTextOption tsOption, senderOption, textOption; styledTimeStamp = QtUi::style()->styleString(msg.formattedTimestamp()); styledSender = QtUi::style()->styleString(msg.formattedSender()); @@ -135,12 +142,12 @@ void ChatLine::setSelection(SelectionMode mode, int start, int end) { } } -uint ChatLine::msgId() const { - return msg.buffer().uid(); +MsgId ChatLine::msgId() const { + return msg.msgId(); } BufferInfo ChatLine::bufferInfo() const { - return msg.buffer(); + return msg.bufferInfo(); } QDateTime ChatLine::timestamp() const { @@ -316,8 +323,15 @@ void ChatLine::draw(QPainter *p, const QPointF &pos) { p->setPen(Qt::NoPen); p->setBrush(pal.brush(QPalette::Highlight)); p->drawRect(QRectF(pos, QSizeF(tsWidth + QtUi::style()->sepTsSender() + senderWidth + QtUi::style()->sepSenderText() + textWidth, height()))); - } else if(selectionMode == Partial) { + } else { + if(isHighlight) { + p->setPen(Qt::NoPen); + p->setBrush(pal.brush(QPalette::AlternateBase)); + p->drawRect(QRectF(pos, QSizeF(tsWidth + QtUi::style()->sepTsSender() + senderWidth + QtUi::style()->sepSenderText() + textWidth, height()))); + } + if(selectionMode == Partial) { + } } /* p->setClipRect(QRectF(pos, QSizeF(tsWidth, height()))); tsLayout.draw(p, pos, tsFormat); @@ -347,6 +361,7 @@ void ChatLine::draw(QPainter *p, const QPointF &pos) { } QPointF tpos = pos + QPointF(tsWidth + QtUi::style()->sepTsSender() + senderWidth + QtUi::style()->sepSenderText(), 0); qreal h = 0; int l = 0; + if(lineLayouts.count() == 0) return; // how can this happen? rect = QRectF(tpos + QPointF(0, h), QSizeF(textWidth, lineLayouts[l].height)); int offset = 0; foreach(FormatRange fr, textFormat) {