[TD]apply translateLabel after all addObject calls
This commit is contained in:
@@ -82,7 +82,9 @@ void DrawDimHelper::makeExtentDim(DrawViewPart* dvp, std::vector<std::string> ed
|
||||
std::string dimName = doc->getUniqueObjectName("DimExtent");
|
||||
Base::Interpreter().runStringArg(
|
||||
"App.activeDocument().addObject('TechDraw::DrawViewDimExtent', '%s')", dimName.c_str());
|
||||
Base::Interpreter().runStringArg(
|
||||
Base::Interpreter().runStringArg(
|
||||
"App.activeDocument().%s.translateLabel('DrawViewDimExtent', 'DimExtent', '%s')",
|
||||
dimName.c_str(), dimName.c_str()); Base::Interpreter().runStringArg(
|
||||
"App.activeDocument().%s.Type = '%s'", dimName.c_str(), dimType.c_str());
|
||||
Base::Interpreter().runStringArg(
|
||||
"App.activeDocument().%s.DirExtent = %d", dimName.c_str(), dimNum);
|
||||
@@ -135,7 +137,9 @@ void DrawDimHelper::makeExtentDim3d(DrawViewPart* dvp, ReferenceVector reference
|
||||
std::string dimName = doc->getUniqueObjectName("DimExtent");
|
||||
Base::Interpreter().runStringArg(
|
||||
"App.activeDocument().addObject('TechDraw::DrawViewDimExtent', '%s')", dimName.c_str());
|
||||
Base::Interpreter().runStringArg(
|
||||
Base::Interpreter().runStringArg(
|
||||
"App.activeDocument().%s.translateLabel('DrawViewDimExtent', 'DimExtent', '%s')",
|
||||
dimName.c_str(), dimName.c_str()); Base::Interpreter().runStringArg(
|
||||
"App.activeDocument().%s.Type = '%s'", dimName.c_str(), dimType.c_str());
|
||||
Base::Interpreter().runStringArg(
|
||||
"App.activeDocument().%s.DirExtent = %d", dimName.c_str(), dimNum);
|
||||
@@ -426,11 +430,16 @@ DrawDimHelper::makeDistDim(DrawViewPart* dvp, std::string dimType,
|
||||
if (extent) {
|
||||
Base::Interpreter().runStringArg(
|
||||
"App.activeDocument().addObject('TechDraw::DrawViewDimExtent', '%s')", dimName.c_str());
|
||||
Base::Interpreter().runStringArg(
|
||||
"App.activeDocument().%s.translateLabel('DrawViewDimExtent', 'DimExtent', '%s')",
|
||||
dimName.c_str(), dimName.c_str());
|
||||
}
|
||||
else {
|
||||
|
||||
Base::Interpreter().runStringArg(
|
||||
"App.activeDocument().addObject('TechDraw::DrawViewDimension', '%s')", dimName.c_str());
|
||||
Base::Interpreter().runStringArg(
|
||||
"App.activeDocument().%s.translateLabel('DrawViewDimimension', 'Dimension', '%s')",
|
||||
dimName.c_str(), dimName.c_str());
|
||||
}
|
||||
|
||||
Base::Interpreter().runStringArg(
|
||||
|
||||
@@ -474,11 +474,11 @@ App::DocumentObject* DrawProjGroup::addProjection(const char* viewProjType)
|
||||
if (view) {//coverity CID 151722
|
||||
// the label must be set before the view is added
|
||||
view->Label.setValue(viewProjType);
|
||||
// somewhere deep in DocumentObject, duplicate Labels have a numeric suffix applied,
|
||||
// so we need to wait until that happens before building the translated label
|
||||
view->translateLabel("DrawProjGroupItem", viewProjType, view->Label.getValue());
|
||||
addView(view);//from DrawViewCollection
|
||||
view->Source.setValues(Source.getValues());
|
||||
// std::vector<DocumentObject*> xLinks;
|
||||
// XSource.getLinks(xLinks);
|
||||
// view->XSource.setValues(xLinks);
|
||||
view->XSource.setValues(XSource.getValues());
|
||||
|
||||
// the Scale is already set by DrawView
|
||||
|
||||
@@ -54,7 +54,7 @@ using namespace TechDraw;
|
||||
QT_TRANSLATE_NOOP("DrawView", "View");
|
||||
QT_TRANSLATE_NOOP("DrawViewPart", "View");
|
||||
QT_TRANSLATE_NOOP("DrawViewSection", "Section");
|
||||
QT_TRANSLATE_NOOP("DrawComplexSection", "ComplexSection");
|
||||
QT_TRANSLATE_NOOP("DrawComplexSection", "Section");
|
||||
QT_TRANSLATE_NOOP("DrawViewDetail", "Detail");
|
||||
QT_TRANSLATE_NOOP("DrawActiveView", "ActiveView");
|
||||
QT_TRANSLATE_NOOP("DrawViewAnnotation", "Annotation");
|
||||
@@ -619,15 +619,23 @@ void DrawView::showProgressMessage(std::string featureName, std::string text)
|
||||
//! the unique name within the document (ex ActiveView001), and use it to update the Label property.
|
||||
void DrawView::translateLabel(std::string context, std::string baseName, std::string uniqueName)
|
||||
{
|
||||
// Base::Console().Message("DV::getTranslatedLabel - context: %s baseName: %s uniqueName: %s\n",
|
||||
// Base::Console().Message("DV::translateLabel - context: %s baseName: %s uniqueName: %s\n",
|
||||
// context.c_str(), baseName.c_str(), uniqueName.c_str());
|
||||
|
||||
Label.setValue(translateArbitrary(context, baseName, uniqueName));
|
||||
// Base::Console().Message("DV::translateLabel - new label: %s\n", Label.getValue());
|
||||
}
|
||||
|
||||
//! static method that provides a translated std::string for objects that are not derived from DrawView
|
||||
std::string DrawView::translateArbitrary(std::string context, std::string baseName, std::string uniqueName)
|
||||
{
|
||||
std::string suffix("");
|
||||
if (uniqueName.length() > baseName.length()) {
|
||||
suffix = uniqueName.substr(baseName.length(), uniqueName.length() - baseName.length());
|
||||
}
|
||||
QString qTranslated = qApp->translate(context.c_str(), baseName.c_str());
|
||||
std::string ssTranslated = Base::Tools::toStdString(qTranslated);
|
||||
Label.setValue(ssTranslated + suffix);
|
||||
return ssTranslated + suffix;
|
||||
}
|
||||
|
||||
PyObject *DrawView::getPyObject(void)
|
||||
|
||||
@@ -113,7 +113,9 @@ public:
|
||||
void overrideKeepUpdated(bool s) { m_overrideKeepUpdated = s; }
|
||||
bool overrideKeepUpdated(void) { return m_overrideKeepUpdated; }
|
||||
|
||||
void translateLabel(std::string context, std::string objectName, std::string uniqueName);
|
||||
void translateLabel(std::string context, std::string baseName, std::string uniqueName);
|
||||
static std::string translateArbitrary(std::string context, std::string baseName, std::string uniqueName);
|
||||
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "DrawWeldSymbolPy.h" // generated from DrawWeldSymbolPy.xml
|
||||
#include "DrawLeaderLine.h"
|
||||
#include "DrawTileWeld.h"
|
||||
#include "DrawView.h" // for translateArbitrary
|
||||
|
||||
|
||||
using namespace TechDraw;
|
||||
@@ -79,6 +80,7 @@ void DrawWeldSymbol::onSettingDocument()
|
||||
auto tile1Obj( doc->addObject( "TechDraw::DrawTileWeld", tileName1.c_str() ) );
|
||||
DrawTileWeld* tile1 = dynamic_cast<DrawTileWeld*>(tile1Obj);
|
||||
if (tile1) {
|
||||
tile1->Label.setValue(DrawView::translateArbitrary("DrawTileWeld", "TileWeld", tileName1));
|
||||
tile1->TileParent.setValue(this);
|
||||
}
|
||||
|
||||
@@ -86,6 +88,7 @@ void DrawWeldSymbol::onSettingDocument()
|
||||
auto tile2Obj( doc->addObject( "TechDraw::DrawTileWeld", tileName2.c_str() ) );
|
||||
DrawTileWeld* tile2 = dynamic_cast<DrawTileWeld*>(tile2Obj);
|
||||
if (tile2) {
|
||||
tile2->Label.setValue(DrawView::translateArbitrary("DrawTileWeld", "TileWeld", tileName2));
|
||||
tile2->TileParent.setValue(this);
|
||||
tile2->TileRow.setValue(-1); //other side is row -1
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user