[qet] qet/qet: [5182] Dynamic element text item : remove the "tagg" property: |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/qet Archives
]
Revision: 5182
Author: blacksun
Date: 2017-12-13 22:15:05 +0100 (Wed, 13 Dec 2017)
Log Message:
-----------
Dynamic element text item : remove the "tagg" property:
Tree Widget for edit the element text item :
-Change a value of a spinbox with the mouse wheel, apply the change in live (no need to press enter or leave focus).
-Remove the sub-level of source of text.
Modified Paths:
--------------
trunk/sources/qetgraphicsitem/dynamicelementtextitem.cpp
trunk/sources/qetgraphicsitem/dynamicelementtextitem.h
trunk/sources/ui/dynamicelementtextmodel.cpp
trunk/sources/ui/dynamicelementtextmodel.h
Modified: trunk/sources/qetgraphicsitem/dynamicelementtextitem.cpp
===================================================================
--- trunk/sources/qetgraphicsitem/dynamicelementtextitem.cpp 2017-12-13 04:14:16 UTC (rev 5181)
+++ trunk/sources/qetgraphicsitem/dynamicelementtextitem.cpp 2017-12-13 21:15:05 UTC (rev 5182)
@@ -139,14 +139,6 @@
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))
@@ -208,11 +200,6 @@
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");
@@ -357,25 +344,6 @@
}
/**
- * @brief DynamicElementTextItem::tagg
- * @return the tagg of this text
- */
-QString DynamicElementTextItem::tagg() const {
- return m_tagg;
-}
-
-/**
- * @brief DynamicElementTextItem::setTagg
- * set the taggof this text
- * @param tagg
- */
-void DynamicElementTextItem::setTagg(const QString &tagg)
-{
- m_tagg = tagg;
- emit taggChanged(m_tagg);
-}
-
-/**
* @brief DynamicElementTextItem::text
* @return the text of this text
*/
Modified: trunk/sources/qetgraphicsitem/dynamicelementtextitem.h
===================================================================
--- trunk/sources/qetgraphicsitem/dynamicelementtextitem.h 2017-12-13 04:14:16 UTC (rev 5181)
+++ trunk/sources/qetgraphicsitem/dynamicelementtextitem.h 2017-12-13 21:15:05 UTC (rev 5182)
@@ -40,7 +40,6 @@
Q_OBJECT
- Q_PROPERTY(QString tagg READ tagg WRITE setTagg NOTIFY taggChanged)
Q_PROPERTY(QString text READ text WRITE setText NOTIFY textChanged)
Q_PROPERTY(TextFrom textFrom READ textFrom WRITE setTextFrom NOTIFY textFromChanged)
Q_PROPERTY(QString infoName READ infoName WRITE setInfoName NOTIFY infoNameChanged)
@@ -58,7 +57,6 @@
int type() const override {return Type;}
signals:
- void taggChanged(QString tagg);
void textChanged(QString text);
void textFromChanged(DynamicElementTextItem::TextFrom text_from);
void infoNameChanged(QString info);
@@ -84,8 +82,6 @@
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);
static QString xmlTaggName() {return QString("dynamic_elmt_text");}
@@ -129,8 +125,7 @@
m_master_element,
m_other_report;
QPointer <Conductor> m_watched_conductor;
- QString m_tagg,
- m_text,
+ QString m_text,
m_info_name,
m_composite_text,
m_report_formula,
Modified: trunk/sources/ui/dynamicelementtextmodel.cpp
===================================================================
--- trunk/sources/ui/dynamicelementtextmodel.cpp 2017-12-13 04:14:16 UTC (rev 5181)
+++ trunk/sources/ui/dynamicelementtextmodel.cpp 2017-12-13 21:15:05 UTC (rev 5182)
@@ -34,6 +34,21 @@
#include "diagram.h"
#include "addelementtextcommand.h"
+int src_txt_row = 0;
+int usr_txt_row = 1;
+int info_txt_row = 2;
+int compo_txt_row = 3;
+int size_txt_row = 4;
+int color_txt_row = 5;
+int frame_txt_row = 6;
+int x_txt_row = 7;
+int y_txt_row = 8;
+int rot_txt_row = 9;
+
+int align_grp_row = 0;
+int rot_grp_row = 1;
+int adjust_grp_row = 2;
+
DynamicElementTextModel::DynamicElementTextModel(Element *element, QObject *parent) :
QStandardItemModel(parent),
m_element(element)
@@ -133,7 +148,7 @@
qsi_list.clear();
qsi_list << usr << usra;
- src->appendRow(qsi_list);
+ qsi->appendRow(qsi_list);
//Info text
QStandardItem *info = new QStandardItem(tr("Information"));
@@ -146,7 +161,7 @@
qsi_list.clear();
qsi_list << info << infoa;
- src->appendRow(qsi_list);
+ qsi->appendRow(qsi_list);
//Composite text
QStandardItem *composite = new QStandardItem(tr("Texte composé"));
@@ -164,18 +179,6 @@
qsi_list.clear();
qsi_list << composite << compositea;
- src->appendRow(qsi_list);
-
- //Tagg
- QStandardItem *tagg = new QStandardItem(tr("Tagg"));
- tagg->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
-
- QStandardItem *tagga = new QStandardItem(deti->tagg());
- tagga->setData(DynamicElementTextModel::tagg, Qt::UserRole+1);
- tagga->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
-
- qsi_list.clear();
- qsi_list << tagg << tagga;
qsi->appendRow(qsi_list);
//Size
@@ -406,7 +409,7 @@
QStandardItem *text_qsi = m_texts_list.value(deti);
- QString from = text_qsi->child(0,1)->data(Qt::DisplayRole).toString();
+ QString from = text_qsi->child(src_txt_row,1)->data(Qt::DisplayRole).toString();
if ((from == tr("Texte utilisateur")) && (deti->textFrom() != DynamicElementTextItem::UserText))
new QPropertyUndoCommand(deti, "textFrom", QVariant(deti->textFrom()), QVariant(DynamicElementTextItem::UserText), undo);
else if ((from == tr("Information de l'élément")) && (deti->textFrom() != DynamicElementTextItem::ElementInfo))
@@ -416,31 +419,24 @@
if(from == tr("Texte utilisateur"))
{
- QString text = text_qsi->child(0,0)->child(0,1)->data(Qt::DisplayRole).toString();
+ QString text = text_qsi->child(usr_txt_row,1)->data(Qt::DisplayRole).toString();
if (text != deti->text())
new QPropertyUndoCommand(deti, "text", QVariant(deti->text()), QVariant(text), undo);
}
else if (from == tr("Information de l'élément"))
{
- QString info_name = text_qsi->child(0,0)->child(1,1)->data(Qt::UserRole+2).toString();
+ QString info_name = text_qsi->child(info_txt_row,1)->data(Qt::UserRole+2).toString();
if(info_name != deti->infoName())
new QPropertyUndoCommand(deti, "infoName", QVariant(deti->infoName()), QVariant(info_name), undo);
}
else if (from == tr("Texte composé"))
{
- QString composite_text = text_qsi->child(0,0)->child(2,1)->data(Qt::UserRole+2).toString();
+ QString composite_text = text_qsi->child(compo_txt_row,1)->data(Qt::UserRole+2).toString();
if(composite_text != deti->compositeText())
new QPropertyUndoCommand(deti, "compositeText", QVariant(deti->compositeText()), QVariant(composite_text), undo);
}
- QString tagg = text_qsi->child(1,1)->data(Qt::DisplayRole).toString();
- if(tagg != deti->tagg())
- {
- QUndoCommand *quc = new QPropertyUndoCommand(deti, "tagg", QVariant(deti->tagg()), QVariant(tagg), undo);
- quc->setText(tr("Modifier le tagg d'un texte d'élément"));
- }
-
- int fs = text_qsi->child(2,1)->data(Qt::EditRole).toInt();
+ int fs = text_qsi->child(size_txt_row,1)->data(Qt::EditRole).toInt();
if (fs != deti->fontSize())
{
QUndoCommand *quc = new QPropertyUndoCommand(deti, "fontSize", QVariant(deti->fontSize()), QVariant(fs), undo);
@@ -447,7 +443,7 @@
quc->setText(tr("Modifier la taille d'un texte d'élément"));
}
- QColor color = text_qsi->child(3,1)->data(Qt::EditRole).value<QColor>();
+ QColor color = text_qsi->child(color_txt_row,1)->data(Qt::EditRole).value<QColor>();
if(color != deti->color())
{
QUndoCommand *quc = new QPropertyUndoCommand(deti, "color", QVariant(deti->color()), QVariant(color), undo);
@@ -454,7 +450,7 @@
quc->setText(tr("Modifier la couleur d'un texte d'élément"));
}
- bool frame = text_qsi->child(4,1)->checkState() == Qt::Checked? true : false;
+ bool frame = text_qsi->child(frame_txt_row,1)->checkState() == Qt::Checked? true : false;
if(frame != deti->frame())
{
QUndoCommand *quc = new QPropertyUndoCommand(deti, "frame", QVariant(deti->frame()), QVariant(frame), undo);
@@ -462,10 +458,10 @@
}
//When text is in a group, they're isn't item for position of the text
- if(text_qsi->child(5,1) && text_qsi->child(6,1))
+ if(text_qsi->child(x_txt_row,1) && text_qsi->child(y_txt_row,1))
{
- QPointF p(text_qsi->child(5,1)->data(Qt::EditRole).toDouble(),
- text_qsi->child(6,1)->data(Qt::EditRole).toDouble());
+ QPointF p(text_qsi->child(x_txt_row,1)->data(Qt::EditRole).toDouble(),
+ text_qsi->child(y_txt_row,1)->data(Qt::EditRole).toDouble());
if(p != deti->pos())
{
QPropertyUndoCommand *quc = new QPropertyUndoCommand(deti, "pos", QVariant(deti->pos()), QVariant(p), undo);
@@ -473,9 +469,9 @@
}
}
//When text is in a group, they're isn't item for the rotation of the text
- if(text_qsi->child(7,1))
+ if(text_qsi->child(rot_txt_row,1))
{
- qreal rot = text_qsi->child(7,1)->data(Qt::EditRole).toDouble();
+ qreal rot = text_qsi->child(rot_txt_row,1)->data(Qt::EditRole).toDouble();
rot = QET::correctAngle(rot);
if(rot != deti->rotation())
{
@@ -508,7 +504,7 @@
QStandardItem *group_qsi = m_groups_list.value(group);
- QString alignment = group_qsi->child(0,1)->data(Qt::DisplayRole).toString();
+ QString alignment = group_qsi->child(align_grp_row,1)->data(Qt::DisplayRole).toString();
if((alignment == tr("Gauche")) && (group->alignment() != Qt::AlignLeft))
new QPropertyUndoCommand(group, "alignment", QVariant(group->alignment()), QVariant(Qt::AlignLeft), undo);
else if((alignment == tr("Droite")) && (group->alignment() != Qt::AlignRight))
@@ -516,11 +512,11 @@
else if((alignment == tr("Centre")) && (group->alignment() != Qt::AlignVCenter))
new QPropertyUndoCommand(group, "alignment", QVariant(group->alignment()), QVariant(Qt::AlignVCenter), undo);
- qreal rotation = group_qsi->child(1,1)->data(Qt::EditRole).toDouble();
+ qreal rotation = group_qsi->child(rot_grp_row,1)->data(Qt::EditRole).toDouble();
if(group->rotation() != rotation)
new QPropertyUndoCommand(group, "rotation", QVariant(group->rotation()), QVariant(rotation), undo);
- int v_adjustment = group_qsi->child(2,1)->data(Qt::EditRole).toInt();
+ int v_adjustment = group_qsi->child(adjust_grp_row,1)->data(Qt::EditRole).toInt();
if(group->verticalAdjustment() != v_adjustment)
new QPropertyUndoCommand(group, "verticalAdjustment", QVariant(group->verticalAdjustment()), QVariant(v_adjustment), undo);
@@ -947,7 +943,7 @@
if (!m_texts_list.contains(deti))
return;
- QStandardItem *qsi = m_texts_list.value(deti)->child(0,0);
+ QStandardItem *qsi = m_texts_list.value(deti);
bool usr = false, info = false, compo = false;
@@ -958,14 +954,14 @@
}
//User text
- qsi->child(0,0)->setEnabled(usr);
- qsi->child(0,1)->setEnabled(usr);
+ qsi->child(usr_txt_row,0)->setEnabled(usr);
+ qsi->child(usr_txt_row,1)->setEnabled(usr);
//Info text
- qsi->child(1,0)->setEnabled(info);
- qsi->child(1,1)->setEnabled(info);
+ qsi->child(info_txt_row,0)->setEnabled(info);
+ qsi->child(info_txt_row,1)->setEnabled(info);
//Composite text
- qsi->child(2,0)->setEnabled(compo);
- qsi->child(2,1)->setEnabled(compo);
+ qsi->child(compo_txt_row,0)->setEnabled(compo);
+ qsi->child(compo_txt_row,1)->setEnabled(compo);
}
void DynamicElementTextModel::itemDataChanged(QStandardItem *qsi)
@@ -984,24 +980,23 @@
if (qsi->data().toInt() == textFrom)
{
- QStandardItem *text_from_qsi = text_qsi->child(0,0);
QString from = qsi->data(Qt::DisplayRole).toString();
if (from == tr("Texte utilisateur"))
{
enableSourceText(deti, DynamicElementTextItem::UserText);
- text_qsi->setData(text_from_qsi->child(0,1)->data(Qt::DisplayRole).toString());
+ text_qsi->setData(text_qsi->child(usr_txt_row,1)->data(Qt::DisplayRole).toString());
}
else if (from == tr("Information de l'élément"))
{
enableSourceText(deti, DynamicElementTextItem::ElementInfo);
- QString info = text_from_qsi->child(1,1)->data(Qt::UserRole+2).toString();
+ QString info = text_qsi->child(info_txt_row,1)->data(Qt::UserRole+2).toString();
text_qsi->setData(dc.value(info), Qt::DisplayRole);
}
else
{
enableSourceText(deti, DynamicElementTextItem::CompositeText);
- QString compo = text_from_qsi->child(2,1)->data(Qt::UserRole+2).toString();
+ QString compo = text_qsi->child(compo_txt_row,1)->data(Qt::UserRole+2).toString();
text_qsi->setData(autonum::AssignVariables::replaceVariable(compo, dc), Qt::DisplayRole);
}
@@ -1047,7 +1042,6 @@
QList<QMetaObject::Connection> connection_list;
connection_list << connect(deti, &DynamicElementTextItem::colorChanged, [deti,this](){this->updateDataFromText(deti, color);});
connection_list << connect(deti, &DynamicElementTextItem::fontSizeChanged, [deti,this](){this->updateDataFromText(deti, size);});
- connection_list << connect(deti, &DynamicElementTextItem::taggChanged, [deti,this](){this->updateDataFromText(deti, tagg);});
connection_list << connect(deti, &DynamicElementTextItem::textFromChanged, [deti,this](){this->updateDataFromText(deti, textFrom);});
connection_list << connect(deti, &DynamicElementTextItem::textChanged, [deti,this](){this->updateDataFromText(deti, userText);});
connection_list << connect(deti, &DynamicElementTextItem::infoNameChanged, [deti,this](){this->updateDataFromText(deti, infoText);});
@@ -1129,8 +1123,7 @@
case userText:
{
qsi->setData(deti->toPlainText(), Qt::DisplayRole);
- QStandardItem *qsia = qsi->child(0,0);
- qsia->child(0,1)->setData(deti->toPlainText(), Qt::DisplayRole);
+ qsi->child(usr_txt_row,1)->setData(deti->toPlainText(), Qt::DisplayRole);
qsi->setData(deti->toPlainText(), Qt::DisplayRole);
break;
}
@@ -1137,55 +1130,47 @@
case infoText:
{
qsi->setData(deti->toPlainText(), Qt::DisplayRole);
- QStandardItem *qsia = qsi->child(0,0);
QString info_name = deti->infoName();
- qsia->child(1,1)->setData(info_name, Qt::UserRole+2);
- qsia->child(1,1)->setData(QETApp::elementTranslatedInfoKey(info_name), Qt::DisplayRole);
+ qsi->child(info_txt_row,1)->setData(info_name, Qt::UserRole+2);
+ qsi->child(info_txt_row,1)->setData(QETApp::elementTranslatedInfoKey(info_name), Qt::DisplayRole);
break;
}
case compositeText:
{
qsi->setData(deti->toPlainText(), Qt::DisplayRole);
- QStandardItem *qsia = qsi->child(0,0);
- qsia->child(2,1)->setData(deti->compositeText(), Qt::UserRole+2);
- qsia->child(2,1)->setData(deti->toPlainText(), Qt::DisplayRole);
+ qsi->child(compo_txt_row,1)->setData(deti->compositeText(), Qt::UserRole+2);
+ qsi->child(compo_txt_row,1)->setData(deti->toPlainText(), Qt::DisplayRole);
qsi->setData(deti->toPlainText(), Qt::DisplayRole);
break;
}
case size:
- qsi->child(2,1)->setData(deti->fontSize(), Qt::EditRole);
+ qsi->child(size_txt_row,1)->setData(deti->fontSize(), Qt::EditRole);
break;
- case tagg:
- qsi->child(1,1)->setData(deti->tagg(), Qt::DisplayRole);
- break;
case color:
{
- qsi->child(3,1)->setData(deti->color(), Qt::EditRole);
- qsi->child(3,1)->setData(deti->color(), Qt::ForegroundRole);
+ qsi->child(color_txt_row,1)->setData(deti->color(), Qt::EditRole);
+ qsi->child(color_txt_row,1)->setData(deti->color(), Qt::ForegroundRole);
break;
}
case pos:
{
- if(qsi->child(5,1))
- qsi->child(5,1)->setData(deti->pos().x(), Qt::EditRole);
- if(qsi->child(6,1))
- qsi->child(6,1)->setData(deti->pos().y(), Qt::EditRole);
+ if(qsi->child(x_txt_row,1))
+ qsi->child(x_txt_row,1)->setData(deti->pos().x(), Qt::EditRole);
+ if(qsi->child(y_txt_row,1))
+ qsi->child(y_txt_row,1)->setData(deti->pos().y(), Qt::EditRole);
break;
}
case frame:
{
- qsi->child(4,1)->setCheckState(deti->frame()? Qt::Checked : Qt::Unchecked);
+ qsi->child(frame_txt_row,1)->setCheckState(deti->frame()? Qt::Checked : Qt::Unchecked);
break;
}
case rotation:
{
- if(qsi->child(7,1))
- qsi->child(7,1)->setData(deti->rotation(), Qt::EditRole);
+ if(qsi->child(rot_txt_row,1))
+ qsi->child(rot_txt_row,1)->setData(deti->rotation(), Qt::EditRole);
break;
}
- case grp_alignment: break;
- case grp_rotation: break;
- case grp_v_adjust: break;
}
m_block_dataChanged = false;
@@ -1201,32 +1186,22 @@
switch (type)
{
- case textFrom: break;
- case userText: break;
- case infoText: break;
- case compositeText: break;
- case size: break;
- case tagg: break;
- case color: break;
- case pos: break;
- case frame: break;
- case rotation: break;
case grp_alignment:
{
switch (group->alignment())
{
- case Qt::AlignLeft: qsi->child(0,1)->setData(tr("Gauche"), Qt::DisplayRole); break;
- case Qt::AlignRight : qsi->child(0,1)->setData(tr("Droite"), Qt::DisplayRole); break;
- case Qt::AlignVCenter : qsi->child(0,1)->setData(tr("Centre"), Qt::DisplayRole); break;
+ case Qt::AlignLeft: qsi->child(align_grp_row,1)->setData(tr("Gauche"), Qt::DisplayRole); break;
+ case Qt::AlignRight : qsi->child(align_grp_row,1)->setData(tr("Droite"), Qt::DisplayRole); break;
+ case Qt::AlignVCenter : qsi->child(align_grp_row,1)->setData(tr("Centre"), Qt::DisplayRole); break;
default: qsi->child(0,1)->setData("", Qt::DisplayRole); break;
}
break;
}
case grp_rotation:
- qsi->child(1,1)->setData(group->rotation(), Qt::EditRole);
+ qsi->child(rot_grp_row,1)->setData(group->rotation(), Qt::EditRole);
break;
case grp_v_adjust:
- qsi->child(2,1)->setData(group->verticalAdjustment(), Qt::EditRole);
+ qsi->child(adjust_grp_row,1)->setData(group->verticalAdjustment(), Qt::EditRole);
break;
}
@@ -1441,22 +1416,34 @@
bool DynamicTextItemDelegate::eventFilter(QObject *object, QEvent *event)
{
+
//This is a bad hack, for change the normal behavior :
//in normal behavior, the value is commited when the spinbox lose focus or enter key is pressed
- //With this hack the value is commited each time the value change, so the text is moved in live.
- //We also use this hack for the font size spinbox
+ //With this hack the value is commited each time the value change without the need to validate.
+ //then the change is apply in live
if(object->objectName() == "pos_dialog" || object->objectName() == "font_size" || object->objectName() == "rot_spinbox" || \
object->objectName() == "group_rotation" || object->objectName() == "group_v_adjustment")
{
+ object->event(event);
+
QSpinBox *sb = static_cast<QSpinBox *>(object);
- if(event->type() == QEvent::KeyRelease)
- emit commitData(sb);
- else if (event->type() == QEvent::MouseButtonRelease)
- emit commitData(sb);
+ switch (event->type()) {
+ case QEvent::KeyPress:
+ emit commitData(sb); break;
+ case QEvent::KeyRelease:
+ emit commitData(sb); break;
+ case QEvent::MouseButtonPress:
+ emit commitData(sb); break;
+ case QEvent::MouseButtonRelease:
+ emit commitData(sb); break;
+ case QEvent::Wheel:
+ emit commitData(sb); break;
+ }
+ return true;
}
//Like the hack above, change the current index of the combobox, apply the change immediately, no need to lose focus or press enter.
- if((object->objectName() == "text_from" || object->objectName() == "info_text") && event->type() == QEvent::FocusIn)
+ if((object->objectName() == "text_from" || object->objectName() == "info_text" || object->objectName() == "group_alignment") && event->type() == QEvent::FocusIn)
{
QComboBox *qcb = static_cast<QComboBox *>(object);
connect(qcb, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [this,qcb](){emit commitData(qcb);});
Modified: trunk/sources/ui/dynamicelementtextmodel.h
===================================================================
--- trunk/sources/ui/dynamicelementtextmodel.h 2017-12-13 04:14:16 UTC (rev 5181)
+++ trunk/sources/ui/dynamicelementtextmodel.h 2017-12-13 21:15:05 UTC (rev 5182)
@@ -43,7 +43,6 @@
infoText,
compositeText,
size,
- tagg,
color,
pos,
frame,