From 1661aba15f2e09fca6f922816deb2e4660995e81 Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Fri, 22 Aug 2008 21:02:33 +0000 Subject: [PATCH] implemented correct behaviour when cloning BB-tracks (closes #2042409) git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1465 0778d3d1-df1d-0410-868b-ea421aaaa00d --- ChangeLog | 6 ++++++ include/bb_track_container.h | 3 +-- include/track.h | 12 ++++++------ src/core/track.cpp | 2 +- src/tracks/bb_track.cpp | 29 +++++++++++++++++++++++++---- 5 files changed, 39 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8aaeefaba..b328b1704 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2008-08-22 Tobias Doerffel + * include/bb_track_container.h: + * include/track.h: + * src/core/track.cpp: + * src/tracks/bb_track.cpp: + implemented correct behaviour when cloning BB-tracks (closes #2042409) + * src/core/midi/midi_alsa_seq.cpp: fixed strange ALSA-sequencer behaviour when using MIDI-controllers and controlling intrument-tracks via MIDI (closes #2062907) diff --git a/include/bb_track_container.h b/include/bb_track_container.h index 51bb87188..7685d8742 100644 --- a/include/bb_track_container.h +++ b/include/bb_track_container.h @@ -61,6 +61,7 @@ public: void updateBBTrack( trackContentObject * _tco ); void fixIncorrectPositions( void ); + void createTCOsForBB( int _bb ); public slots: @@ -71,8 +72,6 @@ public slots: private: - void createTCOsForBB( int _bb ); - comboBoxModel m_bbComboBoxModel; diff --git a/include/track.h b/include/track.h index bd65a678b..7a5d02d77 100644 --- a/include/track.h +++ b/include/track.h @@ -112,17 +112,17 @@ public: virtual trackContentObjectView * createView( trackView * _tv ) = 0; -protected: - virtual void undoStep( journalEntry & _je ); - virtual void redoStep( journalEntry & _je ); - - -protected slots: +public slots: void copy( void ); void paste( void ); void toggleMute( void ); +protected: + virtual void undoStep( journalEntry & _je ); + virtual void redoStep( journalEntry & _je ); + + signals: void lengthChanged( void ); void positionChanged( void ); diff --git a/src/core/track.cpp b/src/core/track.cpp index 01f904a49..49c9cad53 100644 --- a/src/core/track.cpp +++ b/src/core/track.cpp @@ -1613,7 +1613,7 @@ track * track::create( TrackTypes _tt, trackContainer * _tc ) -/*! \brief Create a track from track type in a QDomElement and a container object. +/*! \brief Create a track inside trackContainer from track type in a QDomElement and restore state from XML * * \param _this The QDomElement containing the type of track to create * \param _tc The track container to attach to diff --git a/src/tracks/bb_track.cpp b/src/tracks/bb_track.cpp index ad82d3d95..7a1be0dae 100644 --- a/src/tracks/bb_track.cpp +++ b/src/tracks/bb_track.cpp @@ -437,6 +437,10 @@ void bbTrack::saveTrackSpecificSettings( QDomDocument & _doc, ( (journallingObject *)( engine::getBBTrackContainer() ) )-> saveState( _doc, _this ); } + if( _this.parentNode().parentNode().nodeName() == "clone" ) + { + _this.setAttribute( "clonebbt", s_infoMap[this] ); + } } @@ -448,13 +452,30 @@ void bbTrack::loadTrackSpecificSettings( const QDomElement & _this ) { m_trackLabel->setPixmapFile( _this.attribute( "icon" ) ); }*/ -// engine::getBBTrackContainer()->updateComboBox(); - QDomNode node = _this.namedItem( trackContainer::classNodeName() ); - if( node.isElement() ) + if( _this.hasAttribute( "clonebbt" ) ) { - ( (journallingObject *)engine::getBBTrackContainer() )-> + const int src = _this.attribute( "clonebb" ).toInt(); + const int dst = s_infoMap[this]; + engine::getBBTrackContainer()->createTCOsForBB( dst ); + trackContainer::trackList tl = + engine::getBBTrackContainer()->tracks(); + for( trackContainer::trackList::iterator it = tl.begin(); + it != tl.end(); ++it ) + { + ( *it )->getTCO( src )->copy(); + ( *it )->getTCO( dst )->paste(); + } + } + else + { + QDomNode node = _this.namedItem( + trackContainer::classNodeName() ); + if( node.isElement() ) + { + ( (journallingObject *)engine::getBBTrackContainer() )-> restoreState( node.toElement() ); + } } /* doesn't work yet because bbTrack-ctor also sets current bb so if bb-tracks are created after this function is called, this doesn't