Salome HOME
Merge remote-tracking branch 'remotes/origin/master' into SolveSpace
[modules/shaper.git] / src / XGUI / XGUI_ObjectsBrowser.h
index de43e5272f7b6466f61286cb464559ab8f9d5ec7..b8e275ae688e3d6f7478bc832ef244377a4eea38 100644 (file)
@@ -5,15 +5,55 @@
 #include "XGUI.h"
 #include "XGUI_Constants.h"
 
+#include <QWidget>
 #include <QTreeView>
 
 class XGUI_DocumentDataModel;
+class QLineEdit;
+
+
+class XGUI_DataTree: public QTreeView
+{
+  Q_OBJECT
+public:
+  XGUI_DataTree(QWidget* theParent);
+  virtual ~XGUI_DataTree();
+
+  //! Returns list of currently selected features
+  QFeatureList selectedFeatures() const { return mySelectedData; }
+
+  XGUI_DocumentDataModel* dataModel() const;
+
+signals:
+  //! Emited when selection is changed
+  void selectionChanged();
+  void activePartChanged(FeaturePtr thePart); 
+  //! Emited on context menu request
+  void contextMenuRequested(QContextMenuEvent* theEvent);
+
+protected slots:
+  virtual void commitData(QWidget* theEditor);
+
+protected:
+  virtual void mouseDoubleClickEvent(QMouseEvent* theEvent);
+  virtual void contextMenuEvent(QContextMenuEvent* theEvent);
+
+private slots:
+  //! Called when selection in Data Tree is changed
+  void onSelectionChanged(const QItemSelection& theSelected, const QItemSelection& theDeselected);
+
+private:
+  //! List of currently selected data
+  QFeatureList mySelectedData;
+};
+
 
 /**\class XGUI_ObjectsBrowser
  * \ingroup GUI
  * \brief Object browser window object. Represents data tree of current data structure
  */
- class XGUI_EXPORT XGUI_ObjectsBrowser : public QTreeView
+ class XGUI_EXPORT XGUI_ObjectsBrowser : public QWidget
 {
   Q_OBJECT
 public:
@@ -24,28 +64,48 @@ public:
   XGUI_DocumentDataModel* dataModel() const { return myDocModel; }
 
   //! Returns list of currently selected features
-  QFeatureList selectedFeatures() const { return mySelectedData; }
+  QFeatureList selectedFeatures() const { return myFeaturesList; }
+
+  //! Returns currently selected indexes
+  QModelIndexList selectedIndexes() const { return myTreeView->selectionModel()->selectedIndexes(); }
+
+  //! Returns TreeView widget
+  XGUI_DataTree* treeView() const { return myTreeView; }
+
+  //! Activates currently selected part. Signal activePartChanged will not be sent
+  void activatePart(const FeaturePtr& thePart);
 
 signals:
   //! Emited when selection is changed
   void selectionChanged();
+
+  //! Emited when current active document is changed
   void activePartChanged(FeaturePtr thePart); 
+  //! Emited on context menu request
+  void contextMenuRequested(QContextMenuEvent* theEvent);
 
 protected:
-  virtual void mouseDoubleClickEvent(QMouseEvent* theEvent);
+  virtual bool eventFilter(QObject* obj, QEvent* theEvent);
 
 private slots:
-  //! Called when selection in Data Tree is changed
-  void onSelectionChanged(const QItemSelection& theSelected, const QItemSelection& theDeselected);
+  void onActivePartChanged(FeaturePtr thePart);
+  void onContextMenuRequested(QContextMenuEvent* theEvent);
+  void onLabelContextMenuRequested(const QPoint& thePnt);
+
+  //! Called on Edit command request
+  void onEditItem();
 
 private:
+  void closeDocNameEditing(bool toSave);
+
   //! Internal model
   XGUI_DocumentDataModel* myDocModel;
 
-  //! List of currently selected data
-  QFeatureList mySelectedData;
+  QLineEdit* myActiveDocLbl;
+  XGUI_DataTree* myTreeView;
 
-  //QModelIndex myActivePartIndex;
+  QFeatureList myFeaturesList;
 };
 
 #endif
\ No newline at end of file