+#include <QStyledItemDelegate>
+
+class XGUI_TreeViewItemDelegate: public QStyledItemDelegate
+{
+public:
+ XGUI_TreeViewItemDelegate(XGUI_DataTree* theParent):QStyledItemDelegate(theParent), myTreedView(theParent) {}
+
+ virtual void setEditorData ( QWidget* editor, const QModelIndex& index ) const
+ {
+ QLineEdit* aEditor = dynamic_cast<QLineEdit*>(editor);
+ if (aEditor) {
+ XGUI_DocumentDataModel* aModel = myTreedView->dataModel();
+ ObjectPtr aObj = aModel->object(index);
+ if (aObj.get() != NULL) {
+ aEditor->setText(aObj->data()->name().c_str());
+ return;
+ }
+ }
+ QStyledItemDelegate::setEditorData(editor, index);
+ }
+
+private:
+ XGUI_DataTree* myTreedView;
+};
+