+ rework edit modes

git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5102 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d
This commit is contained in:
wmayer
2011-11-08 21:15:49 +00:00
parent c152e988be
commit c7985e5c06
15 changed files with 155 additions and 131 deletions

View File

@@ -58,50 +58,54 @@ void ViewProviderPad::setupContextMenu(QMenu* menu, QObject* receiver, const cha
{
QAction* act;
act = menu->addAction(QObject::tr("Edit pad"), receiver, member);
act->setData(QVariant((int)ViewProvider::Default));
act = menu->addAction(QObject::tr("Transform"), receiver, member);
act->setData(QVariant((int)ViewProvider::Transform));
act->setData(QVariant((int)ViewProvider::Pad));
PartGui::ViewProviderPart::setupContextMenu(menu, receiver, member);
}
bool ViewProviderPad::setEdit(int ModNum)
{
// When double-clicking on the item for this pad the
// object unsets and sets its edit mode without closing
// the task panel
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
TaskDlgPadParameters *padDlg = qobject_cast<TaskDlgPadParameters *>(dlg);
if (padDlg && padDlg->getPadView() != this)
padDlg = 0; // another pad left open its task panel
if (dlg && !padDlg) {
QMessageBox msgBox;
msgBox.setText(QObject::tr("A dialog is already open in the task panel"));
msgBox.setInformativeText(QObject::tr("Do you want to close this dialog?"));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::Yes);
int ret = msgBox.exec();
if (ret == QMessageBox::Yes)
Gui::Control().closeDialog();
if (ModNum == ViewProvider::Default || ModNum == ViewProvider::Pad) {
// When double-clicking on the item for this pad the
// object unsets and sets its edit mode without closing
// the task panel
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
TaskDlgPadParameters *padDlg = qobject_cast<TaskDlgPadParameters *>(dlg);
if (padDlg && padDlg->getPadView() != this)
padDlg = 0; // another pad left open its task panel
if (dlg && !padDlg) {
QMessageBox msgBox;
msgBox.setText(QObject::tr("A dialog is already open in the task panel"));
msgBox.setInformativeText(QObject::tr("Do you want to close this dialog?"));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::Yes);
int ret = msgBox.exec();
if (ret == QMessageBox::Yes)
Gui::Control().closeDialog();
else
return false;
}
// clear the selection (convenience)
Gui::Selection().clearSelection();
if (ModNum == 1)
Gui::Command::openCommand("Change pad parameters");
// start the edit dialog
if (padDlg)
Gui::Control().showDialog(padDlg);
else
return false;
Gui::Control().showDialog(new TaskDlgPadParameters(this));
return true;
}
else {
return ViewProviderPart::setEdit(ModNum);
}
// clear the selection (convenience)
Gui::Selection().clearSelection();
if(ModNum == 1)
Gui::Command::openCommand("Change pad parameters");
// start the edit dialog
if (padDlg)
Gui::Control().showDialog(padDlg);
else
Gui::Control().showDialog(new TaskDlgPadParameters(this));
return true;
}
void ViewProviderPad::unsetEdit(int ModNum)
{
if (ModNum == ViewProvider::Default) {
if (ModNum == ViewProvider::Default || ModNum == ViewProvider::Pad) {
// and update the pad
//getSketchObject()->getDocument()->recompute();