Element editor : dynamic text field can be set with element info as source of text.

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@5260 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
blacksun
2018-03-11 12:59:53 +00:00
parent 7384f22017
commit 275f20fa61
9 changed files with 336 additions and 178 deletions

View File

@@ -604,16 +604,18 @@ ChangePropertiesCommand::ChangePropertiesCommand(ElementScene *scene, QString ty
ChangePropertiesCommand::~ChangePropertiesCommand() {} ChangePropertiesCommand::~ChangePropertiesCommand() {}
void ChangePropertiesCommand::undo() { void ChangePropertiesCommand::undo()
{
m_scene->m_elmt_type = m_type.first(); m_scene->m_elmt_type = m_type.first();
m_scene->m_elmt_kindInfo = m_kind_info.first(); m_scene->m_elmt_kindInfo = m_kind_info.first();
m_scene->m_elmt_information = m_elmt_info.first(); m_scene->setElementInfo(m_elmt_info.first());
} }
void ChangePropertiesCommand::redo() { void ChangePropertiesCommand::redo()
{
m_scene->m_elmt_type = m_type.last(); m_scene->m_elmt_type = m_type.last();
m_scene->m_elmt_kindInfo = m_kind_info.last(); m_scene->m_elmt_kindInfo = m_kind_info.last();
m_scene->m_elmt_information = m_elmt_info.last(); m_scene->setElementInfo(m_elmt_info.last());
} }

View File

@@ -532,6 +532,15 @@ QETElementEditor* ElementScene::editor() const {
return m_element_editor; return m_element_editor;
} }
void ElementScene::setElementInfo(DiagramContext dc)
{
if(m_elmt_information != dc)
{
m_elmt_information = dc;
emit elementInfoChanged();
}
}
/** /**
* @brief ElementScene::slot_select * @brief ElementScene::slot_select
* Select the item in content, every others items in the scene are deselected * Select the item in content, every others items in the scene are deselected

View File

@@ -63,39 +63,28 @@ class ElementScene : public QGraphicsScene
// attributes // attributes
private: private:
/// List of localized names NamesList m_names_list; /// List of localized names
NamesList m_names_list; QString m_informations; /// Extra informations
/// Extra informations QString m_elmt_type; /// element type
QString m_informations;
/// element type
QString m_elmt_type;
/// element kind info
DiagramContext m_elmt_kindInfo, DiagramContext m_elmt_kindInfo,
m_elmt_information; m_elmt_information; /// element kind info
/// QGraphicsItem manager
QGIManager m_qgi_manager; QGIManager m_qgi_manager;
/// Undo stack
QUndoStack m_undo_stack; QUndoStack m_undo_stack;
/// Variables related to drawing
ESEventInterface *m_event_interface = nullptr; ESEventInterface *m_event_interface = nullptr;
Behavior m_behavior; Behavior m_behavior;
QETElementEditor *m_element_editor = nullptr; QETElementEditor *m_element_editor = nullptr;
/// Variables to manage the paste area on the scene
QGraphicsRectItem *m_paste_area; QGraphicsRectItem *m_paste_area;
QRectF m_defined_paste_area; QRectF m_defined_paste_area;
/// Variables to handle copy/paste with offset
QString m_last_copied; QString m_last_copied;
/// Decorator item displayed when at least one item is selected /// Decorator item displayed when at least one item is selected
ElementPrimitiveDecorator *m_decorator = nullptr; ElementPrimitiveDecorator *m_decorator = nullptr;
///< Size of the horizontal grid step int m_x_grid,
int m_x_grid; m_y_grid;
///< Size of the vertical grid step
int m_y_grid;
// methods // methods
public: public:
@@ -109,6 +98,7 @@ class ElementScene : public QGraphicsScene
void setInformations(const QString &); void setInformations(const QString &);
QString elementType () const {return m_elmt_type;} QString elementType () const {return m_elmt_type;}
DiagramContext elementKindInfo () const {return m_elmt_kindInfo;} DiagramContext elementKindInfo () const {return m_elmt_kindInfo;}
DiagramContext elementInformation() const {return m_elmt_information;}
virtual int xGrid() const; virtual int xGrid() const;
virtual int yGrid() const; virtual int yGrid() const;
virtual void setGrid(int, int); virtual void setGrid(int, int);
@@ -129,6 +119,7 @@ class ElementScene : public QGraphicsScene
void cut(); void cut();
void copy(); void copy();
QETElementEditor* editor() const; QETElementEditor* editor() const;
void setElementInfo(DiagramContext dc);
protected: protected:
void mouseMoveEvent (QGraphicsSceneMouseEvent *) override; void mouseMoveEvent (QGraphicsSceneMouseEvent *) override;
@@ -179,6 +170,7 @@ class ElementScene : public QGraphicsScene
void pasteAreaDefined(const QRectF &); void pasteAreaDefined(const QRectF &);
/// Signal emitted when need zoomFit /// Signal emitted when need zoomFit
void needZoomFit(); void needZoomFit();
void elementInfoChanged();
}; };
Q_DECLARE_OPERATORS_FOR_FLAGS(ElementScene::ItemOptions) Q_DECLARE_OPERATORS_FOR_FLAGS(ElementScene::ItemOptions)

View File

@@ -54,6 +54,11 @@ PartDynamicTextField::PartDynamicTextField(QETElementEditor *editor, QGraphicsIt
setTextFrom(DynamicElementTextItem::UserText); setTextFrom(DynamicElementTextItem::UserText);
setFlags(QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemSendsGeometryChanges | QGraphicsItem::ItemIsMovable); setFlags(QGraphicsItem::ItemIsSelectable | QGraphicsItem::ItemSendsGeometryChanges | QGraphicsItem::ItemIsMovable);
//Option when text is displayed in multiple line
QTextOption option = document()->defaultTextOption();
option.setAlignment(Qt::AlignHCenter);
option.setWrapMode(QTextOption::WordWrap);
document()->setDefaultTextOption(option);
} }
QString PartDynamicTextField::name() const QString PartDynamicTextField::name() const
@@ -106,6 +111,7 @@ const QDomElement PartDynamicTextField::toXml(QDomDocument &dom_doc) const
root_element.setAttribute("font_size", font().pointSize()); root_element.setAttribute("font_size", font().pointSize());
root_element.setAttribute("uuid", m_uuid.toString()); root_element.setAttribute("uuid", m_uuid.toString());
root_element.setAttribute("frame", m_frame? "true" : "false"); root_element.setAttribute("frame", m_frame? "true" : "false");
root_element.setAttribute("text_width", QString::number(m_text_width));
QMetaEnum me = DynamicElementTextItem::textFromMetaEnum(); QMetaEnum me = DynamicElementTextItem::textFromMetaEnum();
@@ -131,14 +137,6 @@ const QDomElement PartDynamicTextField::toXml(QDomDocument &dom_doc) const
root_element.appendChild(dom_comp_text); root_element.appendChild(dom_comp_text);
} }
//tagg
if (!m_tagg.isEmpty())
{
QDomElement dom_tagg = dom_doc.createElement("tagg");
dom_tagg.appendChild(dom_doc.createTextNode(m_tagg));
root_element.appendChild(dom_tagg);
}
//Color //Color
if(color() != QColor(Qt::black)) if(color() != QColor(Qt::black))
{ {
@@ -167,7 +165,8 @@ void PartDynamicTextField::fromXml(const QDomElement &dom_elmt)
QGraphicsTextItem::setRotation(dom_elmt.attribute("rotation", QString::number(0)).toDouble()); QGraphicsTextItem::setRotation(dom_elmt.attribute("rotation", QString::number(0)).toDouble());
setFont(QETApp::diagramTextsFont(dom_elmt.attribute("font_size", QString::number(9)).toInt())); setFont(QETApp::diagramTextsFont(dom_elmt.attribute("font_size", QString::number(9)).toInt()));
m_uuid = QUuid(dom_elmt.attribute("uuid", QUuid::createUuid().toString())); m_uuid = QUuid(dom_elmt.attribute("uuid", QUuid::createUuid().toString()));
m_frame = dom_elmt.attribute("frame", "false") == "true"? true : false; setFrame(dom_elmt.attribute("frame", "false") == "true"? true : false);
setTextWidth(dom_elmt.attribute("text_width", QString::number(-1)).toDouble());
QMetaEnum me = DynamicElementTextItem::textFromMetaEnum(); QMetaEnum me = DynamicElementTextItem::textFromMetaEnum();
m_text_from = DynamicElementTextItem::TextFrom(me.keyToValue(dom_elmt.attribute("text_from").toStdString().data())); m_text_from = DynamicElementTextItem::TextFrom(me.keyToValue(dom_elmt.attribute("text_from").toStdString().data()));
@@ -190,11 +189,6 @@ void PartDynamicTextField::fromXml(const QDomElement &dom_elmt)
if(!dom_comp_text.isNull()) if(!dom_comp_text.isNull())
m_composite_text = dom_comp_text.text(); m_composite_text = dom_comp_text.text();
//tagg
QDomElement dom_tagg = dom_elmt.firstChildElement("tagg");
if (!dom_tagg.isNull())
m_tagg = dom_tagg.text();
//Color //Color
QDomElement dom_color = dom_elmt.firstChildElement("color"); QDomElement dom_color = dom_elmt.firstChildElement("color");
if(!dom_color.isNull()) if(!dom_color.isNull())
@@ -249,25 +243,6 @@ void PartDynamicTextField::setTextFrom(DynamicElementTextItem::TextFrom text_fro
emit textFromChanged(m_text_from); emit textFromChanged(m_text_from);
} }
/**
* @brief PartDynamicTextField::tagg
* @return the tagg of this text
*/
QString PartDynamicTextField::tagg() const {
return m_tagg;
}
/**
* @brief PartDynamicTextField::setTagg
* set the taggof this text
* @param tagg
*/
void PartDynamicTextField::setTagg(const QString &tagg)
{
m_tagg = tagg;
emit taggChanged(m_tagg);
}
/** /**
* @brief PartDynamicTextField::text * @brief PartDynamicTextField::text
* @return the text of this text * @return the text of this text
@@ -364,6 +339,36 @@ bool PartDynamicTextField::frame() const
return m_frame; return m_frame;
} }
void PartDynamicTextField::setTextWidth(qreal width)
{
this->document()->setTextWidth(width);
//Adjust the width, to ideal width if needed
if(width > 0 && document()->size().width() > width)
document()->setTextWidth(document()->idealWidth());
m_text_width = document()->textWidth();
emit textWidthChanged(m_text_width);
}
void PartDynamicTextField::setPlainText(const QString &text)
{
QGraphicsTextItem::setPlainText(text);
//User define a text width
if(m_text_width > 0)
{
if(document()->size().width() > m_text_width)
{
document()->setTextWidth(m_text_width);
if(document()->size().width() > m_text_width)
{
document()->setTextWidth(document()->idealWidth());
}
}
}
}
/** /**
* @brief PartDynamicTextField::mouseMoveEvent * @brief PartDynamicTextField::mouseMoveEvent
* @param event * @param event
@@ -417,7 +422,16 @@ void PartDynamicTextField::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
QVariant PartDynamicTextField::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) QVariant PartDynamicTextField::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
{ {
if (change == QGraphicsItem::ItemPositionHasChanged || change == QGraphicsItem::ItemSceneHasChanged) if (change == QGraphicsItem::ItemPositionHasChanged || change == QGraphicsItem::ItemSceneHasChanged)
{
updateCurrentPartEditor(); updateCurrentPartEditor();
if(change == QGraphicsItem::ItemSceneHasChanged &&
m_first_add &&
elementScene() != nullptr)
{
connect(elementScene(), &ElementScene::elementInfoChanged, this, &PartDynamicTextField::elementInfoChanged);
m_first_add = false;
}
}
else if ((change == QGraphicsItem::ItemSelectedHasChanged) && (value.toBool() == true)) else if ((change == QGraphicsItem::ItemSelectedHasChanged) && (value.toBool() == true))
updateCurrentPartEditor(); updateCurrentPartEditor();
@@ -449,17 +463,37 @@ void PartDynamicTextField::paint(QPainter *painter, const QStyleOptionGraphicsIt
painter->setRenderHint(QPainter::Antialiasing); painter->setRenderHint(QPainter::Antialiasing);
//Get the bounding rectangle of the text //Get the bounding rectangle of the text
QRectF text_bounding = painter->boundingRect(boundingRect(), toPlainText()); QSizeF size = document()->size();
//Center text_bounding in the bounding rect of this size.setWidth(document()->idealWidth());
text_bounding.moveTop((boundingRect().height()-text_bounding.height())/2); //Remove the margin. Size is exactly the bounding rect of the text
text_bounding.moveLeft((boundingRect().width() - text_bounding.width())/2); size.rheight() -= document()->documentMargin()*2;
//adjust only for better visual size.rwidth() -= document()->documentMargin()*2;
text_bounding.adjust(-2,0,2,0); //Add a little margin only for a better visual;
size.rheight() += 2;
size.rwidth() += 2;
//The pos of the rect
QPointF pos = boundingRect().center();
pos.rx() -= size.width()/2;
pos.ry() -= size.height()/2;
//Adjust the rounding of the rectangle according to the size of the font //Adjust the rounding of the rectangle according to the size of the font
qreal ro = (qreal)fontSize()/3; qreal ro = (qreal)fontSize()/3;
painter->drawRoundedRect(text_bounding, ro, ro); painter->drawRoundedRect(QRectF(pos, size), ro, ro);
painter->restore(); painter->restore();
} }
} }
/**
* @brief PartDynamicTextField::elementInfoChanged
* Used to up to date this text field, when the element information (see elementScene) changed
*/
void PartDynamicTextField::elementInfoChanged()
{
if(m_text_from == DynamicElementTextItem::ElementInfo)
{
DiagramContext dc = elementScene()->elementInformation();
setPlainText(dc.value(m_info_name).toString());
}
}

