_bufferList(buffers)
{
setSourceModel(source);
-
}
QString MessageFilter::idString() const {
virtual bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
virtual QString idString() const;
-
+ inline bool isSingleBufferFilter() const { return _bufferList.count() == 1; }
+
private:
QList<BufferId> _bufferList;
};
buffItem->parent()->removeChild(buffItem);
}
+MsgId NetworkModel::lastSeenMsgId(BufferId bufferId) {
+ if(!_bufferItemCache.contains(bufferId))
+ return MsgId();
+
+ return _bufferItemCache[bufferId]->lastSeenMsgId();
+}
+
void NetworkModel::setLastSeenMsgId(const BufferId &bufferId, const MsgId &msgId) {
BufferItem *bufferItem = findBufferItem(bufferId);
if(!bufferItem) {
Buffer::ActivityLevel bufferActivity(const BufferInfo &buffer) const;
QString bufferName(BufferId bufferId);
- MsgId lastSeenMsgId(BufferId BufferId);
+ MsgId lastSeenMsgId(BufferId bufferId);
NetworkId networkId(BufferId bufferId);
QString networkName(BufferId bufferId);
BufferInfo::Type bufferType(BufferId bufferId);
#include "chatitem.h"
#include "chatline.h"
#include "messagemodel.h"
+#include "networkmodel.h"
#include "qtui.h"
ChatLine::ChatLine(int row, QAbstractItemModel *model, QGraphicsItem *parent)
}
void ChatLine::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
-// const QAbstractItemModel *model_ = model();
-// if(model_ && row() > 0) {
-// MsgId msgId = model_->data(model_->index(row() - 1, 0), MessageModel::MsgIdRole).value<MsgId>();
-// BufferId bufferId = model_->data(model_->index(row() - 1, 0), MessageModel::BufferIdRole).value<BufferId>();
-// qDebug() << msgId;
-// }
if(_selection & Highlighted) {
painter->fillRect(boundingRect(), QBrush(QtUi::style()->highlightColor()));
}
QRectF selectRect(left, 0, width() - left, height());
painter->fillRect(selectRect, QApplication::palette().brush(QPalette::Highlight));
}
+
+ const QAbstractItemModel *model_ = model();
+ if(model_ && row() > 0) {
+ MsgId msgId = model_->data(model_->index(row() - 1, 0), MessageModel::MsgIdRole).value<MsgId>();
+ BufferId bufferId = model_->data(model_->index(row() - 1, 0), MessageModel::BufferIdRole).value<BufferId>();
+ if(msgId == Client::networkModel()->lastSeenMsgId(bufferId) && chatScene()->isSingleBufferScene()) {
+ QLinearGradient gradient(0, 0, 0, height());
+ gradient.setColorAt(0, Qt::transparent);
+ gradient.setColorAt(1, Qt::red);
+ painter->fillRect(boundingRect(), gradient);
+ }
+ }
+
+
}
#include "client.h"
#include "clientbacklogmanager.h"
#include "columnhandleitem.h"
+#include "messagefilter.h"
#include "qtui.h"
#include "qtuisettings.h"
ChatScene::ChatScene(QAbstractItemModel *model, const QString &idString, QObject *parent)
: QGraphicsScene(parent),
- _idString(idString),
- _model(model)
+ _idString(idString),
+ _width(0),
+ _height(0),
+ _model(model),
+ _singleBufferScene(false),
+ _selectingItem(0),
+ _lastItem(0),
+ _selectionStart(-1),
+ _isSelecting(false),
+ _fetchingBacklog(false)
{
- _width = 0;
- _selectingItem = 0;
- _isSelecting = false;
- _selectionStart = -1;
- _fetchingBacklog = false;
+ MessageFilter *filter = qobject_cast<MessageFilter*>(model);
+ if(filter) {
+ _singleBufferScene = filter->isSingleBufferFilter();
+ }
connect(this, SIGNAL(sceneRectChanged(const QRectF &)), this, SLOT(rectChanged(const QRectF &)));
inline BufferId bufferForBacklogFetching() const;
int sectionByScenePos(int x);
inline int sectionByScenePos(const QPoint &pos) { return sectionByScenePos(pos.x()); }
+ inline bool isSingleBufferScene() const { return _singleBufferScene; }
public slots:
void setWidth(qreal);
qreal _width, _height;
QAbstractItemModel *_model;
QList<ChatLine *> _lines;
+ bool _singleBufferScene;
ColumnHandleItem *firstColHandle, *secondColHandle;
qreal firstColHandlePos, secondColHandlePos;
_currentBuffer = bufferId;
showChatView(bufferId);
Client::networkModel()->setBufferActivity(bufferId, Buffer::NoActivity);
- Client::setBufferLastSeenMsg(bufferId, _chatViews[bufferId]->lastMsgId());
+ // Client::setBufferLastSeenMsg(bufferId, _chatViews[bufferId]->lastMsgId());
setFocus();
}