Logo Search packages:      
Sourcecode: canorus version File versions  Download package

void CAMainWin::scoreViewPortMouseRelease ( QMouseEvent *  e,
const QPoint  coords 
) [private, slot]

Processes the mouse move event e with coordinates coords. Any action happened in any of the viewports are always linked to its main window slots.

See also:
CAScoreViewPort::mouseReleaseEvent(), scoreViewPortMousePress(), scoreViewPortMouseMove(), scoreViewPortWheel(), scoreViewPortKeyPress()

Definition at line 1793 of file mainwin.cpp.

References CAScoreViewPort::addToSelection(), CAScoreViewPort::clearSelection(), CAScoreViewPort::clearSelectionRegionList(), CAScoreViewPort::findContextsInRegion(), CAScoreViewPort::lastMousePressCoords(), CAScoreViewPort::resizeDirection(), CAScoreViewPort::selectedVoice(), CAScoreViewPort::sheet(), and CAVoice::staff().

Referenced by initViewPort().

                                                                       {
      CAScoreViewPort *c = static_cast<CAScoreViewPort*>(sender());
      if ( c->resizeDirection()!=CADrawable::Undefined ) {
            CACanorus::undo()->pushUndoCommand();
            CACanorus::rebuildUI(document(), c->sheet());
      }

      if ( mode() != InsertMode  && c->lastMousePressCoords()!=coords ) { // area was selected
            c->clearSelectionRegionList();

            if (e->modifiers()==Qt::NoModifier)
                  c->clearSelection();

            int x=c->lastMousePressCoords().x(), y=c->lastMousePressCoords().y(),
                w=coords.x()-c->lastMousePressCoords().x(), h=coords.y()-c->lastMousePressCoords().y();
            if (w<0) { x+=w; w*=(-1); } // user selected from right to left
            if (h<0) { y+=h; h*=(-1); } // user selected from bottom to top
            QRect selectionRect( x, y, w, h );

            QList<CADrawableContext*> dcList = c->findContextsInRegion( selectionRect );
            for (int i=0; i<dcList.size(); i++) {
                  QList<CADrawableMusElement*> musEltList = dcList[i]->findInRange( selectionRect.x(), selectionRect.x() + selectionRect.width() );
                  if ( c->selectedVoice() && dcList[i]->context()!=c->selectedVoice()->staff() )
                        continue;

                  for (int j=0; j<musEltList.size(); j++)
                        if ((!musEltList[j]->isSelectable()) ||
                              (c->selectedVoice() && musEltList[j]->musElement()->isPlayable() &&
                                    static_cast<CAPlayable*>(musEltList[j]->musElement())->voice()!=c->selectedVoice()) ||
                              (musEltList[j]->drawableMusElementType()==CADrawableMusElement::DrawableSlur)
                        )
                              musEltList.removeAt(j--);
                  c->addToSelection(musEltList);
            }
            c->repaint();
      }
}


Generated by  Doxygen 1.6.0   Back to index