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

Method createTCODataFiles

src/core/Track.cpp:605–647  ·  view source on GitHub ↗

! \brief Create a DataFile suitable for copying multiple trackContentObjects. * * trackContentObjects in the vector are written to the "tcos" node in the * DataFile. The trackContentObjectView's initial mouse position is written * to the "initialMouseX" node in the DataFile. When dropped on a track, * this is used to create copies of the TCOs. * * \param tcos The trackContectObjects to

Source from the content-addressed store, hash-verified

603 * \param tcos The trackContectObjects to save in a DataFile
604 */
605DataFile TrackContentObjectView::createTCODataFiles(
606 const QVector<TrackContentObjectView *> & tcoViews) const
607{
608 Track * t = m_trackView->getTrack();
609 TrackContainer * tc = t->trackContainer();
610 DataFile dataFile( DataFile::DragNDropData );
611 QDomElement tcoParent = dataFile.createElement( "tcos" );
612
613 typedef QVector<TrackContentObjectView *> tcoViewVector;
614 for( tcoViewVector::const_iterator it = tcoViews.begin();
615 it != tcoViews.end(); ++it )
616 {
617 // Insert into the dom under the "tcos" element
618 Track* tcoTrack = ( *it )->m_trackView->getTrack();
619 int trackIndex = tc->tracks().indexOf( tcoTrack );
620 QDomElement tcoElement = dataFile.createElement( "tco" );
621 tcoElement.setAttribute( "trackIndex", trackIndex );
622 tcoElement.setAttribute( "trackType", tcoTrack->type() );
623 tcoElement.setAttribute( "trackName", tcoTrack->name() );
624 ( *it )->m_tco->saveState( dataFile, tcoElement );
625 tcoParent.appendChild( tcoElement );
626 }
627
628 dataFile.content().appendChild( tcoParent );
629
630 // Add extra metadata needed for calculations later
631 int initialTrackIndex = tc->tracks().indexOf( t );
632 if( initialTrackIndex < 0 )
633 {
634 printf("Failed to find selected track in the TrackContainer.\n");
635 return dataFile;
636 }
637 QDomElement metadata = dataFile.createElement( "copyMetadata" );
638 // initialTrackIndex is the index of the track that was touched
639 metadata.setAttribute( "initialTrackIndex", initialTrackIndex );
640 metadata.setAttribute( "trackContainerId", tc->id() );
641 // grabbedTCOPos is the pos of the tact containing the TCO we grabbed
642 metadata.setAttribute( "grabbedTCOPos", m_tco->startPosition() );
643
644 dataFile.content().appendChild( metadata );
645
646 return dataFile;
647}
648
649/*! \brief Handle a mouse press on this trackContentObjectView.
650 *

Callers

nothing calls this directly

Calls 7

tracksMethod · 0.80
getTrackMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
typeMethod · 0.45
nameMethod · 0.45
saveStateMethod · 0.45

Tested by

no test coverage detected