mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-19 06:20:53 +01:00
Fix code style
This commit is contained in:
@@ -94,7 +94,8 @@ ElementScene::~ElementScene()
|
|||||||
@brief ElementScene::mouseMoveEvent
|
@brief ElementScene::mouseMoveEvent
|
||||||
@param e
|
@param e
|
||||||
*/
|
*/
|
||||||
void ElementScene::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
|
void ElementScene::mouseMoveEvent(QGraphicsSceneMouseEvent *e)
|
||||||
|
{
|
||||||
if (m_event_interface) {
|
if (m_event_interface) {
|
||||||
if (m_event_interface -> mouseMoveEvent(e)) {
|
if (m_event_interface -> mouseMoveEvent(e)) {
|
||||||
if (m_event_interface->isFinish()) {
|
if (m_event_interface->isFinish()) {
|
||||||
@@ -125,7 +126,8 @@ void ElementScene::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
@brief ElementScene::mousePressEvent
|
@brief ElementScene::mousePressEvent
|
||||||
@param e
|
@param e
|
||||||
*/
|
*/
|
||||||
void ElementScene::mousePressEvent(QGraphicsSceneMouseEvent *e) {
|
void ElementScene::mousePressEvent(QGraphicsSceneMouseEvent *e)
|
||||||
|
{
|
||||||
if (m_event_interface) {
|
if (m_event_interface) {
|
||||||
if (m_event_interface -> mousePressEvent(e)) {
|
if (m_event_interface -> mousePressEvent(e)) {
|
||||||
if (m_event_interface->isFinish()) {
|
if (m_event_interface->isFinish()) {
|
||||||
@@ -144,7 +146,8 @@ void ElementScene::mousePressEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
@brief ElementScene::mouseReleaseEvent
|
@brief ElementScene::mouseReleaseEvent
|
||||||
@param e
|
@param e
|
||||||
*/
|
*/
|
||||||
void ElementScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
|
void ElementScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *e)
|
||||||
|
{
|
||||||
if (m_event_interface) {
|
if (m_event_interface) {
|
||||||
if (m_event_interface -> mouseReleaseEvent(e)) {
|
if (m_event_interface -> mouseReleaseEvent(e)) {
|
||||||
if (m_event_interface->isFinish()) {
|
if (m_event_interface->isFinish()) {
|
||||||
@@ -171,7 +174,8 @@ void ElementScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
|
|||||||
@brief ElementScene::mouseDoubleClickEvent
|
@brief ElementScene::mouseDoubleClickEvent
|
||||||
@param event
|
@param event
|
||||||
*/
|
*/
|
||||||
void ElementScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) {
|
void ElementScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
{
|
||||||
if (m_event_interface) {
|
if (m_event_interface) {
|
||||||
if (m_event_interface -> mouseDoubleClickEvent(event)) {
|
if (m_event_interface -> mouseDoubleClickEvent(event)) {
|
||||||
if (m_event_interface->isFinish()) {
|
if (m_event_interface->isFinish()) {
|
||||||
@@ -252,10 +256,8 @@ void ElementScene::keyPressEvent(QKeyEvent *event)
|
|||||||
|
|
||||||
qgo->setPos(p);
|
qgo->setPos(p);
|
||||||
QPropertyUndoCommand *undo =
|
QPropertyUndoCommand *undo =
|
||||||
new QPropertyUndoCommand(qgo,
|
new QPropertyUndoCommand(
|
||||||
"pos",
|
qgo,"pos",QVariant(original_pos),QVariant(p));
|
||||||
QVariant(original_pos),
|
|
||||||
QVariant(p));
|
|
||||||
undo->setText(tr("Déplacer une primitive"));
|
undo->setText(tr("Déplacer une primitive"));
|
||||||
undo->enableAnimation();
|
undo->enableAnimation();
|
||||||
undoStack().push(undo);
|
undoStack().push(undo);
|
||||||
@@ -343,7 +345,8 @@ void ElementScene::clearEventInterface()
|
|||||||
\~French Modifie the current behavior of this scene
|
\~French Modifie the current behavior of this scene
|
||||||
\~ @param b
|
\~ @param b
|
||||||
*/
|
*/
|
||||||
void ElementScene::setBehavior(ElementScene::Behavior b) {
|
void ElementScene::setBehavior(ElementScene::Behavior b)
|
||||||
|
{
|
||||||
m_behavior = b;
|
m_behavior = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -379,7 +382,8 @@ int ElementScene::yGrid() const
|
|||||||
\~ @param y_g : Vertical grid size
|
\~ @param y_g : Vertical grid size
|
||||||
\~French Taille verticale de la grille
|
\~French Taille verticale de la grille
|
||||||
*/
|
*/
|
||||||
void ElementScene::setGrid(int x_g, int y_g) {
|
void ElementScene::setGrid(int x_g, int y_g)
|
||||||
|
{
|
||||||
m_x_grid = x_g ? x_g : 1;
|
m_x_grid = x_g ? x_g : 1;
|
||||||
m_y_grid = y_g ? y_g : 1;
|
m_y_grid = y_g ? y_g : 1;
|
||||||
}
|
}
|
||||||
@@ -490,7 +494,8 @@ const QDomDocument ElementScene::toXml(bool all_parts)
|
|||||||
\~ @return the boundingRect of the element's content
|
\~ @return the boundingRect of the element's content
|
||||||
\~French le boundingRect du contenu de l'element
|
\~French le boundingRect du contenu de l'element
|
||||||
*/
|
*/
|
||||||
QRectF ElementScene::boundingRectFromXml(const QDomDocument &xml_document) {
|
QRectF ElementScene::boundingRectFromXml(const QDomDocument &xml_document)
|
||||||
|
{
|
||||||
// load parts from XML document
|
// load parts from XML document
|
||||||
// charge les parties depuis le document XML
|
// charge les parties depuis le document XML
|
||||||
ElementContent loaded_content = loadContent(xml_document);
|
ElementContent loaded_content = loadContent(xml_document);
|
||||||
@@ -531,10 +536,11 @@ QRectF ElementScene::boundingRectFromXml(const QDomDocument &xml_document) {
|
|||||||
\~French si ce pointeur vers un ElementContent est different de 0,
|
\~French si ce pointeur vers un ElementContent est different de 0,
|
||||||
il sera rempli avec le contenu ajoute a l'element par le fromXml
|
il sera rempli avec le contenu ajoute a l'element par le fromXml
|
||||||
*/
|
*/
|
||||||
void ElementScene::fromXml(const QDomDocument &xml_document,
|
void ElementScene::fromXml(
|
||||||
const QPointF &position,
|
const QDomDocument &xml_document,
|
||||||
bool consider_informations,
|
const QPointF &position,
|
||||||
ElementContent *content_ptr)
|
bool consider_informations,
|
||||||
|
ElementContent *content_ptr)
|
||||||
{
|
{
|
||||||
bool state = true;
|
bool state = true;
|
||||||
|
|
||||||
@@ -563,7 +569,8 @@ void ElementScene::fromXml(const QDomDocument &xml_document,
|
|||||||
It is different from itemsBoundingRect() because it is not supposed
|
It is different from itemsBoundingRect() because it is not supposed
|
||||||
to imply any margin.
|
to imply any margin.
|
||||||
*/
|
*/
|
||||||
QRectF ElementScene::elementSceneGeometricRect() const{
|
QRectF ElementScene::elementSceneGeometricRect() const
|
||||||
|
{
|
||||||
QRectF esgr;
|
QRectF esgr;
|
||||||
foreach (QGraphicsItem *qgi, items()) {
|
foreach (QGraphicsItem *qgi, items()) {
|
||||||
if (qgi->type() == ElementPrimitiveDecorator::Type) continue;
|
if (qgi->type() == ElementPrimitiveDecorator::Type) continue;
|
||||||
@@ -585,8 +592,10 @@ QRectF ElementScene::elementSceneGeometricRect() const{
|
|||||||
*/
|
*/
|
||||||
bool ElementScene::containsTerminals() const
|
bool ElementScene::containsTerminals() const
|
||||||
{
|
{
|
||||||
foreach(QGraphicsItem *qgi,items()) {
|
foreach(QGraphicsItem *qgi,items())
|
||||||
if (qgraphicsitem_cast<PartTerminal *>(qgi)) {
|
{
|
||||||
|
if (qgraphicsitem_cast<PartTerminal *>(qgi))
|
||||||
|
{
|
||||||
return(true);
|
return(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -635,7 +644,8 @@ bool ElementScene::clipboardMayContainElement()
|
|||||||
true if clipboard_content has been copied from this element.
|
true if clipboard_content has been copied from this element.
|
||||||
\~French true si clipboard_content a ete copie depuis cet element.
|
\~French true si clipboard_content a ete copie depuis cet element.
|
||||||
*/
|
*/
|
||||||
bool ElementScene::wasCopiedFromThisElement(const QString &clipboard_content) {
|
bool ElementScene::wasCopiedFromThisElement(const QString &clipboard_content)
|
||||||
|
{
|
||||||
return(clipboard_content == m_last_copied);
|
return(clipboard_content == m_last_copied);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -807,7 +817,8 @@ void ElementScene::slot_editAuthorInformations()
|
|||||||
dialog_author.setWindowFlags(Qt::Sheet);
|
dialog_author.setWindowFlags(Qt::Sheet);
|
||||||
#endif
|
#endif
|
||||||
dialog_author.setMinimumSize(400, 260);
|
dialog_author.setMinimumSize(400, 260);
|
||||||
dialog_author.setWindowTitle(tr("Éditer les informations sur l'auteur", "window title"));
|
dialog_author.setWindowTitle(
|
||||||
|
tr("Éditer les informations sur l'auteur", "window title"));
|
||||||
QVBoxLayout *dialog_layout = new QVBoxLayout(&dialog_author);
|
QVBoxLayout *dialog_layout = new QVBoxLayout(&dialog_author);
|
||||||
|
|
||||||
// adds an explanatory field to the dialogue
|
// adds an explanatory field to the dialogue
|
||||||
@@ -828,18 +839,21 @@ void ElementScene::slot_editAuthorInformations()
|
|||||||
// ajoute deux boutons au dialogue
|
// ajoute deux boutons au dialogue
|
||||||
QDialogButtonBox *dialog_buttons = new QDialogButtonBox(
|
QDialogButtonBox *dialog_buttons = new QDialogButtonBox(
|
||||||
is_read_only ? QDialogButtonBox::Ok :
|
is_read_only ? QDialogButtonBox::Ok :
|
||||||
QDialogButtonBox::Ok
|
QDialogButtonBox::Ok
|
||||||
| QDialogButtonBox::Cancel);
|
| QDialogButtonBox::Cancel);
|
||||||
dialog_layout -> addWidget(dialog_buttons);
|
dialog_layout -> addWidget(dialog_buttons);
|
||||||
connect(dialog_buttons, SIGNAL(accepted()),&dialog_author, SLOT(accept()));
|
connect(dialog_buttons, SIGNAL(accepted()),&dialog_author, SLOT(accept()));
|
||||||
connect(dialog_buttons, SIGNAL(rejected()),&dialog_author, SLOT(reject()));
|
connect(dialog_buttons, SIGNAL(rejected()),&dialog_author, SLOT(reject()));
|
||||||
|
|
||||||
// start the dialogue
|
// start the dialogue
|
||||||
// lance le dialogue
|
// lance le dialogue
|
||||||
if (dialog_author.exec() == QDialog::Accepted && !is_read_only) {
|
if (dialog_author.exec() == QDialog::Accepted && !is_read_only)
|
||||||
|
{
|
||||||
QString new_infos = text_field -> toPlainText().remove(QChar(13)); // CR-less text
|
QString new_infos = text_field -> toPlainText().remove(QChar(13)); // CR-less text
|
||||||
if (new_infos != informations()) {
|
if (new_infos != informations())
|
||||||
undoStack().push(new ChangeInformationsCommand(this, informations(), new_infos));
|
{
|
||||||
|
undoStack().push(new ChangeInformationsCommand(
|
||||||
|
this, informations(), new_infos));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -861,9 +875,9 @@ void ElementScene::slot_editProperties()
|
|||||||
kind_info != m_elmt_kindInfo ||
|
kind_info != m_elmt_kindInfo ||
|
||||||
elmt_info != m_elmt_information)
|
elmt_info != m_elmt_information)
|
||||||
undoStack().push(new ChangePropertiesCommand(this,
|
undoStack().push(new ChangePropertiesCommand(this,
|
||||||
type,
|
type,
|
||||||
kind_info,
|
kind_info,
|
||||||
elmt_info));
|
elmt_info));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -904,8 +918,10 @@ void ElementScene::slot_editNames()
|
|||||||
QList<CustomElementPart *> ElementScene::primitives() const
|
QList<CustomElementPart *> ElementScene::primitives() const
|
||||||
{
|
{
|
||||||
QList<CustomElementPart *> primitives_list;
|
QList<CustomElementPart *> primitives_list;
|
||||||
foreach (QGraphicsItem *item, items()) {
|
foreach (QGraphicsItem *item, items())
|
||||||
if (CustomElementPart *primitive = dynamic_cast<CustomElementPart *>(item)) {
|
{
|
||||||
|
if (CustomElementPart *primitive = dynamic_cast<CustomElementPart *>(item))
|
||||||
|
{
|
||||||
primitives_list << primitive;
|
primitives_list << primitive;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -923,7 +939,8 @@ QList<QGraphicsItem *> ElementScene::zItems(ItemOptions options) const
|
|||||||
// handle dummy request, i.e. when neither Selected nor NonSelected are set
|
// handle dummy request, i.e. when neither Selected nor NonSelected are set
|
||||||
if (!(options & ElementScene::Selected)
|
if (!(options & ElementScene::Selected)
|
||||||
&&
|
&&
|
||||||
!(options & ElementScene::NonSelected)) {
|
!(options & ElementScene::NonSelected))
|
||||||
|
{
|
||||||
return(QList<QGraphicsItem *>());
|
return(QList<QGraphicsItem *>());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -944,7 +961,8 @@ QList<QGraphicsItem *> ElementScene::zItems(ItemOptions options) const
|
|||||||
|
|
||||||
QList<QGraphicsItem *> terminals;
|
QList<QGraphicsItem *> terminals;
|
||||||
QList<QGraphicsItem *> helpers;
|
QList<QGraphicsItem *> helpers;
|
||||||
for (i.toFront(); i.hasNext(); ) {
|
for (i.toFront(); i.hasNext(); )
|
||||||
|
{
|
||||||
i.next();
|
i.next();
|
||||||
QGraphicsItem *qgi = i.value();
|
QGraphicsItem *qgi = i.value();
|
||||||
if (
|
if (
|
||||||
@@ -955,7 +973,8 @@ QList<QGraphicsItem *> ElementScene::zItems(ItemOptions options) const
|
|||||||
i.remove();
|
i.remove();
|
||||||
helpers << qgi;
|
helpers << qgi;
|
||||||
}
|
}
|
||||||
else if (qgraphicsitem_cast<PartTerminal *>(qgi)) {
|
else if (qgraphicsitem_cast<PartTerminal *>(qgi))
|
||||||
|
{
|
||||||
i.remove();
|
i.remove();
|
||||||
terminals << qgi;
|
terminals << qgi;
|
||||||
}
|
}
|
||||||
@@ -963,18 +982,22 @@ QList<QGraphicsItem *> ElementScene::zItems(ItemOptions options) const
|
|||||||
|
|
||||||
// orders the parts by their zValue
|
// orders the parts by their zValue
|
||||||
// ordonne les parties par leur zValue
|
// ordonne les parties par leur zValue
|
||||||
if (options & SortByZValue) {
|
if (options & SortByZValue)
|
||||||
std::sort (all_items_list.begin(),
|
{
|
||||||
all_items_list.end(),
|
std::sort (
|
||||||
ElementScene::zValueLessThan);
|
all_items_list.begin(),
|
||||||
|
all_items_list.end(),
|
||||||
|
ElementScene::zValueLessThan);
|
||||||
}
|
}
|
||||||
|
|
||||||
// possibly add the limits
|
// possibly add the limits
|
||||||
// rajoute eventuellement les bornes
|
// rajoute eventuellement les bornes
|
||||||
if (options & ElementScene::IncludeTerminals) {
|
if (options & ElementScene::IncludeTerminals)
|
||||||
|
{
|
||||||
all_items_list += terminals;
|
all_items_list += terminals;
|
||||||
}
|
}
|
||||||
if (options & ElementScene::IncludeHelperItems) {
|
if (options & ElementScene::IncludeHelperItems)
|
||||||
|
{
|
||||||
all_items_list += helpers;
|
all_items_list += helpers;
|
||||||
}
|
}
|
||||||
return(all_items_list);
|
return(all_items_list);
|
||||||
@@ -988,7 +1011,8 @@ QList<QGraphicsItem *> ElementScene::zItems(ItemOptions options) const
|
|||||||
ElementContent ElementScene::selectedContent() const
|
ElementContent ElementScene::selectedContent() const
|
||||||
{
|
{
|
||||||
ElementContent content;
|
ElementContent content;
|
||||||
foreach(QGraphicsItem *qgi, zItems()) {
|
foreach(QGraphicsItem *qgi, zItems())
|
||||||
|
{
|
||||||
if (qgi -> isSelected()) content << qgi;
|
if (qgi -> isSelected()) content << qgi;
|
||||||
}
|
}
|
||||||
return(content);
|
return(content);
|
||||||
@@ -1001,7 +1025,8 @@ ElementContent ElementScene::selectedContent() const
|
|||||||
\~ @return the rectangle where you will have to glue these parts
|
\~ @return the rectangle where you will have to glue these parts
|
||||||
\~French le rectangle ou il faudra coller ces parties
|
\~French le rectangle ou il faudra coller ces parties
|
||||||
*/
|
*/
|
||||||
void ElementScene::getPasteArea(const QRectF &to_paste) {
|
void ElementScene::getPasteArea(const QRectF &to_paste)
|
||||||
|
{
|
||||||
// we draw it on the stage
|
// we draw it on the stage
|
||||||
// on le dessine sur la scene
|
// on le dessine sur la scene
|
||||||
m_paste_area -> setRect(to_paste);
|
m_paste_area -> setRect(to_paste);
|
||||||
@@ -1102,8 +1127,8 @@ bool ElementScene::applyInformations(const QDomDocument &xml_document)
|
|||||||
//extract additional informations
|
//extract additional informations
|
||||||
setInformations(QString());
|
setInformations(QString());
|
||||||
for (QDomNode node = root.firstChild() ;
|
for (QDomNode node = root.firstChild() ;
|
||||||
!node.isNull() ;
|
!node.isNull() ;
|
||||||
node = node.nextSibling())
|
node = node.nextSibling())
|
||||||
{
|
{
|
||||||
QDomElement elmt = node.toElement();
|
QDomElement elmt = node.toElement();
|
||||||
if (elmt.isNull()) continue;
|
if (elmt.isNull()) continue;
|
||||||
@@ -1195,7 +1220,8 @@ ElementContent ElementScene::loadContent(const QDomDocument &xml_document)
|
|||||||
\~ @return Content adds
|
\~ @return Content adds
|
||||||
\~French Le contenu ajoute
|
\~French Le contenu ajoute
|
||||||
*/
|
*/
|
||||||
ElementContent ElementScene::addContent(const ElementContent &content) {
|
ElementContent ElementScene::addContent(const ElementContent &content)
|
||||||
|
{
|
||||||
foreach(QGraphicsItem *part, content) {
|
foreach(QGraphicsItem *part, content) {
|
||||||
addPrimitive(part);
|
addPrimitive(part);
|
||||||
}
|
}
|
||||||
@@ -1215,8 +1241,10 @@ ElementContent ElementScene::addContent(const ElementContent &content) {
|
|||||||
\~ @return Content adds
|
\~ @return Content adds
|
||||||
\~French Le contenu ajoute
|
\~French Le contenu ajoute
|
||||||
*/
|
*/
|
||||||
ElementContent ElementScene::addContentAtPos(const ElementContent &content,
|
ElementContent ElementScene::addContentAtPos(
|
||||||
const QPointF &pos) {
|
const ElementContent &content,
|
||||||
|
const QPointF &pos)
|
||||||
|
{
|
||||||
// calculate the boundingRect of the content to add
|
// calculate the boundingRect of the content to add
|
||||||
// calcule le boundingRect du contenu a ajouter
|
// calcule le boundingRect du contenu a ajouter
|
||||||
QRectF bounding_rect = elementContentBoundingRect(content);
|
QRectF bounding_rect = elementContentBoundingRect(content);
|
||||||
@@ -1243,7 +1271,8 @@ ElementContent ElementScene::addContentAtPos(const ElementContent &content,
|
|||||||
ElementPrimitiveDecorator group.
|
ElementPrimitiveDecorator group.
|
||||||
@param primitive
|
@param primitive
|
||||||
*/
|
*/
|
||||||
void ElementScene::addPrimitive(QGraphicsItem *primitive) {
|
void ElementScene::addPrimitive(QGraphicsItem *primitive)
|
||||||
|
{
|
||||||
if (!primitive) return;
|
if (!primitive) return;
|
||||||
addItem(primitive);
|
addItem(primitive);
|
||||||
}
|
}
|
||||||
@@ -1281,7 +1310,8 @@ void ElementScene::initPasteArea()
|
|||||||
\~French une reference vers un QPointF. Cet objet sera modifie.
|
\~French une reference vers un QPointF. Cet objet sera modifie.
|
||||||
\~ @return point
|
\~ @return point
|
||||||
*/
|
*/
|
||||||
QPointF ElementScene::snapToGrid(QPointF point) {
|
QPointF ElementScene::snapToGrid(QPointF point)
|
||||||
|
{
|
||||||
point.rx() = qRound(point.x() / m_x_grid) * m_x_grid;
|
point.rx() = qRound(point.x() / m_x_grid) * m_x_grid;
|
||||||
point.ry() = qRound(point.y() / m_y_grid) * m_y_grid;
|
point.ry() = qRound(point.y() / m_y_grid) * m_y_grid;
|
||||||
return point;
|
return point;
|
||||||
@@ -1293,7 +1323,8 @@ QPointF ElementScene::snapToGrid(QPointF point) {
|
|||||||
@param item2 : QGraphicsItem
|
@param item2 : QGraphicsItem
|
||||||
@return true if \a item1's zValue() is less than \a item2's.
|
@return true if \a item1's zValue() is less than \a item2's.
|
||||||
*/
|
*/
|
||||||
bool ElementScene::zValueLessThan(QGraphicsItem *item1, QGraphicsItem *item2) {
|
bool ElementScene::zValueLessThan(QGraphicsItem *item1, QGraphicsItem *item2)
|
||||||
|
{
|
||||||
return(item1-> zValue() < item2 -> zValue());
|
return(item1-> zValue() < item2 -> zValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1376,7 +1407,8 @@ void ElementScene::managePrimitivesGroups()
|
|||||||
Push the provided \a command on the undo stack.
|
Push the provided \a command on the undo stack.
|
||||||
@param command
|
@param command
|
||||||
*/
|
*/
|
||||||
void ElementScene::stackAction(ElementEditionCommand *command) {
|
void ElementScene::stackAction(ElementEditionCommand *command)
|
||||||
|
{
|
||||||
if (command -> elementScene()) {
|
if (command -> elementScene()) {
|
||||||
if (command -> elementScene() != this) return;
|
if (command -> elementScene() != this) return;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user