From: Manuel Nickschas Date: Wed, 23 Jul 2008 23:34:21 +0000 (+0200) Subject: Sanitize ChatView's scrolling behavior X-Git-Tag: 0.3.0~160 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=69617bf3e612562feda908587c5fec2c50b77aaf Sanitize ChatView's scrolling behavior --- diff --git a/src/qtui/chatscene.cpp b/src/qtui/chatscene.cpp index 10ebfc7a..72099e67 100644 --- a/src/qtui/chatscene.cpp +++ b/src/qtui/chatscene.cpp @@ -67,6 +67,7 @@ void ChatScene::rowsInserted(const QModelIndex &index, int start, int end) { for(int i = end+1; i < _lines.count(); i++) { _lines.value(i)->moveBy(0, h); } + setSceneRect(QRectF(0, 0, _width, _height)); emit heightChanged(height()); } } @@ -78,7 +79,8 @@ void ChatScene::setWidth(int w) { line->setPos(0, _height); _height += line->setColumnWidths(_timestampWidth, _senderWidth, w - _timestampWidth - _senderWidth); } - emit heightChanged(_height); + setSceneRect(QRectF(0, 0, w, _height)); + emit heightChanged(height()); } void ChatScene::mousePressEvent ( QGraphicsSceneMouseEvent * mouseEvent ) { diff --git a/src/qtui/chatview.cpp b/src/qtui/chatview.cpp index 59b5681f..fe15416b 100644 --- a/src/qtui/chatview.cpp +++ b/src/qtui/chatview.cpp @@ -19,6 +19,7 @@ ***************************************************************************/ #include +#include #include "buffer.h" #include "chatlinemodelitem.h" @@ -33,6 +34,7 @@ ChatView::ChatView(Buffer *buf, QWidget *parent) : QGraphicsView(parent), Abstra setOptimizationFlags(QGraphicsView::DontClipPainter |QGraphicsView::DontSavePainterState |QGraphicsView::DontAdjustForAntialiasing); + setAlignment(Qt::AlignBottom); QList filterList; filterList.append(buf->bufferInfo().bufferId()); @@ -41,8 +43,6 @@ ChatView::ChatView(Buffer *buf, QWidget *parent) : QGraphicsView(parent), Abstra _scene = new ChatScene(filter, this); connect(_scene, SIGNAL(heightChanged(int)), this, SLOT(sceneHeightChanged(int))); setScene(_scene); - setSceneRect(0, 0, width(), 0); - } @@ -56,11 +56,14 @@ ChatScene *ChatView::scene() const { } void ChatView::resizeEvent(QResizeEvent *event) { - scene()->setWidth(event->size().width()); + scene()->setWidth(event->size().width() - 2); // FIXME figure out why we have to hardcode the -2 here + verticalScrollBar()->setValue(verticalScrollBar()->maximum()); } void ChatView::sceneHeightChanged(int h) { - setSceneRect(0, 0, width(), h); + bool scrollable = verticalScrollBar()->value() == verticalScrollBar()->maximum(); + setSceneRect(scene()->sceneRect()); + if(scrollable) verticalScrollBar()->setValue(verticalScrollBar()->maximum()); } void ChatView::clear() @@ -94,7 +97,7 @@ void ChatView::appendChatLine(ChatLine *line) { void ChatView::appendChatLines(QList list) { //foreach(ChatLine *line, list) { - + //} }