[TD]allow template fields to re-apply autofill
This commit is contained in:
@@ -67,6 +67,11 @@ QString DlgTemplateField::getFieldContent()
|
||||
return ui->leInput->text();
|
||||
}
|
||||
|
||||
bool DlgTemplateField::getAutofillState()
|
||||
{
|
||||
return ui->cbAutofill->isChecked();
|
||||
}
|
||||
|
||||
void DlgTemplateField::accept()
|
||||
{
|
||||
QDialog::accept();
|
||||
|
||||
@@ -45,6 +45,7 @@ public:
|
||||
void setFieldLength(int length);
|
||||
void setFieldContent(std::string content);
|
||||
QString getFieldContent();
|
||||
bool getAutofillState();
|
||||
|
||||
public Q_SLOTS:
|
||||
void accept() override;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>340</width>
|
||||
<height>90</height>
|
||||
<height>127</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -46,6 +46,16 @@
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="leInput"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="cbAutofill">
|
||||
<property name="toolTip">
|
||||
<string>Check this box to reapply autofill to this field. </string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Autofill</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
||||
@@ -30,12 +30,16 @@
|
||||
#endif // #ifndef _PreCmp_
|
||||
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Tools.h>
|
||||
|
||||
#include <Mod/TechDraw/App/DrawTemplate.h>
|
||||
#include <Mod/TechDraw/App/DrawSVGTemplate.h>
|
||||
|
||||
#include "DlgTemplateField.h"
|
||||
#include "TemplateTextField.h"
|
||||
|
||||
using namespace TechDrawGui;
|
||||
using namespace TechDraw;
|
||||
|
||||
TemplateTextField::TemplateTextField(QGraphicsItem *parent,
|
||||
TechDraw::DrawTemplate *myTmplte,
|
||||
@@ -76,12 +80,18 @@ void TemplateTextField::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
ui.setFieldContent(tmplte->EditableTexts[fieldNameStr]);
|
||||
|
||||
if (ui.exec() == QDialog::Accepted) {
|
||||
//WF: why is this escaped?
|
||||
// "<" is converted elsewhere and no other characters cause problems.
|
||||
// escaping causes "&" to appear as "&" etc
|
||||
// QString qsClean = ui.getFieldContent().toHtmlEscaped();
|
||||
QString qsClean = ui.getFieldContent();
|
||||
std::string utf8Content = qsClean.toUtf8().constData();
|
||||
if (ui.getAutofillState()) {
|
||||
auto svgTemplate = dynamic_cast<DrawSVGTemplate*>(tmplte);
|
||||
if (svgTemplate) {
|
||||
QString fieldName = Base::Tools::fromStdString(fieldNameStr);
|
||||
QString autofillValue = svgTemplate->getAutofillByEditableName(fieldName);
|
||||
if (!autofillValue.isEmpty()) {
|
||||
utf8Content = autofillValue.toUtf8().constData();
|
||||
}
|
||||
}
|
||||
}
|
||||
tmplte->EditableTexts.setValue(fieldNameStr, utf8Content);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user