MCPcopy Create free account
hub / github.com/LMMS/lmms / dropEvent

Method dropEvent

src/core/Track.cpp:536–575  ·  view source on GitHub ↗

! \brief Handle something being dropped on this trackContentObjectView. * * When something has been dropped on this trackContentObjectView, and * it's a track content object, then use an instance of our dataFile reader * to take the xml of the track content object and turn it into something * we can write over our current state. * * \param de The QDropEvent to handle. */

Source from the content-addressed store, hash-verified

534 * \param de The QDropEvent to handle.
535 */
536void TrackContentObjectView::dropEvent( QDropEvent * de )
537{
538 QString type = StringPairDrag::decodeKey( de );
539 QString value = StringPairDrag::decodeValue( de );
540
541 // Track must be the same type to paste into
542 if( type != ( "tco_" + QString::number( m_tco->getTrack()->type() ) ) )
543 {
544 return;
545 }
546
547 // Defer to rubberband paste if we're in that mode
548 if( m_trackView->trackContainerView()->allowRubberband() == true )
549 {
550 TrackContentWidget * tcw = getTrackView()->getTrackContentWidget();
551 MidiTime tcoPos = MidiTime( m_tco->startPosition().getTact(), 0 );
552 if( tcw->pasteSelection( tcoPos, de ) == true )
553 {
554 de->accept();
555 }
556 return;
557 }
558
559 // Don't allow pasting a tco into itself.
560 QObject* qwSource = de->source();
561 if( qwSource != NULL &&
562 dynamic_cast<TrackContentObjectView *>( qwSource ) == this )
563 {
564 return;
565 }
566
567 // Copy state into existing tco
568 DataFile dataFile( value.toUtf8() );
569 MidiTime pos = m_tco->startPosition();
570 QDomElement tcos = dataFile.content().firstChildElement( "tcos" );
571 m_tco->restoreState( tcos.firstChildElement().firstChildElement() );
572 m_tco->movePosition( pos );
573 AutomationPattern::resolveAllIDs();
574 de->accept();
575}
576
577
578

Callers

nothing calls this directly

Calls 14

MidiTimeClass · 0.85
mixerFunction · 0.85
getTrackContentWidgetMethod · 0.80
getTactMethod · 0.80
pasteSelectionMethod · 0.80
requestChangeInModelMethod · 0.80
doneChangeInModelMethod · 0.80
typeMethod · 0.45
getTrackMethod · 0.45
allowRubberbandMethod · 0.45
trackContainerViewMethod · 0.45
acceptMethod · 0.45

Tested by

no test coverage detected