mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 12:40:35 +01:00
Disable deletion if a terminal can't be deleted.
In case of user try to delete a terminal element who is bridged or belong to a physical terminal with more than one level, the deletion is aborted to avoid mistake in the terminal strip parent of the terminal element. A dialog is opened when the deletion can't be to explain to user what to do for enable the deletion.
This commit is contained in:
@@ -28,6 +28,8 @@
|
||||
#include "../qetgraphicsitem/elementtextitemgroup.h"
|
||||
#include "../qetgraphicsitem/terminal.h"
|
||||
#include "addelementtextcommand.h"
|
||||
#include "../TerminalStrip/realterminal.h"
|
||||
#include "../TerminalStrip/physicalterminal.h"
|
||||
|
||||
/**
|
||||
@brief DeleteQGraphicsItemCommand::DeleteQGraphicsItemCommand
|
||||
@@ -115,6 +117,36 @@ DeleteQGraphicsItemCommand::~DeleteQGraphicsItemCommand()
|
||||
m_diagram->qgiManager().release(m_removed_contents.items(DiagramContent::All));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief DeleteQGraphicsItemCommand::hasNonDeletableTerminal
|
||||
* Return true if @content have terminal element which can't be deleted.
|
||||
* The reason why a terminal can't be deleted is because they have bridge
|
||||
* or belong to a physical terminal with more than one level.
|
||||
* @param diagram
|
||||
* @param content
|
||||
* @param dialog
|
||||
* @return
|
||||
*/
|
||||
bool DeleteQGraphicsItemCommand::hasNonDeletableTerminal(const DiagramContent &content)
|
||||
{
|
||||
if (!content.m_terminal_elements.isEmpty())
|
||||
{
|
||||
for (const auto &terminal : content.m_terminal_elements)
|
||||
{
|
||||
if (!terminal.isNull())
|
||||
{
|
||||
if (terminal->parentTerminalStrip()
|
||||
&& (terminal->realTerminal()->isBridged()
|
||||
|| terminal->realTerminal()->physicalTerminal()->levelCount() != 1)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@brief DeleteQGraphicsItemCommand::setPotentialsOfRemovedElements
|
||||
This function creates new conductors (if needed) for conserve the electrical potentials
|
||||
|
||||
Reference in New Issue
Block a user