2017-08-16 13:52:15 +00:00
|
|
|
#include "compositetexteditdialog.h"
|
2018-07-19 14:14:31 +00:00
|
|
|
|
2020-12-08 19:57:35 +01:00
|
|
|
#include "../qetapp.h"
|
|
|
|
#include "../qetgraphicsitem/conductor.h"
|
|
|
|
#include "../qetgraphicsitem/dynamicelementtextitem.h"
|
|
|
|
#include "../qetgraphicsitem/element.h"
|
|
|
|
#include "../qetinformation.h"
|
2017-08-16 13:52:15 +00:00
|
|
|
#include "ui_compositetexteditdialog.h"
|
2020-12-08 19:57:35 +01:00
|
|
|
|
|
|
|
#include <utility>
|
2017-08-16 13:52:15 +00:00
|
|
|
|
|
|
|
CompositeTextEditDialog::CompositeTextEditDialog(DynamicElementTextItem *text, QWidget *parent) :
|
|
|
|
QDialog(parent),
|
|
|
|
ui(new Ui::CompositeTextEditDialog),
|
|
|
|
m_text(text)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
m_default_text = m_text->compositeText();
|
|
|
|
ui->m_plain_text_edit->setPlainText(m_default_text);
|
2017-08-24 12:38:35 +00:00
|
|
|
ui->m_plain_text_edit->setPlaceholderText(tr("Entrée votre texte composé ici, en vous aidant des variables disponible"));
|
2024-12-31 21:58:42 +01:00
|
|
|
bool report = false;
|
|
|
|
if ((m_text) &&(m_text->parentElement()->linkType()) & (Element::AllReport))
|
|
|
|
{
|
|
|
|
report = true;
|
|
|
|
}
|
|
|
|
setUpComboBox(report);
|
2017-08-16 13:52:15 +00:00
|
|
|
}
|
|
|
|
|
2024-12-31 21:58:42 +01:00
|
|
|
CompositeTextEditDialog::CompositeTextEditDialog(QString text, bool report, QWidget *parent) :
|
2018-03-11 16:00:58 +00:00
|
|
|
QDialog(parent),
|
|
|
|
ui(new Ui::CompositeTextEditDialog)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
2018-07-19 14:14:31 +00:00
|
|
|
m_default_text = std::move(text);
|
2018-03-11 16:00:58 +00:00
|
|
|
ui->m_plain_text_edit->setPlainText(m_default_text);
|
|
|
|
ui->m_plain_text_edit->setPlaceholderText(tr("Entrée votre texte composé ici, en vous aidant des variables disponible"));
|
2024-12-31 21:58:42 +01:00
|
|
|
setUpComboBox(report);
|
2018-03-11 16:00:58 +00:00
|
|
|
}
|
|
|
|
|
2020-09-07 22:03:40 +02:00
|
|
|
CompositeTextEditDialog::~CompositeTextEditDialog()
|
|
|
|
{
|
2017-08-16 13:52:15 +00:00
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
@brief CompositeTextEditDialog::plainText
|
|
|
|
@return The edited text
|
|
|
|
*/
|
2020-09-07 22:03:40 +02:00
|
|
|
QString CompositeTextEditDialog::plainText() const
|
|
|
|
{
|
2017-08-16 13:52:15 +00:00
|
|
|
return ui->m_plain_text_edit->toPlainText();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
@brief CompositeTextEditDialog::setUpComboBox
|
|
|
|
Add the available element information in the combo box
|
|
|
|
*/
|
2024-12-31 21:58:42 +01:00
|
|
|
void CompositeTextEditDialog::setUpComboBox(bool is_report)
|
2017-08-16 13:52:15 +00:00
|
|
|
{
|
|
|
|
QStringList qstrl;
|
2021-02-06 19:41:22 +01:00
|
|
|
|
|
|
|
if(is_report) //Special treatment for text owned by a folio report
|
2017-09-13 16:38:16 +00:00
|
|
|
{
|
2021-02-06 19:41:22 +01:00
|
|
|
qstrl = QETInformation::folioReportInfoKeys();
|
2017-09-13 16:38:16 +00:00
|
|
|
}
|
|
|
|
else
|
2017-08-16 13:52:15 +00:00
|
|
|
{
|
2020-11-14 19:09:40 +01:00
|
|
|
qstrl = QETInformation::elementInfoKeys();
|
2018-05-03 09:33:30 +00:00
|
|
|
qstrl.removeAll("formula");
|
2017-08-16 13:52:15 +00:00
|
|
|
}
|
2024-12-22 16:17:32 +01:00
|
|
|
|
2024-12-31 08:40:03 +01:00
|
|
|
for (int i=0; i<qstrl.size();++i) {
|
|
|
|
ui -> m_info_cb -> addItem(QETInformation::translatedInfoKey(qstrl[i]),
|
|
|
|
is_report ? QETInformation::folioReportInfoToVar(qstrl[i]) : QETInformation::elementInfoToVar(qstrl[i]));
|
2017-08-16 13:52:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CompositeTextEditDialog::on_m_info_cb_activated(const QString &arg1)
|
|
|
|
{
|
|
|
|
Q_UNUSED(arg1)
|
|
|
|
ui->m_plain_text_edit->insertPlainText(ui->m_info_cb->currentData().toString());
|
|
|
|
}
|
2017-11-06 16:17:48 +00:00
|
|
|
|
|
|
|
/**
|
2020-08-16 11:19:36 +02:00
|
|
|
@brief CompositeTextEditDialog::focusInEvent
|
|
|
|
Reimplemented from QWidget::focusInEvent
|
|
|
|
@param event
|
|
|
|
*/
|
2017-11-06 16:17:48 +00:00
|
|
|
void CompositeTextEditDialog::focusInEvent(QFocusEvent *event)
|
|
|
|
{
|
|
|
|
ui->m_plain_text_edit->setFocus();
|
|
|
|
QDialog::focusInEvent(event);
|
|
|
|
}
|