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