Update of /cvsroot/audacity/audacity-src/src
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv32199
Modified Files:
Project.cpp Track.cpp Track.h
Log Message:
Added TrackAndGroupIterator that can iterate over tracks and groups.
Fixed Clear bug for multiple tracks within a Group (reported by Vaughan
Johnson).
Index: Track.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/Track.cpp,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -d -r1.64 -r1.65
--- Track.cpp 25 Jun 2009 02:16:00 -0000 1.64
+++ Track.cpp 1 Jul 2009 14:10:40 -0000 1.65
@@ -477,6 +477,33 @@
return t;
}
+// TrackAndGroupIterator
+//
+// Based on TrackListIterator has methods to retrieve both tracks and groups
+//
+TrackAndGroupIterator::TrackAndGroupIterator(TrackList * val)
+: TrackListIterator(val)
+{
+}
+
+Track *TrackAndGroupIterator::NextGroup(bool skiplinked)
+{
+ if (!cur)
+ return NULL;
+
+ Track* t = cur->t;
+
+ //skip the remaining tracks of the current group
+ for (; t != NULL && t->GetKind() != Track::Label; t =
TrackListIterator::Next(skiplinked) );
+
+ if (t) {
+ //Reached final Label track, let's go to the next group
+ t = TrackListIterator::Next(skiplinked);
+ }
+
+ return t;
+}
+
// TrackList
//
// The TrackList sends itself events whenever an update occurs to the list it
Index: Track.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/Track.h,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -d -r1.60 -r1.61
--- Track.h 25 Jun 2009 02:16:00 -0000 1.60
+++ Track.h 1 Jul 2009 14:10:40 -0000 1.61
@@ -284,6 +284,20 @@
bool mEndOfGroup;
};
+//
+// TrackAndGroupIterator
+//
+// Based on TrackListIterator has methods to retrieve both tracks and groups
+//
+class AUDACITY_DLL_API TrackAndGroupIterator: public TrackListIterator
+{
+ public:
+ TrackAndGroupIterator(TrackList * val);
+
+ // Iterate functions
+ Track *NextGroup(bool skiplinked = false);
+};
+
/** \brief TrackList is a flat linked list of tracks supporting Add, Remove,
* Clear, and Contains, plus serialization of the list of tracks.
*/
Index: Project.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/Project.cpp,v
retrieving revision 1.430
retrieving revision 1.431
diff -u -d -r1.430 -r1.431
--- Project.cpp 4 Jun 2009 05:37:07 -0000 1.430
+++ Project.cpp 1 Jul 2009 14:10:40 -0000 1.431
@@ -3355,14 +3355,16 @@
void AudacityProject::Clear()
{
- TrackListIterator iter(mTracks);
+ TrackAndGroupIterator iter(mTracks);
Track *n = iter.First();
while (n) {
- if (n->GetSelected())
+ if (n->GetSelected()) {
n->Clear(mViewInfo.sel0, mViewInfo.sel1);
- n = iter.Next();
+ n = iter.NextGroup();
+ }
+ else n = iter.Next();
}
double seconds = mViewInfo.sel1 - mViewInfo.sel0;
------------------------------------------------------------------------------
_______________________________________________
Audacity-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/audacity-cvs