Open transaction when start editing with context-menu
This commit is contained in:
parent
2c8009cb74
commit
dd67c22837
|
@ -255,7 +255,12 @@ void TreeWidget::onStartEditing()
|
|||
Gui::Document* doc = Gui::Application::Instance->getDocument(obj->getDocument());
|
||||
MDIView *view = doc->getActiveView();
|
||||
if (view) getMainWindow()->setActiveWindow(view);
|
||||
doc->setEdit(objitem->object(), edit);
|
||||
// open a transaction before starting edit mode
|
||||
std::string cmd("Edit ");
|
||||
cmd += obj->Label.getValue();
|
||||
doc->openCommand(cmd.c_str());
|
||||
bool ok = doc->setEdit(objitem->object(), edit);
|
||||
if (!ok) doc->abortCommand();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -268,6 +273,7 @@ void TreeWidget::onFinishEditing()
|
|||
App::DocumentObject* obj = objitem->object()->getObject();
|
||||
if (!obj) return;
|
||||
Gui::Document* doc = Gui::Application::Instance->getDocument(obj->getDocument());
|
||||
doc->commitCommand();
|
||||
doc->resetEdit();
|
||||
doc->getDocument()->recompute();
|
||||
}
|
||||
|
|
|
@ -67,8 +67,6 @@ public:
|
|||
OffsetWidget::OffsetWidget(Part::Offset* offset, QWidget* parent)
|
||||
: d(new Private())
|
||||
{
|
||||
if (!Gui::Command::hasPendingCommand())
|
||||
Gui::Command::openCommand("Edit offset");
|
||||
Gui::Application::Instance->runPythonCode("from FreeCAD import Base");
|
||||
Gui::Application::Instance->runPythonCode("import Part");
|
||||
|
||||
|
|
|
@ -58,8 +58,7 @@ public:
|
|||
QString text;
|
||||
std::string selection;
|
||||
Part::Thickness* thickness;
|
||||
bool edit;
|
||||
Private() : edit(false)
|
||||
Private()
|
||||
{
|
||||
}
|
||||
~Private()
|
||||
|
@ -91,10 +90,6 @@ public:
|
|||
ThicknessWidget::ThicknessWidget(Part::Thickness* thickness, QWidget* parent)
|
||||
: d(new Private())
|
||||
{
|
||||
if (!Gui::Command::hasPendingCommand()) {
|
||||
d->edit = true;
|
||||
Gui::Command::openCommand("Edit thickness");
|
||||
}
|
||||
Gui::Application::Instance->runPythonCode("from FreeCAD import Base");
|
||||
Gui::Application::Instance->runPythonCode("import Part");
|
||||
|
||||
|
@ -244,19 +239,22 @@ bool ThicknessWidget::reject()
|
|||
{
|
||||
if (d->loop.isRunning())
|
||||
return false;
|
||||
// object has been created right before opening this panel
|
||||
if (d->edit == false) {
|
||||
App::DocumentObject* source = d->thickness->Faces.getValue();
|
||||
if (source){
|
||||
Gui::Application::Instance->getViewProvider(source)->show();
|
||||
}
|
||||
}
|
||||
|
||||
// save this and check if the object is still there after the
|
||||
// transaction is aborted
|
||||
std::string objname = d->thickness->getNameInDocument();
|
||||
App::DocumentObject* source = d->thickness->Faces.getValue();
|
||||
|
||||
// roll back the done things
|
||||
Gui::Command::abortCommand();
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()");
|
||||
Gui::Command::updateActive();
|
||||
|
||||
// Thickness object was deleted
|
||||
if (source && !source->getDocument()->getObject(objname.c_str())) {
|
||||
Gui::Application::Instance->getViewProvider(source)->show();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -81,6 +81,7 @@
|
|||
#include <Base/Exception.h>
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/SoFCSelection.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/View3DInventorViewer.h>
|
||||
|
@ -107,6 +108,17 @@ ViewProviderPart::ViewProviderPart()
|
|||
ViewProviderPart::~ViewProviderPart()
|
||||
{
|
||||
}
|
||||
|
||||
bool ViewProviderPart::doubleClicked(void)
|
||||
{
|
||||
std::string Msg("Edit ");
|
||||
Msg += this->pcObject->Label.getValue();
|
||||
Gui::Command::openCommand(Msg.c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.setEdit('%s',0)",
|
||||
this->pcObject->getNameInDocument());
|
||||
return true;
|
||||
}
|
||||
|
||||
#else
|
||||
PROPERTY_SOURCE(PartGui::ViewProviderPart, PartGui::ViewProviderPartBase)
|
||||
|
||||
|
|
|
@ -156,6 +156,7 @@ public:
|
|||
ViewProviderPart();
|
||||
/// destructor
|
||||
virtual ~ViewProviderPart();
|
||||
virtual bool doubleClicked(void);
|
||||
};
|
||||
#else
|
||||
class PartGuiExport ViewProviderPart : public ViewProviderPartBase
|
||||
|
|
|
@ -45,8 +45,8 @@ ViewProvider::~ViewProvider()
|
|||
|
||||
bool ViewProvider::doubleClicked(void)
|
||||
{
|
||||
std::string Msg("Change ");
|
||||
Msg += this->pcObject->getNameInDocument();
|
||||
std::string Msg("Edit ");
|
||||
Msg += this->pcObject->Label.getValue();
|
||||
Gui::Command::openCommand(Msg.c_str());
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().setEdit('%s',0)",this->pcObject->getNameInDocument());
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue
Block a user