mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2025-12-18 13:30:34 +01:00
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:
@@ -604,16 +604,18 @@ ChangePropertiesCommand::ChangePropertiesCommand(ElementScene *scene, QString ty
|
||||
|
||||
ChangePropertiesCommand::~ChangePropertiesCommand() {}
|
||||
|
||||
void ChangePropertiesCommand::undo() {
|
||||
void ChangePropertiesCommand::undo()
|
||||
{
|
||||
m_scene->m_elmt_type = m_type.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_kindInfo = m_kind_info.last();
|
||||
m_scene->m_elmt_information = m_elmt_info.last();
|
||||
m_scene->setElementInfo(m_elmt_info.last());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -532,6 +532,15 @@ QETElementEditor* ElementScene::editor() const {
|
||||
return m_element_editor;
|
||||
}
|
||||
|
||||
void ElementScene::setElementInfo(DiagramContext dc)
|
||||
{
|
||||
if(m_elmt_information != dc)
|
||||
{
|
||||
m_elmt_information = dc;
|
||||
emit elementInfoChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief ElementScene::slot_select
|
||||
* Select the item in content, every others items in the scene are deselected
|
||||
|
||||
@@ -63,41 +63,30 @@ class ElementScene : public QGraphicsScene
|
||||
|
||||
// attributes
|
||||
private:
|
||||
/// List of localized names
|
||||
NamesList m_names_list;
|
||||
/// Extra informations
|
||||
QString m_informations;
|
||||
/// element type
|
||||
QString m_elmt_type;
|
||||
/// element kind info
|
||||
NamesList m_names_list; /// List of localized names
|
||||
QString m_informations; /// Extra informations
|
||||
QString m_elmt_type; /// element type
|
||||
DiagramContext m_elmt_kindInfo,
|
||||
m_elmt_information;
|
||||
/// QGraphicsItem manager
|
||||
m_elmt_information; /// element kind info
|
||||
QGIManager m_qgi_manager;
|
||||
/// Undo stack
|
||||
QUndoStack m_undo_stack;
|
||||
|
||||
/// Variables related to drawing
|
||||
|
||||
ESEventInterface *m_event_interface = nullptr;
|
||||
Behavior m_behavior;
|
||||
QETElementEditor *m_element_editor = nullptr;
|
||||
|
||||
/// Variables to manage the paste area on the scene
|
||||
QGraphicsRectItem *m_paste_area;
|
||||
QRectF m_defined_paste_area;
|
||||
|
||||
/// Variables to handle copy/paste with offset
|
||||
|
||||
QString m_last_copied;
|
||||
|
||||
/// Decorator item displayed when at least one item is selected
|
||||
ElementPrimitiveDecorator *m_decorator = nullptr;
|
||||
|
||||
int m_x_grid,
|
||||
m_y_grid;
|
||||
|
||||
///< Size of the horizontal grid step
|
||||
int m_x_grid;
|
||||
///< Size of the vertical grid step
|
||||
int m_y_grid;
|
||||
|
||||
// methods
|
||||
// methods
|
||||
public:
|
||||
void setEventInterface (ESEventInterface *event_interface);
|
||||
void clearEventInterface();
|
||||
@@ -109,6 +98,7 @@ class ElementScene : public QGraphicsScene
|
||||
void setInformations(const QString &);
|
||||
QString elementType () const {return m_elmt_type;}
|
||||
DiagramContext elementKindInfo () const {return m_elmt_kindInfo;}
|
||||
DiagramContext elementInformation() const {return m_elmt_information;}
|
||||
virtual int xGrid() const;
|
||||
virtual int yGrid() const;
|
||||
virtual void setGrid(int, int);
|
||||
@@ -129,6 +119,7 @@ class ElementScene : public QGraphicsScene
|
||||
void cut();
|
||||
void copy();
|
||||
QETElementEditor* editor() const;
|
||||
void setElementInfo(DiagramContext dc);
|
||||
|
||||
protected:
|
||||
void mouseMoveEvent (QGraphicsSceneMouseEvent *) override;
|
||||
@@ -169,16 +160,17 @@ class ElementScene : public QGraphicsScene
|
||||
void stackAction(ElementEditionCommand *);
|
||||
|
||||
signals:
|
||||
/// Signal emitted after one or several parts were added
|
||||
/// Signal emitted after one or several parts were added
|
||||
void partsAdded();
|
||||
/// Signal emitted after one or several parts were removed
|
||||
/// Signal emitted after one or several parts were removed
|
||||
void partsRemoved();
|
||||
/// Signal emitted when the zValue of one or several parts change
|
||||
/// Signal emitted when the zValue of one or several parts change
|
||||
void partsZValueChanged();
|
||||
/// Signal emitted when users have defined the copy/paste area
|
||||
/// Signal emitted when users have defined the copy/paste area
|
||||
void pasteAreaDefined(const QRectF &);
|
||||
/// Signal emitted when need zoomFit
|
||||
/// Signal emitted when need zoomFit
|
||||
void needZoomFit();
|
||||
void elementInfoChanged();
|
||||
};
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(ElementScene::ItemOptions)
|
||||
|
||||
@@ -54,6 +54,11 @@ PartDynamicTextField::PartDynamicTextField(QETElementEditor *editor, QGraphicsIt
|
||||
setTextFrom(DynamicElementTextItem::UserText);
|
||||
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
|
||||
@@ -106,6 +111,7 @@ const QDomElement PartDynamicTextField::toXml(QDomDocument &dom_doc) const
|
||||
root_element.setAttribute("font_size", font().pointSize());
|
||||
root_element.setAttribute("uuid", m_uuid.toString());
|
||||
root_element.setAttribute("frame", m_frame? "true" : "false");
|
||||
root_element.setAttribute("text_width", QString::number(m_text_width));
|
||||
|
||||
|
||||
QMetaEnum me = DynamicElementTextItem::textFromMetaEnum();
|
||||
@@ -130,14 +136,6 @@ const QDomElement PartDynamicTextField::toXml(QDomDocument &dom_doc) const
|
||||
dom_comp_text.appendChild(dom_doc.createTextNode(m_composite_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
|
||||
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());
|
||||
setFont(QETApp::diagramTextsFont(dom_elmt.attribute("font_size", QString::number(9)).toInt()));
|
||||
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();
|
||||
m_text_from = DynamicElementTextItem::TextFrom(me.keyToValue(dom_elmt.attribute("text_from").toStdString().data()));
|
||||
@@ -189,11 +188,6 @@ void PartDynamicTextField::fromXml(const QDomElement &dom_elmt)
|
||||
QDomElement dom_comp_text = dom_elmt.firstChildElement("composite_text");
|
||||
if(!dom_comp_text.isNull())
|
||||
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
|
||||
QDomElement dom_color = dom_elmt.firstChildElement("color");
|
||||
@@ -249,25 +243,6 @@ void PartDynamicTextField::setTextFrom(DynamicElementTextItem::TextFrom text_fro
|
||||
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
|
||||
* @return the text of this text
|
||||
@@ -364,6 +339,36 @@ bool PartDynamicTextField::frame() const
|
||||
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
|
||||
* @param event
|
||||
@@ -417,7 +422,16 @@ void PartDynamicTextField::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
QVariant PartDynamicTextField::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
|
||||
{
|
||||
if (change == QGraphicsItem::ItemPositionHasChanged || change == QGraphicsItem::ItemSceneHasChanged)
|
||||
{
|
||||
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))
|
||||
updateCurrentPartEditor();
|
||||
|
||||
@@ -441,25 +455,45 @@ void PartDynamicTextField::paint(QPainter *painter, const QStyleOptionGraphicsIt
|
||||
if(w > 2.5)
|
||||
w = 2.5;
|
||||
}
|
||||
|
||||
|
||||
QPen pen;
|
||||
pen.setColor(color());
|
||||
pen.setWidthF(w);
|
||||
painter->setPen(pen);
|
||||
painter->setRenderHint(QPainter::Antialiasing);
|
||||
|
||||
//Get the bounding rectangle of the text
|
||||
QRectF text_bounding = painter->boundingRect(boundingRect(), toPlainText());
|
||||
//Center text_bounding in the bounding rect of this
|
||||
text_bounding.moveTop((boundingRect().height()-text_bounding.height())/2);
|
||||
text_bounding.moveLeft((boundingRect().width() - text_bounding.width())/2);
|
||||
//adjust only for better visual
|
||||
text_bounding.adjust(-2,0,2,0);
|
||||
//Get the bounding rectangle of the text
|
||||
QSizeF size = document()->size();
|
||||
size.setWidth(document()->idealWidth());
|
||||
//Remove the margin. Size is exactly the bounding rect of the text
|
||||
size.rheight() -= document()->documentMargin()*2;
|
||||
size.rwidth() -= document()->documentMargin()*2;
|
||||
//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
|
||||
qreal ro = (qreal)fontSize()/3;
|
||||
painter->drawRoundedRect(text_bounding, ro, ro);
|
||||
painter->drawRoundedRect(QRectF(pos, size), ro, ro);
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ class PartDynamicTextField : public QGraphicsTextItem, public CustomElementPart
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QString tagg READ tagg WRITE setTagg NOTIFY taggChanged)
|
||||
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
|
||||
Q_PROPERTY(DynamicElementTextItem::TextFrom textFrom READ textFrom WRITE setTextFrom NOTIFY textFromChanged)
|
||||
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(int fontSize READ fontSize WRITE setFontSize NOTIFY fontSizeChanged)
|
||||
Q_PROPERTY(bool frame READ frame WRITE setFrame NOTIFY frameChanged)
|
||||
Q_PROPERTY(qreal textWidth READ textWidth WRITE setTextWidth NOTIFY textWidthChanged)
|
||||
|
||||
public:
|
||||
static bool canImportFromTextField(const QDomElement &dom_element);
|
||||
@@ -59,6 +59,7 @@ class PartDynamicTextField : public QGraphicsTextItem, public CustomElementPart
|
||||
void colorChanged(QColor color);
|
||||
void fontSizeChanged(int size);
|
||||
void frameChanged(bool frame);
|
||||
void textWidthChanged(qreal width);
|
||||
|
||||
public:
|
||||
PartDynamicTextField(QETElementEditor *editor, QGraphicsItem *parent = nullptr);
|
||||
@@ -68,6 +69,7 @@ class PartDynamicTextField : public QGraphicsTextItem, public CustomElementPart
|
||||
|
||||
QString name() const override;
|
||||
QString xmlName() const override;
|
||||
static QString xmlTaggName() {return QString("dynamic_text");}
|
||||
bool isUseless() const override {return false;}
|
||||
QRectF sceneGeometricRect() const override {return sceneBoundingRect();}
|
||||
void startUserTransformation(const QRectF &initial_selection_rect) override;
|
||||
@@ -79,8 +81,6 @@ class PartDynamicTextField : public QGraphicsTextItem, public CustomElementPart
|
||||
|
||||
DynamicElementTextItem::TextFrom textFrom() const;
|
||||
void setTextFrom (DynamicElementTextItem::TextFrom text_from);
|
||||
QString tagg() const;
|
||||
void setTagg(const QString &tagg);
|
||||
QString text() const;
|
||||
void setText(const QString &text);
|
||||
void setInfoName(const QString &info_name);
|
||||
@@ -93,6 +93,8 @@ class PartDynamicTextField : public QGraphicsTextItem, public CustomElementPart
|
||||
int fontSize()const;
|
||||
void setFrame(bool frame);
|
||||
bool frame() const;
|
||||
void setTextWidth(qreal width);
|
||||
void setPlainText(const QString &text);
|
||||
|
||||
protected:
|
||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
||||
@@ -101,18 +103,20 @@ class PartDynamicTextField : public QGraphicsTextItem, public CustomElementPart
|
||||
QVariant itemChange(GraphicsItemChange change, const QVariant &value) override;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||
|
||||
private:
|
||||
void elementInfoChanged();
|
||||
|
||||
private:
|
||||
QPointF m_origine_pos,
|
||||
m_saved_point;
|
||||
QString m_tagg,
|
||||
m_text,
|
||||
QString m_text,
|
||||
m_info_name,
|
||||
m_composite_text;
|
||||
|
||||
DynamicElementTextItem::TextFrom m_text_from = DynamicElementTextItem::UserText;
|
||||
QUuid m_uuid;
|
||||
|
||||
bool m_frame = false;
|
||||
bool m_frame = false,
|
||||
m_first_add = true;
|
||||
qreal m_text_width = -1;
|
||||
};
|
||||
|
||||
#endif // PARTDYNAMICTEXTFIELD_H
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#include "customelementpart.h"
|
||||
#include "partdynamictextfield.h"
|
||||
#include "QPropertyUndoCommand/qpropertyundocommand.h"
|
||||
#include "qetelementeditor.h"
|
||||
#include "qetapp.h"
|
||||
|
||||
#include <QPointer>
|
||||
#include <QGraphicsItem>
|
||||
@@ -34,6 +36,7 @@ DynamicTextFieldEditor::DynamicTextFieldEditor(QETElementEditor *editor, PartDyn
|
||||
ui->m_elmt_info_cb->setDisabled(true);
|
||||
if(text_field)
|
||||
setPart(text_field);
|
||||
fillInfoComboBox();
|
||||
}
|
||||
|
||||
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::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();});
|
||||
|
||||
return true;
|
||||
@@ -99,8 +103,27 @@ void DynamicTextFieldEditor::updateForm()
|
||||
ui->m_frame_cb->setChecked(m_text_field.data()->frame());
|
||||
ui->m_user_text_le->setText(m_text_field.data()->text());
|
||||
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());
|
||||
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()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @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()
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ class DynamicTextFieldEditor : public ElementItemEditor
|
||||
|
||||
private:
|
||||
void setColorPushButton(QColor color);
|
||||
void fillInfoComboBox();
|
||||
|
||||
private slots:
|
||||
void on_m_x_sb_editingFinished();
|
||||
@@ -52,6 +53,9 @@ class DynamicTextFieldEditor : public ElementItemEditor
|
||||
void on_m_size_sb_editingFinished();
|
||||
void on_m_color_pb_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:
|
||||
Ui::DynamicTextFieldEditor *ui;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>419</width>
|
||||
<width>299</width>
|
||||
<height>332</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -14,7 +14,7 @@
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<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">
|
||||
<item>
|
||||
<property name="text">
|
||||
@@ -33,107 +33,21 @@
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Couleur</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<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">
|
||||
<item row="7" column="1" colspan="2">
|
||||
<widget class="QPushButton" name="m_color_pb">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="1">
|
||||
<item row="8" column="1">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@@ -146,16 +60,16 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="4" column="1" colspan="6">
|
||||
<item row="4" column="1" colspan="2">
|
||||
<widget class="QComboBox" name="m_elmt_info_cb"/>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="6">
|
||||
<item row="3" column="1" colspan="2">
|
||||
<widget class="QLineEdit" name="m_user_text_le"/>
|
||||
</item>
|
||||
<item row="5" column="1" colspan="6">
|
||||
<item row="5" column="1" colspan="2">
|
||||
<widget class="QPushButton" name="m_composite_text_pb">
|
||||
<property name="text">
|
||||
<string/>
|
||||
<string>Texte composé</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@@ -166,7 +80,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1" colspan="6">
|
||||
<item row="6" column="1" colspan="2">
|
||||
<widget class="QSpinBox" name="m_size_sb"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
@@ -189,6 +103,102 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</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>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
||||
@@ -192,7 +192,7 @@ bool CustomElement::buildFromXml(const QDomElement &xml_def_elmt, int *state) {
|
||||
++ parsed_elements_count;
|
||||
|
||||
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;
|
||||
parseElement(qde, low_zoom_qp, false);
|
||||
|
||||
Reference in New Issue
Block a user