void NoteYellowBar::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { Q_UNUSED(option); Q_UNUSED(widget); QRectF headRect(headPixmap_.pos(),headPixmap_.size()); QRectF tailRect(headPixmap_.pos(),tailPixmap_.size()); QRectF bodyRect(headPixmap_.pos(),notePixmap_.size()); tailRect.moveLeft(length_ * unitWidth_ - tailRect.width() - headRect.left()); bodyRect.setLeft(headRect.width()); bodyRect.setRight(tailRect.left()); painter->drawPixmap(tailRect,tailPixmap_,tailPixmap_.rect()); painter->drawPixmap(bodyRect,notePixmap_,notePixmap_.rect()); painter->drawPixmap(headRect,headPixmap_,headPixmap_.rect()); }
/** * Reimplemented from UMLWidget::attributeChange to handle @ref * SizeHasChanged to position the texts as well as build the painter * path corresponding to current size. */ QVariant NodeWidget::attributeChange(WidgetAttributeChange change, const QVariant& oldValue) { if(change == SizeHasChanged) { TextItemGroup *grp = textItemGroupAt(GroupIndex); m_nodeWidgetPath = QPainterPath(); // reset path const qreal w = size().width(); const qreal h = size().height(); const qreal wDepth = qMin(w/3, NodeWidget::DEPTH); const qreal hDepth = qMin(h/3, NodeWidget::DEPTH); const qreal bodyOffsetY = hDepth; const qreal bodyWidth = w - wDepth; const qreal bodyHeight = h - hDepth; QPolygonF poly; poly << QPointF(0, bodyOffsetY) << QPointF(wDepth, 0) << QPointF(w - 1, 0) << QPointF(w - 1, bodyHeight) << QPointF(bodyWidth, h - 1) << QPointF(bodyWidth, bodyOffsetY) << QPointF(0, bodyOffsetY); m_nodeWidgetPath.addPolygon(poly); QRectF bodyRect(0, bodyOffsetY, bodyWidth, bodyHeight); m_nodeWidgetPath.addRect(bodyRect); QLineF line(w - 1, 0, bodyWidth - 2, bodyOffsetY + 1); m_nodeWidgetPath.moveTo(line.p1()); m_nodeWidgetPath.lineTo(line.p2()); grp->setGroupGeometry(bodyRect); } return UMLWidget::attributeChange(change, oldValue); }
QDomElement DetailSection::xml(QDomDocument doc, QList<Container *> &usedItems, QMap<QString, bool> &querys, QList<Section*> sectionPool) { QDomElement node = doc.createElement("Section"); node.setAttribute("id",sectionType()); node.setAttribute("size",(int)rect().height()); node.setAttribute("name",m_SectionName); node.setAttribute("SqlGlobal",m_SqlGlobal); node.setAttribute("SqlInterno",m_SqlInterno); node.setAttribute("ClausulaInterna",m_ClausulaInterna); node.setAttribute("haveSqlInterno",m_header || m_foot); node.setAttribute("colored",m_colorear); node.setAttribute("color1",ColorString(m_color1)); node.setAttribute("alternative",m_use2Colors); node.setAttribute("color2",ColorString(m_color2)); QPointF br(rect().bottomRight().x(),rect().bottomRight().y()); QPointF tl(rect().topLeft().x(),rect().topLeft().y()); if(m_header) { QDomElement headerNode = doc.createElement("Header"); headerNode.setAttribute("size",m_headerSize); QRectF aux(tl,QPointF(br.x(),tl.y()+m_headerSize)); QRectF headerRect(mapRectToScene(aux)); QList<QGraphicsItem*>items =this->scene()->items(headerRect); QListIterator<QGraphicsItem*> it(items); while (it.hasNext()) { QGraphicsItem* c = it.next(); Container* cont = qgraphicsitem_cast<Container*>(c); if(cont) { if(!usedItems.contains(cont)) { headerNode.appendChild(cont->xml(doc,marginPoint(),sectionPool)); usedItems.append(cont); } } } node.appendChild(headerNode); } QDomElement bodyNode = doc.createElement("Body"); bodyNode.setAttribute("size",this->rect().height() - m_headerSize - m_footSize); QRectF bodyRect(mapToScene(QPointF(tl.x(),tl.y()+m_headerSize)),mapToScene(QPointF(br.x(),br.y()-m_footSize))); QList<QGraphicsItem*>items =this->scene()->items(bodyRect); QListIterator<QGraphicsItem*> it(items); while (it.hasNext()) { QGraphicsItem* c = it.next(); Container* cont = qgraphicsitem_cast<Container*>(c); if(cont) { if(!usedItems.contains(cont)) { bodyNode.appendChild(cont->xml(doc,mapToScene(QPointF(tl.x(),tl.y()+m_headerSize)),sectionPool)); usedItems.append(cont); } } } node.appendChild(bodyNode); if(m_foot) { QDomElement footNode = doc.createElement("Foot"); footNode.setAttribute("size",m_footSize); QRectF footRect(mapToScene(QPointF(tl.x(),br.y()-m_footSize+1)),mapToScene(QPointF(br))); QList<QGraphicsItem*>items =this->scene()->items(footRect); QListIterator<QGraphicsItem*> it(items); while (it.hasNext()) { QGraphicsItem* c = it.next(); Container* cont = qgraphicsitem_cast<Container*>(c); if(cont) { if(!usedItems.contains(cont)) { footNode.appendChild(cont->xml(doc,mapToScene(QPointF(tl.x(),br.y()-m_footSize)),sectionPool)); usedItems.append(cont); } } } node.appendChild(footNode); } return node; }