24
#include "PreCompiled.h"
28
# define _USE_MATH_DEFINES
33
#include <Gui/Application.h>
34
#include <Gui/Control.h>
35
#include <Gui/ViewProviderDocumentObject.h>
37
#include "PropertyEnumAttacherItem.h"
39
using namespace PartGui;
41
PROPERTYITEM_SOURCE(PartGui::PropertyEnumAttacherItem)
43
PropertyEnumAttacherItem::PropertyEnumAttacherItem() = default;
45
QWidget* PropertyEnumAttacherItem::createEditor(QWidget* parent,
46
const std::function<void()>& method) const
48
Gui::LabelButton* modeEditor = new Gui::LabelButton(parent);
49
QObject::connect(modeEditor, &Gui::LabelButton::valueChanged, method);
50
QObject::connect(modeEditor, &Gui::LabelButton::buttonClicked, this, &PropertyEnumAttacherItem::openTask);
51
modeEditor->setDisabled(isReadOnly());
55
void PropertyEnumAttacherItem::setEditorData(QWidget *editor, const QVariant& data) const
57
Gui::LabelButton* modeEditor = qobject_cast<Gui::LabelButton*>(editor);
58
modeEditor->setValue(data);
61
QVariant PropertyEnumAttacherItem::editorData(QWidget *editor) const
63
Gui::LabelButton* modeEditor = qobject_cast<Gui::LabelButton*>(editor);
64
return modeEditor->value();
67
void PropertyEnumAttacherItem::openTask()
69
Gui::TaskView::TaskDialog* dlg = Gui::Control().activeDialog();
70
TaskDlgAttacher* task;
71
task = qobject_cast<TaskDlgAttacher*>(dlg);
75
Gui::Control().showDialog(dlg);
79
const App::Property* prop = getFirstProperty();
81
App::PropertyContainer* parent = prop->getContainer();
83
if (parent->isDerivedFrom<App::DocumentObject>()) {
84
App::DocumentObject* obj = static_cast<App::DocumentObject*>(parent);
85
Gui::ViewProvider* view = Gui::Application::Instance->getViewProvider(obj);
87
if (view->isDerivedFrom<Gui::ViewProviderDocumentObject>()) {
88
task = new TaskDlgAttacher(static_cast<Gui::ViewProviderDocumentObject*>(view));
97
Gui::Control().showDialog(task);
100
#include "moc_PropertyEnumAttacherItem.cpp"