Mercurial > hg > svcore
comparison base/ViewManager.cpp @ 45:b11edc8b8ea0
* Restore proper channel selection support for new layers
* Use binary mode for SV file I/O on Windows
* Commands for selection
author | Chris Cannam |
---|---|
date | Wed, 15 Mar 2006 18:11:23 +0000 |
parents | 7bf163161b88 |
children | 39ae3dee27b9 |
comparison
equal
deleted
inserted
replaced
44:701404725897 | 45:b11edc8b8ea0 |
---|---|
8 */ | 8 */ |
9 | 9 |
10 #include "ViewManager.h" | 10 #include "ViewManager.h" |
11 #include "AudioPlaySource.h" | 11 #include "AudioPlaySource.h" |
12 #include "Model.h" | 12 #include "Model.h" |
13 #include "CommandHistory.h" | |
13 | 14 |
14 #include <iostream> | 15 #include <iostream> |
15 | 16 |
16 //#define DEBUG_VIEW_MANAGER 1 | 17 //#define DEBUG_VIEW_MANAGER 1 |
17 | 18 |
118 } | 119 } |
119 | 120 |
120 void | 121 void |
121 ViewManager::setSelection(const Selection &selection) | 122 ViewManager::setSelection(const Selection &selection) |
122 { | 123 { |
123 m_selections.setSelection(selection); | 124 MultiSelection ms(m_selections); |
125 ms.setSelection(selection); | |
126 setSelections(ms); | |
127 } | |
128 | |
129 void | |
130 ViewManager::addSelection(const Selection &selection) | |
131 { | |
132 MultiSelection ms(m_selections); | |
133 ms.addSelection(selection); | |
134 setSelections(ms); | |
135 } | |
136 | |
137 void | |
138 ViewManager::removeSelection(const Selection &selection) | |
139 { | |
140 MultiSelection ms(m_selections); | |
141 ms.removeSelection(selection); | |
142 setSelections(ms); | |
143 } | |
144 | |
145 void | |
146 ViewManager::clearSelections() | |
147 { | |
148 MultiSelection ms(m_selections); | |
149 ms.clearSelections(); | |
150 setSelections(ms); | |
151 } | |
152 | |
153 void | |
154 ViewManager::setSelections(const MultiSelection &ms) | |
155 { | |
156 if (m_selections.getSelections() == ms.getSelections()) return; | |
157 SetSelectionCommand *command = new SetSelectionCommand(this, ms); | |
158 CommandHistory::getInstance()->addCommand(command); | |
159 } | |
160 | |
161 void | |
162 ViewManager::signalSelectionChange() | |
163 { | |
124 emit selectionChanged(); | 164 emit selectionChanged(); |
125 } | 165 } |
126 | 166 |
127 void | 167 ViewManager::SetSelectionCommand::SetSelectionCommand(ViewManager *vm, |
128 ViewManager::addSelection(const Selection &selection) | 168 const MultiSelection &ms) : |
129 { | 169 m_vm(vm), |
130 m_selections.addSelection(selection); | 170 m_oldSelection(vm->m_selections), |
131 emit selectionChanged(); | 171 m_newSelection(ms) |
132 } | 172 { |
133 | 173 } |
134 void | 174 |
135 ViewManager::removeSelection(const Selection &selection) | 175 ViewManager::SetSelectionCommand::~SetSelectionCommand() { } |
136 { | 176 |
137 m_selections.removeSelection(selection); | 177 void |
138 emit selectionChanged(); | 178 ViewManager::SetSelectionCommand::execute() |
139 } | 179 { |
140 | 180 m_vm->m_selections = m_newSelection; |
141 void | 181 m_vm->signalSelectionChange(); |
142 ViewManager::clearSelections() | 182 } |
143 { | 183 |
144 m_selections.clearSelections(); | 184 void |
145 emit selectionChanged(); | 185 ViewManager::SetSelectionCommand::unexecute() |
186 { | |
187 m_vm->m_selections = m_oldSelection; | |
188 m_vm->signalSelectionChange(); | |
189 } | |
190 | |
191 QString | |
192 ViewManager::SetSelectionCommand::getName() const | |
193 { | |
194 if (m_newSelection.getSelections().empty()) return tr("Clear Selection"); | |
195 else return tr("Select"); | |
146 } | 196 } |
147 | 197 |
148 Selection | 198 Selection |
149 ViewManager::getContainingSelection(size_t frame, bool defaultToFollowing) const | 199 ViewManager::getContainingSelection(size_t frame, bool defaultToFollowing) const |
150 { | 200 { |