@@ -110,11 +110,11 QBrush LegendMarkerItem::labelBrush() const | |||
|
110 | 110 | |
|
111 | 111 | void LegendMarkerItem::setGeometry(const QRectF &rect) |
|
112 | 112 | { |
|
113 |
|
|
|
113 | qreal width = rect.width(); | |
|
114 | 114 | qreal x = m_margin + m_markerRect.width() + m_space + m_margin; |
|
115 | 115 | QRectF truncatedRect; |
|
116 | 116 | |
|
117 | m_textItem->setHtml(ChartPresenter::truncatedText(m_font, m_label, qreal(0.0), width - x, Qt::Horizontal, truncatedRect)); | |
|
117 | m_textItem->setHtml(ChartPresenter::truncatedText(m_textItem->font(), m_label, qreal(0.0), width - x, Qt::Horizontal, truncatedRect)); | |
|
118 | 118 | |
|
119 | 119 | qreal y = qMax(m_markerRect.height() + 2 * m_margin, truncatedRect.height() + 2 * m_margin); |
|
120 | 120 | |
@@ -144,21 +144,26 QSizeF LegendMarkerItem::sizeHint(Qt::SizeHint which, const QSizeF& constraint) | |||
|
144 | 144 | { |
|
145 | 145 | Q_UNUSED(constraint) |
|
146 | 146 | |
|
147 | QFontMetrics fn(m_textItem->font()); | |
|
148 | 147 | QSizeF sh; |
|
149 | 148 | |
|
150 |
|
|
|
151 |
|
|
|
152 | sh = QSizeF(fn.boundingRect("...").width() + 2*m_margin + m_space +m_markerRect.width(),qMax(m_markerRect.height()+2*m_margin,fn.height()+2*m_margin)); | |
|
153 | break; | |
|
154 | case Qt::PreferredSize: | |
|
155 | sh = QSizeF(fn.boundingRect(m_label).width() + 2*m_margin + m_space +m_markerRect.width(),qMax(m_markerRect.height()+2*m_margin,fn.height()+2*m_margin)); | |
|
156 | break; | |
|
157 | default: | |
|
158 | break; | |
|
159 | } | |
|
160 | ||
|
161 |
|
|
|
149 | switch (which) { | |
|
150 | case Qt::MinimumSize: { | |
|
151 | QRectF labelRect = ChartPresenter::textBoundingRect(m_textItem->font(), "..."); | |
|
152 | sh = QSizeF(labelRect.width() + (2.0 * m_margin) + m_space + m_markerRect.width(), | |
|
153 | qMax(m_markerRect.height(), labelRect.height()) + (2.0 * m_margin)); | |
|
154 | break; | |
|
155 | } | |
|
156 | case Qt::PreferredSize: { | |
|
157 | QRectF labelRect = ChartPresenter::textBoundingRect(m_textItem->font(), m_label); | |
|
158 | sh = QSizeF(labelRect.width() + (2.0 * m_margin) + m_space + m_markerRect.width(), | |
|
159 | qMax(m_markerRect.height(), labelRect.height()) + (2.0 * m_margin)); | |
|
160 | break; | |
|
161 | } | |
|
162 | default: | |
|
163 | break; | |
|
164 | } | |
|
165 | ||
|
166 | return sh; | |
|
162 | 167 | } |
|
163 | 168 | |
|
164 | 169 | void LegendMarkerItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) |
General Comments 0
You need to be logged in to leave comments.
Login now