mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 13:30:34 +01:00
Element editor : text field can now have a composite text as source of text
git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@5265 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
@@ -277,6 +277,8 @@ QString PartDynamicTextField::infoName() const{
|
|||||||
void PartDynamicTextField::setCompositeText(const QString &text)
|
void PartDynamicTextField::setCompositeText(const QString &text)
|
||||||
{
|
{
|
||||||
m_composite_text = text;
|
m_composite_text = text;
|
||||||
|
if(elementScene())
|
||||||
|
setPlainText(autonum::AssignVariables::replaceVariable(m_composite_text, elementScene()->elementInformation()));
|
||||||
emit compositeTextChanged(m_composite_text);
|
emit compositeTextChanged(m_composite_text);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -483,9 +485,11 @@ void PartDynamicTextField::paint(QPainter *painter, const QStyleOptionGraphicsIt
|
|||||||
*/
|
*/
|
||||||
void PartDynamicTextField::elementInfoChanged()
|
void PartDynamicTextField::elementInfoChanged()
|
||||||
{
|
{
|
||||||
|
if(!elementScene())
|
||||||
|
return;
|
||||||
|
|
||||||
if(m_text_from == DynamicElementTextItem::ElementInfo)
|
if(m_text_from == DynamicElementTextItem::ElementInfo)
|
||||||
{
|
setPlainText(elementScene()->elementInformation().value(m_info_name).toString());
|
||||||
DiagramContext dc = elementScene()->elementInformation();
|
else if (m_text_from == DynamicElementTextItem::CompositeText && elementScene())
|
||||||
setPlainText(dc.value(m_info_name).toString());
|
setPlainText(autonum::AssignVariables::replaceVariable(m_composite_text, elementScene()->elementInformation()));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#include "QPropertyUndoCommand/qpropertyundocommand.h"
|
#include "QPropertyUndoCommand/qpropertyundocommand.h"
|
||||||
#include "qetelementeditor.h"
|
#include "qetelementeditor.h"
|
||||||
#include "qetapp.h"
|
#include "qetapp.h"
|
||||||
|
#include "compositetexteditdialog.h"
|
||||||
|
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QGraphicsItem>
|
#include <QGraphicsItem>
|
||||||
@@ -277,3 +278,17 @@ void DynamicTextFieldEditor::on_m_text_from_cb_activated(int index)
|
|||||||
undoStack().push(undo);
|
undoStack().push(undo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DynamicTextFieldEditor::on_m_composite_text_pb_clicked()
|
||||||
|
{
|
||||||
|
CompositeTextEditDialog ctd(m_text_field.data()->compositeText(), this);
|
||||||
|
if(ctd.exec())
|
||||||
|
{
|
||||||
|
QString ct = ctd.plainText();
|
||||||
|
if(ct != m_text_field.data()->compositeText())
|
||||||
|
{
|
||||||
|
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_text_field.data(), "compositeText", m_text_field.data()->compositeText(), ctd.plainText());
|
||||||
|
undoStack().push(undo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -57,6 +57,8 @@ class DynamicTextFieldEditor : public ElementItemEditor
|
|||||||
void on_m_elmt_info_cb_activated(const QString &arg1);
|
void on_m_elmt_info_cb_activated(const QString &arg1);
|
||||||
void on_m_text_from_cb_activated(int index);
|
void on_m_text_from_cb_activated(int index);
|
||||||
|
|
||||||
|
void on_m_composite_text_pb_clicked();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::DynamicTextFieldEditor *ui;
|
Ui::DynamicTextFieldEditor *ui;
|
||||||
QPointer<PartDynamicTextField> m_text_field;
|
QPointer<PartDynamicTextField> m_text_field;
|
||||||
|
|||||||
@@ -19,6 +19,19 @@ CompositeTextEditDialog::CompositeTextEditDialog(DynamicElementTextItem *text, Q
|
|||||||
setUpComboBox();
|
setUpComboBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CompositeTextEditDialog::CompositeTextEditDialog(QString text, QWidget *parent) :
|
||||||
|
QDialog(parent),
|
||||||
|
ui(new Ui::CompositeTextEditDialog)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
m_default_text = text;
|
||||||
|
ui->m_plain_text_edit->setPlainText(m_default_text);
|
||||||
|
#if QT_VERSION >= 0x050300
|
||||||
|
ui->m_plain_text_edit->setPlaceholderText(tr("Entrée votre texte composé ici, en vous aidant des variables disponible"));
|
||||||
|
#endif
|
||||||
|
setUpComboBox();
|
||||||
|
}
|
||||||
|
|
||||||
CompositeTextEditDialog::~CompositeTextEditDialog() {
|
CompositeTextEditDialog::~CompositeTextEditDialog() {
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
@@ -38,6 +51,9 @@ QString CompositeTextEditDialog::plainText() const {
|
|||||||
void CompositeTextEditDialog::setUpComboBox()
|
void CompositeTextEditDialog::setUpComboBox()
|
||||||
{
|
{
|
||||||
QStringList qstrl;
|
QStringList qstrl;
|
||||||
|
|
||||||
|
if(m_text)
|
||||||
|
{
|
||||||
if(m_text->parentElement()->linkType() & Element::AllReport) //Special treatment for text owned by a folio report
|
if(m_text->parentElement()->linkType() & Element::AllReport) //Special treatment for text owned by a folio report
|
||||||
{
|
{
|
||||||
qstrl << "label";
|
qstrl << "label";
|
||||||
@@ -67,6 +83,11 @@ void CompositeTextEditDialog::setUpComboBox()
|
|||||||
qstrl << info;
|
qstrl << info;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qstrl = 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
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ class CompositeTextEditDialog : public QDialog
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CompositeTextEditDialog(DynamicElementTextItem *text, QWidget *parent = nullptr);
|
explicit CompositeTextEditDialog(DynamicElementTextItem *text, QWidget *parent = nullptr);
|
||||||
|
explicit CompositeTextEditDialog(QString text, QWidget *parent = nullptr);
|
||||||
~CompositeTextEditDialog() override;
|
~CompositeTextEditDialog() override;
|
||||||
|
|
||||||
QString plainText() const;
|
QString plainText() const;
|
||||||
|
|||||||
Reference in New Issue
Block a user