[qet] [4082] Fix crash : qet crash when element comment ( comment item and cross ref item) is bigger than the width of the rectangle where there are displayed. |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
- To: qet@xxxxxxxxxxxxxxxxxxx
- Subject: [qet] [4082] Fix crash : qet crash when element comment ( comment item and cross ref item) is bigger than the width of the rectangle where there are displayed.
- From: subversion@xxxxxxxxxxxxx
- Date: Fri, 31 Jul 2015 16:20:57 +0200
Revision: 4082
Author: blacksun
Date: 2015-07-31 16:20:56 +0200 (Fri, 31 Jul 2015)
Log Message:
-----------
Fix crash : qet crash when element comment (comment item and cross ref item) is bigger than the width of the rectangle where there are displayed.
The rectangle is now adjusted to the size of the comment.
Modified Paths:
--------------
trunk/sources/qetgraphicsitem/commentitem.cpp
trunk/sources/qetgraphicsitem/crossrefitem.cpp
Modified: trunk/sources/qetgraphicsitem/commentitem.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/commentitem.cpp 2015-07-31 13:29:23 UTC (rev 4081)
+++ trunk/sources/qetgraphicsitem/commentitem.cpp 2015-07-31 14:20:56 UTC (rev 4082)
@@ -105,13 +105,14 @@
* update the content of this item
* (draw this item in a QPicture)
*/
-void CommentItem::updateLabel() {
+void CommentItem::updateLabel()
+{
QString comment = m_element -> elementInformations()["comment"].toString();
if (comment == m_comment && !m_text_parent) return;
- if (comment != m_comment) {
-
+ if (comment != m_comment)
+ {
m_comment = comment;
QPen pen(Qt::black);
@@ -121,10 +122,9 @@
painter.setPen (pen);
painter.setFont (QETApp::diagramTextsFont(6));
- QRectF drawing_rect(QPointF(0,0), QSizeF(70, 100));
- QRectF text_bounding;
+ QRectF text_bounding = painter.boundingRect(QRectF(QPointF(0,0), QSizeF(70, 1)), Qt::TextWordWrap | Qt::AlignHCenter, m_comment);
- painter.drawText(drawing_rect, Qt::TextWordWrap | Qt::AlignHCenter, m_comment, &text_bounding);
+ painter.drawText(text_bounding, Qt::TextWordWrap | Qt::AlignHCenter, m_comment);
text_bounding.adjust(-1,0,1,0); //adjust only for better visual
painter.drawRoundedRect(text_bounding, 2, 2);
Modified: trunk/sources/qetgraphicsitem/crossrefitem.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/crossrefitem.cpp 2015-07-31 13:29:23 UTC (rev 4081)
+++ trunk/sources/qetgraphicsitem/crossrefitem.cpp 2015-07-31 14:20:56 UTC (rev 4082)
@@ -523,19 +523,22 @@
* Add the comment info of the parent item if needed.
* @param painter painter to use for draw the text
*/
-void CrossRefItem::AddExtraInfo(QPainter &painter) {
+void CrossRefItem::AddExtraInfo(QPainter &painter)
+{
QString comment = m_element -> elementInformations()["comment"].toString();
bool must_show = m_element -> elementInformations().keyMustShow("comment");
- if (!comment.isEmpty() && must_show) {
+ if (!comment.isEmpty() && must_show)
+ {
painter.save();
painter.setFont(QETApp::diagramTextsFont(6));
QRectF r, text_bounding;
qreal center = boundingRect().center().x();
r = QRectF(QPointF(center - 35, boundingRect().bottom()),
- QPointF(center + 35, boundingRect().bottom() + 50));
- painter.drawText(r, Qt::TextWordWrap | Qt::AlignHCenter, comment, &text_bounding);
+ QPointF(center + 35, boundingRect().bottom() + 1));
+ text_bounding = painter.boundingRect(r, Qt::TextWordWrap | Qt::AlignHCenter, comment);
+ painter.drawText(text_bounding, Qt::TextWordWrap | Qt::AlignHCenter, comment);
text_bounding.adjust(-1,0,1,0); //adjust only for better visual