1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-23 09:20:16 +01:00

Move writing and reading of common Track fields into functions...

... also now writing selected state of TimeTrack as for other tracks, fixing
an omission, with no harm to forward compatibility
This commit is contained in:
Paul Licameli
2018-11-20 14:37:19 -05:00
parent 2b2d13d5be
commit 98f322d685
7 changed files with 60 additions and 58 deletions

View File

@@ -1279,6 +1279,46 @@ std::shared_ptr<const Track> Track::SubstituteOriginalTrack() const
return SharedPointer();
}
// Serialize, not with tags of its own, but as attributes within a tag.
void Track::WriteCommonXMLAttributes(
XMLWriter &xmlFile, bool includeNameAndSelected) const
{
if (includeNameAndSelected) {
xmlFile.WriteAttr(wxT("name"), GetName());
xmlFile.WriteAttr(wxT("isSelected"), this->GetSelected());
}
xmlFile.WriteAttr(wxT("height"), this->GetActualHeight());
xmlFile.WriteAttr(wxT("minimized"), this->GetMinimized());
}
// Return true iff the attribute is recognized.
bool Track::HandleCommonXMLAttribute(const wxChar *attr, const wxChar *value)
{
long nValue = -1;
wxString strValue( value );
if (!wxStrcmp(attr, wxT("name")) &&
XMLValueChecker::IsGoodString(strValue)) {
SetName( strValue );
return true;
}
else if (!wxStrcmp(attr, wxT("height")) &&
XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue)) {
SetHeight(nValue);
return true;
}
else if (!wxStrcmp(attr, wxT("minimized")) &&
XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue)) {
SetMinimized(nValue != 0);
return true;
}
else if (!wxStrcmp(attr, wxT("isSelected")) &&
XMLValueChecker::IsGoodInt(strValue) && strValue.ToLong(&nValue)) {
this->SetSelected(nValue != 0);
return true;
}
return false;
}
bool TrackList::HasPendingTracks() const
{
if ( !mPendingUpdates.empty() )