mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 05:00:33 +01:00
ElementEditor: dynamictextfieldeditor.cpp improve code style
This commit is contained in:
committed by
Laurent Trinques
parent
ce523b71e2
commit
216374d27c
@@ -30,24 +30,26 @@
|
|||||||
#include <QGraphicsItem>
|
#include <QGraphicsItem>
|
||||||
#include <QColorDialog>
|
#include <QColorDialog>
|
||||||
|
|
||||||
DynamicTextFieldEditor::DynamicTextFieldEditor(QETElementEditor *editor, PartDynamicTextField *text_field, QWidget *parent) :
|
DynamicTextFieldEditor::DynamicTextFieldEditor(
|
||||||
ElementItemEditor(editor, parent),
|
QETElementEditor *editor, PartDynamicTextField *text_field, QWidget *parent) :
|
||||||
ui(new Ui::DynamicTextFieldEditor)
|
ElementItemEditor(editor, parent),
|
||||||
{
|
ui(new Ui::DynamicTextFieldEditor) {
|
||||||
ui->setupUi(this);
|
ui -> setupUi(this);
|
||||||
ui->m_composite_text_pb->setDisabled(true);
|
ui -> m_composite_text_pb -> setDisabled(true);
|
||||||
ui->m_elmt_info_cb->setDisabled(true);
|
ui -> m_elmt_info_cb -> setDisabled(true);
|
||||||
if(text_field)
|
if(text_field) {
|
||||||
setPart(text_field);
|
setPart(text_field);
|
||||||
fillInfoComboBox();
|
fillInfoComboBox();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DynamicTextFieldEditor::~DynamicTextFieldEditor()
|
DynamicTextFieldEditor::~DynamicTextFieldEditor() {
|
||||||
{
|
|
||||||
delete ui;
|
delete ui;
|
||||||
if(!m_connection_list.isEmpty())
|
if(!m_connection_list.isEmpty()) {
|
||||||
for(const QMetaObject::Connection& con : m_connection_list)
|
for(const QMetaObject::Connection& con : m_connection_list) {
|
||||||
disconnect(con);
|
disconnect(con);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -56,27 +58,25 @@ DynamicTextFieldEditor::~DynamicTextFieldEditor()
|
|||||||
* @param part
|
* @param part
|
||||||
* @return true if @part can be edited by this widget
|
* @return true if @part can be edited by this widget
|
||||||
*/
|
*/
|
||||||
bool DynamicTextFieldEditor::setPart(CustomElementPart *part)
|
bool DynamicTextFieldEditor::setPart(CustomElementPart *part) {
|
||||||
{
|
|
||||||
disconnectConnections();
|
disconnectConnections();
|
||||||
|
|
||||||
QGraphicsItem *qgi = part->toItem();
|
QGraphicsItem *qgi = part -> toItem();
|
||||||
if(!qgi)
|
if(!qgi) {
|
||||||
return false;
|
return false;
|
||||||
else if (qgi->type() != PartDynamicTextField::Type)
|
}
|
||||||
|
else if (qgi -> type() != PartDynamicTextField::Type) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
m_text_field = static_cast<PartDynamicTextField *>(qgi);
|
m_text_field = static_cast<PartDynamicTextField *>(qgi);
|
||||||
updateForm();
|
updateForm();
|
||||||
|
|
||||||
setUpConnections();
|
setUpConnections();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DynamicTextFieldEditor::setParts(QList <CustomElementPart *> parts) {
|
bool DynamicTextFieldEditor::setParts(QList <CustomElementPart *> parts) {
|
||||||
if (parts.isEmpty())
|
if (parts.isEmpty()) {
|
||||||
{
|
|
||||||
m_parts.clear();
|
m_parts.clear();
|
||||||
if (m_text_field) {
|
if (m_text_field) {
|
||||||
disconnectConnections();
|
disconnectConnections();
|
||||||
@@ -84,21 +84,19 @@ bool DynamicTextFieldEditor::setParts(QList <CustomElementPart *> parts) {
|
|||||||
m_text_field = nullptr;
|
m_text_field = nullptr;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PartDynamicTextField *part= static_cast<PartDynamicTextField *>(parts.first()))
|
if (PartDynamicTextField *part= static_cast<PartDynamicTextField *>(parts.first())) {
|
||||||
{
|
|
||||||
if (m_text_field) {
|
if (m_text_field) {
|
||||||
disconnectConnections();
|
disconnectConnections();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_text_field = part;
|
m_text_field = part;
|
||||||
m_parts.clear();
|
m_parts.clear();
|
||||||
m_parts.append(part);
|
m_parts.append(part);
|
||||||
for (int i=1; i < parts.length(); i++)
|
for (int i=1; i < parts.length(); i++)
|
||||||
m_parts.append(static_cast<PartDynamicTextField*>(parts[i]));
|
m_parts.append(static_cast<PartDynamicTextField*>(parts[i]));
|
||||||
|
|
||||||
setUpConnections();
|
setUpConnections();
|
||||||
|
|
||||||
updateForm();
|
updateForm();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -122,59 +120,69 @@ QList<CustomElementPart*> DynamicTextFieldEditor::currentParts() const {
|
|||||||
return parts;
|
return parts;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicTextFieldEditor::updateForm()
|
void DynamicTextFieldEditor::updateForm() {
|
||||||
{
|
if(m_text_field) {
|
||||||
if(m_text_field)
|
ui -> m_x_sb -> setValue(m_text_field.data() -> x());
|
||||||
{
|
ui -> m_y_sb -> setValue(m_text_field.data() ->y ());
|
||||||
ui->m_x_sb->setValue(m_text_field.data()->x());
|
ui -> m_rotation_sb -> setValue(QET::correctAngle(m_text_field.data() -> rotation()));
|
||||||
ui->m_y_sb->setValue(m_text_field.data()->y());
|
ui -> m_frame_cb -> setChecked(m_text_field.data() -> frame());
|
||||||
ui->m_rotation_sb->setValue(QET::correctAngle(m_text_field.data()->rotation()));
|
ui -> m_user_text_le -> setText(m_text_field.data() -> text());
|
||||||
ui->m_frame_cb->setChecked(m_text_field.data()->frame());
|
ui -> m_size_sb -> setValue(m_text_field.data() -> font().pointSize());
|
||||||
ui->m_user_text_le->setText(m_text_field.data()->text());
|
ui -> m_color_kpb -> setColor(m_text_field.data() -> color());
|
||||||
ui->m_size_sb->setValue(m_text_field.data()->font().pointSize());
|
ui -> m_width_sb -> setValue(m_text_field.data() -> textWidth());
|
||||||
ui->m_color_kpb->setColor(m_text_field.data()->color());
|
ui -> m_font_pb -> setText(m_text_field -> font().family());
|
||||||
ui->m_width_sb->setValue(m_text_field.data()->textWidth());
|
|
||||||
ui->m_font_pb->setText(m_text_field->font().family());
|
switch (m_text_field.data() -> textFrom()) {
|
||||||
|
case DynamicElementTextItem::UserText: {
|
||||||
switch (m_text_field.data()->textFrom())
|
ui -> m_text_from_cb -> setCurrentIndex(0);
|
||||||
{
|
|
||||||
case DynamicElementTextItem::UserText:
|
|
||||||
ui->m_text_from_cb->setCurrentIndex(0);
|
|
||||||
break;
|
|
||||||
case DynamicElementTextItem::ElementInfo:
|
|
||||||
{
|
|
||||||
ui->m_text_from_cb->setCurrentIndex(1);
|
|
||||||
ui->m_elmt_info_cb->setCurrentIndex(ui->m_elmt_info_cb->findData(m_text_field.data()->infoName()));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case DynamicElementTextItem::CompositeText:
|
case DynamicElementTextItem::ElementInfo: {
|
||||||
ui->m_text_from_cb->setCurrentIndex(2);
|
ui -> m_text_from_cb -> setCurrentIndex(1);
|
||||||
|
ui -> m_elmt_info_cb -> setCurrentIndex(
|
||||||
|
ui -> m_elmt_info_cb -> findData(m_text_field.data() -> infoName()));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DynamicElementTextItem::CompositeText: {
|
||||||
|
ui -> m_text_from_cb -> setCurrentIndex(2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
on_m_text_from_cb_activated(ui->m_text_from_cb->currentIndex()); //For enable the good widget
|
on_m_text_from_cb_activated(ui -> m_text_from_cb -> currentIndex()); //For enable the good widget
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicTextFieldEditor::setUpConnections() {
|
void DynamicTextFieldEditor::setUpConnections() {
|
||||||
assert(m_connection_list.isEmpty());
|
assert(m_connection_list.isEmpty());
|
||||||
//Setup the connection
|
//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::colorChanged,
|
||||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::fontChanged, [this](){this->updateForm();});
|
[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::fontChanged,
|
||||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::textFromChanged, [this](){this->updateForm();});
|
[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::taggChanged,
|
||||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::infoNameChanged, [this](){this->updateForm();});
|
[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::textFromChanged,
|
||||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::frameChanged, [this](){this->updateForm();});
|
[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::textChanged,
|
||||||
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::compositeTextChanged, [this]() {this->updateForm();});
|
[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() {
|
void DynamicTextFieldEditor::disconnectConnections() {
|
||||||
//Remove previous connection
|
//Remove previous connection
|
||||||
if(!m_connection_list.isEmpty())
|
if(!m_connection_list.isEmpty())
|
||||||
for(const QMetaObject::Connection& con : m_connection_list)
|
for(const QMetaObject::Connection& con : m_connection_list) {
|
||||||
disconnect(con);
|
disconnect(con);
|
||||||
|
}
|
||||||
m_connection_list.clear();
|
m_connection_list.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,18 +190,18 @@ void DynamicTextFieldEditor::disconnectConnections() {
|
|||||||
* @brief DynamicTextFieldEditor::fillInfoComboBox
|
* @brief DynamicTextFieldEditor::fillInfoComboBox
|
||||||
* Fill the combo box "element information"
|
* Fill the combo box "element information"
|
||||||
*/
|
*/
|
||||||
void DynamicTextFieldEditor::fillInfoComboBox()
|
void DynamicTextFieldEditor::fillInfoComboBox() {
|
||||||
{
|
ui -> m_elmt_info_cb -> clear();
|
||||||
ui->m_elmt_info_cb->clear();
|
|
||||||
|
|
||||||
QStringList strl;
|
QStringList strl;
|
||||||
QString type = elementEditor()->elementScene()->elementType();
|
QString type = elementEditor() -> elementScene() -> elementType();
|
||||||
|
|
||||||
if(type.contains("report"))
|
if(type.contains("report")) {
|
||||||
strl << "function" << "tension_protocol" << "conductor_color" << "conductor_section";
|
strl << "function" << "tension_protocol" << "conductor_color" << "conductor_section";
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
strl = QETApp::elementInfoKeys();
|
strl = QETApp::elementInfoKeys();
|
||||||
|
}
|
||||||
//We use a QMap because the keys of the map are sorted, then no matter the curent local,
|
//We use a QMap because the keys of the map are sorted, then no matter the curent local,
|
||||||
//the value of the combo box are always alphabetically sorted
|
//the value of the combo box are always alphabetically sorted
|
||||||
QMap <QString, QString> info_map;
|
QMap <QString, QString> info_map;
|
||||||
@@ -201,194 +209,185 @@ void DynamicTextFieldEditor::fillInfoComboBox()
|
|||||||
info_map.insert(QETApp::elementTranslatedInfoKey(str), str);
|
info_map.insert(QETApp::elementTranslatedInfoKey(str), str);
|
||||||
|
|
||||||
for (const QString& key : info_map.keys())
|
for (const QString& key : info_map.keys())
|
||||||
ui->m_elmt_info_cb->addItem(key, info_map.value(key));
|
ui -> m_elmt_info_cb -> addItem(key, info_map.value(key));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicTextFieldEditor::on_m_x_sb_editingFinished()
|
void DynamicTextFieldEditor::on_m_x_sb_editingFinished() {
|
||||||
{
|
double value = ui -> m_x_sb -> value();
|
||||||
double value = ui->m_x_sb->value();
|
|
||||||
for (int i = 0; i < m_parts.length(); i++) {
|
for (int i = 0; i < m_parts.length(); i++) {
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "x", m_parts[i]->x(), value);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "x", m_parts[i] -> x(), value);
|
||||||
undo->setText(tr("Déplacer un champ texte"));
|
undo -> setText(tr("Déplacer un champ texte"));
|
||||||
undo->enableAnimation(true);
|
undo -> enableAnimation(true);
|
||||||
undoStack().push(undo);
|
undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicTextFieldEditor::on_m_y_sb_editingFinished()
|
void DynamicTextFieldEditor::on_m_y_sb_editingFinished() {
|
||||||
{
|
double value = ui -> m_y_sb -> value();
|
||||||
double value = ui->m_y_sb->value();
|
|
||||||
for (int i = 0; i < m_parts.length(); i++) {
|
for (int i = 0; i < m_parts.length(); i++) {
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "y", m_parts[i]->y(), value);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "y", m_parts[i] -> y(), value);
|
||||||
undo->setText(tr("Déplacer un champ texte"));
|
undo -> setText(tr("Déplacer un champ texte"));
|
||||||
undo->enableAnimation(true);
|
undo -> enableAnimation(true);
|
||||||
undoStack().push(undo);
|
undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicTextFieldEditor::on_m_rotation_sb_editingFinished()
|
void DynamicTextFieldEditor::on_m_rotation_sb_editingFinished() {
|
||||||
{
|
int value = ui -> m_rotation_sb -> value();
|
||||||
int value = ui->m_rotation_sb->value();
|
|
||||||
for (int i = 0; i < m_parts.length(); i++) {
|
for (int i = 0; i < m_parts.length(); i++) {
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "rotation", m_parts[i]->rotation(), value);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "rotation", m_parts[i] -> rotation(), value);
|
||||||
undo->setText(tr("Pivoter un champ texte"));
|
undo -> setText(tr("Pivoter un champ texte"));
|
||||||
undo->enableAnimation(true);
|
undo -> enableAnimation(true);
|
||||||
undoStack().push(undo);
|
undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicTextFieldEditor::on_m_user_text_le_editingFinished()
|
void DynamicTextFieldEditor::on_m_user_text_le_editingFinished() {
|
||||||
{
|
QString text = ui -> m_user_text_le -> text();
|
||||||
QString text = ui->m_user_text_le->text();
|
|
||||||
for (int i = 0; i < m_parts.length(); i++) {
|
for (int i = 0; i < m_parts.length(); i++) {
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "text", m_parts[i]->text(), text);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "text", m_parts[i] -> text(), text);
|
||||||
undo->setText(tr("Modifier le texte d'un champ texte"));
|
undo -> setText(tr("Modifier le texte d'un champ texte"));
|
||||||
undoStack().push(undo);
|
undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicTextFieldEditor::on_m_size_sb_editingFinished()
|
void DynamicTextFieldEditor::on_m_size_sb_editingFinished() {
|
||||||
{
|
QFont font_ = m_text_field -> font();
|
||||||
QFont font_ = m_text_field->font();
|
font_.setPointSize(ui -> m_size_sb -> value());
|
||||||
font_.setPointSize(ui->m_size_sb->value());
|
|
||||||
for (int i = 0; i < m_parts.length(); i++) {
|
for (int i = 0; i < m_parts.length(); i++) {
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "font", m_parts[i]->font(), font_);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "font", m_parts[i] -> font(), font_);
|
||||||
undo->setText(tr("Modifier la police d'un champ texte"));
|
undo -> setText(tr("Modifier la police d'un champ texte"));
|
||||||
undoStack().push(undo);
|
undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicTextFieldEditor::on_m_frame_cb_clicked()
|
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++) {
|
for (int i = 0; i < m_parts.length(); i++) {
|
||||||
if(frame != m_parts[i]->frame())
|
if(frame != m_parts[i] -> frame()) {
|
||||||
{
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "frame", m_parts[i] -> frame(), frame);
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "frame", m_parts[i]->frame(), frame);
|
undo -> setText(tr("Modifier le cadre d'un champ texte"));
|
||||||
undo->setText(tr("Modifier le cadre d'un champ texte"));
|
|
||||||
undoStack().push(undo);
|
undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicTextFieldEditor::on_m_width_sb_editingFinished()
|
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++) {
|
for (int i = 0; i < m_parts.length(); i++) {
|
||||||
if(width != m_parts[i]->textWidth())
|
if(width != m_parts[i] -> textWidth()) {
|
||||||
{
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "textWidth", m_parts[i] -> textWidth(), width);
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "textWidth", m_parts[i]->textWidth(), width);
|
undo -> setText(tr("Modifier la largeur d'un texte"));
|
||||||
undo->setText(tr("Modifier la largeur d'un texte"));
|
|
||||||
undoStack().push(undo);
|
undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicTextFieldEditor::on_m_elmt_info_cb_activated(const QString &arg1)
|
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();
|
QString info = ui -> m_elmt_info_cb -> currentData().toString();
|
||||||
for (int i = 0; i < m_parts.length(); i++) {
|
for (int i = 0; i < m_parts.length(); i++) {
|
||||||
if(info != m_parts[i]->infoName())
|
if(info != m_parts[i] -> infoName()) {
|
||||||
{
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "infoName", m_parts[i] -> infoName(), info);
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "infoName", m_parts[i]->infoName(), info);
|
|
||||||
undo->setText(tr("Modifier l'information d'un texte"));
|
undo->setText(tr("Modifier l'information d'un texte"));
|
||||||
undoStack().push(undo);
|
undoStack().push(undo);
|
||||||
|
m_parts[i] -> setPlainText(
|
||||||
m_parts[i]->setPlainText(elementEditor()->elementScene()->elementInformation().value(m_parts[i]->infoName()).toString());
|
elementEditor() -> elementScene() -> elementInformation().value(m_parts[i] -> infoName()).toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicTextFieldEditor::on_m_text_from_cb_activated(int index)
|
void DynamicTextFieldEditor::on_m_text_from_cb_activated(int index) {
|
||||||
{
|
ui -> m_user_text_le -> setDisabled(true);
|
||||||
ui->m_user_text_le->setDisabled(true);
|
ui -> m_elmt_info_cb -> setDisabled(true);
|
||||||
ui->m_elmt_info_cb->setDisabled(true);
|
ui -> m_composite_text_pb -> setDisabled(true);
|
||||||
ui->m_composite_text_pb->setDisabled(true);
|
|
||||||
|
if(index == 0) {
|
||||||
if(index == 0)
|
|
||||||
ui->m_user_text_le->setEnabled(true);
|
ui->m_user_text_le->setEnabled(true);
|
||||||
else if (index == 1)
|
}
|
||||||
|
else if (index == 1) {
|
||||||
ui->m_elmt_info_cb->setEnabled(true);
|
ui->m_elmt_info_cb->setEnabled(true);
|
||||||
else
|
}
|
||||||
|
else {
|
||||||
ui->m_composite_text_pb->setEnabled(true);
|
ui->m_composite_text_pb->setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
DynamicElementTextItem::TextFrom tf;
|
DynamicElementTextItem::TextFrom tf;
|
||||||
if(index == 0) tf = DynamicElementTextItem::UserText;
|
if(index == 0) {
|
||||||
else if(index == 1) tf = DynamicElementTextItem::ElementInfo;
|
tf = DynamicElementTextItem::UserText;
|
||||||
else tf = DynamicElementTextItem::CompositeText;
|
}
|
||||||
|
else if(index == 1) {
|
||||||
|
tf = DynamicElementTextItem::ElementInfo;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
tf = DynamicElementTextItem::CompositeText;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < m_parts.length(); i++) {
|
for (int i = 0; i < m_parts.length(); i++) {
|
||||||
if(tf != m_parts[i]->textFrom())
|
if(tf != m_parts[i] -> textFrom()) {
|
||||||
{
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "textFrom", m_parts[i] -> textFrom(), tf);
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "textFrom", m_parts[i]->textFrom(), tf);
|
undo -> setText(tr("Modifier la source de texte, d'un texte"));
|
||||||
undo->setText(tr("Modifier la source de texte, d'un texte"));
|
|
||||||
undoStack().push(undo);
|
undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicTextFieldEditor::on_m_composite_text_pb_clicked()
|
void DynamicTextFieldEditor::on_m_composite_text_pb_clicked() {
|
||||||
{
|
CompositeTextEditDialog ctd(m_text_field.data() -> compositeText(), this);
|
||||||
CompositeTextEditDialog ctd(m_text_field.data()->compositeText(), this);
|
if(ctd.exec()) {
|
||||||
if(ctd.exec())
|
|
||||||
{
|
|
||||||
QString ct = ctd.plainText();
|
QString ct = ctd.plainText();
|
||||||
for (int i = 0; i < m_parts.length(); i++) {
|
for (int i = 0; i < m_parts.length(); i++) {
|
||||||
if(ct != m_parts[i]->compositeText())
|
if(ct != m_parts[i] -> compositeText()) {
|
||||||
{
|
QPropertyUndoCommand *undo =\
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "compositeText", m_parts[i]->compositeText(), ctd.plainText());
|
new QPropertyUndoCommand(m_parts[i], "compositeText", m_parts[i] -> compositeText(), ctd.plainText());
|
||||||
undoStack().push(undo);
|
undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicTextFieldEditor::on_m_alignment_pb_clicked()
|
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();
|
atd.exec();
|
||||||
|
|
||||||
for (int i = 0; i < m_parts.length(); i++) {
|
for (int i = 0; i < m_parts.length(); i++) {
|
||||||
if(atd.alignment() != m_parts[i]->alignment())
|
if(atd.alignment() != m_parts[i] -> alignment()) {
|
||||||
{
|
QPropertyUndoCommand *undo =\
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "alignment", QVariant(m_parts[i]->alignment()), QVariant(atd.alignment()));
|
new QPropertyUndoCommand(
|
||||||
undo->setText(tr("Modifier l'alignement d'un champ texte"));
|
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);
|
undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicTextFieldEditor::on_m_font_pb_clicked()
|
void DynamicTextFieldEditor::on_m_font_pb_clicked() {
|
||||||
{
|
|
||||||
bool ok;
|
bool ok;
|
||||||
QFont font_ = QFontDialog::getFont(&ok, m_text_field->font(), this);
|
QFont font_ = QFontDialog::getFont(&ok, m_text_field -> font(), this);
|
||||||
if (ok && font_ != this->font())
|
if (ok && font_ != this -> font()) {
|
||||||
{
|
ui -> m_font_pb -> setText(font_.family());
|
||||||
ui->m_font_pb->setText(font_.family());
|
ui -> m_size_sb -> setValue(font_.pointSize());
|
||||||
ui->m_size_sb->setValue(font_.pointSize());
|
|
||||||
|
|
||||||
for (int i = 0; i < m_parts.length(); i++) {
|
for (int i = 0; i < m_parts.length(); i++) {
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "font", m_parts[i]->font(), font_);
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "font", m_parts[i] -> font(), font_);
|
||||||
undo->setText(tr("Modifier la police d'un champ texte"));
|
undo -> setText(tr("Modifier la police d'un champ texte"));
|
||||||
undoStack().push(undo);
|
undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DynamicTextFieldEditor::on_m_color_kpb_changed(const QColor &newColor)
|
void DynamicTextFieldEditor::on_m_color_kpb_changed(const QColor &newColor) {
|
||||||
{
|
if (!newColor.isValid()) {
|
||||||
if (!newColor.isValid())
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < m_parts.length(); i++) {
|
for (int i = 0; i < m_parts.length(); i++) {
|
||||||
if(newColor != m_parts[i]->color())
|
if(newColor != m_parts[i] -> color()) {
|
||||||
{
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "color", m_parts[i] -> color(), newColor);
|
||||||
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_parts[i], "color", m_parts[i]->color(), newColor);
|
undo -> setText(tr("Modifier la couleur d'un champ texte"));
|
||||||
undo->setText(tr("Modifier la couleur d'un champ texte"));
|
|
||||||
undoStack().push(undo);
|
undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user