More const qualifiers, for copying of tracks, and replacing in lists of tracks
... (the tracks may be const, not the list, when replacing)
This commit is contained in:
parent
36f3f8aab2
commit
48a5f55179
|
@ -1270,7 +1270,7 @@ void LabelStruct::MoveLabel( int iEdge, double fNewTime)
|
|||
}
|
||||
|
||||
LabelStruct::TimeRelations LabelStruct::RegionRelation(
|
||||
double reg_t0, double reg_t1, LabelTrack * WXUNUSED(parent))
|
||||
double reg_t0, double reg_t1, const LabelTrack * WXUNUSED(parent))
|
||||
{
|
||||
bool retainLabels = false;
|
||||
|
||||
|
@ -2422,7 +2422,7 @@ bool LabelTrack::SplitCut(double t0, double t1, Track ** dest)
|
|||
}
|
||||
#endif
|
||||
|
||||
bool LabelTrack::Copy(double t0, double t1, Track ** dest)
|
||||
bool LabelTrack::Copy(double t0, double t1, Track ** dest) const
|
||||
{
|
||||
*dest = new LabelTrack(GetDirManager());
|
||||
int len = mLabels.Count();
|
||||
|
|
|
@ -81,7 +81,7 @@ public:
|
|||
/// and end of parent to be within a region that borders them (this makes
|
||||
/// it possible to DELETE capture all labels with a Select All).
|
||||
TimeRelations RegionRelation(double reg_t0, double reg_t1,
|
||||
LabelTrack *parent = NULL);
|
||||
const LabelTrack *parent = NULL);
|
||||
|
||||
public:
|
||||
SelectedRegion selectedRegion;
|
||||
|
@ -157,7 +157,7 @@ class AUDACITY_DLL_API LabelTrack final : public Track
|
|||
// or Paste() because then it
|
||||
// is no longer recognised as a virtual function matching the
|
||||
// one in Track.
|
||||
bool Copy (double t0, double t1, Track ** dest) override;// const;
|
||||
bool Copy (double t0, double t1, Track ** dest) const override;
|
||||
bool Clear(double t0, double t1) override;
|
||||
bool Paste(double t, const Track * src) override;
|
||||
bool Repeat(double t0, double t1, int n);
|
||||
|
|
|
@ -4592,7 +4592,7 @@ void AudacityProject::OnCutLabels()
|
|||
|
||||
// Because of grouping the copy may need to operate on different tracks than
|
||||
// the clear, so we do these actions separately.
|
||||
EditClipboardByLabel( &WaveTrack::Copy );
|
||||
EditClipboardByLabel( &WaveTrack::CopyNonconst );
|
||||
|
||||
if( gPrefs->Read( wxT( "/GUI/EnableCutLines" ), ( long )0 ) )
|
||||
EditByLabel( &WaveTrack::ClearAndAddCutLine, true );
|
||||
|
@ -4635,7 +4635,7 @@ void AudacityProject::OnCopyLabels()
|
|||
if( mViewInfo.selectedRegion.isPoint() )
|
||||
return;
|
||||
|
||||
EditClipboardByLabel( &WaveTrack::Copy );
|
||||
EditClipboardByLabel( &WaveTrack::CopyNonconst );
|
||||
|
||||
msClipProject = this;
|
||||
|
||||
|
|
|
@ -469,7 +469,7 @@ bool NoteTrack::Cut(double t0, double t1, Track **dest){
|
|||
return true;
|
||||
}
|
||||
|
||||
bool NoteTrack::Copy(double t0, double t1, Track **dest){
|
||||
bool NoteTrack::Copy(double t0, double t1, Track **dest) const {
|
||||
|
||||
//dest goes onto clipboard
|
||||
*dest = NULL; // This is redundant and matches WaveTrack::Copy
|
||||
|
|
|
@ -90,7 +90,7 @@ class AUDACITY_DLL_API NoteTrack final : public Track {
|
|||
|
||||
// High-level editing
|
||||
bool Cut (double t0, double t1, Track **dest) override;
|
||||
bool Copy (double t0, double t1, Track **dest) override;
|
||||
bool Copy (double t0, double t1, Track **dest) const override;
|
||||
bool Trim (double t0, double t1) /* not override */;
|
||||
bool Clear(double t0, double t1) override;
|
||||
bool Paste(double t, const Track *src) override;
|
||||
|
|
|
@ -132,7 +132,7 @@ Track::~Track()
|
|||
}
|
||||
|
||||
|
||||
const TrackListNode *Track::GetNode()
|
||||
const TrackListNode *Track::GetNode() const
|
||||
{
|
||||
return mNode;
|
||||
}
|
||||
|
@ -837,18 +837,22 @@ void TrackList::AddToHead(Track * t)
|
|||
ResizedEvent(n);
|
||||
}
|
||||
|
||||
void TrackList::Replace(Track * t, Track * with, bool deletetrack)
|
||||
void TrackList::Replace(const Track * t, const Track * with, bool deletetrack)
|
||||
{
|
||||
if (t && with) {
|
||||
TrackListNode *node = (TrackListNode *) t->GetNode();
|
||||
Track *const mutableT = const_cast<Track*>(t);
|
||||
Track *const mutableWith = const_cast<Track*>(with);
|
||||
|
||||
t->SetOwner(NULL, NULL);
|
||||
if (mutableT && with) {
|
||||
TrackListNode *node =
|
||||
const_cast<TrackListNode *>(mutableT->GetNode());
|
||||
|
||||
mutableT->SetOwner(NULL, NULL);
|
||||
if (deletetrack) {
|
||||
delete t;
|
||||
}
|
||||
|
||||
node->t = with;
|
||||
with->SetOwner(this, node);
|
||||
node->t = mutableWith;
|
||||
mutableWith->SetOwner(this, node);
|
||||
RecalcPositions(node);
|
||||
UpdatedEvent(node);
|
||||
ResizedEvent(node);
|
||||
|
|
|
@ -102,7 +102,7 @@ class AUDACITY_DLL_API Track /* not final */ : public XMLTagHandler
|
|||
#endif
|
||||
Track *GetLink() const;
|
||||
|
||||
const TrackListNode *GetNode();
|
||||
const TrackListNode *GetNode() const;
|
||||
void SetOwner(TrackList *list, TrackListNode *node);
|
||||
|
||||
// Keep in Track
|
||||
|
@ -181,7 +181,7 @@ class AUDACITY_DLL_API Track /* not final */ : public XMLTagHandler
|
|||
DirManager* GetDirManager() const { return mDirManager; }
|
||||
|
||||
virtual bool Cut (double WXUNUSED(t0), double WXUNUSED(t1), Track ** WXUNUSED(dest)) {return false;}
|
||||
virtual bool Copy (double WXUNUSED(t0), double WXUNUSED(t1), Track ** WXUNUSED(dest)) {return false;}
|
||||
virtual bool Copy (double WXUNUSED(t0), double WXUNUSED(t1), Track ** WXUNUSED(dest)) const {return false;}
|
||||
virtual bool Clear(double WXUNUSED(t0), double WXUNUSED(t1)) {return false;}
|
||||
virtual bool Paste(double WXUNUSED(t), const Track * WXUNUSED(src)) {return false;}
|
||||
|
||||
|
@ -385,7 +385,8 @@ class AUDACITY_DLL_API TrackList final : public wxEvtHandler
|
|||
void AddToHead(Track * t);
|
||||
|
||||
/// Replace first track with second track
|
||||
void Replace(Track * t, Track * with, bool deletetrack = false);
|
||||
/// Non-const function of TrackList, but it can take pointers to const tracks
|
||||
void Replace(const Track * t, const Track * with, bool deletetrack = false);
|
||||
|
||||
/// Remove this Track or all children of this TrackList.
|
||||
void Remove(Track * t, bool deletetrack = false);
|
||||
|
|
|
@ -1407,7 +1407,7 @@ void WaveClip::WriteXML(XMLWriter &xmlFile)
|
|||
xmlFile.EndTag(wxT("waveclip"));
|
||||
}
|
||||
|
||||
bool WaveClip::CreateFromCopy(double t0, double t1, WaveClip* other)
|
||||
bool WaveClip::CreateFromCopy(double t0, double t1, const WaveClip* other)
|
||||
{
|
||||
sampleCount s0, s1;
|
||||
|
||||
|
|
|
@ -279,7 +279,7 @@ public:
|
|||
void MarkChanged() { mDirty++; }
|
||||
|
||||
/// Create clip from copy, discarding previous information in the clip
|
||||
bool CreateFromCopy(double t0, double t1, WaveClip* other);
|
||||
bool CreateFromCopy(double t0, double t1, const WaveClip* other);
|
||||
|
||||
/** Getting high-level data from the for screen display and clipping
|
||||
* calculations and Contrast */
|
||||
|
|
|
@ -623,7 +623,7 @@ bool WaveTrack::Trim (double t0, double t1)
|
|||
|
||||
|
||||
|
||||
bool WaveTrack::Copy(double t0, double t1, Track **dest)
|
||||
bool WaveTrack::Copy(double t0, double t1, Track **dest) const
|
||||
{
|
||||
*dest = NULL;
|
||||
|
||||
|
@ -636,9 +636,9 @@ bool WaveTrack::Copy(double t0, double t1, Track **dest)
|
|||
|
||||
WaveClipList::compatibility_iterator it;
|
||||
|
||||
for (it=GetClipIterator(); it; it=it->GetNext())
|
||||
for (it = const_cast<WaveTrack*>(this)->GetClipIterator(); it; it = it->GetNext())
|
||||
{
|
||||
WaveClip *clip = it->GetData();
|
||||
const WaveClip *clip = it->GetData();
|
||||
|
||||
if (t0 <= clip->GetStartTime() && t1 >= clip->GetEndTime())
|
||||
{
|
||||
|
@ -713,6 +713,11 @@ bool WaveTrack::Copy(double t0, double t1, Track **dest)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool WaveTrack::CopyNonconst(double t0, double t1, Track **dest)
|
||||
{
|
||||
return Copy(t0, t1, dest);
|
||||
}
|
||||
|
||||
bool WaveTrack::Clear(double t0, double t1)
|
||||
{
|
||||
return HandleClear(t0, t1, false, false);
|
||||
|
|
|
@ -154,7 +154,8 @@ class AUDACITY_DLL_API WaveTrack final : public Track {
|
|||
//
|
||||
|
||||
bool Cut(double t0, double t1, Track **dest) override;
|
||||
bool Copy(double t0, double t1, Track **dest) override;
|
||||
bool Copy(double t0, double t1, Track **dest) const override;
|
||||
bool CopyNonconst(double t0, double t1, Track **dest) /* not override */;
|
||||
bool Clear(double t0, double t1) override;
|
||||
bool Paste(double t0, const Track *src) override;
|
||||
bool ClearAndPaste(double t0, double t1,
|
||||
|
|
Loading…
Reference in New Issue
Block a user