From 993eb58d467fc3d0d8775932ed895f853d0c9898 Mon Sep 17 00:00:00 2001 From: joshua Date: Thu, 27 Jan 2022 19:07:49 +0100 Subject: [PATCH 1/4] Minor : add undo text --- sources/TerminalStrip/UndoCommand/changeterminalstripcolor.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/TerminalStrip/UndoCommand/changeterminalstripcolor.cpp b/sources/TerminalStrip/UndoCommand/changeterminalstripcolor.cpp index 17507f159..d92d110b5 100644 --- a/sources/TerminalStrip/UndoCommand/changeterminalstripcolor.cpp +++ b/sources/TerminalStrip/UndoCommand/changeterminalstripcolor.cpp @@ -34,6 +34,7 @@ ChangeTerminalStripColor::ChangeTerminalStripColor(QSharedPointercolor(); } + setText(QObject::tr("Modifier la couleur d'un pont de bornes")); } void ChangeTerminalStripColor::redo() From d114b097bf001c452e856dbf356c99de009a5931 Mon Sep 17 00:00:00 2001 From: joshua Date: Thu, 27 Jan 2022 19:45:33 +0100 Subject: [PATCH 2/4] Minor Fix : undo command for unbridge strip don't work --- sources/TerminalStrip/terminalstrip.cpp | 22 +++++++++++++++++++++- sources/TerminalStrip/terminalstrip.h | 1 + 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/sources/TerminalStrip/terminalstrip.cpp b/sources/TerminalStrip/terminalstrip.cpp index 04898f92f..f38a378ab 100644 --- a/sources/TerminalStrip/terminalstrip.cpp +++ b/sources/TerminalStrip/terminalstrip.cpp @@ -469,6 +469,26 @@ bool TerminalStrip::isBridgeable(const QVector> &re return no_bridged; } +/** + * @brief TerminalStrip::isBridgeable + * Check if all RealTerminal of @a real_terminals can be bridged to + * the bridge @a bridge. + * @param real_terminals + * @return true if can be bridged. + */ +bool TerminalStrip::isBridgeable(QSharedPointer bridge, const QVector > &real_terminals) const +{ + if (real_terminals.isEmpty() || + !m_bridge.contains(bridge)) { + return false; + } + + auto vector_ = bridge->realTerminals(); + vector_.append(real_terminals); + + return isBridgeable(vector_); +} + /** * @brief TerminalStrip::setBridge * Set a bridge betwen all real terminal of @a real_terminals @@ -508,7 +528,7 @@ bool TerminalStrip::setBridge(const QSharedPointer &bridge, { if (bridge) { - if (!isBridgeable(real_terminals)) { + if (!isBridgeable(bridge, real_terminals)) { return false; } diff --git a/sources/TerminalStrip/terminalstrip.h b/sources/TerminalStrip/terminalstrip.h index eae42117f..6017b4875 100644 --- a/sources/TerminalStrip/terminalstrip.h +++ b/sources/TerminalStrip/terminalstrip.h @@ -93,6 +93,7 @@ class TerminalStrip : public QObject bool setLevel(const QSharedPointer &real_terminal, int level); bool isBridgeable(const QVector> &real_terminals) const; + bool isBridgeable(QSharedPointer bridge, const QVector> &real_terminals) const; bool setBridge(const QVector> &real_terminals); bool setBridge(const QSharedPointer &bridge, const QVector> &real_terminals); void unBridge(const QVector> &real_terminals); From a31bd6eb0da59d946c011d5bad1abb783d36825a Mon Sep 17 00:00:00 2001 From: joshua Date: Thu, 27 Jan 2022 20:00:46 +0100 Subject: [PATCH 3/4] Minor improvement about undo/redo for bridge creation When a new bridge is created, an undo command is created for that. When undo the action and redo it, all terminals are bridged to a new bridge instead of the first one, who continue to exist but is now empty and 'lost' because he will never be reused. In addition of that, if a more recent undo command (we call it undo2) use this bridge, there is a unknown behavior, because the status of the bridge is not the same as when the undo2 was created. --- .../UndoCommand/bridgeterminalscommand.cpp | 10 ++++++++-- .../TerminalStrip/UndoCommand/bridgeterminalscommand.h | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/sources/TerminalStrip/UndoCommand/bridgeterminalscommand.cpp b/sources/TerminalStrip/UndoCommand/bridgeterminalscommand.cpp index 425adc29c..1a1eec5ba 100644 --- a/sources/TerminalStrip/UndoCommand/bridgeterminalscommand.cpp +++ b/sources/TerminalStrip/UndoCommand/bridgeterminalscommand.cpp @@ -36,8 +36,14 @@ void BridgeTerminalsCommand::undo() void BridgeTerminalsCommand::redo() { - if (m_strip) { - m_strip->setBridge(m_real_terminal_vector); + if (m_strip) + { + if (m_bridge) { + m_strip->setBridge(m_bridge, m_real_terminal_vector); + } else { + m_strip->setBridge(m_real_terminal_vector); + m_bridge = m_strip->isBridged(m_real_terminal_vector.first()); + } } } diff --git a/sources/TerminalStrip/UndoCommand/bridgeterminalscommand.h b/sources/TerminalStrip/UndoCommand/bridgeterminalscommand.h index ec1fcfef4..a642a869e 100644 --- a/sources/TerminalStrip/UndoCommand/bridgeterminalscommand.h +++ b/sources/TerminalStrip/UndoCommand/bridgeterminalscommand.h @@ -42,6 +42,7 @@ class BridgeTerminalsCommand : public QUndoCommand private: QPointer m_strip; QVector> m_real_terminal_vector; + QSharedPointer m_bridge; }; From d562ca8a3954ee47534e0c3f82683a65200b8bb1 Mon Sep 17 00:00:00 2001 From: joshua Date: Fri, 28 Jan 2022 18:08:16 +0100 Subject: [PATCH 4/4] Fix fail to build from sources --- sources/TerminalStrip/ui/terminalstripmodel.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/TerminalStrip/ui/terminalstripmodel.h b/sources/TerminalStrip/ui/terminalstripmodel.h index d3fa6d40c..5e0db6865 100644 --- a/sources/TerminalStrip/ui/terminalstripmodel.h +++ b/sources/TerminalStrip/ui/terminalstripmodel.h @@ -38,7 +38,7 @@ inline uint qHash(const QPointer &key, uint seed) { if (key) return qHash(key->uuid(), seed); else - return qHash(nullptr, seed); + return qHash(QUuid(), seed); } class TerminalStrip;