Thanks for your replies but it is better i post code so that i can highlight fact that i can't write a function for single item.
I have the following kind of usage occurring few times.
QRectF rect
= m_insertibles.
isEmpty() ?
QRectF() : m_insertibles.
first()->sceneBoundingRect
();
foreach(QucsItem *item, m_insertibles) {
item->setSelected(true);
item->setVisible(cursorOnScene);
rect |= item->sceneBoundingRect();
}
QPointF delta
= active
->mapToScene
(pos
) - center;
foreach(QucsItem *item, m_insertibles) {
item->moveBy(delta.x(), delta.y());
}
QRectF rect = m_insertibles.isEmpty() ? QRectF() : m_insertibles.first()->sceneBoundingRect();
foreach(QucsItem *item, m_insertibles) {
item->setSelected(true);
item->setVisible(cursorOnScene);
rect |= item->sceneBoundingRect();
}
QPointF center = rect.center();
QPointF delta = active->mapToScene(pos) - center;
foreach(QucsItem *item, m_insertibles) {
item->moveBy(delta.x(), delta.y());
}
To copy to clipboard, switch view to plain text mode
Well i thought i could write convienience functions like say
QPointF centerOfItems
(const QList<QGraphicsItem
*>
&_list
);
void moveItemsBy
(QList<QGraphicsItem
*>
&_list,
QPointF delta
);
void setVisibilityofItems(QList<QGraphicsItem*> &_list, bool visiblity);
QPointF centerOfItems(const QList<QGraphicsItem*> &_list);
void moveItemsBy(QList<QGraphicsItem*> &_list, QPointF delta);
void setVisibilityofItems(QList<QGraphicsItem*> &_list, bool visiblity);
To copy to clipboard, switch view to plain text mode
But as you can see the three implementations will have repetitions of loop. Ofcourse trying to be optimistic, the code isn't that clumsy
Bookmarks