connect(bufferSyncer(), SIGNAL(lastSeenMsgSet(BufferId, MsgId)), _networkModel, SLOT(setLastSeenMsgId(BufferId, MsgId)));
connect(bufferSyncer(), SIGNAL(bufferRemoved(BufferId)), this, SLOT(bufferRemoved(BufferId)));
connect(bufferSyncer(), SIGNAL(bufferRenamed(BufferId, QString)), this, SLOT(bufferRenamed(BufferId, QString)));
+ connect(networkModel(), SIGNAL(setLastSeenMsg(BufferId, MsgId)), bufferSyncer(), SLOT(requestSetLastSeenMsg(BufferId, const MsgId &)));
signalProxy()->synchronize(bufferSyncer());
// create a new BufferViewManager
}
void BufferItem::updateActivityLevel(const Message &msg) {
- if(isCurrentBuffer())
+ if(isCurrentBuffer()) {
return;
+ }
if(msg.flags() & Message::Self) // don't update activity for our own messages
return;
void BufferItem::setLastSeenMsgId(const MsgId &msgId) {
_lastSeenMsgId = msgId;
+ if(!isCurrentBuffer()) {
+ _lastSeenMarkerMsgId = msgId;
+ }
setActivityLevel(BufferInfo::NoActivity);
}
return _bufferItemCache[bufferId]->lastSeenMsgId();
}
+MsgId NetworkModel::lastSeenMarkerMsgId(BufferId bufferId) {
+ if(!_bufferItemCache.contains(bufferId))
+ return MsgId();
+
+ return _bufferItemCache[bufferId]->lastSeenMarkerMsgId();
+}
+
void NetworkModel::setLastSeenMsgId(const BufferId &bufferId, const MsgId &msgId) {
BufferItem *bufferItem = findBufferItem(bufferId);
if(!bufferItem) {
}
void NetworkModel::updateBufferActivity(const Message &msg) {
- bufferItem(msg.bufferInfo())->updateActivityLevel(msg);
+ BufferItem *item = bufferItem(msg.bufferInfo());
+ item->updateActivityLevel(msg);
+ if(item->isCurrentBuffer())
+ emit setLastSeenMsg(item->bufferId(), msg.msgId());
}
void NetworkModel::setBufferActivity(const BufferId &bufferId, BufferInfo::ActivityLevel level) {
virtual inline bool isActive() const { return qobject_cast<NetworkItem *>(parent())->isActive(); }
inline const MsgId &lastSeenMsgId() const { return _lastSeenMsgId; }
- //inline void setLastSeenMsgId(const MsgId &msgId) { _lastSeenMsgId = msgId; }
+ inline const MsgId &lastSeenMarkerMsgId() const { return _lastSeenMarkerMsgId; }
void setLastSeenMsgId(const MsgId &msgId);
inline BufferInfo::ActivityLevel activityLevel() const { return _activity; }
void setActivityLevel(BufferInfo::ActivityLevel level);
- //void updateActivityLevel(BufferInfo::ActivityLevel level);
void updateActivityLevel(const Message &msg);
bool isCurrentBuffer() const;
BufferInfo _bufferInfo;
BufferInfo::ActivityLevel _activity;
MsgId _lastSeenMsgId;
+ MsgId _lastSeenMarkerMsgId;
};
/*****************************************
BufferInfo::Type bufferType(BufferId bufferId);
BufferInfo bufferInfo(BufferId bufferId);
MsgId lastSeenMsgId(BufferId bufferId);
+ MsgId lastSeenMarkerMsgId(BufferId bufferId);
NetworkId networkId(BufferId bufferId);
QString networkName(BufferId bufferId);
void updateBufferActivity(const Message &msg);
void networkRemoved(const NetworkId &networkId);
+signals:
+ void setLastSeenMsg(BufferId bufferId, MsgId msgId);
+
private slots:
void checkForRemovedBuffers(const QModelIndex &parent, int start, int end);
void checkForNewBuffers(const QModelIndex &parent, int start, int end);
// don't show the marker if we wrote that new line
if(!(flags & Message::Self)) {
BufferId bufferId = BufferId(chatScene()->idString().toInt());
- MsgId lastSeenMsgId = Client::networkModel()->lastSeenMsgId(bufferId);
+ MsgId lastSeenMsgId = Client::networkModel()->lastSeenMarkerMsgId(bufferId);
if(lastSeenMsgId < myMsgId && lastSeenMsgId >= prevMsgId) {
QtUiStyleSettings s("Colors");
QLinearGradient gradient(0, 0, 0, contentsItem().fontMetrics()->lineSpacing());
_currentBuffer = bufferId;
showChatView(bufferId);
Client::networkModel()->setBufferActivity(bufferId, BufferInfo::NoActivity);
- // Client::setBufferLastSeenMsg(bufferId, _chatViews[bufferId]->lastMsgId());
+ Client::setBufferLastSeenMsg(bufferId, _chatViews[bufferId]->lastMsgId());
setFocus();
}
class AbstractBufferContainer : public AbstractItemView {
Q_OBJECT
- public:
- AbstractBufferContainer(QWidget *parent);
- virtual ~AbstractBufferContainer();
-
- inline BufferId currentBuffer() const { return _currentBuffer; }
-
- signals:
- void currentChanged(BufferId);
-
- protected:
- //! Create an AbstractChatView for the given BufferId and add it to the UI if necessary
- virtual AbstractChatView *createChatView(BufferId) = 0;
-
- //! Remove a chat view from the UI and delete it
- /** This method shall remove the view from the UI (for example, from a QStackedWidget) if appropriate.
- * It also shall delete the object afterwards.
- * \param view The chat view to be removed and deleted
- */
- virtual void removeChatView(BufferId) = 0;
-
- protected slots:
- virtual void currentChanged(const QModelIndex ¤t, const QModelIndex &previous);
- virtual void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
-
- //! Show the given chat view
- /** This method is called when the given chat view should be displayed. Use this e.g. for
- * selecting the appropriate page in a QStackedWidget.
- * \param view The chat view to be displayed. May be 0 if no chat view is selected.
- */
- virtual void showChatView(BufferId) = 0;
-
- private slots:
- void removeBuffer(BufferId bufferId);
- void setCurrentBuffer(BufferId bufferId);
-
- private:
- BufferId _currentBuffer;
- QHash<BufferId, AbstractChatView *> _chatViews;
+public:
+ AbstractBufferContainer(QWidget *parent);
+ virtual ~AbstractBufferContainer();
+
+ inline BufferId currentBuffer() const { return _currentBuffer; }
+
+signals:
+ void currentChanged(BufferId);
+
+protected:
+ //! Create an AbstractChatView for the given BufferId and add it to the UI if necessary
+ virtual AbstractChatView *createChatView(BufferId) = 0;
+
+ //! Remove a chat view from the UI and delete it
+ /** This method shall remove the view from the UI (for example, from a QStackedWidget) if appropriate.
+ * It also shall delete the object afterwards.
+ * \param view The chat view to be removed and deleted
+ */
+ virtual void removeChatView(BufferId) = 0;
+
+protected slots:
+ virtual void currentChanged(const QModelIndex ¤t, const QModelIndex &previous);
+ virtual void rowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
+
+ //! Show the given chat view
+ /** This method is called when the given chat view should be displayed. Use this e.g. for
+ * selecting the appropriate page in a QStackedWidget.
+ * \param view The chat view to be displayed. May be 0 if no chat view is selected.
+ */
+ virtual void showChatView(BufferId) = 0;
+
+private slots:
+ void removeBuffer(BufferId bufferId);
+ void setCurrentBuffer(BufferId bufferId);
+
+private:
+ BufferId _currentBuffer;
+ QHash<BufferId, AbstractChatView *> _chatViews;
};
class AbstractChatView {
- public:
- virtual ~AbstractChatView() {};
- virtual MsgId lastMsgId() const = 0;
+public:
+ virtual ~AbstractChatView() {};
+ virtual MsgId lastMsgId() const = 0;
};
#endif