Version: 8.3.0
YACS::HMI::SceneProgressItem Class Reference

#include <SceneProgressItem.hxx>

Inheritance diagram for YACS::HMI::SceneProgressItem:
Collaboration diagram for YACS::HMI::SceneProgressItem:

Public Member Functions

 SceneProgressItem (QGraphicsScene *scene, SceneItem *parent, QString label)
 
virtual ~SceneProgressItem ()
 
virtual QRectF getMinimalBoundingRect () const
 
virtual void paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
 
virtual void setProgress (QString newProgress)
 
virtual int getProgress ()
 
virtual void setText (QString label)
 
virtual void popupMenu (QWidget *caller, const QPoint &globalPos)
 
virtual void adjustGeometry ()
 
- Public Member Functions inherited from YACS::HMI::SceneItem
 SceneItem (QGraphicsScene *scene, SceneItem *parent, QString label)
 
virtual ~SceneItem ()
 
virtual QRectF boundingRect () const
 
virtual QRectF childrenBoundingRect () const
 
virtual void setTopLeft (QPointF topLeft)
 
virtual void checkGeometryChange ()
 
void setParent (SceneItem *parent)
 
void setEventPos (QPointF point)
 
virtual void updateChildItems ()
 
virtual void updateLinks ()
 
virtual void shrinkExpandLink (bool se)
 
virtual void shrinkExpandRecursive (bool isExpanding, bool fromHere, ShrinkMode theShrinkMode)
 
bool isAncestorShrinked ()
 
- Public Member Functions inherited from YACS::HMI::AbstractSceneItem
 AbstractSceneItem (QGraphicsScene *scene, SceneItem *parent, QString label)
 
virtual ~AbstractSceneItem ()
 
int getLevel ()
 
void setLevel ()
 
virtual void reorganize ()
 
virtual QString getLabel ()
 
virtual void addHeader ()
 
virtual void addProgressItem ()
 
virtual qreal getHeaderBottom ()
 
qreal getWidth ()
 
qreal getHeight ()
 
virtual void setWidth (qreal width)
 AbstractSceneItem cannot be resized (only ComposedNodeItem can) More...
 
virtual void setHeight (qreal height)
 AbstractSceneItem cannot be resized (only ComposedNodeItem can) More...
 
virtual void activateSelection (bool selected)
 
virtual void setGeometryOptimization (bool optimize)
 
SceneItemgetParent ()
 

Protected Member Functions

virtual void mousePressEvent (QGraphicsSceneMouseEvent *event)
 
virtual QString getToolTip ()
 
QColor getPenColor ()
 
QColor getBrushColor ()
 
- Protected Member Functions inherited from YACS::HMI::SceneItem
virtual void hoverEnterEvent (QGraphicsSceneHoverEvent *event)
 
virtual void hoverMoveEvent (QGraphicsSceneHoverEvent *event)
 
virtual void hoverLeaveEvent (QGraphicsSceneHoverEvent *event)
 
QColor hoverColor (QColor origColor)
 
- Protected Member Functions inherited from YACS::HMI::AbstractSceneItem
virtual QRectF childBoundingRect (AbstractSceneItem *child) const
 

Protected Attributes

SceneTextItem_text
 
QString _tooltip
 
int _progress
 
- Protected Attributes inherited from YACS::HMI::SceneItem
bool _hover
 
bool _ancestorShrinked
 
QPointF _eventPos
 
- Protected Attributes inherited from YACS::HMI::AbstractSceneItem
SceneItem_parent
 
YACS::HMI::Scene_scene
 
QString _label
 
int _level
 
qreal _width
 
qreal _height
 
qreal _incHeight
 
QColor _penColor
 
QColor _brushColor
 
QColor _hiPenColor
 
QColor _hiBrushColor
 
bool _hasHeader
 
bool _optimize
 
bool _dragable
 
enum Qt::MouseButton _dragButton
 

Additional Inherited Members

- Public Attributes inherited from YACS::HMI::SceneItem
bool _blocX
 
bool _blocY
 

Detailed Description

Definition at line 31 of file SceneProgressItem.hxx.

Constructor & Destructor Documentation

SceneProgressItem::~SceneProgressItem ( )
virtual

Definition at line 57 of file SceneProgressItem.cxx.

58 {
59 }

Member Function Documentation

QColor SceneProgressItem::getBrushColor ( )
protectedvirtual

Reimplemented from YACS::HMI::SceneItem.

Definition at line 148 of file SceneProgressItem.cxx.

References YACS::HMI::AbstractSceneItem::_brushColor, YACS::HMI::AbstractSceneItem::_hiBrushColor, YACS::HMI::SceneItem::_hover, YACS::HMI::AbstractSceneItem::getParent(), and YACS::HMI::SceneItem::hoverColor().

149 {
150  QColor color = _brushColor;
151  if (dynamic_cast<SceneHeaderNodeItem*>(this))
152  if (getParent()->isSelected())
153  color = _hiBrushColor;
154  if (_hover)
155  color = hoverColor(color);
156  return color;
157 }
QRectF SceneProgressItem::getMinimalBoundingRect ( ) const
virtual

Definition at line 61 of file SceneProgressItem.cxx.

References YACS::HMI::AbstractSceneItem::_height, and YACS::HMI::AbstractSceneItem::_width.

62 {
63  return QRectF(x(), y(), _width, _height);
64 }
QColor SceneProgressItem::getPenColor ( )
protectedvirtual