View File

@@ -33,7 +33,6 @@ class PartDynamicTextField : public QGraphicsTextItem, public CustomElementPart
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(QString tagg READ tagg WRITE setTagg NOTIFY taggChanged)
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged) Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
Q_PROPERTY(DynamicElementTextItem::TextFrom textFrom READ textFrom WRITE setTextFrom NOTIFY textFromChanged) Q_PROPERTY(DynamicElementTextItem::TextFrom textFrom READ textFrom WRITE setTextFrom NOTIFY textFromChanged)
Q_PROPERTY(QString infoName READ infoName WRITE setInfoName NOTIFY infoNameChanged) Q_PROPERTY(QString infoName READ infoName WRITE setInfoName NOTIFY infoNameChanged)
@@ -41,6 +40,7 @@ class PartDynamicTextField : public QGraphicsTextItem, public CustomElementPart
Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged) Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
Q_PROPERTY(int fontSize READ fontSize WRITE setFontSize NOTIFY fontSizeChanged) Q_PROPERTY(int fontSize READ fontSize WRITE setFontSize NOTIFY fontSizeChanged)
Q_PROPERTY(bool frame READ frame WRITE setFrame NOTIFY frameChanged) Q_PROPERTY(bool frame READ frame WRITE setFrame NOTIFY frameChanged)
Q_PROPERTY(qreal textWidth READ textWidth WRITE setTextWidth NOTIFY textWidthChanged)
public: public:
static bool canImportFromTextField(const QDomElement &dom_element); static bool canImportFromTextField(const QDomElement &dom_element);
@@ -59,6 +59,7 @@ class PartDynamicTextField : public QGraphicsTextItem, public CustomElementPart
void colorChanged(QColor color); void colorChanged(QColor color);
void fontSizeChanged(int size); void fontSizeChanged(int size);
void frameChanged(bool frame); void frameChanged(bool frame);
void textWidthChanged(qreal width);
public: public:
PartDynamicTextField(QETElementEditor *editor, QGraphicsItem *parent = nullptr); PartDynamicTextField(QETElementEditor *editor, QGraphicsItem *parent = nullptr);
@@ -68,6 +69,7 @@ class PartDynamicTextField : public QGraphicsTextItem, public CustomElementPart
QString name() const override; QString name() const override;
QString xmlName() const override; QString xmlName() const override;
static QString xmlTaggName() {return QString("dynamic_text");}
bool isUseless() const override {return false;} bool isUseless() const override {return false;}
QRectF sceneGeometricRect() const override {return sceneBoundingRect();} QRectF sceneGeometricRect() const override {return sceneBoundingRect();}
void startUserTransformation(const QRectF &initial_selection_rect) override; void startUserTransformation(const QRectF &initial_selection_rect) override;
@@ -79,8 +81,6 @@ class PartDynamicTextField : public QGraphicsTextItem, public CustomElementPart
DynamicElementTextItem::TextFrom textFrom() const; DynamicElementTextItem::TextFrom textFrom() const;
void setTextFrom (DynamicElementTextItem::TextFrom text_from); void setTextFrom (DynamicElementTextItem::TextFrom text_from);
QString tagg() const;
void setTagg(const QString &tagg);
QString text() const; QString text() const;
void setText(const QString &text); void setText(const QString &text);
void setInfoName(const QString &info_name); void setInfoName(const QString &info_name);
@@ -93,6 +93,8 @@ class PartDynamicTextField : public QGraphicsTextItem, public CustomElementPart
int fontSize()const; int fontSize()const;
void setFrame(bool frame); void setFrame(bool frame);
bool frame() const; bool frame() const;
void setTextWidth(qreal width);
void setPlainText(const QString &text);
protected: protected:
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override; void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
@@ -101,18 +103,20 @@ class PartDynamicTextField : public QGraphicsTextItem, public CustomElementPart
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override; QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
private:
void elementInfoChanged();
private: private:
QPointF m_origine_pos, QPointF m_origine_pos,
m_saved_point; m_saved_point;
QString m_tagg, QString m_text,
m_text,
m_info_name, m_info_name,
m_composite_text; m_composite_text;
DynamicElementTextItem::TextFrom m_text_from = DynamicElementTextItem::UserText; DynamicElementTextItem::TextFrom m_text_from = DynamicElementTextItem::UserText;
QUuid m_uuid; QUuid m_uuid;
bool m_frame = false,
bool m_frame = false; m_first_add = true;
qreal m_text_width = -1;
}; };
#endif // PARTDYNAMICTEXTFIELD_H #endif // PARTDYNAMICTEXTFIELD_H

