[TD]show autofill value in dialog

This commit is contained in:
wandererfan
2024-06-28 20:23:33 -04:00
committed by WandererFan
parent 20f5e8f662
commit f53fd6d474
7 changed files with 36 additions and 4 deletions

View File

@@ -86,7 +86,7 @@ void DrawSVGTemplate::onChanged(const App::Property* prop)
replaceFileIncluded(Template.getValue());
EditableTexts.setValues(getEditableTextsFromTemplate());
QDomDocument templateDocument;
if (getTemplateDocument(Template.getValue(), templateDocument)) {
if (getTemplateDocument(PageResult.getValue(), templateDocument)) {
extractTemplateAttributes(templateDocument);
}
}
@@ -251,7 +251,7 @@ std::map<std::string, std::string> DrawSVGTemplate::getEditableTextsFromTemplate
std::map<std::string, std::string> editables;
QDomDocument templateDocument;
if (!getTemplateDocument(Template.getValue(), templateDocument)) {
if (!getTemplateDocument(PageResult.getValue(), templateDocument)) {
return editables;
}
@@ -294,7 +294,7 @@ QString DrawSVGTemplate::getAutofillByEditableName(QString nameToMatch)
QString nameCapture{nameToMatch};
QDomDocument templateDocument;
if (!getTemplateDocument(Template.getValue(), templateDocument)) {
if (!getTemplateDocument(PageResult.getValue(), templateDocument)) {
return {};
}

View File

@@ -62,6 +62,12 @@ void DlgTemplateField::setFieldContent(std::string content)
ui->leInput->setText(qs);
}
void DlgTemplateField::setAutofillContent(std::string content)
{
QString qs = QString::fromUtf8(content.data(), content.size());
ui->leAutofill->setText(qs);
}
QString DlgTemplateField::getFieldContent()
{
return ui->leInput->text();

View File

@@ -44,6 +44,7 @@ public:
void setFieldName(std::string name);
void setFieldLength(int length);
void setFieldContent(std::string content);
void setAutofillContent(std::string content);
QString getFieldContent();
bool getAutofillState();

View File

@@ -10,7 +10,7 @@
<x>0</x>
<y>0</y>
<width>340</width>
<height>127</height>
<height>132</height>
</rect>
</property>
<property name="windowTitle">
@@ -56,6 +56,19 @@
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="leAutofill">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>The autofill replacement value.</string>
</property>
<property name="readOnly">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item>

View File

@@ -230,6 +230,8 @@ void QGISVGTemplate::createClickHandles()
textLength = std::max(charWidth, textLength);
auto item(new TemplateTextField(this, svgTemplate, name.toStdString()));
auto autoValue = svgTemplate->getAutofillByEditableName(name);
item->setAutofill(autoValue);
double pad = 1.0;
double top = Rez::guiX(-svgTemplate->getHeight()) + y - textHeight - pad;

View File

@@ -78,6 +78,7 @@ void TemplateTextField::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
ui.setFieldName(fieldNameStr);
ui.setFieldContent(tmplte->EditableTexts[fieldNameStr]);
ui.setAutofillContent(Base::Tools::toStdString(m_autofillString));
if (ui.exec() == QDialog::Accepted) {
QString qsClean = ui.getFieldContent();
@@ -100,6 +101,13 @@ void TemplateTextField::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
}
}
//void setAutofill(std::string autofillString);
void TemplateTextField::setAutofill(QString autofillString)
{
m_autofillString = autofillString;
}
void TemplateTextField::setRectangle(QRectF rect)
{
m_rect->setRect(rect);

View File

@@ -55,6 +55,7 @@ class TechDrawGuiExport TemplateTextField : public QGraphicsItemGroup
/// Returns the field name that this TemplateTextField represents
std::string fieldName() const { return fieldNameStr; }
void setAutofill(QString autofillString);
void setRectangle(QRectF rect);
void setLine(QPointF from, QPointF to);
void setLineColor(QColor color);
@@ -62,6 +63,7 @@ class TechDrawGuiExport TemplateTextField : public QGraphicsItemGroup
protected:
TechDraw::DrawTemplate *tmplte;
std::string fieldNameStr;
QString m_autofillString;
/// Need this to properly handle mouse release
void mousePressEvent(QGraphicsSceneMouseEvent *event) override;