QElectroTech  0.70
compositetexteditdialog.cpp
Go to the documentation of this file.
2 
3 #include <utility>
4 #include "ui_compositetexteditdialog.h"
6 #include "element.h"
7 #include "qetapp.h"
8 #include "conductor.h"
9 
11  QDialog(parent),
12  ui(new Ui::CompositeTextEditDialog),
13  m_text(text)
14 {
15  ui->setupUi(this);
17  ui->m_plain_text_edit->setPlainText(m_default_text);
18 #if QT_VERSION >= 0x050300
19  ui->m_plain_text_edit->setPlaceholderText(tr("Entrée votre texte composé ici, en vous aidant des variables disponible"));
20 #endif
21  setUpComboBox();
22 }
23 
24 CompositeTextEditDialog::CompositeTextEditDialog(QString text, QWidget *parent) :
25  QDialog(parent),
27 {
28  ui->setupUi(this);
29  m_default_text = std::move(text);
30  ui->m_plain_text_edit->setPlainText(m_default_text);
31 #if QT_VERSION >= 0x050300
32  ui->m_plain_text_edit->setPlaceholderText(tr("Entrée votre texte composé ici, en vous aidant des variables disponible"));
33 #endif
34  setUpComboBox();
35 }
36 
38  delete ui;
39 }
40 
46  return ui->m_plain_text_edit->toPlainText();
47 }
48 
54 {
55  QStringList qstrl;
56 
57  if(m_text && (m_text->parentElement()->linkType() & Element::AllReport)) //Special treatment for text owned by a folio report
58  {
59  qstrl << "label" << "function" << "tension-protocol";
60  }
61  else
62  {
63  qstrl = QETApp::elementInfoKeys();
64  qstrl.removeAll("formula");
65  }
66 
67  //We use a QMap because the keys of the map are sorted, then no matter the curent local,
68  //the value of the combo box are always alphabetically sorted
69  QMap <QString, QString> info_map;
70  for(const QString& str : qstrl) {
72  }
73  for(const QString& key : info_map.keys()) {
74  ui->m_info_cb->addItem(key, info_map.value(key));
75  }
76 }
77 
79 {
80  Q_UNUSED(arg1)
81  ui->m_plain_text_edit->insertPlainText(ui->m_info_cb->currentData().toString());
82 }
83 
89 void CompositeTextEditDialog::focusInEvent(QFocusEvent *event)
90 {
91  ui->m_plain_text_edit->setFocus();
92  QDialog::focusInEvent(event);
93 }
virtual kind linkType() const
Definition: element.h:138
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...
Ui::CompositeTextEditDialog * ui
QString compositeText
DynamicElementTextItem::compositeText.
CompositeTextEditDialog(DynamicElementTextItem *text, QWidget *parent=nullptr)
DynamicElementTextItem * m_text
static QString elementInfoToVar(const QString &info)
QETApp::elementInfoToVar.
Definition: qetapp.cpp:355
QIcon tr
Definition: qeticons.cpp:204
static QStringList elementInfoKeys()
QETApp::elementInfoKeys.
Definition: qetapp.cpp:289
Element * parentElement() const
DynamicElementTextItem::ParentElement.
void on_m_info_cb_activated(const QString &arg1)
void setUpComboBox()
CompositeTextEditDialog::setUpComboBox Add the available element information in the combo box...
static QString elementTranslatedInfoKey(const QString &)
ElementsProperties::translatedInfo Return the translated information key given by If don&#39;t match...
Definition: qetapp.cpp:321
QString plainText() const
CompositeTextEditDialog::plainText.
void focusInEvent(QFocusEvent *event) override
CompositeTextEditDialog::focusInEvent Reimplemented from QWidget::focusInEvent.