On 04/18/2012 02:12 PM, E. Liddell wrote:
void K3bAudioEditorWidget::mousePressEvent(
TQMouseEvent* e ) {
m_draggedRange = 0;
m_draggedMarker = 0;
bool end;
Range* r = findRangeEdge(e->pos(),&end);
if (r) {
m_draggedRange = r;
m_draggingRangeEnd = end;
}
else {
r = findRange( e->pos() );
d->movedRange = r;
d->lastMovePosition = posToMsf( e->pos().x() );
m_draggedMarker = findMarker( e->pos() );
}
setSelectedRange( r );
TQFrame::mousePressEvent(e);
}
What say we do it like this:
void K3bAudioEditorWidget::mousePressEvent( TQMouseEvent* e )
{
Range* r = findRangeEdge( e->pos(), &end );
m_draggedRange = 0;
m_draggedMarker = 0;
bool end;
if (r) {
m_draggedRange = r;
m_draggingRangeEnd = end;
setSelectedRange(r);
}
else {
= findRange( e->pos() );
d->movedRange = r;
d->lastMovePosition = posToMsf( e->pos().x() );
setSelectedRange( r );
m_draggedMarker = findMarker( e->pos() );
}
TQFrame::mousePressEvent(e);
}
Here is why -- looking at the setSelectedRange code it has something to do
with repainting the screen, which brings up the question in my mind: "Does
setSelectedRange( r ); have to come 'before' m_draggedMarker = findMarker(
e->pos() ); -- as it is originally. That's the only reason I could think of
that the original author would have put it both after the 'if' and after the
'else' -- otherwise, I agree with you, just put it at the end.
I'm not sure how to check in the code to see if need to be before the
findMarker( e->pos() ); call. Can somebody who knows this stuff let us know?
Either way, the proposed patch above preserves the order of the calls --
the only remaining question is can we git rid of both setSelectedRange(r);
calls by moving a single call below the conditional... Small potatoes there...
Let me know. Thanks.
--
David C. Rankin, J.D.,P.E.