Fix code style

This commit is contained in:
Simon De Backer
2020-10-13 17:44:08 +02:00
parent 106b17cf2f
commit 364012848c

View File

@@ -94,7 +94,8 @@ ElementScene::~ElementScene()
@brief ElementScene::mouseMoveEvent
@param e
*/
void ElementScene::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
void ElementScene::mouseMoveEvent(QGraphicsSceneMouseEvent *e)
{
if (m_event_interface) {
if (m_event_interface -> mouseMoveEvent(e)) {
if (m_event_interface->isFinish()) {
@@ -125,7 +126,8 @@ void ElementScene::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
@brief ElementScene::mousePressEvent
@param e
*/
void ElementScene::mousePressEvent(QGraphicsSceneMouseEvent *e) {
void ElementScene::mousePressEvent(QGraphicsSceneMouseEvent *e)
{
if (m_event_interface) {
if (m_event_interface -> mousePressEvent(e)) {
if (m_event_interface->isFinish()) {
@@ -144,7 +146,8 @@ void ElementScene::mousePressEvent(QGraphicsSceneMouseEvent *e) {
@brief ElementScene::mouseReleaseEvent
@param e
*/
void ElementScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
void ElementScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *e)
{
if (m_event_interface) {
if (m_event_interface -> mouseReleaseEvent(e)) {
if (m_event_interface->isFinish()) {
@@ -171,7 +174,8 @@ void ElementScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
@brief ElementScene::mouseDoubleClickEvent
@param event
*/
void ElementScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) {
void ElementScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
{
if (m_event_interface) {
if (m_event_interface -> mouseDoubleClickEvent(event)) {
if (m_event_interface->isFinish()) {
@@ -252,10 +256,8 @@ void ElementScene::keyPressEvent(QKeyEvent *event)
qgo->setPos(p);
QPropertyUndoCommand *undo =
new QPropertyUndoCommand(qgo,
"pos",
QVariant(original_pos),
QVariant(p));
new QPropertyUndoCommand(
qgo,"pos",QVariant(original_pos),QVariant(p));
undo->setText(tr("Déplacer une primitive"));
undo->enableAnimation();
undoStack().push(undo);
@@ -343,7 +345,8 @@ void ElementScene::clearEventInterface()
\~French Modifie the current behavior of this scene
\~ @param b
*/
void ElementScene::setBehavior(ElementScene::Behavior b) {
void ElementScene::setBehavior(ElementScene::Behavior b)
{
m_behavior = b;
}
@@ -379,7 +382,8 @@ int ElementScene::yGrid() const
\~ @param y_g : Vertical grid size
\~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_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
\~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
// charge les parties depuis le document XML
ElementContent loaded_content = loadContent(xml_document);
@@ -531,7 +536,8 @@ QRectF ElementScene::boundingRectFromXml(const QDomDocument &xml_document) {
\~French si ce pointeur vers un ElementContent est different de 0,
il sera rempli avec le contenu ajoute a l'element par le fromXml
*/
void ElementScene::fromXml(const QDomDocument &xml_document,
void ElementScene::fromXml(
const QDomDocument &xml_document,
const QPointF &position,
bool consider_informations,
ElementContent *content_ptr)
@@ -563,7 +569,8 @@ void ElementScene::fromXml(const QDomDocument &xml_document,
It is different from itemsBoundingRect() because it is not supposed
to imply any margin.
*/
QRectF ElementScene::elementSceneGeometricRect() const{
QRectF ElementScene::elementSceneGeometricRect() const
{
QRectF esgr;
foreach (QGraphicsItem *qgi, items()) {
if (qgi->type() == ElementPrimitiveDecorator::Type) continue;
@@ -585,8 +592,10 @@ QRectF ElementScene::elementSceneGeometricRect() const{
*/
bool ElementScene::containsTerminals() const
{
foreach(QGraphicsItem *qgi,items()) {
if (qgraphicsitem_cast<PartTerminal *>(qgi)) {
foreach(QGraphicsItem *qgi,items())
{
if (qgraphicsitem_cast<PartTerminal *>(qgi))
{
return(true);
}
}
@@ -635,7 +644,8 @@ bool ElementScene::clipboardMayContainElement()
true if clipboard_content has been copied from this 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);
}
@@ -807,7 +817,8 @@ void ElementScene::slot_editAuthorInformations()
dialog_author.setWindowFlags(Qt::Sheet);
#endif
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);
// adds an explanatory field to the dialogue
@@ -836,10 +847,13 @@ void ElementScene::slot_editAuthorInformations()
// start the 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
if (new_infos != informations()) {
undoStack().push(new ChangeInformationsCommand(this, informations(), new_infos));
if (new_infos != informations())
{
undoStack().push(new ChangeInformationsCommand(
this, informations(), new_infos));
}
}
}
@@ -904,8 +918,10 @@ void ElementScene::slot_editNames()
QList<CustomElementPart *> ElementScene::primitives() const
{
QList<CustomElementPart *> primitives_list;
foreach (QGraphicsItem *item, items()) {
if (CustomElementPart *primitive = dynamic_cast<CustomElementPart *>(item)) {
foreach (QGraphicsItem *item, items())
{
if (CustomElementPart *primitive = dynamic_cast<CustomElementPart *>(item))
{
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
if (!(options & ElementScene::Selected)
&&
!(options & ElementScene::NonSelected)) {
!(options & ElementScene::NonSelected))
{
return(QList<QGraphicsItem *>());
}
@@ -944,7 +961,8 @@ QList<QGraphicsItem *> ElementScene::zItems(ItemOptions options) const
QList<QGraphicsItem *> terminals;
QList<QGraphicsItem *> helpers;
for (i.toFront(); i.hasNext(); ) {
for (i.toFront(); i.hasNext(); )
{
i.next();
QGraphicsItem *qgi = i.value();
if (
@@ -955,7 +973,8 @@ QList<QGraphicsItem *> ElementScene::zItems(ItemOptions options) const
i.remove();
helpers << qgi;
}
else if (qgraphicsitem_cast<PartTerminal *>(qgi)) {
else if (qgraphicsitem_cast<PartTerminal *>(qgi))
{
i.remove();
terminals << qgi;
}
@@ -963,18 +982,22 @@ QList<QGraphicsItem *> ElementScene::zItems(ItemOptions options) const
// orders the parts by their zValue
// ordonne les parties par leur zValue
if (options & SortByZValue) {
std::sort (all_items_list.begin(),
if (options & SortByZValue)
{
std::sort (
all_items_list.begin(),
all_items_list.end(),
ElementScene::zValueLessThan);
}
// possibly add the limits
// rajoute eventuellement les bornes
if (options & ElementScene::IncludeTerminals) {
if (options & ElementScene::IncludeTerminals)
{
all_items_list += terminals;
}
if (options & ElementScene::IncludeHelperItems) {
if (options & ElementScene::IncludeHelperItems)
{
all_items_list += helpers;
}
return(all_items_list);
@@ -988,7 +1011,8 @@ QList<QGraphicsItem *> ElementScene::zItems(ItemOptions options) const
ElementContent ElementScene::selectedContent() const
{
ElementContent content;
foreach(QGraphicsItem *qgi, zItems()) {
foreach(QGraphicsItem *qgi, zItems())
{
if (qgi -> isSelected()) content << qgi;
}
return(content);
@@ -1001,7 +1025,8 @@ ElementContent ElementScene::selectedContent() const
\~ @return the rectangle where you will have to glue these parts
\~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
// on le dessine sur la scene
m_paste_area -> setRect(to_paste);
@@ -1195,7 +1220,8 @@ ElementContent ElementScene::loadContent(const QDomDocument &xml_document)
\~ @return Content adds
\~French Le contenu ajoute
*/
ElementContent ElementScene::addContent(const ElementContent &content) {
ElementContent ElementScene::addContent(const ElementContent &content)
{
foreach(QGraphicsItem *part, content) {
addPrimitive(part);
}
@@ -1215,8 +1241,10 @@ ElementContent ElementScene::addContent(const ElementContent &content) {
\~ @return Content adds
\~French Le contenu ajoute
*/
ElementContent ElementScene::addContentAtPos(const ElementContent &content,
const QPointF &pos) {
ElementContent ElementScene::addContentAtPos(
const ElementContent &content,
const QPointF &pos)
{
// calculate the boundingRect of the content to add
// calcule le boundingRect du contenu a ajouter
QRectF bounding_rect = elementContentBoundingRect(content);
@@ -1243,7 +1271,8 @@ ElementContent ElementScene::addContentAtPos(const ElementContent &content,
ElementPrimitiveDecorator group.
@param primitive
*/
void ElementScene::addPrimitive(QGraphicsItem *primitive) {
void ElementScene::addPrimitive(QGraphicsItem *primitive)
{
if (!primitive) return;
addItem(primitive);
}
@@ -1281,7 +1310,8 @@ void ElementScene::initPasteArea()
\~French une reference vers un QPointF. Cet objet sera modifie.
\~ @return point
*/
QPointF ElementScene::snapToGrid(QPointF point) {
QPointF ElementScene::snapToGrid(QPointF point)
{
point.rx() = qRound(point.x() / m_x_grid) * m_x_grid;
point.ry() = qRound(point.y() / m_y_grid) * m_y_grid;
return point;
@@ -1293,7 +1323,8 @@ QPointF ElementScene::snapToGrid(QPointF point) {
@param item2 : QGraphicsItem
@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());
}
@@ -1376,7 +1407,8 @@ void ElementScene::managePrimitivesGroups()
Push the provided \a command on the undo stack.
@param command
*/
void ElementScene::stackAction(ElementEditionCommand *command) {
void ElementScene::stackAction(ElementEditionCommand *command)
{
if (command -> elementScene()) {
if (command -> elementScene() != this) return;
} else {