[TD]backport fix for no Detail without BaseView

This commit is contained in:
wandererfan
2022-11-29 02:17:14 +01:00
committed by Uwe
parent 9bf0c5890f
commit 1bcb7275db
4 changed files with 43 additions and 1 deletions
+33
View File
@@ -424,6 +424,39 @@ bool DrawProjGroup::hasProjection(const char *viewProjType) const
return false;
}
bool DrawProjGroup::canDelete(const char *viewProjType) const
{
// Base::Console().Message("DPG::canDelete(%s)\n", viewProjType);
TechDraw::DrawProjGroupItem* foundItem(nullptr);
for( const auto it : Views.getValues() ) {
auto view( dynamic_cast<TechDraw::DrawProjGroupItem *>(it) );
if (!view) {
//should never have a item in DPG that is not a DPGI.
Base::Console().Log("PROBLEM - DPG::hasProjection finds non-DPGI in Group %s / %s\n",
getNameInDocument(), viewProjType);
throw Base::TypeError("Error: projection in DPG list is not a DPGI!");
}
if (strcmp(viewProjType, view->Type.getValueAsString()) == 0 ) {
foundItem = view;
break;
}
}
if (foundItem) {
auto linkedItems = foundItem->getInList();
for (auto& item : linkedItems) {
if (item == this) {
continue;
}
if (item->isDerivedFrom(TechDraw::DrawView::getClassTypeId())) {
return false;
}
}
}
return true;
}
App::DocumentObject * DrawProjGroup::addProjection(const char *viewProjType)
{
DrawProjGroupItem *view( nullptr );
+2
View File
@@ -74,6 +74,8 @@ public:
virtual QRectF getRect(void) const override;
/// Check if container has a view of a specific type
bool hasProjection(const char *viewProjType) const;
///check if it is safe to delete item
bool canDelete(const char *viewProjType) const;
App::DocumentObject * getProjObj(const char *viewProjType) const;
DrawProjGroupItem* getProjItem(const char *viewProjType) const;
+3
View File
@@ -482,6 +482,9 @@ void TaskProjGroup::setupViewCheckboxes(bool addConnections)
const char *viewStr = viewChkIndexToCStr(i);
if ( viewStr != nullptr && multiView->hasProjection(viewStr) ) {
box->setCheckState(Qt::Checked);
if (!multiView->canDelete(viewStr)) {
box->setEnabled(false);
}
} else {
box->setCheckState(Qt::Unchecked);
}
@@ -242,7 +242,11 @@ bool ViewProviderViewPart::setEdit(int ModNum)
}
TechDraw::DrawViewPart* dvp = getViewObject();
TechDraw::DrawViewDetail* dvd = dynamic_cast<TechDraw::DrawViewDetail*>(dvp);
if (dvd != nullptr) {
if (dvd != nullptr) {
if (!dvd->BaseView.getValue()) {
Base::Console().Error("DrawViewDetail - %s - has no BaseView!\n", dvd->getNameInDocument());
return false;
}
// clear the selection (convenience)
Gui::Selection().clearSelection();
Gui::Control().showDialog(new TaskDlgDetail(dvd));