Mercurial > hg > svgui
comparison widgets/PropertyStack.cpp @ 771:a964151832a7
Merge from branch tony_integration
author | Chris Cannam |
---|---|
date | Wed, 14 May 2014 09:54:34 +0100 |
parents | b6dc57688c72 |
children | e4773943c9c1 |
comparison
equal
deleted
inserted
replaced
768:8b614632568c | 771:a964151832a7 |
---|---|
21 #include "layer/LayerFactory.h" | 21 #include "layer/LayerFactory.h" |
22 #include "widgets/NotifyingTabBar.h" | 22 #include "widgets/NotifyingTabBar.h" |
23 #include "widgets/IconLoader.h" | 23 #include "widgets/IconLoader.h" |
24 #include "base/Command.h" | 24 #include "base/Command.h" |
25 #include "widgets/CommandHistory.h" | 25 #include "widgets/CommandHistory.h" |
26 #include "layer/ShowLayerCommand.h" | |
26 | 27 |
27 #include <QIcon> | 28 #include <QIcon> |
28 #include <QTabWidget> | 29 #include <QTabWidget> |
29 | 30 |
30 #include <iostream> | 31 #include <iostream> |
155 } | 156 } |
156 | 157 |
157 int | 158 int |
158 PropertyStack::getContainerIndex(PropertyContainer *pc) const | 159 PropertyStack::getContainerIndex(PropertyContainer *pc) const |
159 { | 160 { |
160 for (size_t i = 0; i < m_client->getPropertyContainerCount(); ++i) { | 161 // This is used to obtain an index to be passed to setCurrentIndex |
161 PropertyContainer *container = m_client->getPropertyContainer(i); | 162 // -- which is the index of the property container's box in our |
162 if (pc == container) return i; | 163 // stack of boxes. That is not the same thing as the index of the |
164 // container (i.e. the layer) in the view: the view reorders its | |
165 // containers whenever one is raised to the top, while our boxes | |
166 // remain in the same order. So we must find this container in the | |
167 // box list, not in the view. | |
168 | |
169 for (size_t i = 0; i < m_boxes.size(); ++i) { | |
170 PropertyContainer *container = m_boxes[i]->getContainer(); | |
171 if (pc == container) { | |
172 return i; | |
173 } | |
163 } | 174 } |
164 | 175 |
165 return false; | 176 return false; |
166 } | 177 } |
167 | 178 |
208 PropertyStack::propertyContainerNameChanged(PropertyContainer *) | 219 PropertyStack::propertyContainerNameChanged(PropertyContainer *) |
209 { | 220 { |
210 if (sender() != m_client) return; | 221 if (sender() != m_client) return; |
211 repopulate(); | 222 repopulate(); |
212 } | 223 } |
213 | |
214 class ShowLayerCommand : public QObject, public Command | |
215 { | |
216 public: | |
217 ShowLayerCommand(View *view, Layer *layer, bool show, QString name) : | |
218 m_view(view), m_layer(layer), m_show(show), m_name(name) { } | |
219 void execute() { | |
220 m_layer->showLayer(m_view, m_show); | |
221 } | |
222 void unexecute() { | |
223 m_layer->showLayer(m_view, !m_show); | |
224 } | |
225 QString getName() const { | |
226 return m_name; | |
227 } | |
228 protected: | |
229 View *m_view; | |
230 Layer *m_layer; | |
231 bool m_show; | |
232 QString m_name; | |
233 }; | |
234 | 224 |
235 void | 225 void |
236 PropertyStack::showLayer(bool show) | 226 PropertyStack::showLayer(bool show) |
237 { | 227 { |
238 QObject *obj = sender(); | 228 QObject *obj = sender(); |