Wrap code for better readability

This commit is contained in:
Simon De Backer
2020-08-16 14:23:42 +02:00
parent 8a484ef901
commit 8144e9b21b
2 changed files with 16 additions and 5 deletions

View File

@@ -27,19 +27,25 @@
@param old_info : old info of element @param old_info : old info of element
@param new_info : new info of element @param new_info : new info of element
*/ */
ChangeElementInformationCommand::ChangeElementInformationCommand(Element *elmt, DiagramContext &old_info, DiagramContext &new_info, QUndoCommand *parent) : ChangeElementInformationCommand::ChangeElementInformationCommand(
Element *elmt,
DiagramContext &old_info,
DiagramContext &new_info,
QUndoCommand *parent) :
QUndoCommand (parent), QUndoCommand (parent),
m_element (elmt), m_element (elmt),
m_old_info (old_info), m_old_info (old_info),
m_new_info (new_info) m_new_info (new_info)
{ {
setText(QObject::tr("Modifier les informations de l'élément : %1").arg(elmt -> name())); setText(QObject::tr("Modifier les informations de l'élément : %1")
.arg(elmt -> name()));
} }
bool ChangeElementInformationCommand::mergeWith(const QUndoCommand *other) bool ChangeElementInformationCommand::mergeWith(const QUndoCommand *other)
{ {
if (id() != other->id()) return false; if (id() != other->id()) return false;
ChangeElementInformationCommand const *undo = static_cast<const ChangeElementInformationCommand*>(other); ChangeElementInformationCommand const *undo =
static_cast<const ChangeElementInformationCommand*>(other);
if (m_element != undo->m_element) return false; if (m_element != undo->m_element) return false;
m_new_info = undo->m_new_info; m_new_info = undo->m_new_info;
return true; return true;
@@ -64,6 +70,7 @@ void ChangeElementInformationCommand::redo() {
void ChangeElementInformationCommand::updateProjectDB() void ChangeElementInformationCommand::updateProjectDB()
{ {
if(m_element->diagram()) { if(m_element->diagram()) {
m_element->diagram()->project()->dataBase()->elementInfoChanged(m_element); m_element->diagram()->project()->dataBase()->elementInfoChanged(
m_element);
} }
} }

View File

@@ -30,7 +30,11 @@ class Element;
class ChangeElementInformationCommand : public QUndoCommand class ChangeElementInformationCommand : public QUndoCommand
{ {
public: public:
ChangeElementInformationCommand(Element *elmt, DiagramContext &old_info, DiagramContext &new_info, QUndoCommand *parent = nullptr); ChangeElementInformationCommand(
Element *elmt,
DiagramContext &old_info,
DiagramContext &new_info,
QUndoCommand *parent = nullptr);
int id() const override {return 1;} int id() const override {return 1;}
bool mergeWith(const QUndoCommand *other) override; bool mergeWith(const QUndoCommand *other) override;