From 07eed05123091927ba6b85fd690f711cafa79013 Mon Sep 17 00:00:00 2001 From: blacksun Date: Wed, 2 Apr 2014 16:57:13 +0000 Subject: [PATCH] improve commit 2954 git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2956 bfdf4180-ca20-0410-9c96-a3a8aa849046 --- sources/qetgraphicsitem/crossrefitem.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/sources/qetgraphicsitem/crossrefitem.cpp b/sources/qetgraphicsitem/crossrefitem.cpp index 0a6f3fc74..cc3667aa7 100644 --- a/sources/qetgraphicsitem/crossrefitem.cpp +++ b/sources/qetgraphicsitem/crossrefitem.cpp @@ -22,6 +22,8 @@ //define the height of the header. #define header 5 +//define the widht of the cross +#define crossWidth 50 /** * @brief CrossRefItem::CrossRefItem @@ -209,7 +211,7 @@ void CrossRefItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) { */ void CrossRefItem::setUpBoundingRect(QPainter &painter) { //this is the default size of cross ref item - QRectF default_bounding(0, 0, 50, 40); + QRectF default_bounding(0, 0, crossWidth, 40); //No need to calcul if nothing is linked if (!element_->isFree()) { @@ -281,7 +283,7 @@ void CrossRefItem::fillCrossRef(QPainter &painter) { } painter.setFont(QETApp::diagramTextsFont(5)); - qreal half_cross = bounding_rect_.width()/2; + qreal middle_cross = bounding_rect_.width()/2; //fill the NO QString contact_str; foreach (Element *elmt, NO_list) { @@ -290,7 +292,10 @@ void CrossRefItem::fillCrossRef(QPainter &painter) { contact_str += elmt->diagram()->convertPosition(elmt -> scenePos()).toString(); contact_str += "\n"; } - QRectF rect_(half_cross-26, header, half_cross, (bounding_rect_.height()-header)); + QRectF rect_(middle_cross - (crossWidth/2), + header, + middle_cross, + (bounding_rect_.height()-header)); painter.drawText(rect_, Qt::AlignTop | Qt::AlignLeft, contact_str); //fill the NC @@ -301,8 +306,11 @@ void CrossRefItem::fillCrossRef(QPainter &painter) { contact_str += elmt->diagram()->convertPosition(elmt -> scenePos()).toString(); contact_str += "\n"; } - rect_.setRect(half_cross+3 , header, half_cross+22, (bounding_rect_.height()-header)); - painter.drawText(rect_, Qt::AlignTop | Qt::AlignLeft, contact_str); + rect_.setRect(middle_cross, + header, + crossWidth/2, + (bounding_rect_.height()-header)); + painter.drawText(rect_, Qt::AlignTop | Qt::AlignRight, contact_str); fillExtraInfo(painter); }