diff --git a/src/Gui/propertyeditor/PropertyEditor.cpp b/src/Gui/propertyeditor/PropertyEditor.cpp index d90de436a5..c1075fa670 100644 --- a/src/Gui/propertyeditor/PropertyEditor.cpp +++ b/src/Gui/propertyeditor/PropertyEditor.cpp @@ -124,26 +124,6 @@ bool PropertyEditor::event(QEvent* event) return QTreeView::event(event); } -void PropertyEditor::closeEditor (QWidget * editor, QAbstractItemDelegate::EndEditHint hint) -{ - if (autoupdate) { - App::Document* doc = App::GetApplication().getActiveDocument(); - if (doc) { - if (!doc->isTransactionEmpty()) { - doc->commitTransaction(); - // Between opening and committing a transaction a recompute - // could already have been done - if (doc->isTouched()) - doc->recompute(); - } - else { - doc->abortTransaction(); - } - } - } - QTreeView::closeEditor(editor, hint); -} - void PropertyEditor::commitData (QWidget * editor) { committing = true; @@ -185,6 +165,40 @@ void PropertyEditor::onItemActivated ( const QModelIndex & index ) openPersistentEditor(model()->buddy(index)); } +void PropertyEditor::closeEditor (QWidget * editor, QAbstractItemDelegate::EndEditHint hint) +{ + if (autoupdate) { + App::Document* doc = App::GetApplication().getActiveDocument(); + if (doc) { + if (!doc->isTransactionEmpty()) { + doc->commitTransaction(); + // Between opening and committing a transaction a recompute + // could already have been done + if (doc->isTouched()) + doc->recompute(); + } + else { + doc->abortTransaction(); + } + } + } + + QTreeView::closeEditor(editor, hint); + + if (autoupdate && this->state() == EditingState) { + App::Document* doc = App::GetApplication().getActiveDocument(); + if (doc) { + QString edit; + QModelIndex index = currentIndex(); + if (index.isValid()) { + PropertyItem* property = static_cast(index.internalPointer()); + edit = tr("Edit %1").arg(property->propertyName()); + } + doc->openTransaction(edit.toUtf8()); + } + } +} + void PropertyEditor::reset() { QTreeView::reset(); diff --git a/src/Gui/propertyeditor/PropertyItemDelegate.cpp b/src/Gui/propertyeditor/PropertyItemDelegate.cpp index c5f5352869..f5d367d271 100644 --- a/src/Gui/propertyeditor/PropertyItemDelegate.cpp +++ b/src/Gui/propertyeditor/PropertyItemDelegate.cpp @@ -38,8 +38,8 @@ using namespace Gui::PropertyEditor; PropertyItemDelegate::PropertyItemDelegate(QObject* parent) : QItemDelegate(parent), pressed(false) { - connect(this, SIGNAL(closeEditor(QWidget*,QAbstractItemDelegate::EndEditHint)), - this, SLOT(editorClosed(QWidget*))); + connect(this, SIGNAL(closeEditor(QWidget*, QAbstractItemDelegate::EndEditHint)), + this, SLOT(editorClosed(QWidget*, QAbstractItemDelegate::EndEditHint))); } PropertyItemDelegate::~PropertyItemDelegate() @@ -114,9 +114,11 @@ bool PropertyItemDelegate::editorEvent (QEvent * event, QAbstractItemModel* mode return QItemDelegate::editorEvent(event, model, option, index); } -void PropertyItemDelegate::editorClosed(QWidget *editor) +void PropertyItemDelegate::editorClosed(QWidget *editor, QAbstractItemDelegate::EndEditHint hint) { - editor->close(); + // don't close the editor when pressing Tab or Shift+Tab + if (hint != EditNextItem && hint != EditPreviousItem) + editor->close(); } QWidget * PropertyItemDelegate::createEditor (QWidget * parent, const QStyleOptionViewItem & /*option*/, diff --git a/src/Gui/propertyeditor/PropertyItemDelegate.h b/src/Gui/propertyeditor/PropertyItemDelegate.h index 23d0a41f3c..d19c712c74 100644 --- a/src/Gui/propertyeditor/PropertyItemDelegate.h +++ b/src/Gui/propertyeditor/PropertyItemDelegate.h @@ -47,7 +47,7 @@ public: public Q_SLOTS: void valueChanged(); - void editorClosed(QWidget *); + void editorClosed (QWidget * editor, QAbstractItemDelegate::EndEditHint hint); private: mutable bool pressed;