mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-02-24 05:49:59 +01:00
Fix indentation code
This commit is contained in:
@@ -58,7 +58,7 @@ DynamicTextFieldEditor::~DynamicTextFieldEditor()
|
||||
*/
|
||||
bool DynamicTextFieldEditor::setPart(CustomElementPart *part)
|
||||
{
|
||||
disconnectConnections();
|
||||
disconnectConnections();
|
||||
|
||||
QGraphicsItem *qgi = part->toItem();
|
||||
if(!qgi)
|
||||
@@ -69,40 +69,40 @@ bool DynamicTextFieldEditor::setPart(CustomElementPart *part)
|
||||
m_text_field = static_cast<PartDynamicTextField *>(qgi);
|
||||
updateForm();
|
||||
|
||||
setUpConnections();
|
||||
setUpConnections();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DynamicTextFieldEditor::setParts(QList <CustomElementPart *> parts) {
|
||||
if (parts.isEmpty())
|
||||
{
|
||||
m_parts.clear();
|
||||
if (m_text_field) {
|
||||
disconnectConnections();
|
||||
}
|
||||
m_text_field = nullptr;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (PartDynamicTextField *part= static_cast<PartDynamicTextField *>(parts.first()))
|
||||
{
|
||||
if (m_text_field) {
|
||||
disconnectConnections();
|
||||
}
|
||||
|
||||
m_text_field = part;
|
||||
m_parts.clear();
|
||||
m_parts.append(part);
|
||||
for (int i=1; i < parts.length(); i++)
|
||||
m_parts.append(static_cast<PartDynamicTextField*>(parts[i]));
|
||||
|
||||
setUpConnections();
|
||||
|
||||
updateForm();
|
||||
return true;
|
||||
}
|
||||
return(false);
|
||||
if (parts.isEmpty())
|
||||
{
|
||||
m_parts.clear();
|
||||
if (m_text_field) {
|
||||
disconnectConnections();
|
||||
}
|
||||
m_text_field = nullptr;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (PartDynamicTextField *part= static_cast<PartDynamicTextField *>(parts.first()))
|
||||
{
|
||||
if (m_text_field) {
|
||||
disconnectConnections();
|
||||
}
|
||||
|
||||
m_text_field = part;
|
||||
m_parts.clear();
|
||||
m_parts.append(part);
|
||||
for (int i=1; i < parts.length(); i++)
|
||||
m_parts.append(static_cast<PartDynamicTextField*>(parts[i]));
|
||||
|
||||
setUpConnections();
|
||||
|
||||
updateForm();
|
||||
return true;
|
||||
}
|
||||
return(false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -115,11 +115,11 @@ CustomElementPart *DynamicTextFieldEditor::currentPart() const {
|
||||
}
|
||||
|
||||
QList<CustomElementPart*> DynamicTextFieldEditor::currentParts() const {
|
||||
QList<CustomElementPart*> parts;
|
||||
for (auto part: m_parts) {
|
||||
parts.append(static_cast<CustomElementPart*>(part));
|
||||
}
|
||||
return parts;
|
||||
QList<CustomElementPart*> parts;
|
||||
for (auto part: m_parts) {
|
||||
parts.append(static_cast<CustomElementPart*>(part));
|
||||
}
|
||||
return parts;
|
||||
}
|
||||
|
||||
void DynamicTextFieldEditor::updateForm()
|
||||
@@ -156,26 +156,26 @@ void DynamicTextFieldEditor::updateForm()
|
||||
}
|
||||
|
||||
void DynamicTextFieldEditor::setUpConnections() {
|
||||
assert(m_connection_list.isEmpty());
|
||||
//Setup the connection
|
||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::colorChanged, [this](){this->updateForm();});
|
||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::fontChanged, [this](){this->updateForm();});
|
||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::taggChanged, [this](){this->updateForm();});
|
||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::textFromChanged, [this](){this->updateForm();});
|
||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::textChanged, [this](){this->updateForm();});
|
||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::infoNameChanged, [this](){this->updateForm();});
|
||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::rotationChanged, [this](){this->updateForm();});
|
||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::frameChanged, [this](){this->updateForm();});
|
||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::textWidthChanged,[this]() {this->updateForm();});
|
||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::compositeTextChanged, [this]() {this->updateForm();});
|
||||
assert(m_connection_list.isEmpty());
|
||||
//Setup the connection
|
||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::colorChanged, [this](){this->updateForm();});
|
||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::fontChanged, [this](){this->updateForm();});
|
||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::taggChanged, [this](){this->updateForm();});
|
||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::textFromChanged, [this](){this->updateForm();});
|
||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::textChanged, [this](){this->updateForm();});
|
||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::infoNameChanged, [this](){this->updateForm();});
|
||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::rotationChanged, [this](){this->updateForm();});
|
||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::frameChanged, [this](){this->updateForm();});
|
||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::textWidthChanged,[this]() {this->updateForm();});
|
||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::compositeTextChanged, [this]() {this->updateForm();});
|
||||
}
|
||||
|
||||
void DynamicTextFieldEditor::disconnectConnections() {
|
||||
//Remove previous connection
|
||||
if(!m_connection_list.isEmpty())
|
||||
for(const QMetaObject::Connection& con : m_connection_list)
|
||||
disconnect(con);
|
||||
m_connection_list.clear();
|
||||
//Remove previous connection
|
||||
if(!m_connection_list.isEmpty())
|
||||
for(const QMetaObject::Connection& con : m_connection_list)
|
||||
disconnect(con);
|
||||
m_connection_list.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -206,101 +206,101 @@ void DynamicTextFieldEditor::fillInfoComboBox()
|
||||
|
||||
void DynamicTextFieldEditor::on_m_x_sb_editingFinished()
|
||||
{
|
||||
double value = ui->m_x_sb->value();
|
||||
for (int i = 0; i < m_parts.length(); i++) {
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "x", m_parts[i]->x(), value);
|
||||
undo->setText(tr("Déplacer un champ texte"));
|
||||
undo->enableAnimation(true);
|
||||
undoStack().push(undo);
|
||||
}
|
||||
double value = ui->m_x_sb->value();
|
||||
for (int i = 0; i < m_parts.length(); i++) {
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "x", m_parts[i]->x(), value);
|
||||
undo->setText(tr("Déplacer un champ texte"));
|
||||
undo->enableAnimation(true);
|
||||
undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicTextFieldEditor::on_m_y_sb_editingFinished()
|
||||
{
|
||||
double value = ui->m_y_sb->value();
|
||||
for (int i = 0; i < m_parts.length(); i++) {
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "y", m_parts[i]->y(), value);
|
||||
undo->setText(tr("Déplacer un champ texte"));
|
||||
undo->enableAnimation(true);
|
||||
undoStack().push(undo);
|
||||
}
|
||||
double value = ui->m_y_sb->value();
|
||||
for (int i = 0; i < m_parts.length(); i++) {
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "y", m_parts[i]->y(), value);
|
||||
undo->setText(tr("Déplacer un champ texte"));
|
||||
undo->enableAnimation(true);
|
||||
undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicTextFieldEditor::on_m_rotation_sb_editingFinished()
|
||||
{
|
||||
int value = ui->m_rotation_sb->value();
|
||||
for (int i = 0; i < m_parts.length(); i++) {
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "rotation", m_parts[i]->rotation(), value);
|
||||
undo->setText(tr("Pivoter un champ texte"));
|
||||
undo->enableAnimation(true);
|
||||
undoStack().push(undo);
|
||||
}
|
||||
int value = ui->m_rotation_sb->value();
|
||||
for (int i = 0; i < m_parts.length(); i++) {
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "rotation", m_parts[i]->rotation(), value);
|
||||
undo->setText(tr("Pivoter un champ texte"));
|
||||
undo->enableAnimation(true);
|
||||
undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicTextFieldEditor::on_m_user_text_le_editingFinished()
|
||||
{
|
||||
QString text = ui->m_user_text_le->text();
|
||||
for (int i = 0; i < m_parts.length(); i++) {
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "text", m_parts[i]->text(), text);
|
||||
undo->setText(tr("Modifier le texte d'un champ texte"));
|
||||
undoStack().push(undo);
|
||||
}
|
||||
QString text = ui->m_user_text_le->text();
|
||||
for (int i = 0; i < m_parts.length(); i++) {
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "text", m_parts[i]->text(), text);
|
||||
undo->setText(tr("Modifier le texte d'un champ texte"));
|
||||
undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicTextFieldEditor::on_m_size_sb_editingFinished()
|
||||
{
|
||||
QFont font_ = m_text_field->font();
|
||||
font_.setPointSize(ui->m_size_sb->value());
|
||||
for (int i = 0; i < m_parts.length(); i++) {
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "font", m_parts[i]->font(), font_);
|
||||
undo->setText(tr("Modifier la police d'un champ texte"));
|
||||
undoStack().push(undo);
|
||||
}
|
||||
for (int i = 0; i < m_parts.length(); i++) {
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "font", m_parts[i]->font(), font_);
|
||||
undo->setText(tr("Modifier la police d'un champ texte"));
|
||||
undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicTextFieldEditor::on_m_frame_cb_clicked()
|
||||
{
|
||||
bool frame = ui->m_frame_cb->isChecked();
|
||||
bool frame = ui->m_frame_cb->isChecked();
|
||||
|
||||
for (int i = 0; i < m_parts.length(); i++) {
|
||||
if(frame != m_parts[i]->frame())
|
||||
{
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "frame", m_parts[i]->frame(), frame);
|
||||
undo->setText(tr("Modifier le cadre d'un champ texte"));
|
||||
undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < m_parts.length(); i++) {
|
||||
if(frame != m_parts[i]->frame())
|
||||
{
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "frame", m_parts[i]->frame(), frame);
|
||||
undo->setText(tr("Modifier le cadre d'un champ texte"));
|
||||
undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicTextFieldEditor::on_m_width_sb_editingFinished()
|
||||
{
|
||||
qreal width = (qreal)ui->m_width_sb->value();
|
||||
qreal width = (qreal)ui->m_width_sb->value();
|
||||
|
||||
for (int i = 0; i < m_parts.length(); i++) {
|
||||
if(width != m_parts[i]->textWidth())
|
||||
{
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "textWidth", m_parts[i]->textWidth(), width);
|
||||
undo->setText(tr("Modifier la largeur d'un texte"));
|
||||
undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < m_parts.length(); i++) {
|
||||
if(width != m_parts[i]->textWidth())
|
||||
{
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "textWidth", m_parts[i]->textWidth(), width);
|
||||
undo->setText(tr("Modifier la largeur d'un texte"));
|
||||
undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicTextFieldEditor::on_m_elmt_info_cb_activated(const QString &arg1)
|
||||
{
|
||||
Q_UNUSED(arg1)
|
||||
Q_UNUSED(arg1)
|
||||
|
||||
QString info = ui->m_elmt_info_cb->currentData().toString();
|
||||
for (int i = 0; i < m_parts.length(); i++) {
|
||||
if(info != m_parts[i]->infoName())
|
||||
{
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "infoName", m_parts[i]->infoName(), info);
|
||||
undo->setText(tr("Modifier l'information d'un texte"));
|
||||
undoStack().push(undo);
|
||||
|
||||
m_parts[i]->setPlainText(elementEditor()->elementScene()->elementInformation().value(m_parts[i]->infoName()).toString());
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < m_parts.length(); i++) {
|
||||
if(info != m_parts[i]->infoName())
|
||||
{
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "infoName", m_parts[i]->infoName(), info);
|
||||
undo->setText(tr("Modifier l'information d'un texte"));
|
||||
undoStack().push(undo);
|
||||
|
||||
m_parts[i]->setPlainText(elementEditor()->elementScene()->elementInformation().value(m_parts[i]->infoName()).toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicTextFieldEditor::on_m_text_from_cb_activated(int index)
|
||||
@@ -308,7 +308,7 @@ void DynamicTextFieldEditor::on_m_text_from_cb_activated(int index)
|
||||
ui->m_user_text_le->setDisabled(true);
|
||||
ui->m_elmt_info_cb->setDisabled(true);
|
||||
ui->m_composite_text_pb->setDisabled(true);
|
||||
|
||||
|
||||
if(index == 0)
|
||||
ui->m_user_text_le->setEnabled(true);
|
||||
else if (index == 1)
|
||||
@@ -321,14 +321,14 @@ void DynamicTextFieldEditor::on_m_text_from_cb_activated(int index)
|
||||
else if(index == 1) tf = DynamicElementTextItem::ElementInfo;
|
||||
else tf = DynamicElementTextItem::CompositeText;
|
||||
|
||||
for (int i = 0; i < m_parts.length(); i++) {
|
||||
if(tf != m_parts[i]->textFrom())
|
||||
{
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "textFrom", m_parts[i]->textFrom(), tf);
|
||||
undo->setText(tr("Modifier la source de texte, d'un texte"));
|
||||
undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < m_parts.length(); i++) {
|
||||
if(tf != m_parts[i]->textFrom())
|
||||
{
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "textFrom", m_parts[i]->textFrom(), tf);
|
||||
undo->setText(tr("Modifier la source de texte, d'un texte"));
|
||||
undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicTextFieldEditor::on_m_composite_text_pb_clicked()
|
||||
@@ -337,29 +337,29 @@ void DynamicTextFieldEditor::on_m_composite_text_pb_clicked()
|
||||
if(ctd.exec())
|
||||
{
|
||||
QString ct = ctd.plainText();
|
||||
for (int i = 0; i < m_parts.length(); i++) {
|
||||
if(ct != m_parts[i]->compositeText())
|
||||
{
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "compositeText", m_parts[i]->compositeText(), ctd.plainText());
|
||||
undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < m_parts.length(); i++) {
|
||||
if(ct != m_parts[i]->compositeText())
|
||||
{
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "compositeText", m_parts[i]->compositeText(), ctd.plainText());
|
||||
undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicTextFieldEditor::on_m_alignment_pb_clicked()
|
||||
{
|
||||
AlignmentTextDialog atd(m_text_field.data()->alignment(), this);
|
||||
AlignmentTextDialog atd(m_text_field.data()->alignment(), this);
|
||||
atd.exec();
|
||||
|
||||
for (int i = 0; i < m_parts.length(); i++) {
|
||||
if(atd.alignment() != m_parts[i]->alignment())
|
||||
{
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "alignment", QVariant(m_parts[i]->alignment()), QVariant(atd.alignment()));
|
||||
undo->setText(tr("Modifier l'alignement d'un champ texte"));
|
||||
undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < m_parts.length(); i++) {
|
||||
if(atd.alignment() != m_parts[i]->alignment())
|
||||
{
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "alignment", QVariant(m_parts[i]->alignment()), QVariant(atd.alignment()));
|
||||
undo->setText(tr("Modifier l'alignement d'un champ texte"));
|
||||
undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicTextFieldEditor::on_m_font_pb_clicked()
|
||||
@@ -370,26 +370,26 @@ void DynamicTextFieldEditor::on_m_font_pb_clicked()
|
||||
{
|
||||
ui->m_font_pb->setText(font_.family());
|
||||
ui->m_size_sb->setValue(font_.pointSize());
|
||||
|
||||
for (int i = 0; i < m_parts.length(); i++) {
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "font", m_parts[i]->font(), font_);
|
||||
undo->setText(tr("Modifier la police d'un champ texte"));
|
||||
undoStack().push(undo);
|
||||
}
|
||||
|
||||
for (int i = 0; i < m_parts.length(); i++) {
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "font", m_parts[i]->font(), font_);
|
||||
undo->setText(tr("Modifier la police d'un champ texte"));
|
||||
undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicTextFieldEditor::on_m_color_kpb_changed(const QColor &newColor)
|
||||
{
|
||||
if (!newColor.isValid())
|
||||
return;
|
||||
|
||||
for (int i = 0; i < m_parts.length(); i++) {
|
||||
if(newColor != m_parts[i]->color())
|
||||
{
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "color", m_parts[i]->color(), newColor);
|
||||
undo->setText(tr("Modifier la couleur d'un champ texte"));
|
||||
undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
if (!newColor.isValid())
|
||||
return;
|
||||
|
||||
for (int i = 0; i < m_parts.length(); i++) {
|
||||
if(newColor != m_parts[i]->color())
|
||||
{
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "color", m_parts[i]->color(), newColor);
|
||||
undo->setText(tr("Modifier la couleur d'un champ texte"));
|
||||
undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,30 +73,30 @@ void PolygonEditor::disconnectChangeConnections()
|
||||
*/
|
||||
bool PolygonEditor::setPart(CustomElementPart *new_part)
|
||||
{
|
||||
if (!new_part)
|
||||
{
|
||||
if (m_part)
|
||||
{
|
||||
disconnectChangeConnections();
|
||||
}
|
||||
m_part = nullptr;
|
||||
m_style -> setPart(nullptr);
|
||||
return(true);
|
||||
}
|
||||
if (PartPolygon *part_polygon = dynamic_cast<PartPolygon *>(new_part))
|
||||
{
|
||||
if (m_part == part_polygon) return true;
|
||||
if (m_part)
|
||||
{
|
||||
disconnectChangeConnections();
|
||||
}
|
||||
m_part = part_polygon;
|
||||
m_style -> setPart(m_part);
|
||||
updateForm();
|
||||
setUpChangeConnections();
|
||||
return(true);
|
||||
}
|
||||
return(false);
|
||||
if (!new_part)
|
||||
{
|
||||
if (m_part)
|
||||
{
|
||||
disconnectChangeConnections();
|
||||
}
|
||||
m_part = nullptr;
|
||||
m_style -> setPart(nullptr);
|
||||
return(true);
|
||||
}
|
||||
if (PartPolygon *part_polygon = dynamic_cast<PartPolygon *>(new_part))
|
||||
{
|
||||
if (m_part == part_polygon) return true;
|
||||
if (m_part)
|
||||
{
|
||||
disconnectChangeConnections();
|
||||
}
|
||||
m_part = part_polygon;
|
||||
m_style -> setPart(m_part);
|
||||
updateForm();
|
||||
setUpChangeConnections();
|
||||
return(true);
|
||||
}
|
||||
return(false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,35 +143,35 @@ void PolygonEditor::updateForm()
|
||||
*/
|
||||
QVector<QPointF> PolygonEditor::pointsFromTree()
|
||||
{
|
||||
QVector<QPointF> points;
|
||||
if (!m_part) {
|
||||
return points;
|
||||
}
|
||||
|
||||
for(int i = 0 ; i < ui->m_points_list_tree->topLevelItemCount() ; ++ i)
|
||||
{
|
||||
QTreeWidgetItem *qtwi = ui->m_points_list_tree->topLevelItem(i);
|
||||
bool x_convert_ok, y_convert_ok;
|
||||
qreal x = qtwi->data(0, Qt::EditRole).toReal(&x_convert_ok);
|
||||
qreal y = qtwi->data(1, Qt::EditRole).toReal(&y_convert_ok);
|
||||
if (x_convert_ok && y_convert_ok) {
|
||||
points << m_part->mapFromScene(QPointF(x, y));
|
||||
}
|
||||
}
|
||||
return(points);
|
||||
QVector<QPointF> points;
|
||||
if (!m_part) {
|
||||
return points;
|
||||
}
|
||||
|
||||
for(int i = 0 ; i < ui->m_points_list_tree->topLevelItemCount() ; ++ i)
|
||||
{
|
||||
QTreeWidgetItem *qtwi = ui->m_points_list_tree->topLevelItem(i);
|
||||
bool x_convert_ok, y_convert_ok;
|
||||
qreal x = qtwi->data(0, Qt::EditRole).toReal(&x_convert_ok);
|
||||
qreal y = qtwi->data(1, Qt::EditRole).toReal(&y_convert_ok);
|
||||
if (x_convert_ok && y_convert_ok) {
|
||||
points << m_part->mapFromScene(QPointF(x, y));
|
||||
}
|
||||
}
|
||||
return(points);
|
||||
}
|
||||
|
||||
bool PolygonEditor::eventFilter(QObject *watched, QEvent *event)
|
||||
{
|
||||
if (watched == ui->m_points_list_tree &&
|
||||
event->type() == QEvent::FocusOut &&
|
||||
m_part)
|
||||
{
|
||||
m_part->resetAllHandlerColor();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
if (watched == ui->m_points_list_tree &&
|
||||
event->type() == QEvent::FocusOut &&
|
||||
m_part)
|
||||
{
|
||||
m_part->resetAllHandlerColor();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -179,18 +179,18 @@ bool PolygonEditor::eventFilter(QObject *watched, QEvent *event)
|
||||
*/
|
||||
void PolygonEditor::on_m_close_polygon_cb_stateChanged(int arg1)
|
||||
{
|
||||
Q_UNUSED(arg1);
|
||||
|
||||
if (!m_part) {
|
||||
return;
|
||||
}
|
||||
bool close = ui->m_close_polygon_cb->isChecked();
|
||||
if (close != m_part->isClosed())
|
||||
{
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_part, "closed", m_part->property("closed"), close);
|
||||
undo->setText(tr("Modifier un polygone"));
|
||||
undoStack().push(undo);
|
||||
}
|
||||
Q_UNUSED(arg1);
|
||||
|
||||
if (!m_part) {
|
||||
return;
|
||||
}
|
||||
bool close = ui->m_close_polygon_cb->isChecked();
|
||||
if (close != m_part->isClosed())
|
||||
{
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_part, "closed", m_part->property("closed"), close);
|
||||
undo->setText(tr("Modifier un polygone"));
|
||||
undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -199,26 +199,26 @@ void PolygonEditor::on_m_close_polygon_cb_stateChanged(int arg1)
|
||||
*/
|
||||
void PolygonEditor::on_m_points_list_tree_itemChanged(QTreeWidgetItem *item, int column)
|
||||
{
|
||||
Q_UNUSED(item);
|
||||
Q_UNUSED(column);
|
||||
|
||||
if (!m_part) {
|
||||
return;
|
||||
}
|
||||
|
||||
QPolygonF points = pointsFromTree();
|
||||
if (points.count() < 2)
|
||||
{
|
||||
QET::QetMessageBox::warning(this, tr("Erreur", "message box title"), tr("Le polygone doit comporter au moins deux points.", "message box content"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (points != m_part->polygon())
|
||||
{
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_part, "polygon", m_part->property("polygon"), points);
|
||||
undo->setText(tr("Modifier un polygone"));
|
||||
undoStack().push(undo);
|
||||
}
|
||||
Q_UNUSED(item);
|
||||
Q_UNUSED(column);
|
||||
|
||||
if (!m_part) {
|
||||
return;
|
||||
}
|
||||
|
||||
QPolygonF points = pointsFromTree();
|
||||
if (points.count() < 2)
|
||||
{
|
||||
QET::QetMessageBox::warning(this, tr("Erreur", "message box title"), tr("Le polygone doit comporter au moins deux points.", "message box content"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (points != m_part->polygon())
|
||||
{
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_part, "polygon", m_part->property("polygon"), points);
|
||||
undo->setText(tr("Modifier un polygone"));
|
||||
undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -227,76 +227,76 @@ void PolygonEditor::on_m_points_list_tree_itemChanged(QTreeWidgetItem *item, int
|
||||
*/
|
||||
void PolygonEditor::on_m_points_list_tree_itemSelectionChanged()
|
||||
{
|
||||
//Prevent when selection change but the widget ins't focused
|
||||
if (!ui->m_points_list_tree->hasFocus()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QTreeWidgetItem *qtwi = ui->m_points_list_tree->currentItem();
|
||||
if (!qtwi || !m_part) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_part->resetAllHandlerColor();
|
||||
int index = ui->m_points_list_tree->indexOfTopLevelItem(qtwi);
|
||||
|
||||
//We need to check if index isn't out of range of polygon
|
||||
//this case can occur when user remove the last point of the polygon
|
||||
//with the context menu of the tree widget
|
||||
if(index >= 0 &&
|
||||
index < m_part->polygon().size())
|
||||
{
|
||||
m_part->setHandlerColor(m_part->polygon().at(index), QColor(0, 255, 128));
|
||||
}
|
||||
//Prevent when selection change but the widget ins't focused
|
||||
if (!ui->m_points_list_tree->hasFocus()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QTreeWidgetItem *qtwi = ui->m_points_list_tree->currentItem();
|
||||
if (!qtwi || !m_part) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_part->resetAllHandlerColor();
|
||||
int index = ui->m_points_list_tree->indexOfTopLevelItem(qtwi);
|
||||
|
||||
//We need to check if index isn't out of range of polygon
|
||||
//this case can occur when user remove the last point of the polygon
|
||||
//with the context menu of the tree widget
|
||||
if(index >= 0 &&
|
||||
index < m_part->polygon().size())
|
||||
{
|
||||
m_part->setHandlerColor(m_part->polygon().at(index), QColor(0, 255, 128));
|
||||
}
|
||||
}
|
||||
|
||||
void PolygonEditor::on_m_add_point_action_triggered()
|
||||
{
|
||||
QTreeWidgetItem *qtwi = ui->m_points_list_tree->currentItem();
|
||||
if (!qtwi || !m_part) {
|
||||
return;
|
||||
}
|
||||
|
||||
int index = ui->m_points_list_tree->indexOfTopLevelItem(qtwi);
|
||||
QPolygonF new_polygon = m_part->polygon();
|
||||
|
||||
//Special case when user add a point after the last point of the polygon
|
||||
if (index == m_part->polygon().size()-1)
|
||||
{
|
||||
QPointF p = m_part->polygon().last();
|
||||
p.rx()+=20;
|
||||
p.ry()+=20;
|
||||
new_polygon.append(p);
|
||||
}
|
||||
else
|
||||
{
|
||||
QPointF p = m_part->polygon().at(index) +
|
||||
m_part->polygon().at(index+1);
|
||||
p/=2;
|
||||
new_polygon.insert(index+1, p);
|
||||
}
|
||||
|
||||
//Wrap the undo for avoid to merge the undo commands when user add several points.
|
||||
QUndoCommand *undo = new QUndoCommand(tr("Ajouter un point à un polygone"));
|
||||
new QPropertyUndoCommand(m_part, "polygon", m_part->polygon(), new_polygon, undo);
|
||||
elementScene()->undoStack().push(undo);
|
||||
|
||||
m_part->resetAllHandlerColor();
|
||||
m_part->setHandlerColor(m_part->polygon().at(index+1), QColor(0, 255, 128));
|
||||
QTreeWidgetItem *qtwi = ui->m_points_list_tree->currentItem();
|
||||
if (!qtwi || !m_part) {
|
||||
return;
|
||||
}
|
||||
|
||||
int index = ui->m_points_list_tree->indexOfTopLevelItem(qtwi);
|
||||
QPolygonF new_polygon = m_part->polygon();
|
||||
|
||||
//Special case when user add a point after the last point of the polygon
|
||||
if (index == m_part->polygon().size()-1)
|
||||
{
|
||||
QPointF p = m_part->polygon().last();
|
||||
p.rx()+=20;
|
||||
p.ry()+=20;
|
||||
new_polygon.append(p);
|
||||
}
|
||||
else
|
||||
{
|
||||
QPointF p = m_part->polygon().at(index) +
|
||||
m_part->polygon().at(index+1);
|
||||
p/=2;
|
||||
new_polygon.insert(index+1, p);
|
||||
}
|
||||
|
||||
//Wrap the undo for avoid to merge the undo commands when user add several points.
|
||||
QUndoCommand *undo = new QUndoCommand(tr("Ajouter un point à un polygone"));
|
||||
new QPropertyUndoCommand(m_part, "polygon", m_part->polygon(), new_polygon, undo);
|
||||
elementScene()->undoStack().push(undo);
|
||||
|
||||
m_part->resetAllHandlerColor();
|
||||
m_part->setHandlerColor(m_part->polygon().at(index+1), QColor(0, 255, 128));
|
||||
}
|
||||
|
||||
void PolygonEditor::on_m_remove_point_action_triggered()
|
||||
{
|
||||
QTreeWidgetItem *qtwi = ui->m_points_list_tree->currentItem();
|
||||
if (!qtwi || !m_part) {
|
||||
return;
|
||||
}
|
||||
|
||||
QPolygonF new_polygon = m_part->polygon();
|
||||
new_polygon.removeAt(ui->m_points_list_tree->indexOfTopLevelItem(qtwi));
|
||||
|
||||
//Wrap the undo for avoid to merge the undo commands when user remove several points.
|
||||
QUndoCommand *undo = new QUndoCommand(tr("Supprimer un point d'un polygone"));
|
||||
new QPropertyUndoCommand(m_part, "polygon", m_part->polygon(), new_polygon, undo);
|
||||
elementScene()->undoStack().push(undo);
|
||||
QTreeWidgetItem *qtwi = ui->m_points_list_tree->currentItem();
|
||||
if (!qtwi || !m_part) {
|
||||
return;
|
||||
}
|
||||
|
||||
QPolygonF new_polygon = m_part->polygon();
|
||||
new_polygon.removeAt(ui->m_points_list_tree->indexOfTopLevelItem(qtwi));
|
||||
|
||||
//Wrap the undo for avoid to merge the undo commands when user remove several points.
|
||||
QUndoCommand *undo = new QUndoCommand(tr("Supprimer un point d'un polygone"));
|
||||
new QPropertyUndoCommand(m_part, "polygon", m_part->polygon(), new_polygon, undo);
|
||||
elementScene()->undoStack().push(undo);
|
||||
}
|
||||
|
||||
@@ -30,39 +30,39 @@ namespace Ui {
|
||||
|
||||
class PolygonEditor : public ElementItemEditor
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PolygonEditor(QETElementEditor *editor, PartPolygon *part = nullptr, QWidget *parent = nullptr);
|
||||
~PolygonEditor() override;
|
||||
|
||||
bool setPart(CustomElementPart *part) override;
|
||||
CustomElementPart *currentPart() const override;
|
||||
QList<CustomElementPart*> currentParts() const override;
|
||||
void updateForm() override;
|
||||
QVector<QPointF> pointsFromTree();
|
||||
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||
|
||||
private slots:
|
||||
void on_m_close_polygon_cb_stateChanged(int arg1);
|
||||
void on_m_points_list_tree_itemChanged(QTreeWidgetItem *item, int column);
|
||||
void on_m_points_list_tree_itemSelectionChanged();
|
||||
void on_m_add_point_action_triggered();
|
||||
void on_m_remove_point_action_triggered();
|
||||
|
||||
private:
|
||||
/*!
|
||||
* \brief setUpChangeConnections
|
||||
* Setup the connection from the line(s) to the widget, to update it when the line(s) are changed (moved ...)
|
||||
*/
|
||||
void setUpChangeConnections();
|
||||
void disconnectChangeConnections();
|
||||
|
||||
private:
|
||||
Ui::PolygonEditor *ui;
|
||||
StyleEditor *m_style = nullptr;
|
||||
PartPolygon *m_part = nullptr;
|
||||
QList <QMetaObject::Connection> m_change_connections;
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PolygonEditor(QETElementEditor *editor, PartPolygon *part = nullptr, QWidget *parent = nullptr);
|
||||
~PolygonEditor() override;
|
||||
|
||||
bool setPart(CustomElementPart *part) override;
|
||||
CustomElementPart *currentPart() const override;
|
||||
QList<CustomElementPart*> currentParts() const override;
|
||||
void updateForm() override;
|
||||
QVector<QPointF> pointsFromTree();
|
||||
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||
|
||||
private slots:
|
||||
void on_m_close_polygon_cb_stateChanged(int arg1);
|
||||
void on_m_points_list_tree_itemChanged(QTreeWidgetItem *item, int column);
|
||||
void on_m_points_list_tree_itemSelectionChanged();
|
||||
void on_m_add_point_action_triggered();
|
||||
void on_m_remove_point_action_triggered();
|
||||
|
||||
private:
|
||||
/*!
|
||||
* \brief setUpChangeConnections
|
||||
* Setup the connection from the line(s) to the widget, to update it when the line(s) are changed (moved ...)
|
||||
*/
|
||||
void setUpChangeConnections();
|
||||
void disconnectChangeConnections();
|
||||
|
||||
private:
|
||||
Ui::PolygonEditor *ui;
|
||||
StyleEditor *m_style = nullptr;
|
||||
PartPolygon *m_part = nullptr;
|
||||
QList <QMetaObject::Connection> m_change_connections;
|
||||
};
|
||||
|
||||
#endif // POLYGONEDITOR_H
|
||||
|
||||
@@ -48,19 +48,19 @@ RectangleEditor::~RectangleEditor() {
|
||||
|
||||
void RectangleEditor::setUpChangeConnections()
|
||||
{
|
||||
m_change_connections << connect(m_part, &PartRectangle::rectChanged, this, &RectangleEditor::updateForm);
|
||||
m_change_connections << connect(m_part, &PartRectangle::XRadiusChanged, this, &RectangleEditor::updateForm);
|
||||
m_change_connections << connect(m_part, &PartRectangle::YRadiusChanged, this, &RectangleEditor::updateForm);
|
||||
m_change_connections << connect(m_part, &PartRectangle::xChanged, this, &RectangleEditor::updateForm);
|
||||
m_change_connections << connect(m_part, &PartRectangle::yChanged, this, &RectangleEditor::updateForm);
|
||||
m_change_connections << connect(m_part, &PartRectangle::rectChanged, this, &RectangleEditor::updateForm);
|
||||
m_change_connections << connect(m_part, &PartRectangle::XRadiusChanged, this, &RectangleEditor::updateForm);
|
||||
m_change_connections << connect(m_part, &PartRectangle::YRadiusChanged, this, &RectangleEditor::updateForm);
|
||||
m_change_connections << connect(m_part, &PartRectangle::xChanged, this, &RectangleEditor::updateForm);
|
||||
m_change_connections << connect(m_part, &PartRectangle::yChanged, this, &RectangleEditor::updateForm);
|
||||
}
|
||||
|
||||
void RectangleEditor::disconnectChangeConnections()
|
||||
{
|
||||
for (QMetaObject::Connection c : m_change_connections) {
|
||||
disconnect(c);
|
||||
}
|
||||
m_change_connections.clear();
|
||||
for (QMetaObject::Connection c : m_change_connections) {
|
||||
disconnect(c);
|
||||
}
|
||||
m_change_connections.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,13 +74,13 @@ bool RectangleEditor::setPart(CustomElementPart *part)
|
||||
{
|
||||
if (m_part)
|
||||
{
|
||||
disconnectChangeConnections();
|
||||
disconnectChangeConnections();
|
||||
}
|
||||
m_part = nullptr;
|
||||
m_style->setPart(nullptr);
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
||||
if (PartRectangle *part_rectangle = dynamic_cast<PartRectangle *>(part))
|
||||
{
|
||||
if (m_part == part_rectangle) {
|
||||
@@ -88,26 +88,26 @@ bool RectangleEditor::setPart(CustomElementPart *part)
|
||||
}
|
||||
if (m_part)
|
||||
{
|
||||
disconnectChangeConnections();
|
||||
disconnectChangeConnections();
|
||||
}
|
||||
m_part = part_rectangle;
|
||||
m_style->setPart(m_part);
|
||||
updateForm();
|
||||
setUpChangeConnections();
|
||||
setUpChangeConnections();
|
||||
return(true);
|
||||
}
|
||||
|
||||
|
||||
return(false);
|
||||
}
|
||||
|
||||
bool RectangleEditor::setParts(QList <CustomElementPart *> parts)
|
||||
{
|
||||
if (parts.isEmpty())
|
||||
return false;
|
||||
|
||||
if (!setPart(parts.first()))
|
||||
return false;
|
||||
return m_style->setParts(parts);
|
||||
if (parts.isEmpty())
|
||||
return false;
|
||||
|
||||
if (!setPart(parts.first()))
|
||||
return false;
|
||||
return m_style->setParts(parts);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -119,7 +119,7 @@ CustomElementPart *RectangleEditor::currentPart() const {
|
||||
}
|
||||
|
||||
QList<CustomElementPart*> RectangleEditor::currentParts() const {
|
||||
return m_style->currentParts();
|
||||
return m_style->currentParts();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -165,7 +165,7 @@ void RectangleEditor::editingFinished()
|
||||
return;
|
||||
}
|
||||
m_locked = true;
|
||||
|
||||
|
||||
QUndoCommand *undo = new QUndoCommand();
|
||||
undo->setText(tr("Modifier un rectangle"));
|
||||
|
||||
@@ -186,158 +186,158 @@ void RectangleEditor::editingFinished()
|
||||
u->setAnimated();
|
||||
}
|
||||
elementScene()->undoStack().push(undo);
|
||||
|
||||
|
||||
m_locked = false;
|
||||
}
|
||||
|
||||
void RectangleEditor::xPosChanged()
|
||||
{
|
||||
if (m_locked) {
|
||||
return;
|
||||
}
|
||||
m_locked = true;
|
||||
|
||||
for (auto part: m_style->currentParts()) {
|
||||
|
||||
PartRectangle* rec = static_cast<PartRectangle*>(part);
|
||||
|
||||
QRectF rect = rec->rect();
|
||||
|
||||
QPointF p = rec->mapFromScene(ui->m_x_sb->value(), ui->m_y_sb->value());
|
||||
|
||||
if (rect.x() != p.x()) {
|
||||
rect.moveLeft(p.x());
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(rec, "rect", rec->rect(), rect);
|
||||
undo->enableAnimation();
|
||||
elementScene()->undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
|
||||
m_locked = false;
|
||||
if (m_locked) {
|
||||
return;
|
||||
}
|
||||
m_locked = true;
|
||||
|
||||
for (auto part: m_style->currentParts()) {
|
||||
|
||||
PartRectangle* rec = static_cast<PartRectangle*>(part);
|
||||
|
||||
QRectF rect = rec->rect();
|
||||
|
||||
QPointF p = rec->mapFromScene(ui->m_x_sb->value(), ui->m_y_sb->value());
|
||||
|
||||
if (rect.x() != p.x()) {
|
||||
rect.moveLeft(p.x());
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(rec, "rect", rec->rect(), rect);
|
||||
undo->enableAnimation();
|
||||
elementScene()->undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
|
||||
m_locked = false;
|
||||
}
|
||||
|
||||
void RectangleEditor::yPosChanged()
|
||||
{
|
||||
if (m_locked) {
|
||||
return;
|
||||
}
|
||||
m_locked = true;
|
||||
|
||||
for (auto part: m_style->currentParts()) {
|
||||
|
||||
PartRectangle* rec = static_cast<PartRectangle*>(part);
|
||||
|
||||
QRectF rect = rec->rect();
|
||||
|
||||
QPointF p = rec->mapFromScene(ui->m_x_sb->value(), ui->m_y_sb->value());
|
||||
|
||||
if (rect.y() != p.y()) {
|
||||
rect.moveTop(p.y());
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(rec, "rect", rec->rect(), rect);
|
||||
undo->enableAnimation();
|
||||
elementScene()->undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
|
||||
m_locked = false;
|
||||
if (m_locked) {
|
||||
return;
|
||||
}
|
||||
m_locked = true;
|
||||
|
||||
for (auto part: m_style->currentParts()) {
|
||||
|
||||
PartRectangle* rec = static_cast<PartRectangle*>(part);
|
||||
|
||||
QRectF rect = rec->rect();
|
||||
|
||||
QPointF p = rec->mapFromScene(ui->m_x_sb->value(), ui->m_y_sb->value());
|
||||
|
||||
if (rect.y() != p.y()) {
|
||||
rect.moveTop(p.y());
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(rec, "rect", rec->rect(), rect);
|
||||
undo->enableAnimation();
|
||||
elementScene()->undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
|
||||
m_locked = false;
|
||||
}
|
||||
|
||||
void RectangleEditor::widthChanged()
|
||||
{
|
||||
if (m_locked) {
|
||||
return;
|
||||
}
|
||||
m_locked = true;
|
||||
|
||||
double width = ui->m_width_sb->value();
|
||||
|
||||
for (auto part: m_style->currentParts()) {
|
||||
|
||||
PartRectangle* rec = static_cast<PartRectangle*>(part);
|
||||
|
||||
QRectF rect = rec->rect();
|
||||
|
||||
if (rect.width() != width) {
|
||||
rect.setWidth(width);
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(rec, "rect", rec->rect(), rect);
|
||||
undo->enableAnimation();
|
||||
elementScene()->undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
|
||||
m_locked = false;
|
||||
if (m_locked) {
|
||||
return;
|
||||
}
|
||||
m_locked = true;
|
||||
|
||||
double width = ui->m_width_sb->value();
|
||||
|
||||
for (auto part: m_style->currentParts()) {
|
||||
|
||||
PartRectangle* rec = static_cast<PartRectangle*>(part);
|
||||
|
||||
QRectF rect = rec->rect();
|
||||
|
||||
if (rect.width() != width) {
|
||||
rect.setWidth(width);
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(rec, "rect", rec->rect(), rect);
|
||||
undo->enableAnimation();
|
||||
elementScene()->undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
|
||||
m_locked = false;
|
||||
}
|
||||
|
||||
void RectangleEditor::heightChanged()
|
||||
{
|
||||
if (m_locked) {
|
||||
return;
|
||||
}
|
||||
m_locked = true;
|
||||
|
||||
double height = ui->m_height_sb->value();
|
||||
|
||||
for (auto part: m_style->currentParts()) {
|
||||
|
||||
PartRectangle* rec = static_cast<PartRectangle*>(part);
|
||||
|
||||
QRectF rect = rec->rect();
|
||||
|
||||
if (rect.height() != height) {
|
||||
rect.setHeight(height);
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(rec, "rect", rec->rect(), rect);
|
||||
undo->enableAnimation();
|
||||
elementScene()->undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
|
||||
m_locked = false;
|
||||
if (m_locked) {
|
||||
return;
|
||||
}
|
||||
m_locked = true;
|
||||
|
||||
double height = ui->m_height_sb->value();
|
||||
|
||||
for (auto part: m_style->currentParts()) {
|
||||
|
||||
PartRectangle* rec = static_cast<PartRectangle*>(part);
|
||||
|
||||
QRectF rect = rec->rect();
|
||||
|
||||
if (rect.height() != height) {
|
||||
rect.setHeight(height);
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(rec, "rect", rec->rect(), rect);
|
||||
undo->enableAnimation();
|
||||
elementScene()->undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
|
||||
m_locked = false;
|
||||
}
|
||||
|
||||
void RectangleEditor::xRadiusChanged()
|
||||
{
|
||||
if (m_locked) {
|
||||
return;
|
||||
}
|
||||
m_locked = true;
|
||||
|
||||
double radius = ui->m_rx_sb->value();
|
||||
|
||||
for (auto part: m_style->currentParts()) {
|
||||
|
||||
PartRectangle* rec = static_cast<PartRectangle*>(part);
|
||||
|
||||
if (rec->XRadius() != radius) {
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(rec, "xRadius", rec->XRadius(), radius);
|
||||
undo->setAnimated();
|
||||
elementScene()->undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
|
||||
m_locked = false;
|
||||
if (m_locked) {
|
||||
return;
|
||||
}
|
||||
m_locked = true;
|
||||
|
||||
double radius = ui->m_rx_sb->value();
|
||||
|
||||
for (auto part: m_style->currentParts()) {
|
||||
|
||||
PartRectangle* rec = static_cast<PartRectangle*>(part);
|
||||
|
||||
if (rec->XRadius() != radius) {
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(rec, "xRadius", rec->XRadius(), radius);
|
||||
undo->setAnimated();
|
||||
elementScene()->undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
|
||||
m_locked = false;
|
||||
}
|
||||
|
||||
void RectangleEditor::yRadiusChanged()
|
||||
{
|
||||
if (m_locked) {
|
||||
return;
|
||||
}
|
||||
m_locked = true;
|
||||
|
||||
double radius = ui->m_ry_sb->value();
|
||||
|
||||
for (auto part: m_style->currentParts()) {
|
||||
|
||||
PartRectangle* rec = static_cast<PartRectangle*>(part);
|
||||
|
||||
if (rec->YRadius() != radius) {
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(rec, "yRadius", rec->YRadius(), radius);
|
||||
undo->setAnimated();
|
||||
elementScene()->undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
|
||||
m_locked = false;
|
||||
if (m_locked) {
|
||||
return;
|
||||
}
|
||||
m_locked = true;
|
||||
|
||||
double radius = ui->m_ry_sb->value();
|
||||
|
||||
for (auto part: m_style->currentParts()) {
|
||||
|
||||
PartRectangle* rec = static_cast<PartRectangle*>(part);
|
||||
|
||||
if (rec->YRadius() != radius) {
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(rec, "yRadius", rec->YRadius(), radius);
|
||||
undo->setAnimated();
|
||||
elementScene()->undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
|
||||
m_locked = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -351,20 +351,20 @@ void RectangleEditor::activeConnections(bool active)
|
||||
{
|
||||
if (active)
|
||||
{
|
||||
connect(ui->m_x_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::xPosChanged);
|
||||
connect(ui->m_y_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::yPosChanged);
|
||||
connect(ui->m_width_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::widthChanged);
|
||||
connect(ui->m_height_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::heightChanged);
|
||||
connect(ui->m_rx_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::xRadiusChanged);
|
||||
connect(ui->m_ry_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::yRadiusChanged);
|
||||
connect(ui->m_x_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::xPosChanged);
|
||||
connect(ui->m_y_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::yPosChanged);
|
||||
connect(ui->m_width_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::widthChanged);
|
||||
connect(ui->m_height_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::heightChanged);
|
||||
connect(ui->m_rx_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::xRadiusChanged);
|
||||
connect(ui->m_ry_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::yRadiusChanged);
|
||||
}
|
||||
else
|
||||
{
|
||||
disconnect(ui->m_x_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::xPosChanged);
|
||||
disconnect(ui->m_y_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::yPosChanged);
|
||||
disconnect(ui->m_width_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::widthChanged);
|
||||
disconnect(ui->m_height_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::heightChanged);
|
||||
disconnect(ui->m_rx_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::xRadiusChanged);
|
||||
disconnect(ui->m_ry_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::yRadiusChanged);
|
||||
disconnect(ui->m_x_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::xPosChanged);
|
||||
disconnect(ui->m_y_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::yPosChanged);
|
||||
disconnect(ui->m_width_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::widthChanged);
|
||||
disconnect(ui->m_height_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::heightChanged);
|
||||
disconnect(ui->m_rx_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::xRadiusChanged);
|
||||
disconnect(ui->m_ry_sb, &QDoubleSpinBox::editingFinished, this, &RectangleEditor::yRadiusChanged);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,38 +38,38 @@ class RectangleEditor : public ElementItemEditor
|
||||
|
||||
public:
|
||||
explicit RectangleEditor(QETElementEditor *editor, PartRectangle *rect = nullptr, QWidget *parent = nullptr);
|
||||
~RectangleEditor() override;
|
||||
~RectangleEditor() override;
|
||||
|
||||
bool setPart(CustomElementPart *part) override;
|
||||
bool setParts(QList <CustomElementPart *> parts) override;
|
||||
CustomElementPart *currentPart() const override;
|
||||
QList<CustomElementPart*> currentParts() const override;
|
||||
QPointF editedTopLeft () const;
|
||||
bool setPart(CustomElementPart *part) override;
|
||||
bool setParts(QList <CustomElementPart *> parts) override;
|
||||
CustomElementPart *currentPart() const override;
|
||||
QList<CustomElementPart*> currentParts() const override;
|
||||
QPointF editedTopLeft () const;
|
||||
|
||||
public slots:
|
||||
void updateForm() override;
|
||||
void updateForm() override;
|
||||
private:
|
||||
void editingFinished();
|
||||
void activeConnections(bool active);
|
||||
void xPosChanged();
|
||||
void yPosChanged();
|
||||
void widthChanged();
|
||||
void heightChanged();
|
||||
void xRadiusChanged();
|
||||
void yRadiusChanged();
|
||||
/*!
|
||||
* \brief setUpChangeConnections
|
||||
* Setup the connection from the rectangles(s) to the widget, to update it when the rectangles(s) are changed (moved ...)
|
||||
*/
|
||||
void setUpChangeConnections();
|
||||
void disconnectChangeConnections();
|
||||
void editingFinished();
|
||||
void activeConnections(bool active);
|
||||
void xPosChanged();
|
||||
void yPosChanged();
|
||||
void widthChanged();
|
||||
void heightChanged();
|
||||
void xRadiusChanged();
|
||||
void yRadiusChanged();
|
||||
/*!
|
||||
* \brief setUpChangeConnections
|
||||
* Setup the connection from the rectangles(s) to the widget, to update it when the rectangles(s) are changed (moved ...)
|
||||
*/
|
||||
void setUpChangeConnections();
|
||||
void disconnectChangeConnections();
|
||||
|
||||
private:
|
||||
bool m_locked = false;
|
||||
StyleEditor *m_style;
|
||||
PartRectangle *m_part;
|
||||
Ui::RectangleEditor *ui;
|
||||
QList <QMetaObject::Connection> m_change_connections;
|
||||
bool m_locked = false;
|
||||
StyleEditor *m_style;
|
||||
PartRectangle *m_part;
|
||||
Ui::RectangleEditor *ui;
|
||||
QList <QMetaObject::Connection> m_change_connections;
|
||||
};
|
||||
|
||||
#endif // RECTANGLEEDITOR_H
|
||||
|
||||
@@ -107,19 +107,19 @@ bool TextEditor::setPart(CustomElementPart *part)
|
||||
if (!part)
|
||||
{
|
||||
m_text = nullptr;
|
||||
disconnectChangeConnection();
|
||||
disconnectChangeConnection();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (PartText *part_text = static_cast<PartText *>(part))
|
||||
|
||||
if (PartText *part_text = static_cast<PartText *>(part))
|
||||
{
|
||||
if (part_text == m_text) {
|
||||
return true;
|
||||
}
|
||||
m_text = part_text;
|
||||
|
||||
setUpChangeConnection(m_text);
|
||||
|
||||
|
||||
setUpChangeConnection(m_text);
|
||||
|
||||
updateForm();
|
||||
return true;
|
||||
}
|
||||
@@ -127,34 +127,34 @@ bool TextEditor::setPart(CustomElementPart *part)
|
||||
}
|
||||
|
||||
bool TextEditor::setParts(QList <CustomElementPart *> parts) {
|
||||
if (parts.isEmpty())
|
||||
{
|
||||
m_parts.clear();
|
||||
if (m_text) {
|
||||
disconnectChangeConnection();
|
||||
}
|
||||
m_text = nullptr;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (PartText *part= static_cast<PartText *>(parts.first()))
|
||||
{
|
||||
if (m_text) {
|
||||
disconnectChangeConnection();
|
||||
}
|
||||
|
||||
m_text = part;
|
||||
m_parts.clear();
|
||||
m_parts.append(part);
|
||||
for (int i=1; i < parts.length(); i++)
|
||||
m_parts.append(static_cast<PartText*>(parts[i]));
|
||||
|
||||
setUpChangeConnection(m_text);
|
||||
|
||||
updateForm();
|
||||
return true;
|
||||
}
|
||||
return(false);
|
||||
if (parts.isEmpty())
|
||||
{
|
||||
m_parts.clear();
|
||||
if (m_text) {
|
||||
disconnectChangeConnection();
|
||||
}
|
||||
m_text = nullptr;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (PartText *part= static_cast<PartText *>(parts.first()))
|
||||
{
|
||||
if (m_text) {
|
||||
disconnectChangeConnection();
|
||||
}
|
||||
|
||||
m_text = part;
|
||||
m_parts.clear();
|
||||
m_parts.append(part);
|
||||
for (int i=1; i < parts.length(); i++)
|
||||
m_parts.append(static_cast<PartText*>(parts[i]));
|
||||
|
||||
setUpChangeConnection(m_text);
|
||||
|
||||
updateForm();
|
||||
return true;
|
||||
}
|
||||
return(false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -166,11 +166,11 @@ CustomElementPart *TextEditor::currentPart() const {
|
||||
}
|
||||
|
||||
QList<CustomElementPart*> TextEditor::currentParts() const {
|
||||
QList<CustomElementPart*> parts;
|
||||
for (auto part: m_parts) {
|
||||
parts.append(static_cast<CustomElementPart*>(part));
|
||||
}
|
||||
return parts;
|
||||
QList<CustomElementPart*> parts;
|
||||
for (auto part: m_parts) {
|
||||
parts.append(static_cast<CustomElementPart*>(part));
|
||||
}
|
||||
return parts;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -180,77 +180,77 @@ QList<CustomElementPart*> TextEditor::currentParts() const {
|
||||
*/
|
||||
void TextEditor::setUpEditConnection()
|
||||
{
|
||||
disconnectEditConnection();
|
||||
|
||||
disconnectEditConnection();
|
||||
|
||||
m_edit_connection << connect(ui->m_line_edit, &QLineEdit::textEdited, [this]()
|
||||
{
|
||||
QString text_ = ui->m_line_edit->text();
|
||||
for (int i=0; i < m_parts.length(); i++) {
|
||||
PartText* partText = m_parts[i];
|
||||
if (text_ != partText->toPlainText())
|
||||
{
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "text", partText->toPlainText(), text_);
|
||||
undo->setText(tr("Modifier le contenu d'un champ texte"));
|
||||
undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
for (int i=0; i < m_parts.length(); i++) {
|
||||
PartText* partText = m_parts[i];
|
||||
if (text_ != partText->toPlainText())
|
||||
{
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "text", partText->toPlainText(), text_);
|
||||
undo->setText(tr("Modifier le contenu d'un champ texte"));
|
||||
undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
});
|
||||
m_edit_connection << connect(ui->m_x_sb, QOverload<int>::of(&QSpinBox::valueChanged), [this]()
|
||||
{
|
||||
QPointF pos(ui->m_x_sb->value(), 0);
|
||||
for (int i=0; i < m_parts.length(); i++) {
|
||||
PartText* partText = m_parts[i];
|
||||
pos.setY(partText->pos().y());
|
||||
if (pos != partText->pos())
|
||||
{
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "pos", partText->pos(), pos);
|
||||
undo->setText(tr("Déplacer un champ texte"));
|
||||
undo->setAnimated(true, false);
|
||||
undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
QPointF pos(ui->m_x_sb->value(), 0);
|
||||
for (int i=0; i < m_parts.length(); i++) {
|
||||
PartText* partText = m_parts[i];
|
||||
pos.setY(partText->pos().y());
|
||||
if (pos != partText->pos())
|
||||
{
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "pos", partText->pos(), pos);
|
||||
undo->setText(tr("Déplacer un champ texte"));
|
||||
undo->setAnimated(true, false);
|
||||
undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
});
|
||||
m_edit_connection << connect(ui->m_y_sb, QOverload<int>::of(&QSpinBox::valueChanged), [this]()
|
||||
{
|
||||
QPointF pos(0, ui->m_y_sb->value());
|
||||
for (int i=0; i < m_parts.length(); i++) {
|
||||
PartText* partText = m_parts[i];
|
||||
pos.setX(partText->pos().x());
|
||||
if (pos != partText->pos())
|
||||
{
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "pos", partText->pos(), pos);
|
||||
undo->setText(tr("Déplacer un champ texte"));
|
||||
undo->setAnimated(true, false);
|
||||
undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
QPointF pos(0, ui->m_y_sb->value());
|
||||
for (int i=0; i < m_parts.length(); i++) {
|
||||
PartText* partText = m_parts[i];
|
||||
pos.setX(partText->pos().x());
|
||||
if (pos != partText->pos())
|
||||
{
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "pos", partText->pos(), pos);
|
||||
undo->setText(tr("Déplacer un champ texte"));
|
||||
undo->setAnimated(true, false);
|
||||
undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
});
|
||||
m_edit_connection << connect(ui->m_rotation_sb, QOverload<int>::of(&QSpinBox::valueChanged), [this]()
|
||||
{
|
||||
for (int i=0; i < m_parts.length(); i++) {
|
||||
PartText* partText = m_parts[i];
|
||||
if (ui->m_rotation_sb->value() != partText->rotation())
|
||||
{
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "rotation", partText->rotation(), ui->m_rotation_sb->value());
|
||||
undo->setText(tr("Pivoter un champ texte"));
|
||||
undo->setAnimated(true, false);
|
||||
undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
for (int i=0; i < m_parts.length(); i++) {
|
||||
PartText* partText = m_parts[i];
|
||||
if (ui->m_rotation_sb->value() != partText->rotation())
|
||||
{
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "rotation", partText->rotation(), ui->m_rotation_sb->value());
|
||||
undo->setText(tr("Pivoter un champ texte"));
|
||||
undo->setAnimated(true, false);
|
||||
undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
});
|
||||
m_edit_connection << connect(ui->m_size_sb, QOverload<int>::of(&QSpinBox::valueChanged), [this]()
|
||||
{
|
||||
for (int i=0; i < m_parts.length(); i++) {
|
||||
PartText* partText = m_parts[i];
|
||||
if (partText->font().pointSize() != ui->m_size_sb->value())
|
||||
{
|
||||
QFont font_ = partText->font();
|
||||
font_.setPointSize(ui->m_size_sb->value());
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "font", partText->font(), font_);
|
||||
undo->setText(tr("Modifier la police d'un texte"));
|
||||
undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
for (int i=0; i < m_parts.length(); i++) {
|
||||
PartText* partText = m_parts[i];
|
||||
if (partText->font().pointSize() != ui->m_size_sb->value())
|
||||
{
|
||||
QFont font_ = partText->font();
|
||||
font_.setPointSize(ui->m_size_sb->value());
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "font", partText->font(), font_);
|
||||
undo->setText(tr("Modifier la police d'un texte"));
|
||||
undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -261,24 +261,24 @@ void TextEditor::on_m_font_pb_clicked()
|
||||
{
|
||||
bool ok;
|
||||
QFont font_ = QFontDialog::getFont(&ok, m_text->font(), this);
|
||||
|
||||
if (ok && font_ != m_text->font()) {
|
||||
ui->m_size_sb->blockSignals(true);
|
||||
ui->m_size_sb->setValue(font_.pointSize());
|
||||
ui->m_size_sb->blockSignals(false);
|
||||
|
||||
ui->m_font_pb->setText(font_.family());
|
||||
}
|
||||
|
||||
for (int i=0; i < m_parts.length(); i++) {
|
||||
PartText* partText = m_parts[i];
|
||||
if (ok && font_ != partText->font())
|
||||
{
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "font", partText->font(), font_);
|
||||
undo->setText(tr("Modifier la police d'un texte"));
|
||||
undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
|
||||
if (ok && font_ != m_text->font()) {
|
||||
ui->m_size_sb->blockSignals(true);
|
||||
ui->m_size_sb->setValue(font_.pointSize());
|
||||
ui->m_size_sb->blockSignals(false);
|
||||
|
||||
ui->m_font_pb->setText(font_.family());
|
||||
}
|
||||
|
||||
for (int i=0; i < m_parts.length(); i++) {
|
||||
PartText* partText = m_parts[i];
|
||||
if (ok && font_ != partText->font())
|
||||
{
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "font", partText->font(), font_);
|
||||
undo->setText(tr("Modifier la police d'un texte"));
|
||||
undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -287,13 +287,13 @@ void TextEditor::on_m_font_pb_clicked()
|
||||
*/
|
||||
void TextEditor::on_m_color_pb_changed(const QColor &newColor)
|
||||
{
|
||||
for (int i=0; i < m_parts.length(); i++) {
|
||||
PartText* partText = m_parts[i];
|
||||
if (newColor != partText->defaultTextColor())
|
||||
{
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "color", partText->defaultTextColor(), newColor);
|
||||
undo->setText(tr("Modifier la couleur d'un texte"));
|
||||
undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
for (int i=0; i < m_parts.length(); i++) {
|
||||
PartText* partText = m_parts[i];
|
||||
if (newColor != partText->defaultTextColor())
|
||||
{
|
||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(partText, "color", partText->defaultTextColor(), newColor);
|
||||
undo->setText(tr("Modifier la couleur d'un texte"));
|
||||
undoStack().push(undo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user