-void ChatView::init(MessageFilter *filter) {
- setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
- setAlignment(Qt::AlignBottom);
- setInteractive(true);
- //setOptimizationFlags(QGraphicsView::DontClipPainter | QGraphicsView::DontAdjustForAntialiasing);
- // setOptimizationFlags(QGraphicsView::DontAdjustForAntialiasing);
- setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
- // setTransformationAnchor(QGraphicsView::NoAnchor);
- setTransformationAnchor(QGraphicsView::AnchorViewCenter);
+void ChatView::init(MessageFilter* filter)
+{
+ _bufferContainer = nullptr;
+ _currentScaleFactor = 1;
+ _invalidateFilter = false;
+
+ setAttribute(Qt::WA_AcceptTouchEvents);
+ setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
+ setAlignment(Qt::AlignLeft | Qt::AlignBottom);
+ setInteractive(true);
+ // setOptimizationFlags(QGraphicsView::DontClipPainter | QGraphicsView::DontAdjustForAntialiasing);
+ // setOptimizationFlags(QGraphicsView::DontAdjustForAntialiasing);
+ setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
+ // setTransformationAnchor(QGraphicsView::NoAnchor);
+ setTransformationAnchor(QGraphicsView::AnchorViewCenter);
+
+ _scrollTimer.setInterval(100);
+ _scrollTimer.setSingleShot(true);
+ connect(&_scrollTimer, &QTimer::timeout, this, &ChatView::scrollTimerTimeout);
+
+ _scene = new ChatScene(filter, filter->idString(), viewport()->width(), this);
+ connect(_scene, &QGraphicsScene::sceneRectChanged, this, &ChatView::adjustSceneRect);
+ connect(_scene, &ChatScene::lastLineChanged, this, &ChatView::lastLineChanged);
+ connect(_scene, &ChatScene::mouseMoveWhileSelecting, this, &ChatView::mouseMoveWhileSelecting);
+ setScene(_scene);
+
+ connect(verticalScrollBar(), &QAbstractSlider::valueChanged, this, &ChatView::verticalScrollbarChanged);
+ _lastScrollbarPos = verticalScrollBar()->maximum();
+
+ connect(Client::networkModel(), &NetworkModel::markerLineSet, this, &ChatView::markerLineSet);
+
+ // only connect if client is synched with a core
+ if (Client::isConnected())
+ connect(Client::ignoreListManager(), &ClientIgnoreListManager::ignoreListChanged, this, &ChatView::invalidateFilter);
+}