23
#include "PreCompiled.h"
29
# include <QMessageBox>
30
# include <QTextStream>
33
#include <App/DocumentObject.h>
34
#include <Gui/Control.h>
35
#include <Gui/MainWindow.h>
36
#include <Gui/Selection.h>
38
#include <Mod/TechDraw/App/DrawLeaderLine.h>
39
#include <Mod/TechDraw/App/DrawProjGroupItem.h>
40
#include <Mod/TechDraw/App/DrawViewDetail.h>
41
#include <Mod/TechDraw/App/DrawViewSection.h>
43
#include "TaskProjGroup.h"
44
#include "ViewProviderProjGroup.h"
46
using namespace TechDrawGui;
48
PROPERTY_SOURCE(TechDrawGui::ViewProviderProjGroup, TechDrawGui::ViewProviderDrawingView)
53
ViewProviderProjGroup::ViewProviderProjGroup()
55
sPixmap = "TechDraw_TreeProjGroup";
58
ViewProviderProjGroup::~ViewProviderProjGroup()
62
void ViewProviderProjGroup::setupContextMenu(QMenu* menu, QObject* receiver, const char* member)
69
bool ViewProviderProjGroup::setEdit(int ModNum)
75
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
76
TaskDlgProjGroup *projDlg = qobject_cast<TaskDlgProjGroup *>(dlg);
77
if (projDlg && projDlg->getViewProvider() != this)
81
Gui::Selection().clearSelection();
85
projDlg->setCreateMode(false);
86
Gui::Control().showDialog(projDlg);
88
Gui::Control().showDialog(new TaskDlgProjGroup(getObject(), false));
94
bool ViewProviderProjGroup::doubleClicked()
100
bool ViewProviderProjGroup::onDelete(const std::vector<std::string> &)
105
QTextStream bodyMessageStream(&bodyMessage);
106
TechDraw::DrawProjGroupItem* Item = nullptr;
107
std::vector<std::string> ViewList;
110
auto objs = claimChildren();
113
for (auto ObjectIterator : objs) {
115
Item = static_cast<TechDraw::DrawProjGroupItem*>(ObjectIterator);
117
auto viewSection = Item->getSectionRefs();
119
if (!viewSection.empty()) {
120
for (auto SecIterator : viewSection) {
121
ViewList.emplace_back(SecIterator->Label.getValue());
125
auto viewDetail = Item->getDetailRefs();
126
if (!viewDetail.empty()) {
127
for (auto DetIterator : viewDetail) {
128
ViewList.emplace_back(DetIterator->Label.getValue());
132
auto viewLead = Item->getLeaders();
133
if (!viewLead.empty()) {
134
for (auto LeadIterator : viewLead) {
135
ViewList.emplace_back(LeadIterator->Label.getValue());
141
if (!ViewList.empty()) {
142
bodyMessageStream << qApp->translate("Std_Delete",
143
"The group cannot be deleted because its items have the following\nsection or detail views, or leader lines that would get broken:");
144
bodyMessageStream << '\n';
145
for (const auto& ListIterator : ViewList)
146
bodyMessageStream << '\n' << QString::fromUtf8(ListIterator.c_str());
147
QMessageBox::warning(Gui::getMainWindow(),
148
qApp->translate("Std_Delete", "Object dependencies"), bodyMessage,
156
bodyMessageStream << qApp->translate("Std_Delete",
157
"The projection group is not empty, therefore\nthe following referencing objects might be lost:");
158
bodyMessageStream << '\n';
159
for (auto ObjIterator : objs)
160
bodyMessageStream << '\n' << QString::fromUtf8(ObjIterator->Label.getValue());
161
bodyMessageStream << "\n\n" << QObject::tr("Are you sure you want to continue?");
163
int DialogResult = QMessageBox::warning(Gui::getMainWindow(),
164
qApp->translate("Std_Delete", "Object dependencies"), bodyMessage,
165
QMessageBox::Yes, QMessageBox::No);
166
if (DialogResult == QMessageBox::Yes)
175
bool ViewProviderProjGroup::canDelete(App::DocumentObject *obj) const
184
std::vector<App::DocumentObject*> ViewProviderProjGroup::claimChildren() const
187
std::vector<App::DocumentObject*> temp;
188
const std::vector<App::DocumentObject *> &views = getObject()->Views.getValues();
190
for (std::vector<App::DocumentObject *>::const_iterator it = views.begin(); it != views.end(); ++it) {
195
std::vector<App::DocumentObject*> tmp;
200
TechDraw::DrawProjGroup* ViewProviderProjGroup::getViewObject() const
202
return dynamic_cast<TechDraw::DrawProjGroup*>(pcObject);
205
TechDraw::DrawProjGroup* ViewProviderProjGroup::getObject() const
207
return getViewObject();