View File

@@ -20,6 +20,8 @@
#include "customelementpart.h" #include "customelementpart.h"
#include "partdynamictextfield.h" #include "partdynamictextfield.h"
#include "QPropertyUndoCommand/qpropertyundocommand.h" #include "QPropertyUndoCommand/qpropertyundocommand.h"
#include "qetelementeditor.h"
#include "qetapp.h"
#include <QPointer> #include <QPointer>
#include <QGraphicsItem> #include <QGraphicsItem>
@@ -34,6 +36,7 @@ DynamicTextFieldEditor::DynamicTextFieldEditor(QETElementEditor *editor, PartDyn
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();
} }
DynamicTextFieldEditor::~DynamicTextFieldEditor() DynamicTextFieldEditor::~DynamicTextFieldEditor()
@@ -75,6 +78,7 @@ bool DynamicTextFieldEditor::setPart(CustomElementPart *part)
m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::infoNameChanged, [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::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::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();}); m_connection_list << connect(m_text_field.data(), &PartDynamicTextField::compositeTextChanged, [this]() {this->updateForm();});
return true; return true;
@@ -99,8 +103,27 @@ void DynamicTextFieldEditor::updateForm()
ui->m_frame_cb->setChecked(m_text_field.data()->frame()); ui->m_frame_cb->setChecked(m_text_field.data()->frame());
ui->m_user_text_le->setText(m_text_field.data()->text()); ui->m_user_text_le->setText(m_text_field.data()->text());
ui->m_size_sb->setValue(m_text_field.data()->fontSize()); ui->m_size_sb->setValue(m_text_field.data()->fontSize());
ui->m_tagg_le->setText(m_text_field.data()->tagg());
setColorPushButton(m_text_field.data()->color()); setColorPushButton(m_text_field.data()->color());
ui->m_width_sb->setValue(m_text_field.data()->textWidth());
switch (m_text_field.data()->textFrom())
{
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;
case DynamicElementTextItem::CompositeText:
ui->m_text_from_cb->setCurrentIndex(2);
default:
break;
}
on_m_text_from_cb_activated(ui->m_text_from_cb->currentIndex()); //For enable the good widget
} }
} }
@@ -111,6 +134,32 @@ void DynamicTextFieldEditor::setColorPushButton(QColor color)
ui->m_color_pb->setStyleSheet(QString("background-color: %1; min-height: 1.5em; border-style: outset; border-width: 2px; border-color: gray; border-radius: 4px;").arg(color.name())); ui->m_color_pb->setStyleSheet(QString("background-color: %1; min-height: 1.5em; border-style: outset; border-width: 2px; border-color: gray; border-radius: 4px;").arg(color.name()));
} }
/**
* @brief DynamicTextFieldEditor::fillInfoComboBox
* Fill the combo box "element information"
*/
void DynamicTextFieldEditor::fillInfoComboBox()
{
ui->m_elmt_info_cb->clear();
QStringList strl;
QString type = elementEditor()->elementScene()->elementType();
if(type.contains("report"))
strl << "function" << "tension-protocol";
else
strl = QETApp::elementInfoKeys();
//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
QMap <QString, QString> info_map;
for(QString str : strl)
info_map.insert(QETApp::elementTranslatedInfoKey(str), str);
for (QString key : info_map.keys())
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()
{ {
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_text_field, "x", m_text_field.data()->x(), ui->m_x_sb->value()); QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_text_field, "x", m_text_field.data()->x(), ui->m_x_sb->value());
@@ -174,3 +223,57 @@ void DynamicTextFieldEditor::on_m_frame_cb_clicked()
undoStack().push(undo); undoStack().push(undo);
} }
} }
void DynamicTextFieldEditor::on_m_width_sb_editingFinished()
{
qreal width = (qreal)ui->m_width_sb->value();
if(width != m_text_field.data()->textWidth())
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_text_field, "textWidth", m_text_field.data()->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)
QString info = ui->m_elmt_info_cb->currentData().toString();
if(info != m_text_field.data()->infoName())
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_text_field, "infoName", m_text_field.data()->infoName(), info);
undo->setText(tr("Modifier l'information d'un texte"));
undoStack().push(undo);
m_text_field.data()->setPlainText(elementEditor()->elementScene()->elementInformation().value(m_text_field.data()->infoName()).toString());
}
}
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)
ui->m_elmt_info_cb->setEnabled(true);
else
ui->m_composite_text_pb->setEnabled(true);
DynamicElementTextItem::TextFrom tf;
if(index == 0) tf = DynamicElementTextItem::UserText;
else if(index == 1) tf = DynamicElementTextItem::ElementInfo;
else tf = DynamicElementTextItem::CompositeText;
if(tf != m_text_field.data()->textFrom())
{
QPropertyUndoCommand *undo = new QPropertyUndoCommand(m_text_field, "textFrom", m_text_field.data()->textFrom(), tf);
undo->setText(tr("Modifier la source de texte, d'un texte"));
undoStack().push(undo);
}
}

