X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fchatview.cpp;h=85fb48ac52c992f50206ee4b1b8ebfbcf56b13e4;hp=024e49d602b4f7e3d04e1ceb017dac6bce809235;hb=3f354bcce2cecfe88a46de90cbf94ffd1bc7c506;hpb=16e4a21c1292448c1a524010d70f6e59b84802f4 diff --git a/src/qtui/chatview.cpp b/src/qtui/chatview.cpp index 024e49d6..85fb48ac 100644 --- a/src/qtui/chatview.cpp +++ b/src/qtui/chatview.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-08 by the Quassel Project * + * Copyright (C) 2005-09 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -19,16 +19,17 @@ ***************************************************************************/ #include +#include #include #include #include "bufferwidget.h" -#include "chatlinemodelitem.h" #include "chatscene.h" #include "chatview.h" #include "client.h" #include "messagefilter.h" -#include "quasselui.h" +#include "qtui.h" +#include "qtuistyle.h" ChatView::ChatView(BufferId bufferId, QWidget *parent) : QGraphicsView(parent), @@ -70,11 +71,37 @@ void ChatView::init(MessageFilter *filter) { connect(_scene, SIGNAL(lastLineChanged(QGraphicsItem *, qreal)), this, SLOT(lastLineChanged(QGraphicsItem *, qreal))); connect(_scene, SIGNAL(mouseMoveWhileSelecting(const QPointF &)), this, SLOT(mouseMoveWhileSelecting(const QPointF &))); setScene(_scene); - // installEventFilter(_scene); connect(verticalScrollBar(), SIGNAL(valueChanged(int)), this, SLOT(verticalScrollbarChanged(int))); } +bool ChatView::event(QEvent *event) { + if(event->type() == QEvent::KeyPress) { + QKeyEvent *keyEvent = static_cast(event); + switch(keyEvent->key()) { + case Qt::Key_Up: + case Qt::Key_Down: + case Qt::Key_PageUp: + case Qt::Key_PageDown: + if(!verticalScrollBar()->isVisible()) { + scene()->requestBacklog(); + return true; + } + default: + break; + } + } + + if(event->type() == QEvent::Wheel) { + if(!verticalScrollBar()->isVisible()) { + scene()->requestBacklog(); + return true; + } + } + + return QGraphicsView::event(event); +} + void ChatView::resizeEvent(QResizeEvent *event) { QGraphicsView::resizeEvent(event); @@ -138,6 +165,10 @@ void ChatView::verticalScrollbarChanged(int newPos) { } } _lastScrollbarPos = newPos; + + // FIXME: Fugly workaround for the ChatView scrolling up 1px on buffer switch + if(vbar->maximum() - newPos <= 2) + vbar->setValue(vbar->maximum()); } MsgId ChatView::lastMsgId() const {