Reimplemented from YACS::HMI::SceneItem.

Definition at line 143 of file SceneProgressItem.cxx.

References YACS::HMI::AbstractSceneItem::_hiPenColor.

Referenced by paint().

144 {
145  return _hiPenColor;
146 }
virtual int YACS::HMI::SceneProgressItem::getProgress ( )
inlinevirtual

Definition at line 42 of file SceneProgressItem.hxx.

References _progress.

42 { return _progress; };
QString SceneProgressItem::getToolTip ( )
protectedvirtual

generic behaviour for headers: obtain the tooltip from parent. Method to be redefined in derived classes.

Reimplemented from YACS::HMI::SceneItem.

Definition at line 164 of file SceneProgressItem.cxx.

References _tooltip.

165 {
166  return _tooltip;;
167 }
void SceneProgressItem::mousePressEvent ( QGraphicsSceneMouseEvent *  event)
protectedvirtual

When Zooming, filter all mouse events to items: do not work, scene do not receive...

Reimplemented from YACS::HMI::SceneItem.

Definition at line 159 of file SceneProgressItem.cxx.

160 {
161  event->ignore();
162 }
void SceneProgressItem::paint ( QPainter *  painter,
const QStyleOptionGraphicsItem *  option,
QWidget widget 
)
virtual

Reimplemented from YACS::HMI::SceneItem.

Definition at line 66 of file SceneProgressItem.cxx.

References YACS::HMI::AbstractSceneItem::_parent, _progress, YACS::HMI::Resource::Corner_Margin, YACS::HMI::Resource::DataPort_Width, getPenColor(), YACS::HMI::AbstractSceneItem::getWidth(), gui.graph::h(), YACS::HMI::Resource::progressBar_Height, YACS::HMI::Resource::progressBarColor, YACS::HMI::Resource::Space_Margin, YACS::HMI::Resource::Thickness, and gui.logview::w.

69 {
70 // DEBTRACE("SceneProgressItem::paint");
71  painter->save();
72 
76  QPen pen(getPenColor());
77  pen.setWidth(Resource::Thickness);
78  painter->setPen(pen);
79  QRect boundRect(0, 0, w, h);
80  painter->drawRect(boundRect);
81 
82  painter->setBrush(Resource::progressBarColor);
83  //correct width according to progress
84  int corr_w = w * _progress / 100;
85  painter->drawRect(QRect(0, 0, corr_w, h));
86  painter->restore();
87 }
void SceneProgressItem::popupMenu ( QWidget caller,
const QPoint &  globalPos 
)
virtual

Reimplemented from YACS::HMI::SceneItem.

Definition at line 131 of file SceneProgressItem.cxx.

References YACS::HMI::AbstractSceneItem::_parent, and YACS::HMI::SceneItem::popupMenu().

132 {
133  if (_parent) _parent->popupMenu(caller, globalPos);
134 }
void SceneProgressItem::setProgress ( QString  newProgress)
virtual

Definition at line 89 of file SceneProgressItem.cxx.

References _progress, _tooltip, YACS::HMI::Resource::progressBarLabel, and setText().

90 {
91  QString percentageLabel;
92  QString nbStepsLabel = "-/-";
93  QStringList aSteps = newProgress.split('/');
94  if (aSteps.count() == 2)
95  { //case '5/10' view of progress
96  _progress = aSteps.at(0).toInt() * 100 / aSteps.at(1).toInt();
97  nbStepsLabel = newProgress;
98  }
99  else
100  { //case '50' view of progress
101  _progress = newProgress.toInt(); //set 0 if the conversion fails.
102  }
103  percentageLabel = QString("%1\%").arg(_progress);
104  QString resultLabel;
106  {
107  case 0: //Percentage: 50%
108  resultLabel = QString("%1").arg(percentageLabel);
109  break;
110  case 1: //Nb.steps: 5/10
111  resultLabel = QString("%1").arg(nbStepsLabel);
112  break;
113  case 2: //Both: 50% (5/10)
114  resultLabel = QString("%1 (%2)").arg(percentageLabel).arg(nbStepsLabel);
115  break;
116  }
117  setText(resultLabel);
118  _tooltip = QString("%1 (%2)").arg(percentageLabel).arg(nbStepsLabel);
119  update();
120 }
void SceneProgressItem::setText ( QString  label)
virtual

Definition at line 122 of file SceneProgressItem.cxx.

References YACS::HMI::AbstractSceneItem::_scene, _text, and YACS::HMI::SceneTextItem::setPlainTextTrunc().

Referenced by YACS::HMI::SceneNodeItem::addProgressItem(), and setProgress().

123 {
124  if (!_text)
125  _text = new SceneTextItem(_scene, this, label, true);
126  else
127  _text->setPlainTextTrunc(label);
128  //QGraphicsItem::update();
129 }

Member Data Documentation

int YACS::HMI::SceneProgressItem::_progress
protected

Definition at line 54 of file SceneProgressItem.hxx.

Referenced by getProgress(), paint(), SceneProgressItem(), and setProgress().

SceneTextItem* YACS::HMI::SceneProgressItem::_text
protected

Definition at line 52 of file SceneProgressItem.hxx.

Referenced by SceneProgressItem(), and setText().

QString YACS::HMI::SceneProgressItem::_tooltip
protected

Definition at line 53 of file SceneProgressItem.hxx.

Referenced by getToolTip(), SceneProgressItem(), and setProgress().


The documentation for this class was generated from the following files: