added simple-serializing mode which makes tracks not save their TCOs - used for improved save and restore of presets (closes #2025902)

git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1417 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
Tobias Doerffel
2008-07-30 22:56:09 +00:00
parent 63edd1e0d7
commit 4541e1abd7
5 changed files with 106 additions and 17 deletions

View File

@@ -1551,6 +1551,7 @@ track::track( TrackTypes _type, trackContainer * _tc ) :
/*!< For controlling track muting */
m_soloModel( FALSE, this, tr( "Solo" ) ),
/*!< For controlling track soloing */
m_simpleSerializingMode( FALSE ),
m_trackContentObjects() /*!< The track content objects (segments) */
{
m_trackContainer->addTrack( this );
@@ -1661,7 +1662,10 @@ void track::clone( void )
*/
void track::saveSettings( QDomDocument & _doc, QDomElement & _this )
{
_this.setTagName( "track" );
if( !m_simpleSerializingMode )
{
_this.setTagName( "track" );
}
_this.setAttribute( "type", type() );
_this.setAttribute( "name", name() );
_this.setAttribute( "muted", isMuted() );
@@ -1674,6 +1678,12 @@ void track::saveSettings( QDomDocument & _doc, QDomElement & _this )
_this.appendChild( ts_de );
saveTrackSpecificSettings( _doc, ts_de );
if( m_simpleSerializingMode )
{
m_simpleSerializingMode = FALSE;
return;
}
// now save settings of all TCO's
for( tcoVector::const_iterator it = m_trackContentObjects.begin();
it != m_trackContentObjects.end(); ++it )
@@ -1710,6 +1720,22 @@ void track::loadSettings( const QDomElement & _this )
setMuted( _this.attribute( "muted" ).toInt() );
if( m_simpleSerializingMode )
{
QDomNode node = _this.firstChild();
while( !node.isNull() )
{
if( node.isElement() && node.nodeName() == nodeName() )
{
loadTrackSpecificSettings( node.toElement() );
break;
}
node = node.nextSibling();
}
m_simpleSerializingMode = FALSE;
return;
}
while( !m_trackContentObjects.empty() )
{
delete m_trackContentObjects.front();

View File

@@ -251,10 +251,8 @@ void listView::activateListItem( QTreeWidgetItem * _item, int _column )
engine::getBBTrackContainer() ) );
if( it != NULL )
{
it->loadTrackSpecificSettings( mmp.content().
firstChild().
toElement() );
//it->toggledInstrumentTrackButton( TRUE );
it->setSimpleSerializing();
it->loadSettings( mmp.content().toElement() );
}
engine::getMixer()->unlock();
}
@@ -312,9 +310,9 @@ void listView::sendToActiveInstrumentTrack( void )
multimediaProject mmp(
m_contextMenuItem->fullName() );
removeMidiPortNode( mmp );
itw->model()->loadTrackSpecificSettings(
mmp.content().firstChild().
toElement() );
itw->model()->setSimpleSerializing();
itw->model()->loadSettings(
mmp.content().toElement() );
}
engine::getMixer()->unlock();
break;
@@ -351,13 +349,11 @@ void listView::openInNewInstrumentTrack( trackContainer * _tc )
multimediaProject mmp( m_contextMenuItem->fullName() );
removeMidiPortNode( mmp );
track * t = track::create( track::InstrumentTrack, _tc );
instrumentTrack * ct = dynamic_cast<instrumentTrack *>( t );
if( ct != NULL )
instrumentTrack * it = dynamic_cast<instrumentTrack *>( t );
if( it != NULL )
{
ct->loadTrackSpecificSettings( mmp.content().
firstChild().
toElement() );
//ct->toggledInstrumentTrackButton( TRUE );
it->setSimpleSerializing();
it->loadSettings( mmp.content().toElement() );
}
}
engine::getMixer()->unlock();

View File

@@ -1236,9 +1236,8 @@ void instrumentTrackWindow::saveSettingsBtnClicked( void )
{
multimediaProject mmp(
multimediaProject::InstrumentTrackSettings );
QDomElement _this = mmp.createElement( m_track->nodeName() );
m_track->saveTrackSpecificSettings( mmp, _this );
mmp.content().appendChild( _this );
m_track->setSimpleSerializing();
m_track->saveSettings( mmp, mmp.content() );
QString f = sfd.selectedFiles()[0];
mmp.writeFile( f );
}