* [TD]allow DrawViewAnno to be attached to another view * [TD]allow image and spreadsheet attach to view * [TD]ensure correct parent in scene * [TD]refactor command helpers to separate file - gathering the helpers in one place - helper redundancy to be address in another change * [TD]create symbol, spreadsheet, image with parent * [TD]fix claimChildren for some views - also includes many lint fixes
This commit is contained in:
@@ -35,7 +35,9 @@
|
||||
#include <Gui/MainWindow.h>
|
||||
#include <Gui/Selection.h>
|
||||
|
||||
#include <Mod/TechDraw/App/DrawViewBalloon.h>
|
||||
#include <Mod/TechDraw/App/DrawLeaderLine.h>
|
||||
#include <Mod/TechDraw/App/DrawRichAnno.h>
|
||||
#include <Mod/TechDraw/App/DrawProjGroupItem.h>
|
||||
#include <Mod/TechDraw/App/DrawViewDetail.h>
|
||||
#include <Mod/TechDraw/App/DrawViewSection.h>
|
||||
@@ -55,16 +57,6 @@ ViewProviderProjGroup::ViewProviderProjGroup()
|
||||
sPixmap = "TechDraw_TreeProjGroup";
|
||||
}
|
||||
|
||||
ViewProviderProjGroup::~ViewProviderProjGroup()
|
||||
{
|
||||
}
|
||||
|
||||
void ViewProviderProjGroup::setupContextMenu(QMenu* menu, QObject* receiver, const char* member)
|
||||
{
|
||||
Q_UNUSED(menu);
|
||||
Q_UNUSED(receiver);
|
||||
Q_UNUSED(member);
|
||||
}
|
||||
|
||||
bool ViewProviderProjGroup::setEdit(int ModNum)
|
||||
{
|
||||
@@ -72,10 +64,11 @@ bool ViewProviderProjGroup::setEdit(int ModNum)
|
||||
// When double-clicking on the item for this sketch the
|
||||
// object unsets and sets its edit mode without closing
|
||||
// the task panel
|
||||
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
|
||||
TaskDlgProjGroup *projDlg = qobject_cast<TaskDlgProjGroup *>(dlg);
|
||||
if (projDlg && projDlg->getViewProvider() != this)
|
||||
auto* dlg = Gui::Control().activeDialog();
|
||||
auto* projDlg = qobject_cast<TaskDlgProjGroup *>(dlg);
|
||||
if (projDlg && projDlg->getViewProvider() != this) {
|
||||
projDlg = nullptr; // another sketch left open its task panel
|
||||
}
|
||||
|
||||
// clear the selection (convenience)
|
||||
Gui::Selection().clearSelection();
|
||||
@@ -97,8 +90,9 @@ bool ViewProviderProjGroup::doubleClicked()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ViewProviderProjGroup::onDelete(const std::vector<std::string> &)
|
||||
bool ViewProviderProjGroup::onDelete(const std::vector<std::string> & parms)
|
||||
{
|
||||
Q_UNUSED(parms)
|
||||
// warn the user if the ProjGroup is not empty
|
||||
|
||||
QString bodyMessage;
|
||||
@@ -142,8 +136,9 @@ bool ViewProviderProjGroup::onDelete(const std::vector<std::string> &)
|
||||
bodyMessageStream << qApp->translate("Std_Delete",
|
||||
"The group cannot be deleted because its items have the following\nsection or detail views, or leader lines that would get broken:");
|
||||
bodyMessageStream << '\n';
|
||||
for (const auto& ListIterator : ViewList)
|
||||
for (const auto& ListIterator : ViewList) {
|
||||
bodyMessageStream << '\n' << QString::fromUtf8(ListIterator.c_str());
|
||||
}
|
||||
QMessageBox::warning(Gui::getMainWindow(),
|
||||
qApp->translate("Std_Delete", "Object dependencies"), bodyMessage,
|
||||
QMessageBox::Ok);
|
||||
@@ -156,20 +151,17 @@ bool ViewProviderProjGroup::onDelete(const std::vector<std::string> &)
|
||||
bodyMessageStream << qApp->translate("Std_Delete",
|
||||
"The projection group is not empty, therefore\nthe following referencing objects might be lost:");
|
||||
bodyMessageStream << '\n';
|
||||
for (auto ObjIterator : objs)
|
||||
for (auto ObjIterator : objs) {
|
||||
bodyMessageStream << '\n' << QString::fromUtf8(ObjIterator->Label.getValue());
|
||||
}
|
||||
bodyMessageStream << "\n\n" << QObject::tr("Are you sure you want to continue?");
|
||||
// show and evaluate dialog
|
||||
int DialogResult = QMessageBox::warning(Gui::getMainWindow(),
|
||||
qApp->translate("Std_Delete", "Object dependencies"), bodyMessage,
|
||||
QMessageBox::Yes, QMessageBox::No);
|
||||
if (DialogResult == QMessageBox::Yes)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
return (DialogResult == QMessageBox::Yes);
|
||||
}
|
||||
else
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ViewProviderProjGroup::canDelete(App::DocumentObject *obj) const
|
||||
@@ -183,17 +175,36 @@ bool ViewProviderProjGroup::canDelete(App::DocumentObject *obj) const
|
||||
|
||||
std::vector<App::DocumentObject*> ViewProviderProjGroup::claimChildren() const
|
||||
{
|
||||
// Collect any child fields
|
||||
// Collect any child Document Objects and put them in the right place in the Feature tree
|
||||
// valid children of an ProjGroup are:
|
||||
// - Balloons
|
||||
// - Leaders
|
||||
// - RichAnno
|
||||
std::vector<App::DocumentObject*> temp;
|
||||
const std::vector<App::DocumentObject*>& candidates = getViewObject()->getInList();
|
||||
// DPGI's do not point at the DPG, the DPG/DVC maintains links to the items
|
||||
|
||||
// why does this need a try/catch??
|
||||
try {
|
||||
for (auto* view : getObject()->Views.getValues()) {
|
||||
temp.push_back(view);
|
||||
}
|
||||
return temp;
|
||||
} catch (...) {
|
||||
std::vector<App::DocumentObject*> tmp;
|
||||
return tmp;
|
||||
for (auto& obj : candidates) {
|
||||
if (obj->isDerivedFrom<TechDraw::DrawViewBalloon>() ||
|
||||
obj->isDerivedFrom<TechDraw::DrawLeaderLine>() ||
|
||||
obj->isDerivedFrom<TechDraw::DrawRichAnno>()) {
|
||||
temp.push_back(obj);
|
||||
}
|
||||
}
|
||||
// return temp;
|
||||
}
|
||||
catch (...) {
|
||||
return {};
|
||||
}
|
||||
|
||||
// plus the individual ProjGroupItems
|
||||
for (auto& view : getViewObject()->Views.getValues()) {
|
||||
temp.push_back(view);
|
||||
}
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
TechDraw::DrawProjGroup* ViewProviderProjGroup::getViewObject() const
|
||||
|
||||
Reference in New Issue
Block a user