Skip to content

Commit b4a7270

Browse files
author
Koen Deforche
committed
fix scrolled() signal in WTableView
1 parent a3815bd commit b4a7270

File tree

7 files changed

+27
-7
lines changed

7 files changed

+27
-7
lines changed

src/Wt/WAbstractItemView

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,12 @@ public:
779779
*/
780780
Signal<int, WMouseEvent> &headerDoubleClicked() { return headerDblClicked_; }
781781

782+
/*! \brief Signals when scrolling.
783+
*
784+
* \note Works only if ajax is available.
785+
*/
786+
virtual EventSignal<WScrollEvent>& scrolled() = 0;
787+
782788
/*! \brief Configures the number of columns that are used as row
783789
* headers.
784790
*
@@ -888,6 +894,7 @@ protected:
888894
*/
889895
virtual WWidget *createPageNavigationBar();
890896

897+
891898
protected:
892899
struct ColumnInfo {
893900
WCssTemplateRule *styleRule;

src/Wt/WTableView

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,7 @@ public:
106106

107107
WModelIndex modelIndexAt(WWidget *widget) const;
108108

109-
/*! \brief Signals when scrolling.
110-
*
111-
* \note Works only if ajax is available.
112-
*/
113-
EventSignal<WScrollEvent>& scrolled();
109+
virtual EventSignal<WScrollEvent>& scrolled();
114110

115111
protected:
116112
virtual void render(WFlags<RenderFlag> flags);

src/Wt/WTableView.C

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ WTableView::WTableView(WContainerWidget *parent)
166166
"if (obj) obj.autoJavaScript();}");
167167

168168
connectObjJS(canvas_->mouseWentDown(), "mouseDown");
169+
connectObjJS(contentsContainer_->scrolled(),
170+
"onContentsContainerScroll");
169171
} else {
170172
plainTable_ = new WTable();
171173
plainTable_->setStyleClass("Wt-plaintable");

src/Wt/WTreeView

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ public:
247247

248248
virtual void scrollTo(const WModelIndex& index,
249249
ScrollHint hint = EnsureVisible);
250+
virtual EventSignal<WScrollEvent>& scrolled();
250251

251252
protected:
252253
virtual void render(WFlags<RenderFlag> flags);

src/Wt/WTreeView.C

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2791,6 +2791,12 @@ void WTreeView::scrollTo(const WModelIndex& index, ScrollHint hint)
27912791
setCurrentPage(row / pageSize());
27922792
}
27932793

2794+
EventSignal<WScrollEvent>& WTreeView::scrolled(){
2795+
if (wApp->environment().ajax() && contentsContainer_ != 0)
2796+
return contentsContainer_->scrolled();
2797+
2798+
throw WException("Scrolled signal existes only with ajax.");
2799+
}
27942800
}
27952801

27962802
#endif // DOXYGEN_ONLY

src/http/WtReply.C

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,15 @@ void WtReply::consumeRequestBody(Buffer::const_iterator begin,
174174
in_->seekg(0); // rewind
175175

176176
// Note: cannot be wrapped in the strand because then we get into
177-
// trouble with recursive event loop?
177+
// trouble with recursive event loop
178+
//
179+
// Are we sure that the reply object isn't deleted before it's used?
180+
// the httpRequest_ has a WtReplyPtr and httpRequest_ is only deleted
181+
// from the destructor, so that's okay.
182+
//
183+
// The WtReplyPtr is reset in HTTPRequest::flush(Done), could that
184+
// be called already? No because nobody is aware yet of this request
185+
// object.
178186
connection->server()->service().post
179187
(boost::bind(&Wt::WebController::handleRequest,
180188
connection->server()->controller(),

src/js/WTableView.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ WT_DECLARE_WT_MEMBER
2828
*/
2929
var scrollTop = 0, scrollLeft = 0, currentWidth = 0, currentHeight = 0;
3030

31-
contentsContainer.onscroll = function() {
31+
this.onContentsContainerScroll = function() {
3232
scrollLeft = headerContainer.scrollLeft
3333
= contentsContainer.scrollLeft;
3434
scrollTop = headerColumnsContainer.scrollTop

0 commit comments

Comments
 (0)