@@ -180,30 +180,31 void LegendLayout::setDettachedGeometry(const QRectF& rect) | |||
|
180 | 180 | |
|
181 | 181 | QSizeF size(0,0); |
|
182 | 182 | |
|
183 | if( m_legend->d_ptr->markers().isEmpty()) return; | |
|
183 | QList<LegendMarker *> markers = m_legend->d_ptr->markers(); | |
|
184 | 184 | |
|
185 | QList<QGraphicsItem *> items = m_legend->d_ptr->items()->childItems(); | |
|
185 | if(markers.isEmpty()) return; | |
|
186 | 186 | |
|
187 | 187 | switch (m_legend->alignment()) { |
|
188 | 188 | case Qt::AlignTop: { |
|
189 | 189 | QPointF point = rect.topLeft(); |
|
190 | 190 | m_width = 0; |
|
191 | 191 | m_height = 0; |
|
192 |
for (int i=0; i< |
|
|
193 |
|
|
|
194 |
if ( |
|
|
195 | const QRectF& boundingRect = item->boundingRect(); | |
|
192 | for (int i=0; i<markers.count(); i++) { | |
|
193 | LegendMarker *marker = markers.at(i); | |
|
194 | if (marker->isVisible()) { | |
|
195 | marker->setGeometry(QRectF(QPoint(0,0),marker->effectiveSizeHint(Qt::PreferredSize))); | |
|
196 | marker->setPos(point.x(),point.y()); | |
|
197 | const QRectF& boundingRect = marker->boundingRect(); | |
|
196 | 198 | qreal w = boundingRect.width(); |
|
197 | 199 | qreal h = boundingRect.height(); |
|
198 | 200 | m_width = qMax(m_width,w); |
|
199 | 201 | m_height = qMax(m_height,h); |
|
200 | item->setPos(point.x(),point.y()); | |
|
201 | 202 | point.setX(point.x() + w); |
|
202 | 203 | if (point.x() + w > rect.topLeft().x() + rect.width()) { |
|
203 | 204 | // Next item would go off rect. |
|
204 | 205 | point.setX(rect.topLeft().x()); |
|
205 | 206 | point.setY(point.y() + h); |
|
206 |
if (i+1 < |
|
|
207 | if (i+1 < markers.count()) { | |
|
207 | 208 | m_height += h; |
|
208 | 209 | } |
|
209 | 210 | } |
@@ -221,21 +222,22 void LegendLayout::setDettachedGeometry(const QRectF& rect) | |||
|
221 | 222 | QPointF point = rect.bottomLeft(); |
|
222 | 223 | m_width = 0; |
|
223 | 224 | m_height = 0; |
|
224 |
for (int i=0; i< |
|
|
225 |
|
|
|
226 |
if ( |
|
|
227 | const QRectF& boundingRect = item->boundingRect(); | |
|
225 | for (int i=0; i<markers.count(); i++) { | |
|
226 | LegendMarker *marker = markers.at(i); | |
|
227 | if (marker->isVisible()) { | |
|
228 | marker->setGeometry(QRectF(QPoint(0,0),marker->effectiveSizeHint(Qt::PreferredSize))); | |
|
229 | const QRectF& boundingRect = marker->boundingRect(); | |
|
228 | 230 | qreal w = boundingRect.width(); |
|
229 | 231 | qreal h = boundingRect.height(); |
|
230 | 232 | m_width = qMax(m_width,w); |
|
231 | 233 | m_height = qMax(m_height,h); |
|
232 |
|
|
|
234 | marker->setPos(point.x(),point.y() - h); | |
|
233 | 235 | point.setX(point.x() + w); |
|
234 | 236 | if (point.x() + w > rect.bottomLeft().x() + rect.width()) { |
|
235 | 237 | // Next item would go off rect. |
|
236 | 238 | point.setX(rect.bottomLeft().x()); |
|
237 | 239 | point.setY(point.y() - h); |
|
238 |
if (i+1 < |
|
|
240 | if (i+1 < markers.count()) { | |
|
239 | 241 | m_height += h; |
|
240 | 242 | } |
|
241 | 243 | } |
@@ -254,21 +256,22 void LegendLayout::setDettachedGeometry(const QRectF& rect) | |||
|
254 | 256 | m_width = 0; |
|
255 | 257 | m_height = 0; |
|
256 | 258 | qreal maxWidth = 0; |
|
257 |
for (int i=0; i< |
|
|
258 |
|
|
|
259 |
if ( |
|
|
260 | const QRectF& boundingRect = item->boundingRect(); | |
|
259 | for (int i=0; i<markers.count(); i++) { | |
|
260 | LegendMarker *marker = markers.at(i); | |
|
261 | if (marker->isVisible()) { | |
|
262 | marker->setGeometry(QRectF(QPoint(0,0),marker->effectiveSizeHint(Qt::PreferredSize))); | |
|
263 | const QRectF& boundingRect = marker->boundingRect(); | |
|
261 | 264 | qreal w = boundingRect.width(); |
|
262 | 265 | qreal h = boundingRect.height(); |
|
263 | 266 | m_height = qMax(m_height,h); |
|
264 | 267 | maxWidth = qMax(maxWidth,w); |
|
265 |
|
|
|
268 | marker->setPos(point.x(),point.y()); | |
|
266 | 269 | point.setY(point.y() + h); |
|
267 | 270 | if (point.y() + h > rect.topLeft().y() + rect.height()) { |
|
268 | 271 | // Next item would go off rect. |
|
269 | 272 | point.setX(point.x() + maxWidth); |
|
270 | 273 | point.setY(rect.topLeft().y()); |
|
271 |
if (i+1 < |
|
|
274 | if (i+1 < markers.count()) { | |
|
272 | 275 | m_width += maxWidth; |
|
273 | 276 | maxWidth = 0; |
|
274 | 277 | } |
@@ -289,21 +292,22 void LegendLayout::setDettachedGeometry(const QRectF& rect) | |||
|
289 | 292 | m_width = 0; |
|
290 | 293 | m_height = 0; |
|
291 | 294 | qreal maxWidth = 0; |
|
292 |
for (int i=0; i< |
|
|
293 |
|
|
|
294 |
if ( |
|
|
295 | const QRectF& boundingRect = item->boundingRect(); | |
|
295 | for (int i=0; i<markers.count(); i++) { | |
|
296 | LegendMarker *marker = markers.at(i); | |
|
297 | if (marker->isVisible()) { | |
|
298 | marker->setGeometry(QRectF(QPoint(0,0),marker->effectiveSizeHint(Qt::PreferredSize))); | |
|
299 | const QRectF& boundingRect = marker->boundingRect(); | |
|
296 | 300 | qreal w = boundingRect.width(); |
|
297 | 301 | qreal h = boundingRect.height(); |
|
298 | 302 | m_height = qMax(m_height,h); |
|
299 | 303 | maxWidth = qMax(maxWidth,w); |
|
300 |
|
|
|
304 | marker->setPos(point.x() - w,point.y()); | |
|
301 | 305 | point.setY(point.y() + h); |
|
302 | 306 | if (point.y() + h > rect.topLeft().y() + rect.height()) { |
|
303 | 307 | // Next item would go off rect. |
|
304 | 308 | point.setX(point.x() - maxWidth); |
|
305 | 309 | point.setY(rect.topLeft().y()); |
|
306 |
if (i+1 < |
|
|
310 | if (i+1 < markers.count()) { | |
|
307 | 311 | m_width += maxWidth; |
|
308 | 312 | maxWidth = 0; |
|
309 | 313 | } |
General Comments 0
You need to be logged in to leave comments.
Login now