blob: 7ec6295c687b43dd6d03da13d537a99073d4366d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
//=========================================================
// MusE
// Linux Music Editor
// $Id: $
//
// (C) Copyright 2010 Andrew Williams and Christopher Cherrett
//=========================================================
#ifndef __TRACKVIEW_H__
#define __TRACKVIEW_H__
#include <QString>
#include <QObject>
#include <vector>
#include <algorithm>
#include "key.h"
#include "node.h"
#include "globaldefs.h"
#include "track.h"
class Xml;
//---------------------------------------------------------
// TrackView
//---------------------------------------------------------
class TrackView
{
private:
QString _comment;
Track::TrackType _type;
TrackList _tracks;
protected:
QString _name;
bool _selected;
bool readProperties(Xml& xml, const QString& tag);
void writeProperties(int level, Xml& xml) const;
public:
TrackView();
~TrackView();
TrackView& operator=(const TrackView& g);
static const char* _cname[];
QString comment() const { return _comment; }
void setComment(const QString& s) { _comment = s; }
Track::TrackType type() const { return _type; }
void setType(const Track::TrackType& t) { _type = t; }
bool selected() const { return _selected; }
void setSelected(bool f) { _selected = f; }
const QString& viewName() const { return _name; }
void setViewName(const QString& s) { _name = s; }
void setDefaultName();
QString cname() const { int t = type(); return QString(_cname[t]); }
void addTrack(Track*);
void removeTrack(Track*);
TrackList* tracks() { return &_tracks; }
virtual void write(int, Xml&) const;
void read(Xml&);
//virtual TrackView* newTrackView() const = 0;
//void dump() const;
//bool readProperty(Xml& xml, const QString& tag);
};
//---------------------------------------------------------
// TrackViewList
//---------------------------------------------------------
template<class T> class viewlist : public std::vector<TrackView*> {
typedef std::vector<TrackView*> vlist;
public:
class iterator : public vlist::iterator {
public:
iterator() : vlist::iterator() {}
iterator(vlist::iterator i) : vlist::iterator(i) {}
T operator*() {
return (T)(**((vlist::iterator*)this));
}
iterator operator++(int) {
return iterator ((*(vlist::iterator*)this).operator++(0));
}
iterator& operator++() {
return (iterator&) ((*(vlist::iterator*)this).operator++());
}
};
class const_iterator : public vlist::const_iterator {
public:
const_iterator() : vlist::const_iterator() {}
const_iterator(vlist::const_iterator i) : vlist::const_iterator(i) {}
const_iterator(vlist::iterator i) : vlist::const_iterator(i) {}
const T operator*() const {
return (T)(**((vlist::const_iterator*)this));
}
};
class reverse_iterator : public vlist::reverse_iterator {
public:
reverse_iterator() : vlist::reverse_iterator() {}
reverse_iterator(vlist::reverse_iterator i) : vlist::reverse_iterator(i) {}
T operator*() {
return (T)(**((vlist::reverse_iterator*)this));
}
};
viewlist() : vlist() {}
virtual ~viewlist() {}
void push_back(T v) { vlist::push_back(v); }
iterator begin() { return vlist::begin(); }
iterator end() { return vlist::end(); }
const_iterator begin() const { return vlist::begin(); }
const_iterator end() const { return vlist::end(); }
reverse_iterator rbegin() { return vlist::rbegin(); }
reverse_iterator rend() { return vlist::rend(); }
T& back() const { return (T&)(vlist::back()); }
T& front() const { return (T&)(vlist::front()); }
iterator find(const TrackView* t) {
return std::find(begin(), end(), t);
}
const_iterator find(const TrackView* t) const {
return std::find(begin(), end(), t);
}
unsigned index(const TrackView* t) const {
unsigned n = 0;
for (vlist::const_iterator i = begin(); i != end(); ++i, ++n) {
if (*i == t)
return n;
}
return -1;
}
T index(int k) const { return (*this)[k]; }
iterator index2iterator(int k) {
if ((unsigned)k >= size())
return end();
return begin() + k;
}
void erase(TrackView* t) { vlist::erase(find(t)); }
void clearDelete() {
for (vlist::iterator i = begin(); i != end(); ++i)
delete *i;
vlist::clear();
}
void erase(vlist::iterator i) { vlist::erase(i); }
void replace(TrackView* ot, TrackView* nt) {
for (vlist::iterator i = begin(); i != end(); ++i) {
if (*i == ot) {
*i = nt;
return;
}
}
}
};
typedef viewlist<TrackView*> TrackViewList;
typedef TrackViewList::iterator iTrackView;
typedef TrackViewList::const_iterator ciTrackView;
#endif
|