102 id_ (_element->getNewId ())
105 bool hasConfig =
false;
107 QGraphicsLinearLayout *layout =
new QGraphicsLinearLayout (Qt::Vertical);
108 layout->setSpacing (0);
110 nameLayout_ =
new QGraphicsLinearLayout (Qt::Vertical);
111 nameLayout_->setSpacing(0);
112 nameLayout_->setContentsMargins(15, 0, 15, 0);
118 QFont font = name_->font ();
119 if (font.pointSize () != -1)
120 font.setPointSize (font.pointSize () + 1);
122 font.setPixelSize (font.pixelSize () + 1);
124 name_->setFont (font);
126 nameLayout_->addItem(name_);
127 nameLayout_->setAlignment (name_, Qt::AlignCenter);
130 font = elementName_->font ();
131 if (font.pointSize () != -1)
132 font.setPointSize (font.pointSize () - 2);
134 font.setPixelSize (font.pixelSize () - 2);
135 elementName_->setFont (font);
137 nameLayout_->addItem(elementName_);
138 nameLayout_->setAlignment (elementName_, Qt::AlignCenter);
140 elementName_->hide ();
142 layout->addItem(nameLayout_);
146 QGraphicsGridLayout *inGrid =
new QGraphicsGridLayout;
147 inGrid->setContentsMargins (0,0,5,0);
157 if (!(in->state () & Input::NoUserInput))
160 configInputs_.append (i);
163 if (in->state () & Input::NoExternalInput)
172 inGrid->addItem (i->
typeTextItem (), row, 1, Qt::AlignLeft | Qt::AlignVCenter);
175 height = qMin (height, i->
typeTextItem ()->preferredHeight () / 2);
176 typeWidth = qMax (i->
typeTextItem ()->preferredWidth (), typeWidth);
180 if (!element_->
inputs ().isEmpty ())
182 inGrid->setColumnMinimumWidth (1, qMin (typeWidth, 100.0));
183 inGrid->setHorizontalSpacing (1);
184 layout->insertItem (index, inGrid);
185 layout->setAlignment (inGrid, Qt::AlignLeft);
186 layout->setItemSpacing (index - 1, 10);
191 QGraphicsGridLayout *outGrid =
new QGraphicsGridLayout;
192 outGrid->setContentsMargins (5,0,0,0);
202 outGrid->addItem (o->
typeTextItem (), row, 1, Qt::AlignRight | Qt::AlignVCenter);
205 height = qMin (height, o->
typeTextItem ()->preferredHeight () / 2);
206 typeWidth = qMax (o->
typeTextItem ()->preferredWidth (), typeWidth);
212 if (!element_->
outputs ().isEmpty ())
214 outGrid->setColumnMinimumWidth (1, qMin (typeWidth, 100.0));
215 outGrid->setHorizontalSpacing (1);
216 layout->insertItem(index, outGrid);
217 layout->setAlignment (outGrid, Qt::AlignRight);
218 layout->setItemSpacing (index - 1, 10);
222 if (hasConfig || !element_->
functions ().isEmpty ())
224 QGraphicsLinearLayout *hl =
new QGraphicsLinearLayout (Qt::Horizontal);
225 QGraphicsLinearLayout *vl =
new QGraphicsLinearLayout (Qt::Vertical);
226 hl->setContentsMargins(15, 0, 15, 0);
232 configButton->setBrush (Qt::black);
238 vl->addItem (configButton);
240 connect (configButton, SIGNAL (pressed()),
this, SLOT (showInputConfig()));
249 config->setBrush (Qt::black);
254 vl->addItem (config);
256 connect (config, SIGNAL (pressed()), ef, SLOT (editFunction ()));
258 functions_.append (ef);
265 layout->insertItem (index, hl);
266 layout->setAlignment (hl, Qt::AlignCenter);
267 layout->setItemSpacing (index - 1, 10);
274 QGraphicsGridLayout *sIO =
new QGraphicsGridLayout ();
283 sIO->addItem (dataIn_->
connectionPointItem (), 0, col++, Qt::AlignLeft | Qt::AlignVCenter);
302 sIO->addItem (dataOut_->
connectionPointItem (), 0, col, Qt::AlignRight | Qt::AlignVCenter);
306 sIO->setContentsMargins (lo, 0, ro, 0);
307 sIO->setHorizontalSpacing (1);
309 layout->insertItem (index, sIO);
310 layout->setAlignment (sIO, Qt::AlignCenter);
311 layout->setItemSpacing (index - 1, 10);
315 layout->setItemSpacing (0, 1);
317 layout->setContentsMargins (0, 2, 0, 6);
321 if (layout->preferredWidth() < 200)
322 setMinimumWidth (layout->preferredWidth());
324 setMinimumWidth (200);
326 setZValue (scene_->
getNewZ ());
328 setFlag (QGraphicsItem::ItemIsSelectable,
true);
329 setFlag (QGraphicsItem::ItemIsMovable,
true);
331 setMaximumWidth (200);
357 int w = geometry().width() - 20;
358 int h = geometry().height();
360 _painter->setRenderHint(QPainter::Antialiasing,
true);
362 _painter->setBrush(QBrush(QColor(SELECTED_BACKGROUND_RED,
363 SELECTED_BACKGROUND_GREEN,
364 SELECTED_BACKGROUND_BLUE,
365 SELECTED_BACKGROUND_ALPHA)));
367 _painter->setBrush(QBrush(QColor(BACKGROUND_RED,
372 _painter->setPen (Qt::NoPen);
373 _painter->drawRoundedRect(10, 0, w, h, 5, 5);
382 path.moveTo (10, 20);
384 path.arcTo (10, 0, 10, 10, 180, -90);
385 path.lineTo (w + 6, 0);
386 path.arcTo (w, 0, 10, 10, 90, -90);
387 path.lineTo (w + 10, 10);
389 path.cubicTo (QPointF (10 + wH, 10), QPointF (10 + wH, 20), QPointF (10, 20));
391 rG.setCenter (10 + wT, 0);
392 rG.setFocalPoint(10 + wT, 0);
394 rG.setColorAt(0, QColor (255, 255, 255, 128));
395 rG.setColorAt(1, Qt::transparent);
396 _painter->setBrush (rG);
397 _painter->setPen (Qt::NoPen);
398 _painter->drawPath(path);
400 path = QPainterPath ();
401 path.moveTo (w + 5, 0);
402 path.arcTo (w, 0, 10, 10, 90, -90);
403 path.lineTo (w + 10, h - 5);
404 path.lineTo (w + 5, h - 5);
405 path.lineTo (w + 5, 0);
407 lG.setStart (w + 5, 0);
408 lG.setFinalStop(w + 10, 0);
409 lG.setColorAt(0, Qt::transparent);
410 lG.setColorAt(1, QColor (255, 255, 255, 128));
411 _painter->setBrush (lG);
412 _painter->drawPath(path);
414 path = QPainterPath ();
415 path.moveTo (10, h - 5);
416 path.arcTo (10, h - 10, 10, 10, 180, 90);
417 path.lineTo (w + 5, h);
418 path.lineTo (w + 5, h - 5);
419 path.lineTo (10, h - 5);
420 lG.setStart (0, h - 5);
421 lG.setFinalStop (0, h);
422 _painter->setBrush (lG);
423 _painter->drawPath (path);
425 path = QPainterPath ();
426 path.moveTo (w + 5, h);
427 path.arcTo (w, h - 10, 10, 10, -90, 90);
428 path.lineTo (w + 5, h - 5);
429 path.lineTo (w + 5, h);
430 rG.setCenter (w + 5, h - 5);
431 rG.setFocalPoint(w + 5, h - 5);
433 rG.setColorAt (0, Qt::transparent);
434 rG.setColorAt (1, QColor (255, 255, 255, 128));
435 _painter->setBrush (rG);
436 _painter->drawPath(path);
438 QGraphicsWidget::paint (_painter, _option, _widget);
static QString getXmlString(QDomElement &_element, const QString &_tag, QString _default="")
Gets the string of a xml query.
void setAlignment(Qt::Alignment _alignment)
Placement of the text in a stretched widget.
void setHorizontalStretch(bool _stretch)
Should this widget be stretchable in horizontal direction.
void setBackground(bool _leftOut, bool _rightOut)
Enables background painting.
QPainterPath shape() const
Returns the shape for proper repainting/event handling.