comparison widgets/PropertyStack.cpp @ 1266:a34a2a25907c

Untabify
author Chris Cannam
date Thu, 01 Mar 2018 18:02:22 +0000
parents 3f5c82034f9b
children 284a38c43721
comparison
equal deleted inserted replaced
1265:6e724c81f18f 1266:a34a2a25907c
52 tabBar()->setIconSize(WidgetScale::scaleQSize(QSize(16, 16))); 52 tabBar()->setIconSize(WidgetScale::scaleQSize(QSize(16, 16)));
53 53
54 repopulate(); 54 repopulate();
55 55
56 connect(this, SIGNAL(currentChanged(int)), 56 connect(this, SIGNAL(currentChanged(int)),
57 this, SLOT(selectedContainerChanged(int))); 57 this, SLOT(selectedContainerChanged(int)));
58 58
59 connect(m_client, SIGNAL(propertyContainerAdded(PropertyContainer *)), 59 connect(m_client, SIGNAL(propertyContainerAdded(PropertyContainer *)),
60 this, SLOT(propertyContainerAdded(PropertyContainer *))); 60 this, SLOT(propertyContainerAdded(PropertyContainer *)));
61 61
62 connect(m_client, SIGNAL(propertyContainerRemoved(PropertyContainer *)), 62 connect(m_client, SIGNAL(propertyContainerRemoved(PropertyContainer *)),
63 this, SLOT(propertyContainerRemoved(PropertyContainer *))); 63 this, SLOT(propertyContainerRemoved(PropertyContainer *)));
64 64
65 connect(m_client, SIGNAL(propertyContainerPropertyChanged(PropertyContainer *)), 65 connect(m_client, SIGNAL(propertyContainerPropertyChanged(PropertyContainer *)),
66 this, SLOT(propertyContainerPropertyChanged(PropertyContainer *))); 66 this, SLOT(propertyContainerPropertyChanged(PropertyContainer *)));
67 67
68 connect(m_client, SIGNAL(propertyContainerPropertyRangeChanged(PropertyContainer *)), 68 connect(m_client, SIGNAL(propertyContainerPropertyRangeChanged(PropertyContainer *)),
69 this, SLOT(propertyContainerPropertyRangeChanged(PropertyContainer *))); 69 this, SLOT(propertyContainerPropertyRangeChanged(PropertyContainer *)));
70 70
71 connect(m_client, SIGNAL(propertyContainerNameChanged(PropertyContainer *)), 71 connect(m_client, SIGNAL(propertyContainerNameChanged(PropertyContainer *)),
72 this, SLOT(propertyContainerNameChanged(PropertyContainer *))); 72 this, SLOT(propertyContainerNameChanged(PropertyContainer *)));
73 73
74 connect(this, SIGNAL(propertyContainerSelected(View *, PropertyContainer *)), 74 connect(this, SIGNAL(propertyContainerSelected(View *, PropertyContainer *)),
75 m_client, SLOT(propertyContainerSelected(View *, PropertyContainer *))); 75 m_client, SLOT(propertyContainerSelected(View *, PropertyContainer *)));
76 } 76 }
77 77
78 PropertyStack::~PropertyStack() 78 PropertyStack::~PropertyStack()
79 { 79 {
80 } 80 }
87 #ifdef DEBUG_PROPERTY_STACK 87 #ifdef DEBUG_PROPERTY_STACK
88 cerr << "PropertyStack[" << this << "]::repopulate" << endl; 88 cerr << "PropertyStack[" << this << "]::repopulate" << endl;
89 #endif 89 #endif
90 90
91 while (count() > 0) { 91 while (count() > 0) {
92 removeTab(0); 92 removeTab(0);
93 } 93 }
94 for (size_t i = 0; i < m_boxes.size(); ++i) { 94 for (size_t i = 0; i < m_boxes.size(); ++i) {
95 delete m_boxes[i]; 95 delete m_boxes[i];
96 } 96 }
97 m_boxes.clear(); 97 m_boxes.clear();
98 98
99 for (int i = 0; i < m_client->getPropertyContainerCount(); ++i) { 99 for (int i = 0; i < m_client->getPropertyContainerCount(); ++i) {
100 100
101 PropertyContainer *container = m_client->getPropertyContainer(i); 101 PropertyContainer *container = m_client->getPropertyContainer(i);
102 QString name = container->getPropertyContainerName(); 102 QString name = container->getPropertyContainerName();
103 103
104 #ifdef DEBUG_PROPERTY_STACK 104 #ifdef DEBUG_PROPERTY_STACK
105 cerr << "PropertyStack[" << this << "]::repopulate: client " << m_client 105 cerr << "PropertyStack[" << this << "]::repopulate: client " << m_client
106 << " returns container " << container << " (name " << name 106 << " returns container " << container << " (name " << name
107 << ") at position " << i << endl; 107 << ") at position " << i << endl;
108 #endif 108 #endif
109 109
110 PropertyBox *box = new PropertyBox(container); 110 PropertyBox *box = new PropertyBox(container);
111 111
112 connect(box, SIGNAL(showLayer(bool)), this, SLOT(showLayer(bool))); 112 connect(box, SIGNAL(showLayer(bool)), this, SLOT(showLayer(bool)));
113 connect(box, SIGNAL(contextHelpChanged(const QString &)), 113 connect(box, SIGNAL(contextHelpChanged(const QString &)),
114 this, SIGNAL(contextHelpChanged(const QString &))); 114 this, SIGNAL(contextHelpChanged(const QString &)));
115 115
116 Layer *layer = dynamic_cast<Layer *>(container); 116 Layer *layer = dynamic_cast<Layer *>(container);
117 if (layer) { 117 if (layer) {
129 } 129 }
130 130
131 bool nameDiffers = (name != shortName); 131 bool nameDiffers = (name != shortName);
132 shortName = QString("&%1 %2").arg(i + 1).arg(shortName); 132 shortName = QString("&%1 %2").arg(i + 1).arg(shortName);
133 133
134 QString iconName = container->getPropertyContainerIconName(); 134 QString iconName = container->getPropertyContainerIconName();
135 135
136 QIcon icon(IconLoader().load(iconName)); 136 QIcon icon(IconLoader().load(iconName));
137 if (icon.isNull()) { 137 if (icon.isNull()) {
138 addTab(box, shortName); 138 addTab(box, shortName);
139 if (nameDiffers) { 139 if (nameDiffers) {
140 setTabToolTip(i, name); 140 setTabToolTip(i, name);
141 } 141 }
142 } else { 142 } else {
143 addTab(box, icon, QString("&%1").arg(i + 1)); 143 addTab(box, icon, QString("&%1").arg(i + 1));
144 setTabToolTip(i, name); 144 setTabToolTip(i, name);
145 } 145 }
146 146
147 m_boxes.push_back(box); 147 m_boxes.push_back(box);
148 } 148 }
149 149
150 blockSignals(false); 150 blockSignals(false);
151 } 151 }
152 152
153 bool 153 bool
154 PropertyStack::containsContainer(PropertyContainer *pc) const 154 PropertyStack::containsContainer(PropertyContainer *pc) const
155 { 155 {
156 for (int i = 0; i < m_client->getPropertyContainerCount(); ++i) { 156 for (int i = 0; i < m_client->getPropertyContainerCount(); ++i) {
157 PropertyContainer *container = m_client->getPropertyContainer(i); 157 PropertyContainer *container = m_client->getPropertyContainer(i);
158 if (pc == container) return true; 158 if (pc == container) return true;
159 } 159 }
160 160
161 return false; 161 return false;
162 } 162 }
163 163
171 // containers whenever one is raised to the top, while our boxes 171 // containers whenever one is raised to the top, while our boxes
172 // remain in the same order. So we must find this container in the 172 // remain in the same order. So we must find this container in the
173 // box list, not in the view. 173 // box list, not in the view.
174 174
175 for (int i = 0; in_range_for(m_boxes, i); ++i) { 175 for (int i = 0; in_range_for(m_boxes, i); ++i) {
176 PropertyContainer *container = m_boxes[i]->getContainer(); 176 PropertyContainer *container = m_boxes[i]->getContainer();
177 if (pc == container) { 177 if (pc == container) {
178 return i; 178 return i;
179 } 179 }
180 } 180 }
181 181
182 return false; 182 return false;
199 void 199 void
200 PropertyStack::propertyContainerPropertyChanged(PropertyContainer *pc) 200 PropertyStack::propertyContainerPropertyChanged(PropertyContainer *pc)
201 { 201 {
202 Layer *layer = dynamic_cast<Layer *>(pc); 202 Layer *layer = dynamic_cast<Layer *>(pc);
203 for (unsigned int i = 0; i < m_boxes.size(); ++i) { 203 for (unsigned int i = 0; i < m_boxes.size(); ++i) {
204 if (pc == m_boxes[i]->getContainer()) { 204 if (pc == m_boxes[i]->getContainer()) {
205 m_boxes[i]->propertyContainerPropertyChanged(pc); 205 m_boxes[i]->propertyContainerPropertyChanged(pc);
206 if (layer) { 206 if (layer) {
207 m_boxes[i]->layerVisibilityChanged 207 m_boxes[i]->layerVisibilityChanged
208 (!layer->isLayerDormant(m_client)); 208 (!layer->isLayerDormant(m_client));
209 } 209 }
210 } 210 }
211 } 211 }
212 } 212 }
213 213
214 void 214 void
215 PropertyStack::propertyContainerPropertyRangeChanged(PropertyContainer *pc) 215 PropertyStack::propertyContainerPropertyRangeChanged(PropertyContainer *pc)
216 { 216 {
217 for (unsigned int i = 0; i < m_boxes.size(); ++i) { 217 for (unsigned int i = 0; i < m_boxes.size(); ++i) {
218 if (pc == m_boxes[i]->getContainer()) { 218 if (pc == m_boxes[i]->getContainer()) {
219 m_boxes[i]->propertyContainerPropertyRangeChanged(pc); 219 m_boxes[i]->propertyContainerPropertyRangeChanged(pc);
220 } 220 }
221 } 221 }
222 } 222 }
223 223
224 void 224 void
225 PropertyStack::propertyContainerNameChanged(PropertyContainer *) 225 PropertyStack::propertyContainerNameChanged(PropertyContainer *)
232 PropertyStack::showLayer(bool show) 232 PropertyStack::showLayer(bool show)
233 { 233 {
234 QObject *obj = sender(); 234 QObject *obj = sender();
235 235
236 for (unsigned int i = 0; i < m_boxes.size(); ++i) { 236 for (unsigned int i = 0; i < m_boxes.size(); ++i) {
237 if (obj == m_boxes[i]) { 237 if (obj == m_boxes[i]) {
238 Layer *layer = dynamic_cast<Layer *>(m_boxes[i]->getContainer()); 238 Layer *layer = dynamic_cast<Layer *>(m_boxes[i]->getContainer());
239 if (layer) { 239 if (layer) {
240 CommandHistory::getInstance()->addCommand 240 CommandHistory::getInstance()->addCommand
241 (new ShowLayerCommand(m_client, layer, show, 241 (new ShowLayerCommand(m_client, layer, show,
242 tr("Change Layer Visibility"))); 242 tr("Change Layer Visibility")));
243 return; 243 return;
244 } 244 }
245 } 245 }
246 } 246 }
247 } 247 }
248 248
249 void 249 void
250 PropertyStack::selectedContainerChanged(int n) 250 PropertyStack::selectedContainerChanged(int n)