+ support of unicode names for sketch constraints

This commit is contained in:
wmayer 2015-09-24 03:17:47 +02:00
parent 8e8ecdd36f
commit 10786c65b8
4 changed files with 13 additions and 10 deletions

View File

@ -318,10 +318,13 @@ PyObject* SketchObjectPy::delConstraint(PyObject *args)
PyObject* SketchObjectPy::renameConstraint(PyObject *args)
{
int Index;
char* Name;
if (!PyArg_ParseTuple(args, "is", &Index, &Name))
char* utf8Name;
if (!PyArg_ParseTuple(args, "iet", &Index, "utf-8", &utf8Name))
return 0;
std::string Name = utf8Name;
PyMem_Free(utf8Name);
if (this->getSketchObjectPtr()->Constraints.getSize() <= Index) {
std::stringstream str;
str << "Not able to rename a constraint with the given index: " << Index;
@ -329,7 +332,7 @@ PyObject* SketchObjectPy::renameConstraint(PyObject *args)
return 0;
}
if (strcmp(Name, "") != 0) {
if (!Name.empty()) {
if (!Sketcher::PropertyConstraintList::validConstraintName(Name)) {
std::stringstream str;

View File

@ -166,7 +166,7 @@ void openEditDatumDialog(Sketcher::SketchObject* sketch, int ConstrNbr)
QString constraintName = ui_ins_datum.name->text().trimmed();
if (Base::Tools::toStdString(constraintName) != sketch->Constraints[ConstrNbr]->Name) {
std::string escapedstr = Base::Tools::escapedUnicodeFromUtf8(constraintName.toUtf8().constData());
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.renameConstraint(%d, '%s')",
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.renameConstraint(%d, u'%s')",
sketch->getNameInDocument(),
ConstrNbr, escapedstr.c_str());
}
@ -2442,7 +2442,7 @@ void CmdSketcherConstrainRadius::activated(int iMsg)
QString constraintName = ui_Datum.name->text().trimmed();
if (Base::Tools::toStdString(constraintName) != Obj->Constraints[indexConstr]->Name) {
std::string escapedstr = Base::Tools::escapedUnicodeFromUtf8(constraintName.toUtf8().constData());
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.renameConstraint(%d, '%s')",
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.renameConstraint(%d, u'%s')",
Obj->getNameInDocument(),
indexConstr, escapedstr.c_str());
}

View File

@ -175,7 +175,7 @@ void EditDatumDialog::exec(bool atCursor)
QString constraintName = ui_ins_datum.name->text().trimmed();
if (Base::Tools::toStdString(constraintName) != sketch->Constraints[ConstrNbr]->Name) {
std::string escapedstr = Base::Tools::escapedUnicodeFromUtf8(constraintName.toUtf8().constData());
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.renameConstraint(%d, '%s')",
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.renameConstraint(%d, u'%s')",
sketch->getNameInDocument(),
ConstrNbr, escapedstr.c_str());
}

View File

@ -477,13 +477,13 @@ void ConstraintView::swapNamedOfSelectedItems()
std::string tmpname = ss.str();
Gui::Command::openCommand("Swap constraint names");
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.renameConstraint(%d, '%s')",
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.renameConstraint(%d, u'%s')",
item1->sketch->getNameInDocument(),
item1->ConstraintNbr, tmpname.c_str());
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.renameConstraint(%d, '%s')",
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.renameConstraint(%d, u'%s')",
item2->sketch->getNameInDocument(),
item2->ConstraintNbr, escapedstr1.c_str());
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.renameConstraint(%d, '%s')",
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.renameConstraint(%d, u'%s')",
item1->sketch->getNameInDocument(),
item1->ConstraintNbr, escapedstr2.c_str());
Gui::Command::commitCommand();
@ -660,7 +660,7 @@ void TaskSketcherConstrains::on_listWidgetConstraints_itemChanged(QListWidgetIte
Gui::Command::openCommand("Rename sketch constraint");
try {
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.renameConstraint(%d, '%s')",
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.renameConstraint(%d, u'%s')",
sketch->getNameInDocument(),
it->ConstraintNbr, escapedstr.c_str());
Gui::Command::commitCommand();