@@ -252,13 +252,6 @@ WAbstractItemView::WAbstractItemView(WContainerWidget *parent)
252252
253253 typedef WAbstractItemView Self ;
254254
255- headerClickedMapper_ = new WSignalMapper < int > (this );
256- headerClickedMapper_ -> mapped ().connect (this , & Self ::handleHeaderClicked );
257-
258- headerDblClickedMapper_ = new WSignalMapper < int > (this );
259- headerDblClickedMapper_ -> mapped ().connect (this ,
260- & Self ::handleHeaderDblClicked );
261-
262255 clickedForCollapseMapper_ = new WSignalMapper < int > (this );
263256 clickedForCollapseMapper_ -> mapped ().connect (this , & Self ::collapseColumn );
264257
@@ -293,11 +286,13 @@ WAbstractItemView::~WAbstractItemView()
293286
294287void WAbstractItemView ::setModel (WAbstractItemModel * model )
295288{
289+ bool isReset = false;
296290 if (model_ ) {
297291 /* disconnect slots from previous model */
298292 for (unsigned i = 0 ; i < modelConnections_ .size (); ++ i )
299293 modelConnections_ [i ].disconnect ();
300294 modelConnections_ .clear ();
295+ isReset = true;
301296 }
302297
303298 model_ = model ;
@@ -312,6 +307,9 @@ void WAbstractItemView::setModel(WAbstractItemModel *model)
312307
313308 editedItems_ .clear ();
314309
310+ if (!isReset )
311+ initDragDrop ();
312+
315313 configureModelDragDrop ();
316314
317315 setRootIndex (WModelIndex ());
@@ -607,8 +605,6 @@ void WAbstractItemView::dropEvent(const WDropEvent& e, const WModelIndex& index)
607605
608606void WAbstractItemView ::configureModelDragDrop ()
609607{
610- initDragDrop ();
611-
612608 if (!model_ )
613609 return ;
614610
@@ -675,20 +671,20 @@ WWidget *WAbstractItemView::extraHeaderWidget(int column)
675671 return columnInfo (column ).extraHeaderWidget ;
676672}
677673
678- void WAbstractItemView ::handleHeaderClicked (int columnid )
674+ void WAbstractItemView ::handleHeaderClicked (int columnid , WMouseEvent event )
679675{
680676 int column = columnById (columnid );
681677 ColumnInfo & info = columnInfo (column );
682678
683679 if (sortEnabled_ && info .sorting )
684680 toggleSortColumn (columnid );
685681
686- headerClicked_ .emit (column );
682+ headerClicked_ .emit (column , event );
687683}
688684
689- void WAbstractItemView ::handleHeaderDblClicked (int columnid )
685+ void WAbstractItemView ::handleHeaderDblClicked (int columnid , WMouseEvent event )
690686{
691- headerDblClicked_ .emit (columnById (columnid ));
687+ headerDblClicked_ .emit (columnById (columnid ), event );
692688}
693689
694690void WAbstractItemView ::toggleSortColumn (int columnid )
@@ -1011,8 +1007,9 @@ WWidget *WAbstractItemView::createHeaderWidget(int column)
10111007 sortIcon -> setObjectName ("sort" );
10121008 sortIcon -> setInline (false);
10131009 sortIcon -> setStyleClass ("Wt-tv-sh Wt-tv-sh-none" );
1014- headerClickedMapper_ -> mapConnect (sortIcon -> clicked (), info .id );
1015-
1010+ sortIcon -> clicked ().connect (
1011+ boost ::bind (& WAbstractItemView ::handleHeaderClicked ,
1012+ this , info .id , _1 ));
10161013 if (currentSortColumn_ == column )
10171014 sortIcon -> setStyleClass (info .sortOrder == AscendingOrder
10181015 ? "Wt-tv-sh Wt-tv-sh-up"
@@ -1043,8 +1040,12 @@ WWidget *WAbstractItemView::createHeaderWidget(int column)
10431040 // FIXME: we probably want this as an API option ?
10441041 WInteractWidget * ww = dynamic_cast < WInteractWidget * > (i );
10451042 if (ww ){
1046- headerClickedMapper_ -> mapConnect (ww -> clicked (), info .id );
1047- headerDblClickedMapper_ -> mapConnect (ww -> doubleClicked (), info .id );
1043+ ww -> clicked ().connect (
1044+ boost ::bind (& WAbstractItemView ::handleHeaderClicked , this ,
1045+ info .id , _1 ));
1046+ ww -> doubleClicked ().connect (
1047+ boost ::bind (& WAbstractItemView ::handleHeaderDblClicked ,
1048+ this , info .id , _1 ));
10481049 }
10491050
10501051 int headerLevel = model_ ? this -> headerLevel (column ) : 0 ;
0 commit comments