17 #include <QTextStream> 120 addSelection(selection);
126 m_selections.insert(selection);
136 for (SelectionList::iterator i = m_selections.begin();
137 i != m_selections.end(); ) {
139 SelectionList::iterator j = i;
140 if (++j == m_selections.end())
break;
142 if (i->getEndFrame() >= j->getStartFrame()) {
144 std::max(i->getEndFrame(), j->getEndFrame()));
145 m_selections.erase(i);
146 m_selections.erase(j);
147 m_selections.insert(merged);
148 i = m_selections.begin();
163 if (m_selections.find(selection) != m_selections.end()) {
164 m_selections.erase(selection);
171 if (!m_selections.empty()) {
172 m_selections.clear();
182 for (SelectionList::const_iterator i = m_selections.begin();
183 i != m_selections.end(); ++i) {
185 if (i == m_selections.begin() || i->getStartFrame() < startFrame) {
186 startFrame = i->getStartFrame();
189 if (i == m_selections.begin() || i->getEndFrame() > endFrame) {
190 endFrame = i->getEndFrame();
202 for (SelectionList::const_iterator i = m_selections.begin();
203 i != m_selections.end(); ++i) {
205 if (i->contains(frame))
return *i;
207 if (i->getStartFrame() > frame) {
208 if (defaultToFollowing)
return *i;
218 QString extraAttributes)
const 220 stream << indent << QString(
"<selections %1>\n").arg(extraAttributes);
221 for (SelectionList::iterator i = m_selections.begin();
222 i != m_selections.end(); ++i) {
224 << QString(
" <selection start=\"%1\" end=\"%2\"/>\n")
225 .arg(i->getStartFrame()).arg(i->getEndFrame());
227 stream << indent <<
"</selections>\n";
234 for (SelectionList::iterator i = m_selections.begin();
235 i != m_selections.end(); ++i) {
236 list << QString(
"(%1,%2)")
237 .arg(i->getStartFrame())
238 .arg(i->getEndFrame());
240 return "(" + list.join(
",") +
")";
sv_frame_t getEndFrame() const
void removeSelection(const Selection &selection)
const SelectionList & getSelections() const
void setSelection(const Selection &selection)
int64_t sv_frame_t
Frame index, the unit of our time axis.
A selection object simply represents a range in time, via start and end frame.
bool operator==(const Selection &) const
virtual ~MultiSelection()
Selection getContainingSelection(sv_frame_t frame, bool defaultToFollowing) const
Return the selection that contains a given frame.
void addSelection(const Selection &selection)
void toXml(QTextStream &stream, QString indent="", QString extraAttributes="") const override
Stream this exportable object out to XML on a text stream.
std::set< Selection > SelectionList
void getExtents(sv_frame_t &startFrame, sv_frame_t &endFrame) const
bool contains(sv_frame_t frame) const
Selection & operator=(const Selection &)
sv_frame_t getStartFrame() const
bool operator<(const Selection &) const