mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-09-14 20:33:05 +02:00
Qet graphics table item can be removed from diagram
This commit is contained in:
parent
50f061697c
commit
0015f4a694
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "renamedialog.h"
|
#include "renamedialog.h"
|
||||||
|
|
||||||
#include <utility>
|
#include <QDate>
|
||||||
#include "ui_renamedialog.h"
|
#include "ui_renamedialog.h"
|
||||||
|
|
||||||
RenameDialog::RenameDialog(QString path, QWidget *parent) :
|
RenameDialog::RenameDialog(QString path, QWidget *parent) :
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
#include "conductorproperties.h"
|
#include "conductorproperties.h"
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <utility>
|
#include <QMetaEnum>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructeur par defaut
|
Constructeur par defaut
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "qet.h"
|
#include "qet.h"
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
|
#include <QSettings>
|
||||||
|
|
||||||
class QPainter;
|
class QPainter;
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "diagram.h"
|
#include "diagram.h"
|
||||||
#include "terminal.h"
|
#include "terminal.h"
|
||||||
#include "conductortextitem.h"
|
#include "conductortextitem.h"
|
||||||
|
#include "qetgraphicstableitem.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief DiagramContent::DiagramContent
|
* @brief DiagramContent::DiagramContent
|
||||||
@ -49,39 +50,41 @@ DiagramContent::DiagramContent(Diagram *diagram, bool selected) :
|
|||||||
item_list = diagram->items();
|
item_list = diagram->items();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (auto item : item_list)
|
||||||
for (QGraphicsItem *item : item_list)
|
|
||||||
{
|
{
|
||||||
if (Element *elmt = qgraphicsitem_cast<Element *>(item))
|
switch (item->type())
|
||||||
m_elements << elmt;
|
|
||||||
else if (IndependentTextItem *iti = qgraphicsitem_cast<IndependentTextItem *>(item))
|
|
||||||
m_text_fields << iti;
|
|
||||||
else if (Conductor *c = qgraphicsitem_cast<Conductor *>(item))
|
|
||||||
{
|
{
|
||||||
//Get the isolated selected conductor (= not movable, but deletable)
|
case Element::Type: { m_elements << qgraphicsitem_cast<Element *>(item); break;}
|
||||||
if (!c->terminal1->parentItem()->isSelected() &&\
|
case IndependentTextItem::Type: { m_text_fields << qgraphicsitem_cast<IndependentTextItem *>(item); break;}
|
||||||
!c->terminal2->parentItem()->isSelected()) {
|
case Conductor::Type:
|
||||||
m_other_conductors << c;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_potential_conductors.isEmpty()) {
|
|
||||||
m_potential_conductors << c;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
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;
|
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
|
else
|
||||||
other_terminal = conductor->terminal1;
|
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_elements.contains(other_terminal -> parentElement())) {
|
||||||
if (!m_conductors_to_move.contains(conductor))
|
if (!m_conductors_to_move.contains(conductor))
|
||||||
m_conductors_to_move << conductor;
|
m_conductors_to_move << conductor;
|
||||||
@ -129,7 +132,8 @@ DiagramContent::DiagramContent(const DiagramContent &other) :
|
|||||||
m_potential_conductors(other.m_potential_conductors),
|
m_potential_conductors(other.m_potential_conductors),
|
||||||
m_element_texts(other.m_element_texts),
|
m_element_texts(other.m_element_texts),
|
||||||
m_texts_groups(other.m_texts_groups),
|
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()
|
DiagramContent::~DiagramContent()
|
||||||
@ -211,7 +215,8 @@ bool DiagramContent::hasDeletableItems() const
|
|||||||
qgi->type() == IndependentTextItem::Type ||
|
qgi->type() == IndependentTextItem::Type ||
|
||||||
qgi->type() == QetShapeItem::Type ||
|
qgi->type() == QetShapeItem::Type ||
|
||||||
qgi->type() == DiagramImageItem::Type ||
|
qgi->type() == DiagramImageItem::Type ||
|
||||||
qgi->type() == DynamicElementTextItem::Type)
|
qgi->type() == DynamicElementTextItem::Type ||
|
||||||
|
qgi->type() == QetGraphicsTableItem::Type)
|
||||||
return true;
|
return true;
|
||||||
if(qgi->type() == QGraphicsItemGroup::Type)
|
if(qgi->type() == QGraphicsItemGroup::Type)
|
||||||
if(dynamic_cast<ElementTextItemGroup *>(qgi))
|
if(dynamic_cast<ElementTextItemGroup *>(qgi))
|
||||||
@ -250,6 +255,7 @@ void DiagramContent::clear()
|
|||||||
m_element_texts.clear();
|
m_element_texts.clear();
|
||||||
m_texts_groups.clear();
|
m_texts_groups.clear();
|
||||||
m_selected_items.clear();
|
m_selected_items.clear();
|
||||||
|
m_tables.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -339,6 +345,10 @@ DiagramContent &DiagramContent::operator+=(const DiagramContent &other)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (auto table : other.m_tables)
|
||||||
|
if (!m_tables.contains(table))
|
||||||
|
m_tables << table;
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -386,12 +396,13 @@ QList<QGraphicsItem *> DiagramContent::items(int filter) const
|
|||||||
|
|
||||||
for(QGraphicsItem *qgi : conductors(filter)) items_list << qgi;
|
for(QGraphicsItem *qgi : conductors(filter)) items_list << qgi;
|
||||||
|
|
||||||
if (filter & Elements) for(QGraphicsItem *qgi : m_elements) items_list << qgi;
|
if (filter & Elements) for(auto qgi : m_elements) items_list << qgi;
|
||||||
if (filter & TextFields) for(QGraphicsItem *qgi : m_text_fields) items_list << qgi;
|
if (filter & TextFields) for(auto qgi : m_text_fields) items_list << qgi;
|
||||||
if (filter & Images) for(QGraphicsItem *qgi : m_images) items_list << qgi;
|
if (filter & Images) for(auto qgi : m_images) items_list << qgi;
|
||||||
if (filter & Shapes) for(QGraphicsItem *qgi : m_shapes) items_list << qgi;
|
if (filter & Shapes) for(auto qgi : m_shapes) items_list << qgi;
|
||||||
if (filter & ElementTextFields) for(QGraphicsItem *qgi : m_element_texts) items_list << qgi;
|
if (filter & ElementTextFields) for(auto qgi : m_element_texts) items_list << qgi;
|
||||||
if (filter & TextGroup) for(QGraphicsItem *qgi : m_texts_groups) 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) {
|
if (filter & SelectedOnly) {
|
||||||
for(QGraphicsItem *qgi : items_list) {
|
for(QGraphicsItem *qgi : items_list) {
|
||||||
@ -410,15 +421,16 @@ int DiagramContent::count(int filter) const
|
|||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
if (filter & SelectedOnly) {
|
if (filter & SelectedOnly) {
|
||||||
if (filter & Elements) for(Element *element : m_elements) { if (element -> isSelected()) ++ count; }
|
if (filter & Elements) for(auto element : m_elements) { if (element -> isSelected()) ++ count; }
|
||||||
if (filter & TextFields) for(DiagramTextItem *dti : m_text_fields) { if (dti -> isSelected()) ++ count; }
|
if (filter & TextFields) for(auto dti : m_text_fields) { if (dti -> isSelected()) ++ count; }
|
||||||
if (filter & Images) for(DiagramImageItem *dii : m_images) { if (dii -> isSelected()) ++ count; }
|
if (filter & Images) for(auto dii : m_images) { if (dii -> isSelected()) ++ count; }
|
||||||
if (filter & Shapes) for(QetShapeItem *dsi : m_shapes) { if (dsi -> isSelected()) ++ count; }
|
if (filter & Shapes) for(auto dsi : m_shapes) { if (dsi -> isSelected()) ++ count; }
|
||||||
if (filter & ConductorsToMove) for(Conductor *conductor : m_conductors_to_move) { if (conductor -> isSelected()) ++ count; }
|
if (filter & ConductorsToMove) for(auto 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 & ConductorsToUpdate) for(auto conductor : m_conductors_to_update) { if (conductor -> isSelected()) ++ count; }
|
||||||
if (filter & OtherConductors) for(Conductor *conductor : m_other_conductors) { if (conductor -> isSelected()) ++ count; }
|
if (filter & OtherConductors) for(auto conductor : m_other_conductors) { if (conductor -> isSelected()) ++ count; }
|
||||||
if (filter & ElementTextFields) for(DynamicElementTextItem *deti : m_element_texts) { if (deti -> isSelected()) ++ count; }
|
if (filter & ElementTextFields) for(auto deti : m_element_texts) { if (deti -> isSelected()) ++ count; }
|
||||||
if (filter & TextGroup) for(ElementTextItemGroup *etig : m_texts_groups) { if (etig -> 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 {
|
else {
|
||||||
if (filter & Elements) count += m_elements.count();
|
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 & OtherConductors) count += m_other_conductors.count();
|
||||||
if (filter & ElementTextFields) count += m_element_texts.count();
|
if (filter & ElementTextFields) count += m_element_texts.count();
|
||||||
if (filter & TextGroup) count += m_texts_groups.count();
|
if (filter & TextGroup) count += m_texts_groups.count();
|
||||||
|
if (filter & Tables) count += m_tables.count();
|
||||||
}
|
}
|
||||||
return(count);
|
return(count);
|
||||||
}
|
}
|
||||||
@ -448,6 +461,7 @@ QString DiagramContent::sentence(int filter) const
|
|||||||
int images_count = (filter & Images) ? m_images.count() : 0;
|
int images_count = (filter & Images) ? m_images.count() : 0;
|
||||||
int shapes_count = (filter & Shapes) ? m_shapes.count() : 0;
|
int shapes_count = (filter & Shapes) ? m_shapes.count() : 0;
|
||||||
int elmt_text_count = (filter & ElementTextFields) ? m_element_texts.count() : 0;
|
int elmt_text_count = (filter & ElementTextFields) ? m_element_texts.count() : 0;
|
||||||
|
int tables_count = (filter & Tables) ? m_tables.count() : 0;
|
||||||
|
|
||||||
return(
|
return(
|
||||||
QET::ElementsAndConductorsSentence(
|
QET::ElementsAndConductorsSentence(
|
||||||
@ -456,7 +470,8 @@ QString DiagramContent::sentence(int filter) const
|
|||||||
textfields_count,
|
textfields_count,
|
||||||
images_count,
|
images_count,
|
||||||
shapes_count,
|
shapes_count,
|
||||||
elmt_text_count
|
elmt_text_count,
|
||||||
|
tables_count
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -468,7 +483,7 @@ QString DiagramContent::sentence(int filter) const
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
QDebug &operator<<(QDebug d, DiagramContent &content) {
|
QDebug &operator<<(QDebug d, DiagramContent &content) {
|
||||||
Q_UNUSED(content);
|
Q_UNUSED(content)
|
||||||
d << "DiagramContent {" << "\n";
|
d << "DiagramContent {" << "\n";
|
||||||
/*
|
/*
|
||||||
FIXME Le double-heritage QObject / QGraphicsItem a casse cet operateur
|
FIXME Le double-heritage QObject / QGraphicsItem a casse cet operateur
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QSaveFile>
|
#include <QSaveFile>
|
||||||
|
#include <QTextStream>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Permet de convertir une chaine de caracteres ("n", "s", "e" ou "w")
|
Permet de convertir une chaine de caracteres ("n", "s", "e" ou "w")
|
||||||
@ -237,7 +238,8 @@ bool QET::attributeIsAReal(const QDomElement &e, const QString& nom_attribut, qr
|
|||||||
@return la proposition decrivant le nombre d'elements, de conducteurs et de
|
@return la proposition decrivant le nombre d'elements, de conducteurs et de
|
||||||
textes
|
textes
|
||||||
*/
|
*/
|
||||||
QString QET::ElementsAndConductorsSentence(int elements_count, int conductors_count, int texts_count, int images_count, int shapes_count, int element_text_count) {
|
QString QET::ElementsAndConductorsSentence(int elements_count, int conductors_count, int texts_count, int images_count, int shapes_count, int element_text_count, int tables_count)
|
||||||
|
{
|
||||||
QString text;
|
QString text;
|
||||||
if (elements_count) {
|
if (elements_count) {
|
||||||
text += QObject::tr(
|
text += QObject::tr(
|
||||||
@ -291,6 +293,14 @@ QString QET::ElementsAndConductorsSentence(int elements_count, int conductors_co
|
|||||||
element_text_count);
|
element_text_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tables_count) {
|
||||||
|
if (!text.isEmpty()) text += ", ";
|
||||||
|
text += QObject::tr(
|
||||||
|
"%n tableau(s)",
|
||||||
|
"part of a sentence listing the content of diagram",
|
||||||
|
tables_count);
|
||||||
|
}
|
||||||
|
|
||||||
return(text);
|
return(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,9 @@
|
|||||||
*/
|
*/
|
||||||
#ifndef _QET_H
|
#ifndef _QET_H
|
||||||
#define _QET_H
|
#define _QET_H
|
||||||
#include <QtXml>
|
|
||||||
|
#include <QDomElement>
|
||||||
|
#include <QFile>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
class QActionGroup;
|
class QActionGroup;
|
||||||
@ -160,7 +162,7 @@ namespace QET {
|
|||||||
bool orthogonalProjection(const QPointF &, const QLineF &, QPointF * = nullptr);
|
bool orthogonalProjection(const QPointF &, const QLineF &, QPointF * = nullptr);
|
||||||
bool attributeIsAnInteger(const QDomElement &, const QString& , int * = nullptr);
|
bool attributeIsAnInteger(const QDomElement &, const QString& , int * = nullptr);
|
||||||
bool attributeIsAReal(const QDomElement &, const QString& , qreal * = nullptr);
|
bool attributeIsAReal(const QDomElement &, const QString& , qreal * = nullptr);
|
||||||
QString ElementsAndConductorsSentence(int, int, int = 0, int = 0, int = 0, int = 0);
|
QString ElementsAndConductorsSentence(int elements=0, int conductors=0, int indi_texts=0, int images=0, int shapes=0, int element_text=0, int tables_count=0);
|
||||||
QList<QDomElement> findInDomElement(const QDomElement &, const QString &);
|
QList<QDomElement> findInDomElement(const QDomElement &, const QString &);
|
||||||
QList<QDomElement> findInDomElement(const QDomElement &, const QString &, const QString &);
|
QList<QDomElement> findInDomElement(const QDomElement &, const QString &, const QString &);
|
||||||
QList<QChar> forbiddenCharacters();
|
QList<QChar> forbiddenCharacters();
|
||||||
|
@ -544,6 +544,24 @@ bool QetGraphicsTableItem::sceneEventFilter(QGraphicsItem *watched, QEvent *even
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief QetGraphicsTableItem::itemChange
|
||||||
|
* @param change
|
||||||
|
* @param value
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
QVariant QetGraphicsTableItem::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
|
||||||
|
{
|
||||||
|
//item was removed from scene, we remove the handler
|
||||||
|
if (change == ItemSceneHasChanged) {
|
||||||
|
if (!scene() && m_handler_item.scene()) {
|
||||||
|
m_handler_item.scene()->removeItem(&m_handler_item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return QetGraphicsItem::itemChange(change, value);
|
||||||
|
}
|
||||||
|
|
||||||
void QetGraphicsTableItem::modelReseted() {
|
void QetGraphicsTableItem::modelReseted() {
|
||||||
dataChanged(m_model->index(0,0), m_model->index(0,0), QVector<int>());
|
dataChanged(m_model->index(0,0), m_model->index(0,0), QVector<int>());
|
||||||
setToMinimumHeight();
|
setToMinimumHeight();
|
||||||
|
@ -83,6 +83,7 @@ class QetGraphicsTableItem : public QetGraphicsItem
|
|||||||
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
|
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
|
||||||
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
|
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
|
||||||
virtual bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override;
|
virtual bool sceneEventFilter(QGraphicsItem *watched, QEvent *event) override;
|
||||||
|
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void modelReseted();
|
void modelReseted();
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
#include "ui_aboutqetdialog.h"
|
#include "ui_aboutqetdialog.h"
|
||||||
#include "qet.h"
|
#include "qet.h"
|
||||||
|
|
||||||
|
#include <QThread>
|
||||||
|
|
||||||
AboutQETDialog::AboutQETDialog(QWidget *parent) :
|
AboutQETDialog::AboutQETDialog(QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::AboutQETDialog)
|
ui(new Ui::AboutQETDialog)
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "addelementtextcommand.h"
|
#include "addelementtextcommand.h"
|
||||||
#include "terminal.h"
|
#include "terminal.h"
|
||||||
#include "diagramcommands.h"
|
#include "diagramcommands.h"
|
||||||
|
#include "qetgraphicstableitem.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief DeleteQGraphicsItemCommand::DeleteQGraphicsItemCommand
|
* @brief DeleteQGraphicsItemCommand::DeleteQGraphicsItemCommand
|
||||||
@ -74,6 +75,15 @@ DeleteQGraphicsItemCommand::DeleteQGraphicsItemCommand(Diagram *diagram, const D
|
|||||||
m_removed_contents.m_texts_groups.clear();
|
m_removed_contents.m_texts_groups.clear();
|
||||||
setPotentialsOfRemovedElements();
|
setPotentialsOfRemovedElements();
|
||||||
|
|
||||||
|
//Store some information about the tables
|
||||||
|
for (auto table : m_removed_contents.m_tables)
|
||||||
|
{
|
||||||
|
tableStatus status;
|
||||||
|
status.next = table->nextTable();
|
||||||
|
status.previous = table->previousTable();
|
||||||
|
m_tables_status.insert(table, status);
|
||||||
|
}
|
||||||
|
|
||||||
setText(QString(QObject::tr("supprimer %1", "undo caption - %1 is a sentence listing the removed content")).arg(m_removed_contents.sentence(DiagramContent::All)));
|
setText(QString(QObject::tr("supprimer %1", "undo caption - %1 is a sentence listing the removed content")).arg(m_removed_contents.sentence(DiagramContent::All)));
|
||||||
m_diagram->qgiManager().manage(m_removed_contents.items(DiagramContent::All));
|
m_diagram->qgiManager().manage(m_removed_contents.items(DiagramContent::All));
|
||||||
}
|
}
|
||||||
@ -230,6 +240,27 @@ void DeleteQGraphicsItemCommand::undo()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (auto table : m_removed_contents.m_tables)
|
||||||
|
{
|
||||||
|
auto pair = m_tables_status.value(table);
|
||||||
|
|
||||||
|
if(pair.next && pair.previous) // Table is between two tables
|
||||||
|
{
|
||||||
|
pair.next->setPreviousTable(nullptr);
|
||||||
|
table->setPreviousTable(pair.previous);
|
||||||
|
pair.next->setPreviousTable(table);
|
||||||
|
}
|
||||||
|
else if (pair.next) //Table is the first table of linked tables
|
||||||
|
{
|
||||||
|
auto model = pair.next->model();
|
||||||
|
pair.next->setPreviousTable(table);
|
||||||
|
table->setModel(model);
|
||||||
|
}
|
||||||
|
else if (pair.previous) { //Table is the last of linked tables
|
||||||
|
table->setPreviousTable(pair.previous);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QUndoCommand::undo();
|
QUndoCommand::undo();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,6 +303,20 @@ void DeleteQGraphicsItemCommand::redo()
|
|||||||
deti->setParentItem(nullptr);
|
deti->setParentItem(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (auto table : m_removed_contents.m_tables)
|
||||||
|
{
|
||||||
|
auto pair = m_tables_status.value(table);
|
||||||
|
|
||||||
|
if(pair.next && pair.previous) { // Table is between two tables
|
||||||
|
pair.next->setPreviousTable(pair.previous); //change the previous table of the current next table of @table
|
||||||
|
} else if (pair.next) { //Table is the first table of linked tables
|
||||||
|
pair.next->setPreviousTable(nullptr); //Next table haven't got model anymore
|
||||||
|
pair.next->setModel(table->model());
|
||||||
|
} else if (pair.previous) { //Table is the last of linked tables
|
||||||
|
table->setPreviousTable(nullptr); //Remove the previous table @table
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
for(QGraphicsItem *item : m_removed_contents.items())
|
for(QGraphicsItem *item : m_removed_contents.items())
|
||||||
m_diagram->removeItem(item);
|
m_diagram->removeItem(item);
|
||||||
|
@ -24,9 +24,16 @@
|
|||||||
class Diagram;
|
class Diagram;
|
||||||
class ElementTextItemGroup;
|
class ElementTextItemGroup;
|
||||||
class Terminal;
|
class Terminal;
|
||||||
|
class QetGraphicsTableItem;
|
||||||
|
|
||||||
class DeleteQGraphicsItemCommand : public QUndoCommand
|
class DeleteQGraphicsItemCommand : public QUndoCommand
|
||||||
{
|
{
|
||||||
|
private :
|
||||||
|
struct tableStatus {
|
||||||
|
QetGraphicsTableItem *previous = nullptr;
|
||||||
|
QetGraphicsTableItem *next = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DeleteQGraphicsItemCommand(Diagram *diagram, const DiagramContent &content, QUndoCommand * parent = nullptr);
|
DeleteQGraphicsItemCommand(Diagram *diagram, const DiagramContent &content, QUndoCommand * parent = nullptr);
|
||||||
~DeleteQGraphicsItemCommand() override;
|
~DeleteQGraphicsItemCommand() override;
|
||||||
@ -49,6 +56,7 @@ class DeleteQGraphicsItemCommand : public QUndoCommand
|
|||||||
QHash <DynamicElementTextItem *, Element *> m_elmt_text_hash; /// Keep the parent element of each deleted dynamic element text item
|
QHash <DynamicElementTextItem *, Element *> m_elmt_text_hash; /// Keep the parent element of each deleted dynamic element text item
|
||||||
QHash <DynamicElementTextItem *, ElementTextItemGroup *> m_grp_texts_hash; ///Keep the parent group of each deleted element text item
|
QHash <DynamicElementTextItem *, ElementTextItemGroup *> m_grp_texts_hash; ///Keep the parent group of each deleted element text item
|
||||||
QList <QPair<Terminal *, Terminal *>> m_connected_terminals;
|
QList <QPair<Terminal *, Terminal *>> m_connected_terminals;
|
||||||
|
QHash <QetGraphicsTableItem *, tableStatus> m_tables_status;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DELETEQGRAPHICSITEMCOMMAND_H
|
#endif // DELETEQGRAPHICSITEMCOMMAND_H
|
||||||
|
Loading…
x
Reference in New Issue
Block a user