QElectroTech  0.70
dynamicelementtextmodel.cpp
Go to the documentation of this file.
1 /*
2  Copyright 2006-2019 The QElectroTech Team
3  This file is part of QElectroTech.
4 
5  QElectroTech is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 2 of the License, or
8  (at your option) any later version.
9 
10  QElectroTech is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with QElectroTech. If not, see <http://www.gnu.org/licenses/>.
17 */
19 #include "dynamicelementtextitem.h"
20 #include <QStandardItem>
21 #include <QHash>
22 #include <QColorDialog>
23 #include <QModelIndex>
24 #include <QComboBox>
25 #include <QUndoCommand>
27 #include "qetapp.h"
28 #include "element.h"
30 #include "terminal.h"
31 #include "conductor.h"
32 #include "elementtextitemgroup.h"
33 #include "qeticons.h"
34 #include "diagram.h"
35 #include "addelementtextcommand.h"
36 #include "alignmenttextdialog.h"
37 
38 static int src_txt_row = 0;
39 static int usr_txt_row = 1;
40 static int info_txt_row = 2;
41 static int compo_txt_row = 3;
42 static int size_txt_row = 4;
43 static int font_txt_row = 5;
44 static int color_txt_row = 6;
45 static int frame_txt_row = 7;
46 static int width_txt_row = 8;
47 static int x_txt_row = 9;
48 static int y_txt_row = 10;
49 static int rot_txt_row = 11;
50 static int align_txt_row = 12;
51 
52 static int align_grp_row = 0;
53 static int x_grp_row = 1;
54 static int y_grp_row = 2;
55 static int rot_grp_row = 3;
56 static int adjust_grp_row = 4;
57 static int frame_grp_row = 5;
58 static int hold_to_bottom_grp_row = 6;
59 
61  QStandardItemModel(parent),
62  m_element(element)
63 {
64  setColumnCount(2);
65  setHeaderData(0, Qt::Horizontal, tr("Propriété"), Qt::DisplayRole);
66  setHeaderData(1, Qt::Horizontal, tr("Valeur"), Qt::DisplayRole);
67 
68  connect(this, &DynamicElementTextModel::itemChanged, this, &DynamicElementTextModel::itemDataChanged);
69 
70  connect(m_element.data(), &Element::textsGroupAdded, this, &DynamicElementTextModel::addGroup, Qt::DirectConnection);
71  connect(m_element.data(), &Element::textsGroupAboutToBeRemoved, this, &DynamicElementTextModel::removeGroup, Qt::DirectConnection);
72  connect(m_element.data(), &Element::textRemoved, this, &DynamicElementTextModel::removeText, Qt::DirectConnection);
73  connect(m_element.data(), &Element::textRemovedFromGroup, this, &DynamicElementTextModel::removeTextFromGroup, Qt::DirectConnection);
74  connect(m_element.data(), &Element::textAdded, this, &DynamicElementTextModel::addText, Qt::DirectConnection);
75  connect(m_element.data(), &Element::textAddedToGroup, this, &DynamicElementTextModel::addTextToGroup, Qt::DirectConnection);
76 
77  for (ElementTextItemGroup *grp : m_element.data()->textGroups())
78  addGroup(grp);
79 
80  for (DynamicElementTextItem *deti : m_element.data()->dynamicTextItems())
81  this->appendRow(itemsForText(deti));
82 }
83 
85 {
86  //Connection is not destroy automaticaly,
87  //because was not connected to a slot, but a lambda
89  setConnection(deti, false);
90  for(ElementTextItemGroup *group : m_hash_group_connect.keys())
91  setConnection(group, false);
92 }
93 
99 bool DynamicElementTextModel::indexIsInGroup(const QModelIndex &index) const
100 {
101  QStandardItem *item = itemFromIndex(index);
102  if(item)
103  {
104  while (item->parent())
105  item = item->parent();
106 
107  if(m_groups_list.values().contains(item))
108  return true;
109  else
110  return false;
111  }
112  return false;
113 }
114 
123 {
124  QList <QStandardItem *> qsi_list;
125 
126  if(m_texts_list.keys().contains(deti))
127  return qsi_list;
128 
129  QStandardItem *qsi = new QStandardItem(deti->toPlainText());
130  qsi->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled |Qt::ItemIsDragEnabled);
131  qsi->setIcon(QET::Icons::PartText);
132 
133 
134  //Source of text
135  QStandardItem *src = new QStandardItem(tr("Source du texte"));
136  src->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
137 
138  QString title;
139  if (deti->textFrom() == DynamicElementTextItem::UserText) title = tr("Texte utilisateur");
140  else if (deti->textFrom() == DynamicElementTextItem::ElementInfo) title = tr("Information de l'élément");
141  else title = tr("Texte composé");
142  QStandardItem *srca = new QStandardItem(title);
143  srca->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
144  srca->setData(textFrom, Qt::UserRole+1);
145 
146  qsi_list << src << srca;
147  qsi->appendRow(qsi_list);
148 
149  //User text
150  QStandardItem *usr = new QStandardItem(tr("Texte"));
151  usr->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
152 
153  QStandardItem *usra = new QStandardItem(deti->toPlainText());
154  usra->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
155  usra->setData(DynamicElementTextModel::userText, Qt::UserRole+1);
156 
157  qsi_list.clear();
158  qsi_list << usr << usra;
159  qsi->appendRow(qsi_list);
160 
161  //Info text
162  QStandardItem *info = new QStandardItem(tr("Information"));
163  info->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
164 
165  QStandardItem *infoa = new QStandardItem(QETApp::elementTranslatedInfoKey(deti->infoName()));
166  infoa->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
167  infoa->setData(DynamicElementTextModel::infoText, Qt::UserRole+1); //Use to know the edited thing
168  infoa->setData(deti->infoName(), Qt::UserRole+2); //Use to know to element info name
169 
170  qsi_list.clear();
171  qsi_list << info << infoa;
172  qsi->appendRow(qsi_list);
173 
174  //Composite text
175  QStandardItem *composite = new QStandardItem(tr("Texte composé"));
176  composite->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
177 
178  DiagramContext dc;
179  if(deti->elementUseForInfo())
180  dc = deti->elementUseForInfo()->elementInformations();
181  QStandardItem *compositea = new QStandardItem(deti->compositeText().isEmpty() ?
182  tr("Mon texte composé") :
184  compositea->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
185  compositea->setData(DynamicElementTextModel::compositeText, Qt::UserRole+1); //Use to know the edited thing
186  compositea->setData(deti->compositeText(), Qt::UserRole+2); //Use to know to element composite formula
187 
188  qsi_list.clear();
189  qsi_list << composite << compositea;
190  qsi->appendRow(qsi_list);
191 
192  //Size
193  QStandardItem *size = new QStandardItem(tr("Taille"));
194  size->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
195 
196  QStandardItem *siza = new QStandardItem();
197  siza->setData(deti->font().pointSize(), Qt::EditRole);
198  siza->setData(DynamicElementTextModel::size, Qt::UserRole+1);
199  siza->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
200 
201  qsi_list.clear();
202  qsi_list << size << siza;
203  qsi->appendRow(qsi_list);
204 
205  //Font
206  QStandardItem *font = new QStandardItem(tr("Police"));
207  font->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
208 
209  QStandardItem *fonta = new QStandardItem();
210  fonta->setData(deti->font().family(), Qt::EditRole);
211  fonta->setData(DynamicElementTextModel::font, Qt::UserRole+1);
212  fonta->setData(deti->font(), Qt::UserRole+2);
213  fonta->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
214 
215  qsi_list.clear();
216  qsi_list << font << fonta;
217  qsi->appendRow(qsi_list);
218 
219  //Color
220  QStandardItem *color = new QStandardItem(tr("Couleur"));
221  color->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
222 
223  QStandardItem *colora = new QStandardItem;
224  colora->setData(deti->color(), Qt::ForegroundRole);
225  colora->setData(deti->color(), Qt::EditRole);
226  colora->setData(DynamicElementTextModel::color, Qt::UserRole+1);
227  colora->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
228 
229  qsi_list.clear();
230  qsi_list << color << colora;
231  qsi->appendRow(qsi_list);
232 
233  //Frame
234  QStandardItem *frame = new QStandardItem(tr("Cadre"));
235  frame->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
236 
237  QStandardItem *frame_a = new QStandardItem;
238  frame_a->setCheckable(true);
239  frame_a->setCheckState(deti->frame()? Qt::Checked : Qt::Unchecked);
240  frame_a->setData(DynamicElementTextModel::frame, Qt::UserRole+1);
241  frame_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable);
242 
243  qsi_list.clear();
244  qsi_list << frame << frame_a;
245  qsi->appendRow(qsi_list);
246 
247  //Width
248  QStandardItem *width = new QStandardItem(tr("Largeur"));
249  width->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
250 
251  QStandardItem *width_a = new QStandardItem;
252  width_a->setData(deti->textWidth(), Qt::EditRole);
253  width_a->setData(DynamicElementTextModel::textWidth, Qt::UserRole+1);
254  width_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
255 
256  qsi_list.clear();
257  qsi_list << width << width_a;
258  qsi->appendRow(qsi_list);
259 
260  if(deti->parentGroup() == nullptr)
261  {
262  //X pos
263  QStandardItem *x_pos = new QStandardItem(tr("Position X"));
264  x_pos->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
265 
266  QStandardItem *x_pos_a = new QStandardItem;
267  x_pos_a->setData(deti->pos().x(), Qt::EditRole);
268  x_pos_a->setData(DynamicElementTextModel::pos, Qt::UserRole+1);
269  x_pos_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
270 
271  qsi_list.clear();
272  qsi_list << x_pos << x_pos_a;
273  qsi->appendRow(qsi_list);
274 
275  //Y pos
276  QStandardItem *y_pos = new QStandardItem(tr("Position Y"));
277  y_pos->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
278 
279  QStandardItem *y_pos_a = new QStandardItem;
280  y_pos_a->setData(deti->pos().y(), Qt::EditRole);
281  y_pos_a->setData(DynamicElementTextModel::pos, Qt::UserRole+1);
282  y_pos_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
283 
284  qsi_list.clear();
285  qsi_list << y_pos << y_pos_a;
286  qsi->appendRow(qsi_list);
287 
288  //Rotation
289  QStandardItem *rot = new QStandardItem(tr("Rotation"));
290  rot->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
291 
292  QStandardItem *rot_a = new QStandardItem;
293  rot_a->setData(deti->rotation(), Qt::EditRole);
294  rot_a->setData(DynamicElementTextModel::rotation, Qt::UserRole+1);
295  rot_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
296 
297  qsi_list.clear();;
298  qsi_list << rot << rot_a;
299  qsi->appendRow(qsi_list);
300 
301  //Alignment
302  QStandardItem *alignment = new QStandardItem(tr("Alignement"));
303  alignment->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
304 
305  QStandardItem *alignmenta = new QStandardItem(tr("Éditer"));
306  alignmenta->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
307  alignmenta->setData(DynamicElementTextModel::txtAlignment, Qt::UserRole+1);
308  alignmenta->setData(QVariant::fromValue(deti->alignment()), Qt::UserRole+2);
309 
310  qsi_list.clear();
311  qsi_list << alignment << alignmenta;
312  qsi->appendRow(qsi_list);
313  }
314 
315 
316  qsi_list.clear();
317  QStandardItem *empty_qsi = new QStandardItem(0);
318  empty_qsi->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
319  qsi_list << qsi << empty_qsi;
320 
321  m_texts_list.insert(deti, qsi);
322  blockSignals(true);
323  enableSourceText(deti, deti->textFrom());
324  blockSignals(false);
325  setConnection(deti, true);
326 
327  return qsi_list;
328 }
329 
335 {
336  this->appendRow(itemsForText(deti));
337 }
338 
344 {
345  if (!m_texts_list.contains(deti))
346  return;
347 
348  QModelIndex text_index = m_texts_list.value(deti)->index();
349  this->removeRow(text_index.row(), text_index.parent());
350  m_texts_list.remove(deti);
351  setConnection(deti, false);
352 }
353 
361 {
362  if(!index.isValid())
363  return nullptr;
364 
365  if (QStandardItem *item = itemFromIndex(index))
366  return textFromItem(item);
367  else
368  return nullptr;
369 }
370 
379 {
380  //Get the item of the column 0
381  if(item->column() == 1)
382  {
383  if(item->parent())
384  item = item->parent()->child(item->row(), 0);
385  else
386  item = itemFromIndex(index(item->row(),0));
387  }
388  //Item haven't got parent, so they can be only a text or a group
389  if(!item->parent())
390  {
391  if(m_texts_list.values().contains(item))
392  return m_texts_list.key(item);
393  else
394  return nullptr;
395  }
396 
397 
398 
399  QStandardItem *text_item = item;
400  while (text_item->parent())
401  text_item = text_item->parent();
402 
403  if (m_texts_list.values().contains(text_item)) //The item is a text
404  return m_texts_list.key(text_item);
405  else if (m_groups_list.values().contains(text_item)) //The item is a group
406  {
407  QStandardItem *previous = item;
408  QStandardItem *top = item;
409  //At the end of the while, previous must be the text
410  //and top the group
411  while(top->parent())
412  {
413  previous = top;
414  top = top->parent();
415  }
416 
417  if(m_texts_list.values().contains(previous))
418  return m_texts_list.key(previous);
419  else
420  return nullptr;
421  }
422  else
423  return nullptr;
424 }
425 
432 {
433  if(m_texts_list.contains(text))
434  return m_texts_list.value(text)->index();
435  else
436  return QModelIndex();
437 }
438 
446 QUndoCommand *DynamicElementTextModel::undoForEditedText(DynamicElementTextItem *deti, QUndoCommand *parent_undo) const
447 {
448 
449  QUndoCommand *undo = nullptr;
450  if(parent_undo)
451  undo = parent_undo;
452  else
453  undo = new QUndoCommand(tr("Éditer un texte d'élément"));
454 
455  if (!m_texts_list.contains(deti))
456  return undo;
457 
458  QStandardItem *text_qsi = m_texts_list.value(deti);
459 
460  QString from = text_qsi->child(src_txt_row,1)->data(Qt::DisplayRole).toString();
461  if ((from == tr("Texte utilisateur")) && (deti->textFrom() != DynamicElementTextItem::UserText))
462  new QPropertyUndoCommand(deti, "textFrom", QVariant(deti->textFrom()), QVariant(DynamicElementTextItem::UserText), undo);
463  else if ((from == tr("Information de l'élément")) && (deti->textFrom() != DynamicElementTextItem::ElementInfo))
464  new QPropertyUndoCommand(deti, "textFrom", QVariant(deti->textFrom()), QVariant(DynamicElementTextItem::ElementInfo), undo);
465  else if ((from == tr("Texte composé")) && (deti->textFrom() != DynamicElementTextItem::CompositeText))
466  new QPropertyUndoCommand(deti, "textFrom", QVariant(deti->textFrom()), QVariant(DynamicElementTextItem::CompositeText), undo);
467 
468  if(from == tr("Texte utilisateur"))
469  {
470  QString text = text_qsi->child(usr_txt_row,1)->data(Qt::DisplayRole).toString();
471  if (text != deti->text())
472  new QPropertyUndoCommand(deti, "text", QVariant(deti->text()), QVariant(text), undo);
473  }
474  else if (from == tr("Information de l'élément"))
475  {
476  QString info_name = text_qsi->child(info_txt_row,1)->data(Qt::UserRole+2).toString();
477  if(info_name != deti->infoName())
478  new QPropertyUndoCommand(deti, "infoName", QVariant(deti->infoName()), QVariant(info_name), undo);
479  }
480  else if (from == tr("Texte composé"))
481  {
482  QString composite_text = text_qsi->child(compo_txt_row,1)->data(Qt::UserRole+2).toString();
483  if(composite_text != deti->compositeText())
484  new QPropertyUndoCommand(deti, "compositeText", QVariant(deti->compositeText()), QVariant(composite_text), undo);
485  }
486 
487  int fs = text_qsi->child(size_txt_row,1)->data(Qt::EditRole).toInt();
488  if (fs != deti->font().pointSize())
489  {
490  QFont font = deti->font();
491  font.setPointSize(fs);
492  QPropertyUndoCommand *quc = new QPropertyUndoCommand(deti, "font", QVariant(deti->font()), QVariant(font), undo);
493  quc->setText(tr("Modifier la taille d'un texte d'élément"));
494  }
495 
496  QFont font = text_qsi->child(font_txt_row, 1)->data(Qt::UserRole+2).value<QFont>();
497  if (font != deti->font())
498  {
499  QPropertyUndoCommand *quc = new QPropertyUndoCommand(deti, "font", QVariant(deti->font()), QVariant(font), undo);
500  quc->setText(tr("Modifier la police d'un texte d'élément"));
501  }
502 
503  QColor color = text_qsi->child(color_txt_row,1)->data(Qt::EditRole).value<QColor>();
504  if(color != deti->color())
505  {
506  QUndoCommand *quc = new QPropertyUndoCommand(deti, "color", QVariant(deti->color()), QVariant(color), undo);
507  quc->setText(tr("Modifier la couleur d'un texte d'élément"));
508  }
509 
510  bool frame = text_qsi->child(frame_txt_row,1)->checkState() == Qt::Checked? true : false;
511  if(frame != deti->frame())
512  {
513  QUndoCommand *quc = new QPropertyUndoCommand(deti, "frame", QVariant(deti->frame()), QVariant(frame), undo);
514  quc->setText(tr("Modifier le cadre d'un texte d'élément"));
515  }
516 
517  qreal text_width = text_qsi->child(width_txt_row, 1)->data(Qt::EditRole).toDouble();
518  if(text_width != deti->textWidth())
519  {
520  QPropertyUndoCommand *quc = new QPropertyUndoCommand(deti, "textWidth", QVariant(deti->textWidth()), QVariant(text_width), undo);
521  quc->setAnimated(true, false);
522  quc->setText(tr("Modifier la largeur d'un texte d'élément"));
523  }
524 
525  //When text is in a group, they're isn't item for position of the text
526  if(text_qsi->child(x_txt_row,1) && text_qsi->child(y_txt_row,1))
527  {
528  QPointF p(text_qsi->child(x_txt_row,1)->data(Qt::EditRole).toDouble(),
529  text_qsi->child(y_txt_row,1)->data(Qt::EditRole).toDouble());
530  if(p != deti->pos())
531  {
532  QPropertyUndoCommand *quc = new QPropertyUndoCommand(deti, "pos", QVariant(deti->pos()), QVariant(p), undo);
533  quc->setAnimated(true, false);
534  quc->setText(tr("Déplacer un texte d'élément"));
535  }
536  }
537  //When text is in a group, they're isn't item for the rotation of the text
538  if(text_qsi->child(rot_txt_row,1))
539  {
540  qreal rot = text_qsi->child(rot_txt_row,1)->data(Qt::EditRole).toDouble();
541  rot = QET::correctAngle(rot);
542  if(rot != deti->rotation())
543  {
544  QPropertyUndoCommand *quc = new QPropertyUndoCommand(deti, "rotation", QVariant(deti->rotation()), QVariant(rot), undo);
545  quc->setAnimated(true, false);
546  quc->setText(tr("Pivoter un texte d'élément"));
547  }
548  }
549 
550  //When text is in a groupe, they're isn't item for alignment of the text
551  if(text_qsi->child(align_txt_row, 1))
552  {
553  Qt::Alignment alignment = text_qsi->child(align_txt_row, 1)->data(Qt::UserRole+2).value<Qt::Alignment>();
554  if (alignment != deti->alignment())
555  {
556  QPropertyUndoCommand *quc = new QPropertyUndoCommand(deti, "alignment", QVariant(deti->alignment()), QVariant(alignment), undo);
557  quc->setText(tr("Modifier l'alignement d'un texte d'élément"));
558  }
559  }
560 
561  return undo;
562 }
563 
572 QUndoCommand *DynamicElementTextModel::undoForEditedGroup(ElementTextItemGroup *group, QUndoCommand *parent_undo) const
573 {
574  QUndoCommand *undo = nullptr;
575  if(parent_undo)
576  undo = parent_undo;
577  else
578  undo = new QUndoCommand(tr("Éditer un groupe de textes"));
579 
580  if (!m_groups_list.contains(group))
581  return undo;
582 
583  QStandardItem *group_qsi = m_groups_list.value(group);
584 
585  QString alignment = group_qsi->child(align_grp_row,1)->data(Qt::DisplayRole).toString();
586  if((alignment == tr("Gauche")) && (group->alignment() != Qt::AlignLeft))
587  new QPropertyUndoCommand(group, "alignment", QVariant(group->alignment()), QVariant(Qt::AlignLeft), undo);
588  else if((alignment == tr("Droite")) && (group->alignment() != Qt::AlignRight))
589  new QPropertyUndoCommand(group, "alignment", QVariant(group->alignment()), QVariant(Qt::AlignRight), undo);
590  else if((alignment == tr("Centre")) && (group->alignment() != Qt::AlignVCenter))
591  new QPropertyUndoCommand(group, "alignment", QVariant(group->alignment()), QVariant(Qt::AlignVCenter), undo);
592 
593 
594  if (group_qsi->child(hold_to_bottom_grp_row, 1)->checkState() == Qt::Unchecked)
595  {
596  QPointF pos(group_qsi->child(x_grp_row,1)->data(Qt::EditRole).toDouble(),
597  group_qsi->child(y_grp_row,1)->data(Qt::EditRole).toDouble());
598  if(group->pos() != pos)
599  {
600  QPropertyUndoCommand *qpuc = new QPropertyUndoCommand(group, "pos", QVariant(group->pos()), QVariant(pos), undo);
601  qpuc->setAnimated(true, false);
602  }
603 
604  qreal rotation = group_qsi->child(rot_grp_row,1)->data(Qt::EditRole).toDouble();
605  if(group->rotation() != rotation)
606  {
607  QPropertyUndoCommand *qpuc = new QPropertyUndoCommand(group, "rotation", QVariant(group->rotation()), QVariant(rotation), undo);
608  qpuc->setAnimated(true, false);
609  }
610  }
611 
612  int v_adjustment = group_qsi->child(adjust_grp_row,1)->data(Qt::EditRole).toInt();
613  if(group->verticalAdjustment() != v_adjustment)
614  new QPropertyUndoCommand(group, "verticalAdjustment", QVariant(group->verticalAdjustment()), QVariant(v_adjustment), undo);
615 
616  QString name = group_qsi->data(Qt::DisplayRole).toString();
617  if(group->name() != name)
618  new QPropertyUndoCommand(group, "name", QVariant(group->name()), QVariant(name), undo);
619 
620  bool hold_to_bottom = group_qsi->child(hold_to_bottom_grp_row, 1)->checkState() == Qt::Checked? true : false;
621  if(group->holdToBottomPage() != hold_to_bottom)
622  new QPropertyUndoCommand(group, "holdToBottomPage", QVariant(group->holdToBottomPage()), QVariant(hold_to_bottom), undo);
623 
624  bool frame_ = group_qsi->child(frame_grp_row, 1)->checkState() == Qt::Checked? true : false;
625  if(group->frame() != frame_)
626  new QPropertyUndoCommand(group, "frame", QVariant(group->frame()), QVariant(frame_), undo);
627 
628  return undo;
629 }
630 
637 {
638  if(m_groups_list.keys().contains(group))
639  return;
640 
641  //Group
642  QStandardItem *grp = new QStandardItem(group->name());
643  grp->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsDropEnabled | Qt::ItemIsEditable);
644  grp->setIcon(QET::Icons::textGroup);
645 
646  QStandardItem *empty_qsi = new QStandardItem(0);
647  empty_qsi->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
648 
649  QList<QStandardItem *> qsi_list;
650  qsi_list << grp << empty_qsi;
651 
652  this->insertRow(0, qsi_list);
653  m_groups_list.insert(group, grp);
654 
655  //Alignment
656  QStandardItem *alignment = new QStandardItem(tr("Alignement"));
657  alignment->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
658 
659  QString text;
660  switch (group->alignment()) {
661  case Qt::AlignLeft: text = tr("Gauche"); break;
662  case Qt::AlignRight: text = tr("Droite"); break;
663  case Qt::AlignVCenter: text = tr("Centre"); break;
664  default: break;}
665 
666  QStandardItem *alignment_a = new QStandardItem(text);
667  alignment_a->setData(DynamicElementTextModel::grpAlignment, Qt::UserRole+1);
668  alignment_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
669  qsi_list.clear();
670  qsi_list << alignment << alignment_a;
671  grp->appendRow(qsi_list);
672 
673  //X pos
674  QStandardItem *x_pos = new QStandardItem(tr("Position X"));
675  x_pos->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
676 
677  QStandardItem *x_pos_a = new QStandardItem;
678  x_pos_a->setData(group->pos().x(), Qt::EditRole);
679  x_pos_a->setData(DynamicElementTextModel::grpPos, Qt::UserRole+1);
680  x_pos_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
681 
682  qsi_list.clear();
683  qsi_list << x_pos << x_pos_a;
684  grp->appendRow(qsi_list);
685 
686  //Y pos
687  QStandardItem *y_pos = new QStandardItem(tr("Position Y"));
688  y_pos->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
689 
690  QStandardItem *y_pos_a = new QStandardItem;
691  y_pos_a->setData(group->pos().y(), Qt::EditRole);
692  y_pos_a->setData(DynamicElementTextModel::grpPos, Qt::UserRole+1);
693  y_pos_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
694 
695  qsi_list.clear();
696  qsi_list << y_pos << y_pos_a;
697  grp->appendRow(qsi_list);
698 
699  //Rotation
700  QStandardItem *rot = new QStandardItem(tr("Rotation"));
701  rot->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
702 
703  QStandardItem *rot_a = new QStandardItem;
704  rot_a->setData(group->rotation(), Qt::EditRole);
705  rot_a->setData(DynamicElementTextModel::grpRotation, Qt::UserRole+1);
706  rot_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
707  qsi_list.clear();
708  qsi_list << rot << rot_a;
709  grp->appendRow(qsi_list);
710 
711  //Vertical adjustment
712  QStandardItem *v_adj = new QStandardItem(tr("Ajustement vertical"));
713  v_adj->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
714 
715  QStandardItem *v_adj_a = new QStandardItem;
716  v_adj_a->setData(group->verticalAdjustment(), Qt::EditRole);
717  v_adj_a->setData(DynamicElementTextModel::grpVAdjust, Qt::UserRole+1);
718  v_adj_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
719  qsi_list.clear();
720  qsi_list << v_adj << v_adj_a;
721  grp->appendRow(qsi_list);
722 
723  //Frame
724  QStandardItem *frame_ = new QStandardItem(tr("Cadre"));
725  frame_->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
726 
727  QStandardItem *frame_a = new QStandardItem;
728  frame_a->setCheckable(true);
729  frame_a->setCheckState(group->frame()? Qt::Checked : Qt::Unchecked);
730  frame_a->setData(DynamicElementTextModel::grpFrame, Qt::UserRole+1);
731  frame_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable);
732  qsi_list.clear();
733  qsi_list << frame_ << frame_a;
734  grp->appendRow(qsi_list);
735 
736 
737  //Hold to the bottom of the page
738  QStandardItem *hold_bottom = new QStandardItem(tr("Maintenir en bas de page"));
739  hold_bottom->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
740 
741  QStandardItem *hold_bottom_a = new QStandardItem();
742  hold_bottom_a->setCheckable(true);
743  hold_bottom_a->setCheckState(group->holdToBottomPage() ? Qt::Checked : Qt::Unchecked);
744  hold_bottom_a->setData(DynamicElementTextModel::grpHoldBottom, Qt::UserRole+1);
745  hold_bottom_a->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable);
746  qsi_list.clear();
747  qsi_list << hold_bottom << hold_bottom_a;
748  grp->appendRow(qsi_list);
749 
750 
751  //Add the texts of the group
752  for(DynamicElementTextItem *deti : group->texts())
753  {
754  QStandardItem *group_item = m_groups_list.value(group);
755  group_item->appendRow(itemsForText(deti));
756  }
757  setConnection(group, true);
759 }
760 
767 {
768  if(m_groups_list.keys().contains(group))
769  {
770  QModelIndex group_index = m_groups_list.value(group)->index();
771  this->removeRow(group_index.row(), group_index.parent());
772  m_groups_list.remove(group);
773  setConnection(group, false);
774  }
775 }
776 
784 {
785  QStandardItem *group_item = m_groups_list.value(group);
786  group_item->appendRow(itemsForText(deti));
787 }
788 
790 {
791  Q_UNUSED(group)
792 
793  if(m_texts_list.keys().contains(deti))
794  {
795  QStandardItem *text_item = m_texts_list.value(deti);
796  QModelIndex text_index = indexFromItem(text_item);
797  removeRow(text_index.row(), text_index.parent());
798  m_texts_list.remove(deti);
799  }
800 }
801 
809 {
810  if(!index.isValid())
811  return nullptr;
812 
813  if (QStandardItem *item = itemFromIndex(index))
814  return groupFromItem(item);
815  else
816  return nullptr;
817 }
818 
826 {
827  //Get the item of the column 0
828  if(item->column() == 1)
829  {
830  if(item->parent())
831  item = item->parent()->child(item->row(), 0);
832  else
833  item = itemFromIndex(index(item->row(),0));
834  }
835 
836  while (item->parent())
837  item = item->parent();
838 
839  if(m_groups_list.values().contains(item))
840  return m_groups_list.key(item);
841  else
842  return nullptr;
843 }
844 
852 {
853  if(m_groups_list.keys().contains(group))
854  return m_groups_list.value(group)->index();
855  else
856  return QModelIndex();
857 }
858 
865 bool DynamicElementTextModel::indexIsText(const QModelIndex &index) const
866 {
867  QStandardItem *item = nullptr;
868 
869  //The item represent the second column
870  if(index.column() == 1)
871  {
872  if(index.parent().isValid())
873  item = itemFromIndex(index.parent().child(index.row(),0));
874  else
875  item = itemFromIndex(this->index(index.row(),0));
876  }
877  else
878  item = itemFromIndex(index);
879 
880  if(item && m_texts_list.values().contains(item))
881  return true;
882  else
883  return false;
884 }
885 
892 bool DynamicElementTextModel::indexIsGroup(const QModelIndex &index) const
893 {
894  QStandardItem *item = nullptr;
895 
896  //The item represent the second column
897  if(index.column() == 1)
898  {
899  if(index.parent().isValid())
900  item = itemFromIndex(index.parent().child(index.row(),0));
901  else
902  item = itemFromIndex(this->index(index.row(),0));
903  }
904  else
905  item = itemFromIndex(index);
906 
907  if(item && m_groups_list.values().contains(item))
908  return true;
909  else
910  return false;
911 }
912 
913 bool DynamicElementTextModel::canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const
914 {
915  Q_UNUSED(action);
916 
917  if(data->hasFormat("application/x-qet-element-text-uuid"))
918  {
919  QModelIndex index;
920  if(parent.isValid() && row != -1 && column !=1) //Insert in child of parent
921  index = parent.child(row, column);
922  else if (parent.isValid() && row == -1 && column == -1) //Drop in parent
923  index = parent;
924 
925  QUuid uuid(data->text());
926 
927  //The data is drop in a group
928  if(indexIsInGroup(index))
929  {
930  //Data is dragged from a text direct child of element
931  for(DynamicElementTextItem *text : m_element.data()->dynamicTextItems())
932  if(text->uuid() == uuid)
933  return true;
934  //Data is dragged from a text in a group
935  for(ElementTextItemGroup *group : m_element.data()->textGroups())
936  {
937  for(DynamicElementTextItem *text : group->texts())
938  if(text->uuid() == uuid)
939  return true;
940  }
941 
942  return false;
943 
944  }
945  else //The data is not drop in a group, then the action must be a drag of text from a group to the element
946  {
947  for(ElementTextItemGroup *group : m_element.data()->textGroups())
948  {
949  for(DynamicElementTextItem *text : group->texts())
950  if(text->uuid() == uuid)
951  return true;
952  }
953  }
954  }
955 
956  return false;
957 }
958 
968 bool DynamicElementTextModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
969 {
970  Q_UNUSED(action)
971 
972  if(data->hasFormat("application/x-qet-element-text-uuid"))
973  {
974  QUuid uuid(data->text());
975  DynamicElementTextItem *deti = nullptr;
976  ElementTextItemGroup *group = nullptr;
977 
978  QModelIndex index;
979  if(parent.isValid() && row != -1 && column !=1) //Insert in child of parent
980  index = parent.child(row, column);
981  else if (parent.isValid() && row == -1 && column == -1) //Drop in parent
982  index = parent;
983 
984  //Darg and drop in a group of text
985  if(indexIsInGroup(index))
986  {
987  //The dragged text is a direct child of element
988  for(DynamicElementTextItem *text : m_element.data()->dynamicTextItems())
989  {
990  if(text->uuid() == uuid)
991  {
992  deti = text;
993  group = groupFromIndex(index);
994 
995  if(group && deti) //Text successfully added in a group
996  {
997  m_element.data()->diagram()->undoStack().push(new AddTextToGroupCommand(deti, group));
998  return true;
999  }
1000  }
1001  }
1002 
1003  //The dragged text is in a group
1004  for(ElementTextItemGroup *grp : m_element.data()->textGroups())
1005  {
1006  for(DynamicElementTextItem *text : grp->texts())
1007  {
1008  if(text->uuid() == uuid)
1009  {
1010  deti = text;
1011  group = groupFromIndex(index);
1012 
1013  //Text successfully moved from a group to another group
1014  if(group && deti)
1015  {
1016  QUndoStack &stack = m_element.data()->diagram()->undoStack();
1017  stack.beginMacro(tr("Déplacer un texte dans un autre groupe"));
1018  stack.push(new RemoveTextFromGroupCommand(deti, grp));
1019  stack.push(new AddTextToGroupCommand(deti, group));
1020  stack.endMacro();
1021 
1022  return true;
1023  }
1024  }
1025  }
1026  }
1027 
1028  return false;
1029  }
1030  else //Drag and drop in anaother place
1031  {
1032  //Get the dropped text
1033  for(ElementTextItemGroup *grp : m_element.data()->textGroups())
1034  {
1035  for(DynamicElementTextItem *text : grp->texts())
1036  {
1037  if(text->uuid() == uuid)
1038  {
1039  deti = text;
1040  group = grp;
1041  break;
1042  }
1043  }
1044  if(deti)
1045  break;
1046  }
1047 
1048  if(deti && group) //Text successfully removed from group
1049  {
1050  m_element.data()->diagram()->undoStack().push((new RemoveTextFromGroupCommand(deti, group)));
1051  return true;
1052  }
1053 
1054  return false;
1055  }
1056  }
1057 
1058  return false;
1059 }
1060 
1061 QMimeData *DynamicElementTextModel::mimeData(const QModelIndexList &indexes) const
1062 {
1063  QModelIndex index = indexes.first();
1064  if (index.isValid())
1065  {
1066  QStandardItem *item = itemFromIndex(index);
1067  if(item)
1068  {
1069  DynamicElementTextItem *deti = m_texts_list.key(item);
1070  if(deti)
1071  {
1072  QMimeData *mime_data = new QMimeData();
1073  mime_data->setText(deti->uuid().toString());
1074  mime_data->setData("application/x-qet-element-text-uuid", deti->uuid().toString().toLatin1());
1075  return mime_data;
1076  }
1077  }
1078  }
1079 
1080  return QStandardItemModel::mimeData(indexes);
1081 }
1082 
1088 {
1089  QStringList mime_list = QAbstractItemModel::mimeTypes();
1090  mime_list << "application/x-qet-element-text-uuid";
1091  return mime_list;
1092 }
1093 
1101 {
1102  if (!m_texts_list.contains(deti))
1103  return;
1104 
1105  QStandardItem *qsi = m_texts_list.value(deti);
1106 
1107  bool usr = false, info = false, compo = false;
1108 
1109  switch (tf) {
1110  case DynamicElementTextItem::UserText: usr = true; break;
1111  case DynamicElementTextItem::ElementInfo: info = true; break;
1112  case DynamicElementTextItem::CompositeText: compo = true;break;
1113  }
1114 
1115  //User text
1116  qsi->child(usr_txt_row,0)->setEnabled(usr);
1117  qsi->child(usr_txt_row,1)->setEnabled(usr);
1118  //Info text
1119  qsi->child(info_txt_row,0)->setEnabled(info);
1120  qsi->child(info_txt_row,1)->setEnabled(info);
1121  //Composite text
1122  qsi->child(compo_txt_row,0)->setEnabled(compo);
1123  qsi->child(compo_txt_row,1)->setEnabled(compo);
1124 }
1125 
1132 {
1133  if(!m_groups_list.contains(group))
1134  return;
1135 
1136  QStandardItem *qsi = m_groups_list.value(group);
1137 
1138  if(group->holdToBottomPage())
1139  {
1140  qsi->child(x_grp_row, 0)->setFlags(Qt::ItemIsSelectable);
1141  qsi->child(x_grp_row, 1)->setFlags(Qt::ItemIsSelectable);
1142  qsi->child(y_grp_row, 0)->setFlags(Qt::ItemIsSelectable);
1143  qsi->child(y_grp_row, 1)->setFlags(Qt::ItemIsSelectable);
1144  qsi->child(rot_grp_row, 0)->setFlags(Qt::ItemIsSelectable);
1145  qsi->child(rot_grp_row, 1)->setFlags(Qt::ItemIsSelectable);
1146  }
1147  else
1148  {
1149  qsi->child(x_grp_row, 0)->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1150  qsi->child(x_grp_row, 1)->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
1151  qsi->child(y_grp_row, 0)->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1152  qsi->child(y_grp_row, 1)->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
1153  qsi->child(rot_grp_row, 0)->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
1154  qsi->child(rot_grp_row, 1)->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable);
1155  }
1156 }
1157 
1159 {
1160  DynamicElementTextItem *deti = textFromItem(qsi);
1161  ElementTextItemGroup *etig = groupFromItem(qsi);
1162  if (!deti && !etig)
1163  return;
1164 
1165  if(deti)
1166  {
1167  QStandardItem *text_qsi = m_texts_list.value(deti);
1168  DiagramContext dc;
1169  if(deti->elementUseForInfo())
1170  dc = deti->elementUseForInfo()->elementInformations();
1171 
1172  if (qsi->data().toInt() == textFrom)
1173  {
1174  QString from = qsi->data(Qt::DisplayRole).toString();
1175 
1176  if (from == tr("Texte utilisateur"))
1177  {
1179  text_qsi->setData(text_qsi->child(usr_txt_row,1)->data(Qt::DisplayRole).toString());
1180  }
1181  else if (from == tr("Information de l'élément"))
1182  {
1184  QString info = text_qsi->child(info_txt_row,1)->data(Qt::UserRole+2).toString();
1185  text_qsi->setData(dc.value(info), Qt::DisplayRole);
1186  }
1187  else
1188  {
1190  QString compo = text_qsi->child(compo_txt_row,1)->data(Qt::UserRole+2).toString();
1191  text_qsi->setData(autonum::AssignVariables::replaceVariable(compo, dc), Qt::DisplayRole);
1192  }
1193 
1194 
1195  }
1196  else if (qsi->data().toInt() == userText)
1197  {
1198  QString text = qsi->data(Qt::DisplayRole).toString();
1199  text_qsi->setData(text, Qt::DisplayRole);
1200  }
1201  else if (qsi->data().toInt() == infoText && deti->elementUseForInfo())
1202  {
1203  QString info = qsi->data(Qt::UserRole+2).toString();
1204  text_qsi->setData(dc.value(info), Qt::DisplayRole);
1205  }
1206  else if (qsi->data().toInt() == compositeText && deti->elementUseForInfo())
1207  {
1208  QString compo = qsi->data(Qt::UserRole+2).toString();
1209  text_qsi->setData(autonum::AssignVariables::replaceVariable(compo, dc), Qt::DisplayRole);
1210  }
1211  }
1212 
1213  //We emit the signal only if @qsi is in the second column, because the data are stored on this column
1214  //the first column is use only for display the title of the property, except for the name of texts group
1215  if((m_groups_list.values().contains(qsi) || qsi->column() == 1) && !m_block_dataChanged)
1216  emit dataChanged();
1217 }
1218 
1227 {
1228  if(set)
1229  {
1230  if(m_hash_text_connect.keys().contains(deti))
1231  return;
1232 
1233  QList<QMetaObject::Connection> connection_list;
1234  connection_list << connect(deti, &DynamicElementTextItem::colorChanged, [deti,this](){this->updateDataFromText(deti, color);});
1235  connection_list << connect(deti, &DynamicElementTextItem::fontChanged, [deti,this](){this->updateDataFromText(deti, font);});
1236  connection_list << connect(deti, &DynamicElementTextItem::textFromChanged, [deti,this](){this->updateDataFromText(deti, textFrom);});
1237  connection_list << connect(deti, &DynamicElementTextItem::textChanged, [deti,this](){this->updateDataFromText(deti, userText);});
1238  connection_list << connect(deti, &DynamicElementTextItem::infoNameChanged, [deti,this](){this->updateDataFromText(deti, infoText);});
1239  connection_list << connect(deti, &DynamicElementTextItem::xChanged, [deti,this](){this->updateDataFromText(deti, pos);});
1240  connection_list << connect(deti, &DynamicElementTextItem::yChanged, [deti,this](){this->updateDataFromText(deti, pos);});
1241  connection_list << connect(deti, &DynamicElementTextItem::frameChanged, [deti,this](){this->updateDataFromText(deti, frame);});
1242  connection_list << connect(deti, &DynamicElementTextItem::rotationChanged, [deti,this](){this->updateDataFromText(deti, rotation);});
1243  connection_list << connect(deti, &DynamicElementTextItem::textWidthChanged,[deti,this](){this->updateDataFromText(deti, textWidth);});
1244  connection_list << connect(deti, &DynamicElementTextItem::compositeTextChanged, [deti, this]() {this->updateDataFromText(deti, compositeText);});
1245  m_hash_text_connect.insert(deti, connection_list);
1246  }
1247  else
1248  {
1249  if(!m_hash_text_connect.keys().contains(deti))
1250  return;
1251 
1252  for (const QMetaObject::Connection& con : m_hash_text_connect.value(deti))
1253  disconnect(con);
1254 
1255  m_hash_text_connect.remove(deti);
1256  }
1257 }
1258 
1267 {
1268  if(set)
1269  {
1270  if(m_hash_group_connect.keys().contains(group))
1271  return;
1272 
1273  QList<QMetaObject::Connection> connection_list;
1274  connection_list << connect(group, &ElementTextItemGroup::alignmentChanged, [group, this]() {this->updateDataFromGroup(group, grpAlignment);});
1275  connection_list << connect(group, &ElementTextItemGroup::rotationChanged, [group, this]() {this->updateDataFromGroup(group, grpRotation);});
1276  connection_list << connect(group, &ElementTextItemGroup::verticalAdjustmentChanged, [group, this]() {this->updateDataFromGroup(group, grpVAdjust);});
1277  connection_list << connect(group, &ElementTextItemGroup::verticalAdjustmentChanged, [group, this]() {this->updateDataFromGroup(group, grpName);});
1278  connection_list << connect(group, &ElementTextItemGroup::holdToBottomPageChanged, [group, this]() {this->updateDataFromGroup(group, grpHoldBottom);});
1279  connection_list << connect(group, &ElementTextItemGroup::xChanged, [group, this]() {this->updateDataFromGroup(group, grpPos);});
1280  connection_list << connect(group, &ElementTextItemGroup::yChanged, [group, this]() {this->updateDataFromGroup(group, grpPos);});
1281  connection_list << connect(group, &ElementTextItemGroup::frameChanged, [group, this]() {this->updateDataFromGroup(group, grpFrame);});
1282 
1283  m_hash_group_connect.insert(group, connection_list);
1284  }
1285  else
1286  {
1287  if(!m_hash_group_connect.keys().contains(group))
1288  return;
1289 
1290  for (const QMetaObject::Connection& con : m_hash_group_connect.value(group))
1291  disconnect(con);
1292 
1293  m_hash_group_connect.remove(group);
1294  }
1295 }
1296 
1298 {
1299  QStandardItem *qsi = m_texts_list.value(deti);
1300  if (!qsi)
1301  return;
1302 
1303  m_block_dataChanged = true;
1304 
1305  switch (type)
1306  {
1307  case textFrom:
1308  {
1309  switch (deti->textFrom())
1310  {
1311  case DynamicElementTextItem::UserText: qsi->child(0,1)->setData(tr("Texte utilisateur"), Qt::DisplayRole); break;
1312  case DynamicElementTextItem::ElementInfo : qsi->child(0,1)->setData(tr("Information de l'élément"), Qt::DisplayRole); break;
1313  case DynamicElementTextItem::CompositeText : qsi->child(0,1)->setData(tr("Texte composé"), Qt::DisplayRole); break;
1314  }
1315  enableSourceText(deti, deti->textFrom());
1316  qsi->setData(deti->toPlainText(), Qt::DisplayRole);
1317  break;
1318  }
1319  case userText:
1320  {
1321  qsi->setData(deti->toPlainText(), Qt::DisplayRole);
1322  qsi->child(usr_txt_row,1)->setData(deti->toPlainText(), Qt::DisplayRole);
1323  qsi->setData(deti->toPlainText(), Qt::DisplayRole);
1324  break;
1325  }
1326  case infoText:
1327  {
1328  qsi->setData(deti->toPlainText(), Qt::DisplayRole);
1329  QString info_name = deti->infoName();
1330  qsi->child(info_txt_row,1)->setData(info_name, Qt::UserRole+2);
1331  qsi->child(info_txt_row,1)->setData(QETApp::elementTranslatedInfoKey(info_name), Qt::DisplayRole);
1332  break;
1333  }
1334  case compositeText:
1335  {
1336  qsi->setData(deti->toPlainText(), Qt::DisplayRole);
1337  qsi->child(compo_txt_row,1)->setData(deti->compositeText(), Qt::UserRole+2);
1338  qsi->child(compo_txt_row,1)->setData(deti->toPlainText(), Qt::DisplayRole);
1339  qsi->setData(deti->toPlainText(), Qt::DisplayRole);
1340  break;
1341  }
1342  case size:
1343  //qsi->child(size_txt_row,1)->setData(deti->fontSize(), Qt::EditRole);
1344  break;
1345  case font:
1346  {
1347  QFont f(deti->font());
1348  qsi->child(font_txt_row,1)->setData(f.family(), Qt::EditRole);
1349  qsi->child(font_txt_row,1)->setData(f, Qt::UserRole+2);
1350  qsi->child(size_txt_row,1)->setData(f.pointSize(), Qt::EditRole);
1351  break;
1352  }
1353  case color:
1354  {
1355  qsi->child(color_txt_row,1)->setData(deti->color(), Qt::EditRole);
1356  qsi->child(color_txt_row,1)->setData(deti->color(), Qt::ForegroundRole);
1357  break;
1358  }
1359  case pos:
1360  {
1361  if(qsi->child(x_txt_row,1))
1362  qsi->child(x_txt_row,1)->setData(deti->pos().x(), Qt::EditRole);
1363  if(qsi->child(y_txt_row,1))
1364  qsi->child(y_txt_row,1)->setData(deti->pos().y(), Qt::EditRole);
1365  break;
1366  }
1367  case frame:
1368  {
1369  qsi->child(frame_txt_row,1)->setCheckState(deti->frame()? Qt::Checked : Qt::Unchecked);
1370  break;
1371  }
1372  case rotation:
1373  {
1374  if(qsi->child(rot_txt_row,1))
1375  qsi->child(rot_txt_row,1)->setData(deti->rotation(), Qt::EditRole);
1376  break;
1377  }
1378  case textWidth:
1379  {
1380  qsi->child(width_txt_row,1)->setData(deti->textWidth(), Qt::EditRole);
1381  break;
1382  }
1383  default:break;
1384  }
1385 
1386  m_block_dataChanged = false;
1387 }
1388 
1390 {
1391  QStandardItem *qsi = m_groups_list.value(group);
1392  if (!qsi)
1393  return;
1394 
1395  m_block_dataChanged = true;
1396 
1397  switch (type)
1398  {
1399  case grpAlignment:
1400  {
1401  switch (group->alignment())
1402  {
1403  case Qt::AlignLeft: qsi->child(align_grp_row,1)->setData(tr("Gauche"), Qt::DisplayRole); break;
1404  case Qt::AlignRight : qsi->child(align_grp_row,1)->setData(tr("Droite"), Qt::DisplayRole); break;
1405  case Qt::AlignVCenter : qsi->child(align_grp_row,1)->setData(tr("Centre"), Qt::DisplayRole); break;
1406  default: qsi->child(0,1)->setData("", Qt::DisplayRole); break;
1407  }
1408  break;
1409  }
1410  case grpPos:
1411  {
1412  qsi->child(x_grp_row,1)->setData(group->pos().x(), Qt::EditRole);
1413  qsi->child(y_grp_row,1)->setData(group->pos().y(), Qt::EditRole);
1414  break;
1415  }
1416  case grpRotation:
1417  qsi->child(rot_grp_row,1)->setData(group->rotation(), Qt::EditRole);
1418  break;
1419  case grpVAdjust:
1420  qsi->child(adjust_grp_row,1)->setData(group->verticalAdjustment(), Qt::EditRole);
1421  break;
1422  case grpName:
1423  qsi->setData(group->name(), Qt::DisplayRole);
1424  break;
1425  case grpHoldBottom:
1426  {
1427  qsi->child(hold_to_bottom_grp_row,1)->setCheckState(group->holdToBottomPage()? Qt::Checked : Qt::Unchecked);
1429  break;
1430  }
1431  case grpFrame:
1432  qsi->child(frame_grp_row, 1)->setCheckState(group->frame()? Qt::Checked : Qt::Unchecked);
1433  break;
1434  default:break;
1435  }
1436 
1437  m_block_dataChanged = false;
1438 }
1439 
1440 
1441 /***************************************************
1442  * A little delegate only for add a combobox and a color dialog,
1443  * for use with the model
1444  ***************************************************/
1445 
1447  QStyledItemDelegate(parent)
1448 {}
1449 
1450 QWidget *DynamicTextItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const
1451 {
1452  switch (index.data(Qt::UserRole+1).toInt())
1453  {
1455  {
1456  QComboBox *qcb = new QComboBox(parent);
1457  qcb->setObjectName("text_from");
1458  qcb->addItem(tr("Texte utilisateur"));
1459  qcb->addItem(tr("Information de l'élément"));
1460  qcb->addItem(tr("Texte composé"));
1461  return qcb;
1462  }
1464  {
1465  const DynamicElementTextModel *detm = static_cast<const DynamicElementTextModel *>(index.model());
1466  QStandardItem *qsi = detm->itemFromIndex(index);
1467 
1468  if(!qsi)
1469  break;
1470 
1471  DynamicElementTextItem *deti = detm->textFromIndex(index);
1472  if(!deti)
1473  break;
1474 
1475  //We use a QMap because the keys of the map are sorted, then no matter the curent local,
1476  //the value of the combo box are always alphabetically sorted
1477  QMap <QString, QString> info_map;
1478  for(const QString& str : availableInfo(deti)) {
1479  info_map.insert(QETApp::elementTranslatedInfoKey(str), str);
1480  }
1481 
1482  QComboBox *qcb = new QComboBox(parent);
1483  qcb->setObjectName("info_text");
1484  for (const QString& key : info_map.keys()) {
1485  qcb->addItem(key, info_map.value(key));
1486  }
1487  return qcb;
1488  }
1490  {
1491  const DynamicElementTextModel *detm = static_cast<const DynamicElementTextModel *>(index.model());
1492  QStandardItem *qsi = detm->itemFromIndex(index);
1493 
1494  if(!qsi)
1495  break;
1496 
1497  DynamicElementTextItem *deti = detm->textFromIndex(index);
1498  if(!deti)
1499  break;
1500 
1501  CompositeTextEditDialog *cted = new CompositeTextEditDialog(deti, parent);
1502  cted->setObjectName("composite_text");
1503  return cted;
1504  }
1506  {
1507  const DynamicElementTextModel *detm = static_cast<const DynamicElementTextModel *>(index.model());
1508  QStandardItem *qsi = detm->itemFromIndex(index);
1509 
1510  if(!qsi)
1511  break;
1512 
1513  DynamicElementTextItem *deti = detm->textFromIndex(index);
1514  if(!deti)
1515  break;
1516 
1517  AlignmentTextDialog *atd = new AlignmentTextDialog(deti->alignment(), parent);
1518  atd->setObjectName("alignment_text");
1519  return atd;
1520  }
1522  {
1523  QSpinBox *sb = new QSpinBox(parent);
1524  sb->setObjectName("font_size");
1525  sb->setFrame(false);
1526  return sb;
1527  }
1529  {
1530  bool ok;
1531  QFont font = QFontDialog::getFont(&ok, index.data(Qt::UserRole+2).value<QFont>(), parent);
1532  QWidget *w = new QWidget(parent);
1533  if (ok)
1534  {
1535  w->setFont(font);
1536  w->setProperty("ok", ok);
1537  }
1538  w->setObjectName("font_dialog");
1539  return w;
1540  }
1542  {
1543  QColorDialog *cd = new QColorDialog(index.data(Qt::EditRole).value<QColor>(), parent);
1544  cd->setObjectName("color_dialog");
1545  return cd;
1546  }
1548  {
1549  QSpinBox *sb = new QSpinBox(parent);
1550  sb->setObjectName("pos_dialog");
1551  sb->setRange(-1000,10000);
1552  sb->setFrame(false);
1553  sb->setSuffix(" px");
1554  return sb;
1555  }
1557  {
1558  QSpinBox *sb = new QSpinBox(parent);
1559  sb->setObjectName("rot_spinbox");
1560  sb->setRange(0, 359);
1561  sb->setWrapping(true);
1562  sb->setFrame(false);
1563  sb->setSuffix(" °");
1564  return sb;
1565  }
1567  {
1568  QSpinBox *sb = new QSpinBox(parent);
1569  sb->setObjectName("width_spinbox");
1570  sb->setRange(-1, 500);
1571  sb->setFrame(false);
1572  sb->setSuffix(" px");
1573  return sb;
1574  }
1576  {
1577  QComboBox *qcb = new QComboBox(parent);
1578  qcb->setFrame(false);
1579  qcb->setObjectName("group_alignment");
1580  qcb->addItem(tr("Gauche"));
1581  qcb->addItem(tr("Centre"));
1582  qcb->addItem(tr("Droite"));
1583  return qcb;
1584  }
1586  {
1587  QSpinBox *sb = new QSpinBox(parent);
1588  sb->setObjectName("group_pos");
1589  sb->setRange(-1000,10000);
1590  sb->setFrame(false);
1591  sb->setSuffix(" px");
1592  return sb;
1593  }
1595  {
1596  QSpinBox *sb = new QSpinBox(parent);
1597  sb->setObjectName("group_rotation");
1598  sb->setRange(0, 359);
1599  sb->setWrapping(true);
1600  sb->setFrame(false);
1601  sb->setSuffix(" °");
1602  return sb;
1603  }
1605  {
1606  QSpinBox *sb = new QSpinBox(parent);
1607  sb->setObjectName("group_v_adjustment");
1608  sb->setRange(-20, 20);
1609  sb->setFrame(false);
1610  sb->setSuffix(" px");
1611  return sb;
1612  }
1613  }
1614  return QStyledItemDelegate::createEditor(parent, option, index);
1615 }
1616 
1617 void DynamicTextItemDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const
1618 {
1619  if (index.isValid())
1620  {
1621  if (editor->objectName() == "font_dialog")
1622  {
1623  if (QStandardItemModel *qsim = dynamic_cast<QStandardItemModel *>(model))
1624  {
1625  if(QStandardItem *qsi = qsim->itemFromIndex(index))
1626  {
1627  if (editor->property("ok").toBool() == true)
1628  {
1629  qsi->setData(editor->font().family(), Qt::EditRole);
1630  qsi->setData(editor->font(), Qt::UserRole+2);
1631  }
1632  return;
1633  }
1634  }
1635  }
1636  else if(editor->objectName() == "color_dialog")
1637  {
1638  if (QStandardItemModel *qsim = dynamic_cast<QStandardItemModel *>(model))
1639  {
1640  if(QStandardItem *qsi = qsim->itemFromIndex(index))
1641  {
1642  QColorDialog *cd = static_cast<QColorDialog *> (editor);
1643  if (cd->result() == QDialog::Accepted)
1644  {
1645  qsi->setData(cd->selectedColor(), Qt::EditRole);
1646  qsi->setData(cd->selectedColor(), Qt::ForegroundRole);
1647  }
1648  return;
1649  }
1650 
1651  }
1652  }
1653  else if (editor->objectName() == "info_text")
1654  {
1655  if (QStandardItemModel *qsim = dynamic_cast<QStandardItemModel *>(model))
1656  {
1657  if(QStandardItem *qsi = qsim->itemFromIndex(index))
1658  {
1659  QComboBox *cb = static_cast<QComboBox *>(editor);
1660  qsi->setData(cb->currentText(), Qt::DisplayRole);
1661  qsi->setData(cb->currentData(), Qt::UserRole+2);
1662  return;
1663  }
1664 
1665  }
1666  }
1667  else if (editor->objectName() == "composite_text")
1668  {
1669  if (QStandardItemModel *qsim = dynamic_cast<QStandardItemModel *>(model))
1670  {
1671  if(QStandardItem *qsi = qsim->itemFromIndex(index))
1672  {
1673 
1674  CompositeTextEditDialog *cted = static_cast<CompositeTextEditDialog *>(editor);
1675 
1676  QString edited_text = cted->plainText();
1677  QString assigned_text;
1678 
1679  const DynamicElementTextModel *detm = static_cast<const DynamicElementTextModel *>(index.model());
1680  DynamicElementTextItem *deti = detm->textFromIndex(index);
1681  if(deti)
1682  {
1683  DiagramContext dc;
1684  if(deti->elementUseForInfo())
1685  dc = deti->elementUseForInfo()->elementInformations();
1686  assigned_text = autonum::AssignVariables::replaceVariable(edited_text, dc);
1687  }
1688 
1689  qsi->setData(assigned_text, Qt::DisplayRole);
1690  qsi->setData(edited_text, Qt::UserRole+2);
1691  return;
1692  }
1693  }
1694  }
1695  else if (editor->objectName() == "alignment_text")
1696  {
1697  if(QStandardItemModel *qsim = dynamic_cast<QStandardItemModel *>(model))
1698  {
1699  if(QStandardItem *qsi = qsim->itemFromIndex(index))
1700  {
1701  AlignmentTextDialog *atd = static_cast<AlignmentTextDialog *>(editor);
1702  Qt::Alignment align = atd->alignment();
1703  qsi->setData(QVariant::fromValue(align), Qt::UserRole+2);
1704  return;
1705  }
1706  }
1707  }
1708  else if (editor->objectName() == "group_alignment")
1709  {
1710  if(QStandardItemModel *qsim = dynamic_cast<QStandardItemModel *>(model))
1711  {
1712  if(QStandardItem *qsi = qsim->itemFromIndex(index))
1713  {
1714  QComboBox *cb = static_cast<QComboBox *>(editor);
1715  qsi->setData(cb->currentText(), Qt::DisplayRole);
1716  }
1717  }
1718  }
1719  }
1720 
1721  QStyledItemDelegate::setModelData(editor, model, index);
1722 }
1723 
1724 bool DynamicTextItemDelegate::eventFilter(QObject *object, QEvent *event)
1725 {
1726 
1727  //This is a bad hack, for change the normal behavior :
1728  //in normal behavior, the value is commited when the spinbox lose focus or enter key is pressed
1729  //With this hack the value is commited each time the value change without the need to validate.
1730  //then the change is apply in live
1731  if(object->objectName() == "pos_dialog" || object->objectName() == "font_size" || object->objectName() == "rot_spinbox" || \
1732  object->objectName() == "group_rotation" || object->objectName() == "group_v_adjustment" || object->objectName() == "width_spinbox" ||\
1733  object->objectName() == "group_pos")
1734  {
1735  object->event(event);
1736 
1737  QSpinBox *sb = static_cast<QSpinBox *>(object);
1738  switch (event->type()) {
1739  case QEvent::KeyPress:
1740  emit commitData(sb); break;
1741  case QEvent::KeyRelease:
1742  emit commitData(sb); break;
1743  case QEvent::MouseButtonPress:
1744  emit commitData(sb); break;
1745  case QEvent::MouseButtonRelease:
1746  emit commitData(sb); break;
1747  case QEvent::Wheel:
1748  emit commitData(sb); break;
1749  default:break;
1750  }
1751  return true;
1752  }
1753 
1754  //Like the hack above, change the current index of the combobox, apply the change immediately, no need to lose focus or press enter.
1755  if((object->objectName() == "text_from" || object->objectName() == "info_text" || object->objectName() == "group_alignment") && event->type() == QEvent::FocusIn)
1756  {
1757  QComboBox *qcb = static_cast<QComboBox *>(object);
1758  connect(qcb, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [this,qcb](){emit commitData(qcb);});
1759  }
1760 
1761  return QStyledItemDelegate::eventFilter(object, event);
1762 }
1763 
1770 {
1771  QStringList qstrl;
1772 
1773  if(deti->parentElement()->linkType() & Element::AllReport) //Special treatment for text owned by a folio report
1774  {
1775  qstrl << "label";
1776 
1777  if(!deti->m_watched_conductor.isNull())
1778  {
1779  Conductor *cond = deti->m_watched_conductor.data();
1780  if (!cond->properties().m_function.isEmpty())
1781  qstrl << "function";
1782  if(!cond->properties().m_tension_protocol.isEmpty())
1783  qstrl << "tension-protocol";
1784  }
1785 
1786  return qstrl;
1787  }
1788  else
1789  {
1790  Element *elmt = deti->elementUseForInfo();
1791  if(!elmt)
1792  return qstrl;
1793 
1794 
1795  QStringList info_list = QETApp::elementInfoKeys();
1796  info_list.removeAll("formula"); //No need to have formula
1797  DiagramContext dc = elmt->elementInformations();
1798 
1799  for(const QString& info : info_list)
1800  {
1801  if(dc.contains(info))
1802  qstrl << info;
1803  }
1804  }
1805  return qstrl;
1806 }
void removeText(DynamicElementTextItem *deti)
DynamicElementTextModel::removeText.
void holdToBottomPageChanged(bool)
void fontChanged(QFont font)
The QPropertyUndoCommand class This undo command manage QProperty of a QObject. This undo command can...
DynamicElementTextModel(Element *element, QObject *parent=nullptr)
ElementTextItemGroup * parentGroup() const
DynamicElementTextItem::parentGroup.
static int frame_txt_row
ConductorProperties properties
Conductor::properties.
Definition: conductor.h:48
QString text
DynamicElementTextItem::text.
virtual kind linkType() const
Definition: element.h:138
void frameChanged(bool frame)
QPointer< Conductor > m_watched_conductor
The CompositeTextEditDialog class CompositeTextEditDialog display a dialog use to write the complex t...
The DynamicElementTextItem class This class provide a simple text field of element who can be added o...
void setConnection(DynamicElementTextItem *deti, bool set)
DynamicElementTextModel::setConnection Set up the connection for to keep up to date the data of this...
void textFromChanged(DynamicElementTextItem::TextFrom text_from)
void textsGroupAdded(ElementTextItemGroup *group)
void enableGroupRotationAndPos(ElementTextItemGroup *group)
DynamicElementTextModel::enableGroupRotation Enable/disable the item "group rotation" according the o...
void addText(DynamicElementTextItem *deti)
DynamicElementTextModel::addText.
static int y_grp_row
DiagramContext elementInformations() const
Definition: element.h:89
TextFrom textFrom
DynamicElementTextItem::textFrom.
static int align_grp_row
QUndoCommand * undoForEditedText(DynamicElementTextItem *deti, QUndoCommand *parent_undo=nullptr) const
DynamicElementTextModel::undoForEditedText.
void colorChanged(QColor color)
static int rot_grp_row
void enableSourceText(DynamicElementTextItem *deti, DynamicElementTextItem::TextFrom tf)
DynamicElementTextModel::enableSourceText Enable the good field, according to the current source of t...
Qt::Alignment alignment() const
AlignmentTextDialog::alignment.
bool eventFilter(QObject *object, QEvent *event) override
static int x_txt_row
QVariant value(const QString &key) const
QHash< DynamicElementTextItem *, QStandardItem * > m_texts_list
QIcon PartText
Definition: qeticons.cpp:134
Element * elementUseForInfo() const
DynamicElementTextItem::elementUseForInfo.
DynamicElementTextItem * textFromItem(QStandardItem *item) const
DynamicElementTextModel::textFromItem.
QList< QStandardItem * > itemsForText(DynamicElementTextItem *deti)
DynamicElementTextModel::itemsForText.
QStringList mimeTypes() const override
DynamicElementTextModel::mimeTypes.
void verticalAdjustmentChanged(int)
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
DynamicElementTextModel::dropMimeData.
void frameChanged(bool frame)
void itemDataChanged(QStandardItem *qsi)
static int width_txt_row
QString compositeText
DynamicElementTextItem::compositeText.
static int align_txt_row
static int y_txt_row
QHash< ElementTextItemGroup *, QList< QMetaObject::Connection > > m_hash_group_connect
void textsGroupAboutToBeRemoved(ElementTextItemGroup *group)
static int compo_txt_row
static int font_txt_row
bool contains(const QString &) const
void textAddedToGroup(DynamicElementTextItem *text, ElementTextItemGroup *group)
QHash< ElementTextItemGroup *, QStandardItem * > m_groups_list
void removeGroup(ElementTextItemGroup *group)
DynamicElementTextModel::removeGroup Remove the text item group from this model.
qreal correctAngle(const qreal &)
Definition: qet.cpp:505
static int size_txt_row
static int frame_grp_row
void updateDataFromText(DynamicElementTextItem *deti, DynamicElementTextModel::ValueType type)
void updateDataFromGroup(ElementTextItemGroup *group, DynamicElementTextModel::ValueType type)
QList< DynamicElementTextItem * > texts() const
ElementTextItemGroup::texts.
Qt::Alignment alignment
QIcon tr
Definition: qeticons.cpp:204
static QStringList elementInfoKeys()
QETApp::elementInfoKeys.
Definition: qetapp.cpp:289
void textRemovedFromGroup(DynamicElementTextItem *text, ElementTextItemGroup *group)
QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override
void addGroup(ElementTextItemGroup *group)
DynamicElementTextModel::AddGroup Add a text item group to this model.
Element * parentElement() const
DynamicElementTextItem::ParentElement.
QIcon textGroup
Definition: qeticons.cpp:215
The ElementTextItemGroup class This class represent a group of element text Texts in the group can be...
bool indexIsText(const QModelIndex &index) const
DynamicElementTextModel::indexIsText.
static int rot_txt_row
void rotationChanged(qreal)
QModelIndex indexFromGroup(ElementTextItemGroup *group) const
DynamicElementTextModel::indexFromGroup.
QMimeData * mimeData(const QModelIndexList &indexes) const override
void textWidthChanged(qreal width)
static int hold_to_bottom_grp_row
bool indexIsGroup(const QModelIndex &index) const
DynamicElementTextModel::indexIsGroup.
ElementTextItemGroup * groupFromIndex(const QModelIndex &index) const
DynamicElementTextModel::groupFromIndex.
void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const override
static int adjust_grp_row
static int color_txt_row
static int src_txt_row
static int usr_txt_row
void textChanged(QString text)
void removeTextFromGroup(DynamicElementTextItem *deti, ElementTextItemGroup *group)
void infoNameChanged(QString info)
DynamicTextItemDelegate(QObject *parent=Q_NULLPTR)
void alignmentChanged(Qt::Alignment)
void compositeTextChanged(QString text)
bool indexIsInGroup(const QModelIndex &index) const
DynamicElementTextModel::indexIsInGroup.
void textAdded(DynamicElementTextItem *deti)
static QString elementTranslatedInfoKey(const QString &)
ElementsProperties::translatedInfo Return the translated information key given by If don&#39;t match...
Definition: qetapp.cpp:321
void textRemoved(DynamicElementTextItem *deti)
static int x_grp_row
void setAnimated(bool animate=true, bool first_time=true)
QPropertyUndoCommand::setAnimated.
ElementTextItemGroup * groupFromItem(QStandardItem *item) const
DynamicElementTextModel::groupFromItem.
QStringList availableInfo(DynamicElementTextItem *deti) const
DynamicTextItemDelegate::availableInfo.
void addTextToGroup(DynamicElementTextItem *deti, ElementTextItemGroup *group)
DynamicElementTextModel::textAddedToGroup Add the text to the group .
QModelIndex indexFromText(DynamicElementTextItem *text) const
DynamicElementTextModel::indexFromText.
Horizontal segment.
Definition: qet.h:87
The DynamicElementTextModel class A model to use with QtView. This model display and can edit the val...
QString plainText() const
CompositeTextEditDialog::plainText.
QString infoName
DynamicElementTextItem::infoName.
static int info_txt_row
static QString replaceVariable(const QString &formula, const DiagramContext &dc)
AssignVariables::replaceVariable Replace the variables in in form %{my-var} to the corresponding val...
bool canDropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const override
QUndoCommand * undoForEditedGroup(ElementTextItemGroup *group, QUndoCommand *parent_undo=nullptr) const
DynamicElementTextModel::undoForEditedGroup.
DynamicElementTextItem * textFromIndex(const QModelIndex &index) const
DynamicElementTextModel::textFromIndex.
QHash< DynamicElementTextItem *, QList< QMetaObject::Connection > > m_hash_text_connect