//this is from QHeader::mouseReleaseEvent
{
if ( e->button() != LeftButton )
return;
int oldOldHandleIdx = oldHandleIdx;
State oldState = state;
state = Idle;
switch ( oldState ) {
case Pressed: {
int section = d->i2s[handleIdx];
emit released( section );
if ( sRect( handleIdx ).contains( e->pos() ) ) {
oldHandleIdx = handleIdx;
emit sectionClicked( handleIdx );
emit clicked( section );
} else {
handleIdx = oldHandleIdx;
}
repaint(sRect( handleIdx ), FALSE);
if ( oldOldHandleIdx != handleIdx )
repaint(sRect(oldOldHandleIdx ), FALSE );
} break;
case Sliding: {
int c = orient == Horizontal ? e->pos().x() : e->pos().y();
c += offset();
if ( reverse() )
c = d->lastPos - c;
handleColumnResize( handleIdx, c - d->pressDelta, TRUE );
} break;
case Moving: {
#ifndef QT_NO_CURSOR
unsetCursor();
#endif
int section = d->i2s[handleIdx];
if ( handleIdx != moveToIdx && moveToIdx != -1 ) {
moveSection( section, moveToIdx );
handleIdx = oldHandleIdx;
//---------------------------------------------------------------------
// looks like all we do here is call moveSection and then emit signals and everyone is happy
//---------------------------------------------------------------------
emit moved( handleIdx, moveToIdx );
emit indexChange( section, handleIdx, moveToIdx );
emit released( section );
repaint(); // a bit overkill, but removes the handle as well
} else {
if ( sRect( handleIdx).contains( e->pos() ) ) {
oldHandleIdx = handleIdx;
emit released( section );
emit sectionClicked( handleIdx );
emit clicked( section );
} else {
handleIdx = oldHandleIdx;
}
repaint(sRect( handleIdx ), FALSE );
if(oldOldHandleIdx != handleIdx)
repaint(sRect(oldOldHandleIdx ), FALSE );
}
break;
}
case Blocked:
//nothing
break;
default:
// empty, probably. Idle, at any rate.
break;
}
}
//-----------------------------------------------------------------------------
//this is inside the QListView's constructor
//-----------------------------------------------------------------------------
connect( d->h, SIGNAL(sizeChange(int,int,int)),
this, SLOT(handleSizeChange(int,int,int)) );
connect( d->h, SIGNAL(indexChange(int,int,int)),
this, SLOT(handleIndexChange()) );
connect( d->h, SIGNAL(sectionClicked(int)),
this, SLOT(changeSortColumn(int)) );
connect( d->h, SIGNAL(sectionHandleDoubleClicked(int)),
this, SLOT(adjustColumn(int)) );
connect( horizontalScrollBar(), SIGNAL(sliderMoved(int)),
d->h, SLOT(setOffset(int)) );
connect( horizontalScrollBar(), SIGNAL(valueChanged(int)),
d->h, SLOT(setOffset(int)) );
//-----------------------------------------------------------------------------
//this is the handleIndexChange() method
//-----------------------------------------------------------------------------
/*!
\internal
Handles renaming when sections are being swapped by the user.
*/
{
if ( isRenaming() ) {
if ( d
->defRenameAction
== QListView::Reject ) { currentItem()->cancelRename( currentItem()->renameCol );
} else {
currentItem()->okRename( currentItem()->renameCol );
}
}
triggerUpdate();
}
//this is from QHeader::mouseReleaseEvent
void QHeader::mouseReleaseEvent( QMouseEvent *e )
{
if ( e->button() != LeftButton )
return;
int oldOldHandleIdx = oldHandleIdx;
State oldState = state;
state = Idle;
switch ( oldState ) {
case Pressed: {
int section = d->i2s[handleIdx];
emit released( section );
if ( sRect( handleIdx ).contains( e->pos() ) ) {
oldHandleIdx = handleIdx;
emit sectionClicked( handleIdx );
emit clicked( section );
} else {
handleIdx = oldHandleIdx;
}
repaint(sRect( handleIdx ), FALSE);
if ( oldOldHandleIdx != handleIdx )
repaint(sRect(oldOldHandleIdx ), FALSE );
} break;
case Sliding: {
int c = orient == Horizontal ? e->pos().x() : e->pos().y();
c += offset();
if ( reverse() )
c = d->lastPos - c;
handleColumnResize( handleIdx, c - d->pressDelta, TRUE );
} break;
case Moving: {
#ifndef QT_NO_CURSOR
unsetCursor();
#endif
int section = d->i2s[handleIdx];
if ( handleIdx != moveToIdx && moveToIdx != -1 ) {
moveSection( section, moveToIdx );
handleIdx = oldHandleIdx;
//---------------------------------------------------------------------
// looks like all we do here is call moveSection and then emit signals and everyone is happy
//---------------------------------------------------------------------
emit moved( handleIdx, moveToIdx );
emit indexChange( section, handleIdx, moveToIdx );
emit released( section );
repaint(); // a bit overkill, but removes the handle as well
} else {
if ( sRect( handleIdx).contains( e->pos() ) ) {
oldHandleIdx = handleIdx;
emit released( section );
emit sectionClicked( handleIdx );
emit clicked( section );
} else {
handleIdx = oldHandleIdx;
}
repaint(sRect( handleIdx ), FALSE );
if(oldOldHandleIdx != handleIdx)
repaint(sRect(oldOldHandleIdx ), FALSE );
}
break;
}
case Blocked:
//nothing
break;
default:
// empty, probably. Idle, at any rate.
break;
}
}
//-----------------------------------------------------------------------------
//this is inside the QListView's constructor
//-----------------------------------------------------------------------------
connect( d->h, SIGNAL(sizeChange(int,int,int)),
this, SLOT(handleSizeChange(int,int,int)) );
connect( d->h, SIGNAL(indexChange(int,int,int)),
this, SLOT(handleIndexChange()) );
connect( d->h, SIGNAL(sectionClicked(int)),
this, SLOT(changeSortColumn(int)) );
connect( d->h, SIGNAL(sectionHandleDoubleClicked(int)),
this, SLOT(adjustColumn(int)) );
connect( horizontalScrollBar(), SIGNAL(sliderMoved(int)),
d->h, SLOT(setOffset(int)) );
connect( horizontalScrollBar(), SIGNAL(valueChanged(int)),
d->h, SLOT(setOffset(int)) );
//-----------------------------------------------------------------------------
//this is the handleIndexChange() method
//-----------------------------------------------------------------------------
/*!
\internal
Handles renaming when sections are being swapped by the user.
*/
void QListView::handleIndexChange()
{
if ( isRenaming() ) {
if ( d->defRenameAction == QListView::Reject ) {
currentItem()->cancelRename( currentItem()->renameCol );
} else {
currentItem()->okRename( currentItem()->renameCol );
}
}
triggerUpdate();
}
To copy to clipboard, switch view to plain text mode
Apparently, all it does is some checks that I know in my case are all true (they PASS when checked by hand) and calls triggerUpdate(). When I call triggerUpdate after the column has moved, nothing happens.
Bookmarks