ChatView now asks the scene if scrolling is ok on message appending
authorManuel Nickschas <sputnick@quassel-irc.org>
Fri, 7 Nov 2008 10:38:32 +0000 (11:38 +0100)
committerManuel Nickschas <sputnick@quassel-irc.org>
Fri, 7 Nov 2008 10:41:02 +0000 (11:41 +0100)
That way, the scene can inhibit autoscroll for example while selecting, or during
a click sequence (nothing is more annoying than a link that scrolls away while you have
the button still pressed...). The former is already implemented, the latter follows next
as soon as I get a decent click handling going.

src/qtui/chatscene.cpp
src/qtui/chatscene.h
src/qtui/chatview.cpp

index 8199648..358eb12 100644 (file)
@@ -513,6 +513,15 @@ void ChatScene::updateSelection(const QPointF &pos) {
   }
 }
 
   }
 }
 
+bool ChatScene::isScrollingAllowed() const {
+  if(_isSelecting)
+    return false;
+
+  // TODO: Handle clicks and single-item selections too
+
+  return true;
+}
+
 void ChatScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
   if(_isSelecting && event->buttons() == Qt::LeftButton) {
     updateSelection(event->scenePos());
 void ChatScene::mouseMoveEvent(QGraphicsSceneMouseEvent *event) {
   if(_isSelecting && event->buttons() == Qt::LeftButton) {
     updateSelection(event->scenePos());
index a932380..0c9329e 100644 (file)
@@ -72,6 +72,8 @@ public:
   inline CutoffMode senderCutoffMode() const { return _cutoffMode; }
   inline void setSenderCutoffMode(CutoffMode mode) { _cutoffMode = mode; }
 
   inline CutoffMode senderCutoffMode() const { return _cutoffMode; }
   inline void setSenderCutoffMode(CutoffMode mode) { _cutoffMode = mode; }
 
+  bool isScrollingAllowed() const;
+
   virtual bool event(QEvent *e);
 
  public slots:
   virtual bool event(QEvent *e);
 
  public slots:
index d360d9d..536a511 100644 (file)
@@ -108,6 +108,9 @@ void ChatView::scrollTimerTimeout() {
 
 void ChatView::lastLineChanged(QGraphicsItem *chatLine, qreal offset) {
   Q_UNUSED(chatLine)
 
 void ChatView::lastLineChanged(QGraphicsItem *chatLine, qreal offset) {
   Q_UNUSED(chatLine)
+  if(!scene()->isScrollingAllowed())
+    return;
+
   QAbstractSlider *vbar = verticalScrollBar();
   Q_ASSERT(vbar);
   if(vbar->maximum() - vbar->value() <= (offset + 5) * _currentScaleFactor ) { // 5px grace area
   QAbstractSlider *vbar = verticalScrollBar();
   Q_ASSERT(vbar);
   if(vbar->maximum() - vbar->value() <= (offset + 5) * _currentScaleFactor ) { // 5px grace area