mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-17 12:40:35 +01:00
Qet graphics table item can be removed from diagram
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
#include "diagram.h"
|
||||
#include "terminal.h"
|
||||
#include "conductortextitem.h"
|
||||
#include "qetgraphicstableitem.h"
|
||||
|
||||
/**
|
||||
* @brief DiagramContent::DiagramContent
|
||||
@@ -49,39 +50,41 @@ DiagramContent::DiagramContent(Diagram *diagram, bool selected) :
|
||||
item_list = diagram->items();
|
||||
}
|
||||
|
||||
|
||||
for (QGraphicsItem *item : item_list)
|
||||
for (auto item : item_list)
|
||||
{
|
||||
if (Element *elmt = qgraphicsitem_cast<Element *>(item))
|
||||
m_elements << elmt;
|
||||
else if (IndependentTextItem *iti = qgraphicsitem_cast<IndependentTextItem *>(item))
|
||||
m_text_fields << iti;
|
||||
else if (Conductor *c = qgraphicsitem_cast<Conductor *>(item))
|
||||
switch (item->type())
|
||||
{
|
||||
//Get the isolated selected conductor (= not movable, but deletable)
|
||||
if (!c->terminal1->parentItem()->isSelected() &&\
|
||||
!c->terminal2->parentItem()->isSelected()) {
|
||||
m_other_conductors << c;
|
||||
}
|
||||
|
||||
if (m_potential_conductors.isEmpty()) {
|
||||
m_potential_conductors << c;
|
||||
}
|
||||
else
|
||||
case Element::Type: { m_elements << qgraphicsitem_cast<Element *>(item); break;}
|
||||
case IndependentTextItem::Type: { m_text_fields << qgraphicsitem_cast<IndependentTextItem *>(item); break;}
|
||||
case Conductor::Type:
|
||||
{
|
||||
if (!potentialIsManaged(c->relatedPotentialConductors(true).toList()))
|
||||
auto c = qgraphicsitem_cast<Conductor *>(item);
|
||||
//Get the isolated selected conductor (= not movable, but deletable)
|
||||
if (!c->terminal1->parentItem()->isSelected() &&\
|
||||
!c->terminal2->parentItem()->isSelected()) {
|
||||
m_other_conductors << c;
|
||||
}
|
||||
|
||||
if (m_potential_conductors.isEmpty()) {
|
||||
m_potential_conductors << c;
|
||||
} else {
|
||||
if (!potentialIsManaged(c->relatedPotentialConductors(true).toList())) {
|
||||
m_potential_conductors << c;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DiagramImageItem::Type: { m_images << qgraphicsitem_cast<DiagramImageItem *>(item); break;}
|
||||
case QetShapeItem::Type: { m_shapes << qgraphicsitem_cast<QetShapeItem *>(item); break;}
|
||||
case DynamicElementTextItem::Type: { m_element_texts << qgraphicsitem_cast<DynamicElementTextItem *>(item); break;}
|
||||
case QGraphicsItemGroup::Type: {
|
||||
if (auto *group = dynamic_cast<ElementTextItemGroup *>(item)) {
|
||||
m_texts_groups << group;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case QetGraphicsTableItem::Type: { m_tables << qgraphicsitem_cast<QetGraphicsTableItem *>(item); break;}
|
||||
}
|
||||
else if (DiagramImageItem *dii = qgraphicsitem_cast<DiagramImageItem *>(item))
|
||||
m_images << dii;
|
||||
else if (QetShapeItem *dsi = qgraphicsitem_cast<QetShapeItem *>(item))
|
||||
m_shapes << dsi;
|
||||
else if (DynamicElementTextItem *deti = qgraphicsitem_cast<DynamicElementTextItem *>(item))
|
||||
m_element_texts << deti;
|
||||
else if (QGraphicsItemGroup *group = qgraphicsitem_cast<QGraphicsItemGroup *>(item))
|
||||
if(ElementTextItemGroup *etig = dynamic_cast<ElementTextItemGroup *>(group))
|
||||
m_texts_groups << etig;
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +103,7 @@ DiagramContent::DiagramContent(Diagram *diagram, bool selected) :
|
||||
else
|
||||
other_terminal = conductor->terminal1;
|
||||
|
||||
//If the two elements of conductor are movable
|
||||
//If the two elements of conductor are movable
|
||||
if (m_elements.contains(other_terminal -> parentElement())) {
|
||||
if (!m_conductors_to_move.contains(conductor))
|
||||
m_conductors_to_move << conductor;
|
||||
@@ -129,7 +132,8 @@ DiagramContent::DiagramContent(const DiagramContent &other) :
|
||||
m_potential_conductors(other.m_potential_conductors),
|
||||
m_element_texts(other.m_element_texts),
|
||||
m_texts_groups(other.m_texts_groups),
|
||||
m_selected_items(other.m_selected_items)
|
||||
m_selected_items(other.m_selected_items),
|
||||
m_tables(other.m_tables)
|
||||
{}
|
||||
|
||||
DiagramContent::~DiagramContent()
|
||||
@@ -211,7 +215,8 @@ bool DiagramContent::hasDeletableItems() const
|
||||
qgi->type() == IndependentTextItem::Type ||
|
||||
qgi->type() == QetShapeItem::Type ||
|
||||
qgi->type() == DiagramImageItem::Type ||
|
||||
qgi->type() == DynamicElementTextItem::Type)
|
||||
qgi->type() == DynamicElementTextItem::Type ||
|
||||
qgi->type() == QetGraphicsTableItem::Type)
|
||||
return true;
|
||||
if(qgi->type() == QGraphicsItemGroup::Type)
|
||||
if(dynamic_cast<ElementTextItemGroup *>(qgi))
|
||||
@@ -250,6 +255,7 @@ void DiagramContent::clear()
|
||||
m_element_texts.clear();
|
||||
m_texts_groups.clear();
|
||||
m_selected_items.clear();
|
||||
m_tables.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -338,6 +344,10 @@ DiagramContent &DiagramContent::operator+=(const DiagramContent &other)
|
||||
m_potential_conductors << c;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto table : other.m_tables)
|
||||
if (!m_tables.contains(table))
|
||||
m_tables << table;
|
||||
|
||||
return *this;
|
||||
}
|
||||
@@ -386,12 +396,13 @@ QList<QGraphicsItem *> DiagramContent::items(int filter) const
|
||||
|
||||
for(QGraphicsItem *qgi : conductors(filter)) items_list << qgi;
|
||||
|
||||
if (filter & Elements) for(QGraphicsItem *qgi : m_elements) items_list << qgi;
|
||||
if (filter & TextFields) for(QGraphicsItem *qgi : m_text_fields) items_list << qgi;
|
||||
if (filter & Images) for(QGraphicsItem *qgi : m_images) items_list << qgi;
|
||||
if (filter & Shapes) for(QGraphicsItem *qgi : m_shapes) items_list << qgi;
|
||||
if (filter & ElementTextFields) for(QGraphicsItem *qgi : m_element_texts) items_list << qgi;
|
||||
if (filter & TextGroup) for(QGraphicsItem *qgi : m_texts_groups) items_list << qgi;
|
||||
if (filter & Elements) for(auto qgi : m_elements) items_list << qgi;
|
||||
if (filter & TextFields) for(auto qgi : m_text_fields) items_list << qgi;
|
||||
if (filter & Images) for(auto qgi : m_images) items_list << qgi;
|
||||
if (filter & Shapes) for(auto qgi : m_shapes) items_list << qgi;
|
||||
if (filter & ElementTextFields) for(auto qgi : m_element_texts) items_list << qgi;
|
||||
if (filter & TextGroup) for(auto qgi : m_texts_groups) items_list << qgi;
|
||||
if (filter & Tables) for(auto qgi : m_tables) items_list << qgi;
|
||||
|
||||
if (filter & SelectedOnly) {
|
||||
for(QGraphicsItem *qgi : items_list) {
|
||||
@@ -410,15 +421,16 @@ int DiagramContent::count(int filter) const
|
||||
{
|
||||
int count = 0;
|
||||
if (filter & SelectedOnly) {
|
||||
if (filter & Elements) for(Element *element : m_elements) { if (element -> isSelected()) ++ count; }
|
||||
if (filter & TextFields) for(DiagramTextItem *dti : m_text_fields) { if (dti -> isSelected()) ++ count; }
|
||||
if (filter & Images) for(DiagramImageItem *dii : m_images) { if (dii -> isSelected()) ++ count; }
|
||||
if (filter & Shapes) for(QetShapeItem *dsi : m_shapes) { if (dsi -> isSelected()) ++ count; }
|
||||
if (filter & ConductorsToMove) for(Conductor *conductor : m_conductors_to_move) { if (conductor -> isSelected()) ++ count; }
|
||||
if (filter & ConductorsToUpdate) for(Conductor *conductor : m_conductors_to_update) { if (conductor -> isSelected()) ++ count; }
|
||||
if (filter & OtherConductors) for(Conductor *conductor : m_other_conductors) { if (conductor -> isSelected()) ++ count; }
|
||||
if (filter & ElementTextFields) for(DynamicElementTextItem *deti : m_element_texts) { if (deti -> isSelected()) ++ count; }
|
||||
if (filter & TextGroup) for(ElementTextItemGroup *etig : m_texts_groups) { if (etig -> isSelected()) ++ count; }
|
||||
if (filter & Elements) for(auto element : m_elements) { if (element -> isSelected()) ++ count; }
|
||||
if (filter & TextFields) for(auto dti : m_text_fields) { if (dti -> isSelected()) ++ count; }
|
||||
if (filter & Images) for(auto dii : m_images) { if (dii -> isSelected()) ++ count; }
|
||||
if (filter & Shapes) for(auto dsi : m_shapes) { if (dsi -> isSelected()) ++ count; }
|
||||
if (filter & ConductorsToMove) for(auto conductor : m_conductors_to_move) { if (conductor -> isSelected()) ++ count; }
|
||||
if (filter & ConductorsToUpdate) for(auto conductor : m_conductors_to_update) { if (conductor -> isSelected()) ++ count; }
|
||||
if (filter & OtherConductors) for(auto conductor : m_other_conductors) { if (conductor -> isSelected()) ++ count; }
|
||||
if (filter & ElementTextFields) for(auto deti : m_element_texts) { if (deti -> isSelected()) ++ count; }
|
||||
if (filter & TextGroup) for(auto etig : m_texts_groups) { if (etig -> isSelected()) ++ count; }
|
||||
if (filter & Tables) for(auto table : m_tables) { if (table -> isSelected()) ++ count; }
|
||||
}
|
||||
else {
|
||||
if (filter & Elements) count += m_elements.count();
|
||||
@@ -430,6 +442,7 @@ int DiagramContent::count(int filter) const
|
||||
if (filter & OtherConductors) count += m_other_conductors.count();
|
||||
if (filter & ElementTextFields) count += m_element_texts.count();
|
||||
if (filter & TextGroup) count += m_texts_groups.count();
|
||||
if (filter & Tables) count += m_tables.count();
|
||||
}
|
||||
return(count);
|
||||
}
|
||||
@@ -448,6 +461,7 @@ QString DiagramContent::sentence(int filter) const
|
||||
int images_count = (filter & Images) ? m_images.count() : 0;
|
||||
int shapes_count = (filter & Shapes) ? m_shapes.count() : 0;
|
||||
int elmt_text_count = (filter & ElementTextFields) ? m_element_texts.count() : 0;
|
||||
int tables_count = (filter & Tables) ? m_tables.count() : 0;
|
||||
|
||||
return(
|
||||
QET::ElementsAndConductorsSentence(
|
||||
@@ -456,7 +470,8 @@ QString DiagramContent::sentence(int filter) const
|
||||
textfields_count,
|
||||
images_count,
|
||||
shapes_count,
|
||||
elmt_text_count
|
||||
elmt_text_count,
|
||||
tables_count
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -468,7 +483,7 @@ QString DiagramContent::sentence(int filter) const
|
||||
* @return
|
||||
*/
|
||||
QDebug &operator<<(QDebug d, DiagramContent &content) {
|
||||
Q_UNUSED(content);
|
||||
Q_UNUSED(content)
|
||||
d << "DiagramContent {" << "\n";
|
||||
/*
|
||||
FIXME Le double-heritage QObject / QGraphicsItem a casse cet operateur
|
||||
|
||||
Reference in New Issue
Block a user