X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fclient%2Fbuffer.cpp;h=df7863967efcb3f8c06ca234928c14afc1af0eb4;hb=0d3d7a861472313710b51c8d19e81af56e2208a1;hp=10f395cf70c22cab1eedfd6108ad42273a056945;hpb=50706d89d4d60e258ebb6873d3778383621898e4;p=quassel.git diff --git a/src/client/buffer.cpp b/src/client/buffer.cpp index 10f395cf..df786396 100644 --- a/src/client/buffer.cpp +++ b/src/client/buffer.cpp @@ -21,47 +21,70 @@ #include "buffer.h" +#include "buffersyncer.h" #include "client.h" +#include "networkmodel.h" +#include "quasselui.h" #include "util.h" Buffer::Buffer(BufferInfo bufferid, QObject *parent) : QObject(parent), - _bufferInfo(bufferid) + _bufferInfo(bufferid), + _isVisible(false), + _activityLevel(NoActivity) { + } BufferInfo Buffer::bufferInfo() const { - // still needed to process user input... *sigh* - // ... and for the gui *sigh* to request the backlogs *sigh* + // still needed by the gui *sigh* to request the backlogs *sigh* return _bufferInfo; } -QList Buffer::contents() const { - return layoutedMsgs; -} - -void Buffer::appendMsg(const Message &msg) { - AbstractUiMsg *m = Client::layoutMsg(msg); - layoutedMsgs.append(m); - emit msgAppended(m); +void Buffer::setVisible(bool visible) { + _isVisible = visible; + setActivityLevel(NoActivity); + if(_lastRcvdMsg.msgId() > 0) setLastSeenMsg(_lastRcvdMsg.msgId()); } -void Buffer::prependMsg(const Message &msg) { - layoutQueue.append(msg); +void Buffer::setLastSeenMsg(const MsgId &msgId) { + const MsgId oldLastSeen = lastSeenMsg(); + if(!oldLastSeen.isValid() || (msgId.isValid() && msgId > oldLastSeen)) { + _lastSeenMsg = msgId; + Client::setBufferLastSeenMsg(bufferInfo().bufferId(), msgId); + setActivityLevel(NoActivity); + } } -bool Buffer::layoutMsg() { - if(layoutQueue.count()) { - AbstractUiMsg *m = Client::layoutMsg(layoutQueue.takeFirst()); - layoutedMsgs.prepend(m); - emit msgPrepended(m); +void Buffer::setActivityLevel(ActivityLevel level) { + _activityLevel = level; + if(bufferInfo().bufferId() > 0) { + Client::networkModel()->setBufferActivity(bufferInfo(), level); } - return layoutQueue.count(); } -void Buffer::processUserInput(QString msg) { - // TODO User Input processing (plugins) -> well, this goes through MainWin into Core for processing... so... - emit userInput(_bufferInfo, msg); -} +void Buffer::updateActivityLevel(const Message &msg) { + // FIXME dirty hack to allow the lastSeen stuff to continue to work + // will be made much nicer once Buffer dies, I hope... + if(msg.msgId() > _lastRcvdMsg.msgId()) _lastRcvdMsg = msg; + + if(isVisible()) + return; + if(msg.flags() & Message::Self) // don't update activity for our own messages + return; + + if(lastSeenMsg().isValid() && lastSeenMsg() >= msg.msgId()) + return; + + ActivityLevel level = activityLevel() | OtherActivity; + if(msg.type() & (Message::Plain | Message::Notice | Message::Action)) + level |= NewMessage; + + if(msg.flags() & Message::Highlight) + level |= Highlight; + + if(level != activityLevel()) + setActivityLevel(level); +}