mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-09-13 20:23:04 +02:00
Improve code style, Wrap code for better readability
This commit is contained in:
parent
4ed33109f4
commit
e9fcd385d5
@ -52,7 +52,7 @@ void PropertiesEditorDockWidget::clear()
|
|||||||
{
|
{
|
||||||
m_editor_list.removeOne(editor);
|
m_editor_list.removeOne(editor);
|
||||||
ui->m_main_vlayout->removeWidget(editor);
|
ui->m_main_vlayout->removeWidget(editor);
|
||||||
delete editor;
|
delete editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_editor_list.clear();
|
m_editor_list.clear();
|
||||||
|
@ -57,18 +57,24 @@ void QetGraphicsHandlerItem::setColor(QColor color)
|
|||||||
@param option
|
@param option
|
||||||
@param widget
|
@param widget
|
||||||
*/
|
*/
|
||||||
void QetGraphicsHandlerItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
void QetGraphicsHandlerItem::paint(QPainter *painter,
|
||||||
|
const QStyleOptionGraphicsItem *option,
|
||||||
|
QWidget *widget)
|
||||||
{
|
{
|
||||||
Q_UNUSED(option)
|
Q_UNUSED(option)
|
||||||
Q_UNUSED(widget)
|
Q_UNUSED(widget)
|
||||||
|
|
||||||
painter->save();
|
painter->save();
|
||||||
painter->setBrush(QBrush(m_color));
|
painter->setBrush(QBrush(m_color));
|
||||||
QPen pen(QBrush(m_color), 2, Qt::SolidLine, Qt::SquareCap, Qt::MiterJoin);
|
QPen pen(QBrush(m_color),
|
||||||
|
2,
|
||||||
|
Qt::SolidLine,
|
||||||
|
Qt::SquareCap,
|
||||||
|
Qt::MiterJoin);
|
||||||
pen.setCosmetic(true);
|
pen.setCosmetic(true);
|
||||||
painter->setPen(pen);
|
painter->setPen(pen);
|
||||||
painter->setRenderHint(QPainter::Antialiasing, true);
|
painter->setRenderHint(QPainter::Antialiasing, true);
|
||||||
painter->drawEllipse(m_handler_rect);
|
painter->drawEllipse(m_handler_rect);
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,15 +83,17 @@ void QetGraphicsHandlerItem::paint(QPainter *painter, const QStyleOptionGraphics
|
|||||||
@param points
|
@param points
|
||||||
@return A list of handler with pos at point
|
@return A list of handler with pos at point
|
||||||
*/
|
*/
|
||||||
QVector<QetGraphicsHandlerItem *> QetGraphicsHandlerItem::handlerForPoint(const QVector<QPointF> &points, int size)
|
QVector<QetGraphicsHandlerItem *> QetGraphicsHandlerItem::handlerForPoint(
|
||||||
|
const QVector<QPointF> &points,
|
||||||
|
int size)
|
||||||
{
|
{
|
||||||
QVector <QetGraphicsHandlerItem *> list_;
|
QVector <QetGraphicsHandlerItem *> list_;
|
||||||
for (QPointF point : points)
|
for (QPointF point : points)
|
||||||
{
|
{
|
||||||
QetGraphicsHandlerItem *qghi = new QetGraphicsHandlerItem(size);
|
QetGraphicsHandlerItem *qghi = new QetGraphicsHandlerItem(size);
|
||||||
qghi->setPos(point);
|
qghi->setPos(point);
|
||||||
list_ << qghi;
|
list_ << qghi;
|
||||||
}
|
}
|
||||||
|
|
||||||
return list_;
|
return list_;
|
||||||
}
|
}
|
||||||
|
@ -23,34 +23,42 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
@brief The QetGraphicsHandlerItem class
|
@brief The QetGraphicsHandlerItem class
|
||||||
This graphics item represents a point, destined to be used as an handler,
|
This graphics item represents a point,
|
||||||
|
destined to be used as an handler,
|
||||||
for modifie the geometrie of a another graphics item (like shapes).
|
for modifie the geometrie of a another graphics item (like shapes).
|
||||||
The graphics item to be modified, must call "installSceneEventFilter" of this item with itself for argument,.
|
The graphics item to be modified,
|
||||||
The ghraphics item to be modified, need to reimplement "sceneEventFilter" for create the modification behavior.
|
must call "installSceneEventFilter"
|
||||||
|
of this item with itself for argument,.
|
||||||
|
The ghraphics item to be modified,
|
||||||
|
need to reimplement "sceneEventFilter"
|
||||||
|
for create the modification behavior.
|
||||||
*/
|
*/
|
||||||
class QetGraphicsHandlerItem : public QGraphicsItem
|
class QetGraphicsHandlerItem : public QGraphicsItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QetGraphicsHandlerItem(qreal size = 10);
|
QetGraphicsHandlerItem(qreal size = 10);
|
||||||
QRectF boundingRect() const override;
|
QRectF boundingRect() const override;
|
||||||
|
|
||||||
enum { Type = UserType + 1200};
|
enum { Type = UserType + 1200};
|
||||||
int type() const override {return Type;}
|
int type() const override {return Type;}
|
||||||
|
|
||||||
void setColor(QColor color);
|
void setColor(QColor color);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
void paint(QPainter *painter,
|
||||||
|
const QStyleOptionGraphicsItem *option,
|
||||||
|
QWidget *widget) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QRectF m_handler_rect,
|
QRectF m_handler_rect,
|
||||||
m_br;
|
m_br;
|
||||||
qreal m_size;
|
qreal m_size;
|
||||||
QColor m_color;
|
QColor m_color;
|
||||||
QPen m_pen;
|
QPen m_pen;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static QVector<QetGraphicsHandlerItem *> handlerForPoint(const QVector<QPointF> &points, int size = 10);
|
static QVector<QetGraphicsHandlerItem *> handlerForPoint(
|
||||||
|
const QVector<QPointF> &points, int size = 10);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // QETGRAPHICSHANDLERITEM_H
|
#endif // QETGRAPHICSHANDLERITEM_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user