View File

@@ -43,6 +43,7 @@ class DynamicTextFieldEditor : public ElementItemEditor
private: private:
void setColorPushButton(QColor color); void setColorPushButton(QColor color);
void fillInfoComboBox();
private slots: private slots:
void on_m_x_sb_editingFinished(); void on_m_x_sb_editingFinished();
@@ -52,6 +53,9 @@ class DynamicTextFieldEditor : public ElementItemEditor
void on_m_size_sb_editingFinished(); void on_m_size_sb_editingFinished();
void on_m_color_pb_clicked(); void on_m_color_pb_clicked();
void on_m_frame_cb_clicked(); void on_m_frame_cb_clicked();
void on_m_width_sb_editingFinished();
void on_m_elmt_info_cb_activated(const QString &arg1);
void on_m_text_from_cb_activated(int index);
private: private:
Ui::DynamicTextFieldEditor *ui; Ui::DynamicTextFieldEditor *ui;

View File

@@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>419</width> <width>299</width>
<height>332</height> <height>332</height>
</rect> </rect>
</property> </property>
@@ -14,7 +14,7 @@
<string>Form</string> <string>Form</string>
</property> </property>
<layout class="QGridLayout" name="gridLayout"> <layout class="QGridLayout" name="gridLayout">
<item row="2" column="1" colspan="6"> <item row="2" column="1" colspan="2">
<widget class="QComboBox" name="m_text_from_cb"> <widget class="QComboBox" name="m_text_from_cb">
<item> <item>
<property name="text"> <property name="text">
@@ -33,107 +33,21 @@
</item> </item>
</widget> </widget>
</item> </item>
<item row="8" column="0"> <item row="7" column="0">
<widget class="QLabel" name="label_3"> <widget class="QLabel" name="label_3">
<property name="text"> <property name="text">
<string>Couleur</string> <string>Couleur</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="7" column="0"> <item row="7" column="1" colspan="2">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Tagg</string>
</property>
</widget>
</item>
<item row="7" column="1" colspan="6">
<widget class="QLineEdit" name="m_tagg_le"/>
</item>
<item row="0" column="0" colspan="7">
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_5">
<property name="text">
<string>X</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="m_x_sb">
<property name="minimum">
<double>-5000.000000000000000</double>
</property>
<property name="maximum">
<double>5000.000000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_6">
<property name="text">
<string>Y</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="m_y_sb">
<property name="minimum">
<double>-5000.000000000000000</double>
</property>
<property name="maximum">
<double>5000.000000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_7">
<property name="text">
<string>Rotation</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="m_rotation_sb">
<property name="maximum">
<number>359</number>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="m_frame_cb">
<property name="text">
<string>cadre</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="8" column="1" colspan="6">
<widget class="QPushButton" name="m_color_pb"> <widget class="QPushButton" name="m_color_pb">
<property name="text"> <property name="text">
<string/> <string/>
</property> </property>
</widget> </widget>
</item> </item>
<item row="9" column="1"> <item row="8" column="1">
<spacer name="verticalSpacer"> <spacer name="verticalSpacer">
<property name="orientation"> <property name="orientation">
<enum>Qt::Vertical</enum> <enum>Qt::Vertical</enum>
@@ -146,16 +60,16 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="4" column="1" colspan="6"> <item row="4" column="1" colspan="2">
<widget class="QComboBox" name="m_elmt_info_cb"/> <widget class="QComboBox" name="m_elmt_info_cb"/>
</item> </item>
<item row="3" column="1" colspan="6"> <item row="3" column="1" colspan="2">
<widget class="QLineEdit" name="m_user_text_le"/> <widget class="QLineEdit" name="m_user_text_le"/>
</item> </item>
<item row="5" column="1" colspan="6"> <item row="5" column="1" colspan="2">
<widget class="QPushButton" name="m_composite_text_pb"> <widget class="QPushButton" name="m_composite_text_pb">
<property name="text"> <property name="text">
<string/> <string>Texte composé</string>
</property> </property>
</widget> </widget>
</item> </item>
@@ -166,7 +80,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="1" colspan="6"> <item row="6" column="1" colspan="2">
<widget class="QSpinBox" name="m_size_sb"/> <widget class="QSpinBox" name="m_size_sb"/>
</item> </item>
<item row="2" column="0"> <item row="2" column="0">
@@ -189,6 +103,102 @@
</property> </property>
</spacer> </spacer>
</item> </item>
<item row="0" column="0" colspan="3">
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="1">
<widget class="QDoubleSpinBox" name="m_x_sb">
<property name="minimum">
<double>-5000.000000000000000</double>
</property>
<property name="maximum">
<double>5000.000000000000000</double>
</property>
</widget>
</item>
<item row="0" column="6">
<widget class="QCheckBox" name="m_frame_cb">
<property name="text">
<string>cadre</string>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QSpinBox" name="m_rotation_sb">
<property name="maximum">
<number>359</number>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QLabel" name="label_7">
<property name="text">
<string>Rotation</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>X</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="5">
<widget class="QSpinBox" name="m_width_sb">
<property name="minimum">
<number>-1</number>
</property>
<property name="maximum">
<number>500</number>
</property>
</widget>
</item>
<item row="1" column="4">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Largeur</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Y</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QDoubleSpinBox" name="m_y_sb">
<property name="minimum">
<double>-5000.000000000000000</double>
</property>
<property name="maximum">
<double>5000.000000000000000</double>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<resources/> <resources/>

View File

@@ -192,7 +192,7 @@ bool CustomElement::buildFromXml(const QDomElement &xml_def_elmt, int *state) {
++ parsed_elements_count; ++ parsed_elements_count;
QString current_tag = qde.tagName(); QString current_tag = qde.tagName();
if (current_tag != "terminal" && current_tag != "input" && current_tag != DynamicElementTextItem::xmlTaggName()) if (current_tag != "terminal" && current_tag != "input" && current_tag != PartDynamicTextField::xmlTaggName())
{ {
forbid_antialiasing = true; forbid_antialiasing = true;
parseElement(qde, low_zoom_qp, false); parseElement(qde, low_zoom_qp, false);