return _bufferInfo;
}
-const QList<AbstractUiMsg *> &Buffer::contents() const {
- return layoutedMsgs;
-}
-
-void Buffer::appendMsg(const Message &msg) {
- updateActivityLevel(msg);
- AbstractUiMsg *m = Client::layoutMsg(msg);
- layoutedMsgs.append(m);
- emit msgAppended(m);
-}
-
-void Buffer::prependMsg(const Message &msg) {
- // check for duplicate first
- if(!layoutedMsgs.isEmpty() && msg.msgId() >= layoutedMsgs.first()->msgId()) {
- return;
- }
- updateActivityLevel(msg);
- layoutQueue.append(msg);
-}
-
-bool Buffer::layoutMsg() {
- if(layoutQueue.isEmpty())
- return false;
-
- AbstractUiMsg *m = Client::layoutMsg(layoutQueue.takeFirst());
- layoutedMsgs.prepend(m);
- emit msgPrepended(m);
-
- return !layoutQueue.isEmpty();
-}
-
void Buffer::setVisible(bool visible) {
_isVisible = visible;
setActivityLevel(NoActivity);
- //if(layoutedMsgs.isEmpty())
- // return;
- //setLastSeenMsg(layoutedMsgs.last()->msgId());
if(_lastRcvdMsg.msgId() > 0) setLastSeenMsg(_lastRcvdMsg.msgId());
- //qDebug() << "setting last seen" << _lastRcvdMsg.msgId();
}
void Buffer::setLastSeenMsg(const MsgId &msgId) {
- // qDebug() << "want to set lastSeen:" << bufferInfo() << seen << lastSeen();
const MsgId oldLastSeen = lastSeenMsg();
if(!oldLastSeen.isValid() || (msgId.isValid() && msgId > oldLastSeen)) {
- //qDebug() << "setting:" << bufferInfo().bufferName() << seen;
_lastSeenMsg = msgId;
Client::setBufferLastSeenMsg(bufferInfo().bufferId(), msgId);
- //qDebug() << "setting lastSeen:" << bufferInfo() << lastSeen();
setActivityLevel(NoActivity);
}
}
_activityLevel = level;
if(bufferInfo().bufferId() > 0) {
Client::networkModel()->setBufferActivity(bufferInfo(), level);
- //qDebug() << "setting level:" << bufferInfo() << lastSeen() << level;
}
}
#include "message.h"
#include "bufferinfo.h"
-/// Encapsulates the contents of a single channel, query or server status context.
/**
*/
class Buffer : public QObject {
Buffer(BufferInfo, QObject *parent = 0);
BufferInfo bufferInfo() const;
- const QList<AbstractUiMsg *> &contents() const;
inline bool isVisible() const { return _isVisible; }
inline MsgId lastSeenMsg() const { return _lastSeenMsg; }
inline ActivityLevel activityLevel() const { return _activityLevel; }
-signals:
- void msgAppended(AbstractUiMsg *);
- void msgPrepended(AbstractUiMsg *);
- void layoutQueueEmpty();
-
public slots:
- void appendMsg(const Message &);
- void prependMsg(const Message &);
- bool layoutMsg();
void setVisible(bool visible);
void setLastSeenMsg(const MsgId &msgId);
void setActivityLevel(ActivityLevel level);
Message _lastRcvdMsg;
ActivityLevel _activityLevel;
- QLinkedList<Message> layoutQueue;
- QList<AbstractUiMsg *> layoutedMsgs;
-
};
Q_DECLARE_OPERATORS_FOR_FLAGS(Buffer::ActivityLevel)
connect(this, SIGNAL(connected()), mainUi, SLOT(connectedToCore()));
connect(this, SIGNAL(disconnected()), mainUi, SLOT(disconnectedFromCore()));
- layoutTimer = new QTimer(this);
- layoutTimer->setInterval(0);
- layoutTimer->setSingleShot(false);
- connect(layoutTimer, SIGNAL(timeout()), this, SLOT(layoutMsg()));
-
}
/*** public static methods ***/
}
Q_ASSERT(_identities.isEmpty());
- layoutQueue.clear();
- layoutTimer->stop();
}
void Client::setCoreConfiguration(const QVariantMap &settings) {
//qDebug() << "processed" << msgs.count() << "backlog lines in" << start.msecsTo(QTime::currentTime());
}
-void Client::layoutMsg() {
- if(layoutQueue.isEmpty()) {
- layoutTimer->stop();
- return;
- }
-
- Buffer *buffer = layoutQueue.takeFirst();
- if(buffer->layoutMsg()) {
- layoutQueue.append(buffer); // Buffer has more messages in its queue --> Round Robin
- return;
- }
-
- if(layoutQueue.isEmpty())
- layoutTimer->stop();
-}
-
-AbstractUiMsg *Client::layoutMsg(const Message &msg) {
- return instance()->mainUi->layoutMsg(msg);
-}
-
// TODO optimize checkForHighlight
void Client::checkForHighlight(Message &msg) {
if(!((msg.type() & (Message::Plain | Message::Notice | Message::Action)) && !(msg.flags() & Message::Self)))
Buffer *buff = 0;
if(_buffers.contains(bufferId)) {
buff = _buffers.take(bufferId);
- layoutQueue.removeAll(buff);
disconnect(buff, 0, this, 0);
}
class SignalProxy;
struct NetworkInfo;
-class QTimer;
-
class Client : public QObject {
Q_OBJECT
static inline ClientBacklogManager *backlogManager() { return instance()->_backlogManager; }
static inline ClientIrcListHelper *ircListHelper() { return instance()->_ircListHelper; }
static inline BufferViewManager *bufferViewManager() { return instance()->_bufferViewManager; }
-
- static AccountId currentCoreAccount();
- static AbstractUiMsg *layoutMsg(const Message &);
+ static AccountId currentCoreAccount();
static bool isConnected();
static bool isSynced();
void backlogReceived(Buffer *, QList<Message>);
void requestBacklog(BufferInfo, QVariant, QVariant);
void requestNetworkStates();
- void messageReceived(const Message &msg);
void showConfigWizard(const QVariantMap &coredata);
void updateBufferInfo(BufferInfo);
void updateLastSeenMsg(BufferId id, const MsgId &msgId);
- void layoutMsg();
-
void bufferDestroyed();
void networkDestroyed();
void coreIdentityCreated(const Identity &);
Buffer *_monitorBuffer;
- QTimer *layoutTimer;
- QLinkedList<Buffer *> layoutQueue;
-
static AccountId _currentCoreAccount;
friend class ClientSyncer;
void ChatView::clear()
{
}
-
-void ChatView::prependMsg(AbstractUiMsg *msg) {
- //ChatLine *line = dynamic_cast<ChatLine*>(msg);
- //Q_ASSERT(line);
- //prependChatLine(line);
-}
-
-void ChatView::prependChatLine(ChatLine *line) {
- //qDebug() << "prepending";
-}
-
-void ChatView::prependChatLines(QList<ChatLine *> clist) {
-
-}
-
-void ChatView::appendMsg(AbstractUiMsg *msg) {
- //ChatLine *line = dynamic_cast<ChatLine*>(msg);
- //Q_ASSERT(line);
- //appendChatLine(line);
-}
-
-void ChatView::appendChatLine(ChatLine *line) {
- //qDebug() << "appending";
-}
-
-
-void ChatView::appendChatLines(QList<ChatLine *> list) {
- //foreach(ChatLine *line, list) {
-
- //}
-}
-
-void ChatView::setContents(const QList<AbstractUiMsg *> &list) {
- //qDebug() << "setting" << list.count();
- //appendChatLines(list);
-}
-
void clear();
- void prependMsg(AbstractUiMsg *);
- void appendMsg(AbstractUiMsg *);
-
- void prependChatLine(ChatLine *);
- void appendChatLine(ChatLine *);
- void prependChatLines(QList<ChatLine *>);
- void appendChatLines(QList<ChatLine *>);
-
- void setContents(const QList<AbstractUiMsg *> &);
-
protected:
virtual void resizeEvent(QResizeEvent *event);
Buffer *buf;
if(!bufferId.isValid() || !(buf = Client::buffer(bufferId))) {
- if(bufferId.isValid())
+ if(bufferId.isValid())
qWarning() << "AbstractBufferContainer::setBuffer(BufferId): Can't show unknown Buffer:" << bufferId;
_currentBuffer = 0;
showChatView(0);
chatView = _chatViews[bufferId];
} else {
chatView = createChatView(bufferId);
- chatView->setContents(buf->contents());
- connect(buf, SIGNAL(msgAppended(AbstractUiMsg *)), this, SLOT(appendMsg(AbstractUiMsg *)));
- connect(buf, SIGNAL(msgPrepended(AbstractUiMsg *)), this, SLOT(prependMsg(AbstractUiMsg *)));
_chatViews[bufferId] = chatView;
}
_currentBuffer = bufferId;
buf->setVisible(true);
setFocus();
}
-
-void AbstractBufferContainer::appendMsg(AbstractUiMsg *msg) {
- Buffer *buf = qobject_cast<Buffer *>(sender());
- if(!buf) {
- qWarning() << "AbstractBufferContainer::appendMsg(): Invalid slot caller!";
- return;
- }
- BufferId id = buf->bufferInfo().bufferId();
- if(!_chatViews.contains(id)) {
- qWarning() << "AbstractBufferContainer::appendMsg(): Received message for unknown buffer!";
- return;
- }
- _chatViews[id]->appendMsg(msg);
-}
-
-void AbstractBufferContainer::prependMsg(AbstractUiMsg *msg) {
- Buffer *buf = qobject_cast<Buffer *>(sender());
- if(!buf) {
- qWarning() << "AbstractBufferContainer:prependMsg(): Invalid slot caller!";
- return;
- }
- BufferId id = buf->bufferInfo().bufferId();
- if(!_chatViews.contains(id)) {
- qWarning() << "AbstractBufferContainer::prependMsg(): Received message for unknown buffer!";
- return;
- }
- _chatViews[id]->prependMsg(msg);
-}
virtual void showChatView(BufferId) = 0;
private slots:
- void appendMsg(AbstractUiMsg *);
- void prependMsg(AbstractUiMsg *);
void removeBuffer(BufferId bufferId);
void setCurrentBuffer(BufferId bufferId);
public:
virtual ~AbstractChatView() {};
- virtual void appendMsg(AbstractUiMsg *msg) = 0;
- virtual void prependMsg(AbstractUiMsg *msg) = 0;
- virtual void setContents(const QList<AbstractUiMsg *> &contents) = 0;
- //virtual BufferId bufferId() const = 0;
};