Py convenience functions for Template EditableTexts
This commit is contained in:
parent
2c73823788
commit
015c538638
|
@ -13,5 +13,15 @@
|
|||
<Author Licence="LGPL" Name="Luke Parry" EMail="l.parry@warwick.ac.uk" />
|
||||
<UserDocu>Feature for creating and manipulating Technical Drawing SVG Templates</UserDocu>
|
||||
</Documentation>
|
||||
<Methode Name="getEditFieldContent">
|
||||
<Documentation>
|
||||
<UserDocu>getEditFieldContent(EditFieldName) - returns the content of a specific Editable Text Field</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
<Methode Name="setEditFieldContent">
|
||||
<Documentation>
|
||||
<UserDocu>setEditFieldContent(EditFieldName, NewContent) - sets a specific Editable Text Field to a new value</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
|
|
|
@ -37,7 +37,40 @@ int DrawSVGTemplatePy::setCustomAttributes(const char* attr, PyObject* obj)
|
|||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
PyObject* DrawSVGTemplatePy::getEditFieldContent(PyObject* args)
|
||||
{
|
||||
PyObject* result = nullptr;
|
||||
char* fieldName;
|
||||
if (!PyArg_ParseTuple(args, "s",&fieldName)) {
|
||||
Base::Console().Error("Error: DrawSVGTemplatePy::getEditFieldNames - Bad Arg\n");
|
||||
return nullptr;
|
||||
}
|
||||
std::string content = getDrawSVGTemplatePtr()->EditableTexts[fieldName];
|
||||
if (!content.empty()) {
|
||||
result = PyString_FromString(content.c_str());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
PyObject* DrawSVGTemplatePy::setEditFieldContent(PyObject* args)
|
||||
{
|
||||
PyObject* result = Py_True;
|
||||
char* fieldName;
|
||||
char* newContent;
|
||||
if (!PyArg_ParseTuple(args, "ss", &fieldName,&newContent)) {
|
||||
Base::Console().Error("Error: DrawSVGTemplatePy::getEditFieldNames - Bad Args\n");
|
||||
result = Py_False;
|
||||
} else {
|
||||
try {
|
||||
getDrawSVGTemplatePtr()->EditableTexts.setValue(fieldName, newContent);
|
||||
}
|
||||
catch (...) {
|
||||
result = Py_False;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -48,8 +48,6 @@ TemplateTextField::~TemplateTextField()
|
|||
|
||||
void TemplateTextField::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
//TODO: Add a command to change template text, and call it from here
|
||||
// ...Interpreter....("App.ActiveDocument().%s.%s.setTextField(%s,%s)",pageName,templateName,fieldName,fieldValue)
|
||||
DlgTemplateField* ui = new DlgTemplateField(nullptr);
|
||||
ui->setFieldName(fieldNameStr);
|
||||
ui->setFieldContent(tmplte->EditableTexts[fieldNameStr]);
|
||||
|
@ -57,7 +55,7 @@ void TemplateTextField::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
|||
std::string newContent = "";
|
||||
if(uiCode == QDialog::Accepted) {
|
||||
std::string newContent = ui->getFieldContent();
|
||||
tmplte->EditableTexts.setValue(fieldNameStr, newContent);
|
||||
tmplte->EditableTexts.setValue(fieldNameStr, newContent);
|
||||
}
|
||||
ui->deleteLater();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user