Jean-Marc Lasgouttes wrote:
>>> you check whether 'val' actually changed value?
>
> Alfredo> It doesn't work. The problem is that the signal is emmited
> Alfredo> when the value has been just changed.
>
> You can also cache the value somewhere.
qt seems to emit only when the value is actually changed (good). The problem
is that on update, we redraw and then call to adjust the scrollbar, with a
new value, and this calls an update again.
The main problem right now with scrolling is that fitCursor adjusts the
scrollbar, that calls an update under qt but not under xforms.
So for adjusting qt without touching xforms we need to set the scrollbar
value without invoking the signal. Something like the attached works
(altough it is not so nice maybe). Alternatively, we can just disconnect
the signal before setValue and reconnect it after. Other ideas welcomed.
Alfredo
Index: QContentPane.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QContentPane.C,v
retrieving revision 1.26
diff -u -p -u -r1.26 QContentPane.C
--- QContentPane.C 21 Sep 2003 16:02:53 -0000 1.26
+++ QContentPane.C 20 Nov 2003 08:29:23 -0000
@@ -76,7 +76,7 @@ mouse_button::state q_motion_state(Qt::B
QContentPane::QContentPane(QWorkArea * parent)
: QWidget(parent, "content_pane", WRepaintNoErase),
- wa_(parent)
+ wa_(parent), track_scrollbar(true)
{
setFocusPolicy(QWidget::WheelFocus);
setFocus();
@@ -91,7 +91,8 @@ QContentPane::QContentPane(QWorkArea * p
void QContentPane::scrollBarChanged(int val)
{
- wa_->scrollDocView(val);
+ if (track_scrollbar)
+ wa_->scrollDocView(val);
}
Index: QContentPane.h
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QContentPane.h,v
retrieving revision 1.10
diff -u -p -u -r1.10 QContentPane.h
--- QContentPane.h 7 Sep 2003 21:25:34 -0000 1.10
+++ QContentPane.h 20 Nov 2003 08:29:23 -0000
@@ -50,6 +50,8 @@ public:
/// return the backing pixmap
QPixmap * pixmap() const { return pixmap_.get(); }
+ ///
+ bool track_scrollbar;
protected:
/// repaint part of the widget
void paintEvent(QPaintEvent * e);
Index: QWorkArea.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/frontends/qt2/QWorkArea.C,v
retrieving revision 1.22
diff -u -p -u -r1.22 QWorkArea.C
--- QWorkArea.C 6 Oct 2003 15:42:52 -0000 1.22
+++ QWorkArea.C 20 Nov 2003 08:29:24 -0000
@@ -66,9 +66,10 @@ void QWorkArea::setScrollbarParams(int h
h += height() / 4;
int max = std::max(0, h - height());
-
scrollbar_->setRange(0, max);
+ content_->track_scrollbar = false;
scrollbar_->setValue(pos);
+ content_->track_scrollbar = true;
scrollbar_->setLineStep(line_h);
scrollbar_->setPageStep(height());
}