for(int i = end+1; i < _lines.count(); i++) {
_lines.value(i)->moveBy(0, h);
}
+ setSceneRect(QRectF(0, 0, _width, _height));
emit heightChanged(height());
}
}
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 ) {
***************************************************************************/
#include <QGraphicsTextItem>
+#include <QScrollBar>
#include "buffer.h"
#include "chatlinemodelitem.h"
setOptimizationFlags(QGraphicsView::DontClipPainter
|QGraphicsView::DontSavePainterState
|QGraphicsView::DontAdjustForAntialiasing);
+ setAlignment(Qt::AlignBottom);
QList<BufferId> filterList;
filterList.append(buf->bufferInfo().bufferId());
_scene = new ChatScene(filter, this);
connect(_scene, SIGNAL(heightChanged(int)), this, SLOT(sceneHeightChanged(int)));
setScene(_scene);
- setSceneRect(0, 0, width(), 0);
-
}
}
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()
void ChatView::appendChatLines(QList<ChatLine *> list) {
//foreach(ChatLine *line, list) {
-
+
//}
}