! \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. */
| 534 | * \param de The QDropEvent to handle. |
| 535 | */ |
| 536 | void 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 |
nothing calls this directly
no test coverage detected