Salome HOME
Do not clear in neutral point correction.
[modules/shaper.git] / src / XGUI / XGUI_DataModel.h
index 4f3dbd50e2e895f2ebaa0f03ac055e5aebeb7bd2..24bcf9cc7e4ce93d24ee9ead006caa0d3bb5e5e4 100644 (file)
@@ -9,12 +9,14 @@
 #define XGUI_DataModel_H
 
 #include "XGUI.h"
+#include <ModuleBase_Definitions.h>
 #include <ModelAPI_Object.h>
 #include <ModelAPI_Document.h>
-#include <Config_DataModelReader.h>
-#include <QAbstractItemModel>
 #include <Events_Listener.h>
 
+#include <QAbstractItemModel>
+
+class Config_DataModelReader;
 
 /**\class XGUI_DataModel
  * \ingroup GUI
@@ -30,8 +32,13 @@ class XGUI_EXPORT XGUI_DataModel : public QAbstractItemModel, public Events_List
 {
 Q_OBJECT
 public:
+  /// Constructor
+  /// \param theParent a parent object
   XGUI_DataModel(QObject* theParent);
 
+  /// Destructor
+  virtual ~XGUI_DataModel();
+
   /// Event Listener method
   /// \param theMessage an event message
   virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
@@ -106,12 +113,50 @@ public:
   /// \param theIndex a model index
   virtual Qt::ItemFlags flags(const QModelIndex& theIndex) const;
 
+  /// Returns an index which is root of the given document
+  /// \param theDoc a document
+  QModelIndex documentRootIndex(DocumentPtr theDoc) const;
+
+  /// Returns last history object index
+  virtual QModelIndex lastHistoryIndex() const;
+
+  /// Initialises XML data model reader. It must be initialised before DataModel using.
+  void setXMLReader(Config_DataModelReader* theReader) { myXMLReader = theReader; }
+
+signals:
+  /// Signal about tree had been rebuilt
+  void treeRebuilt();
 
 private:
-  QModelIndex findDocumentRootIndex(ModelAPI_Document* theDoc) const;
+  /// Find a root index which contains objects of the given document
+  /// \param theDoc the document object
+  QModelIndex findDocumentRootIndex(const ModelAPI_Document* theDoc) const;
+
+  /// Returns number of folders in document. Considered folders which has to be shown only if they are not empty.
+  /// \param theDoc document which has to be checked. If 0 then Root document will be considered 
+  int foldersCount(ModelAPI_Document* theDoc = 0) const;
+
+  /// Retrurns indexes of folders which can not be shown because they are empty
+  /// \param theDoc document which has to be checked. If 0 then Root document will be considered 
+  QIntList missedFolderIndexes(ModelAPI_Document* theDoc = 0) const;
+
+  /// Returns Id (row) of a folder taking into consideration folders which can not be shown non empty
+  /// \param theType Type of the folder
+  /// \param theDoc a document which contains this folder
+  int folderId(std::string theType, ModelAPI_Document* theDoc = 0);
+
+  /// Removes a row from branch of tree
+  /// \param theStart - start row to update indexes
+  /// \param theSize - number of indexes in the folder
+  /// \param theParent - index of parent folder
+  void rebuildBranch(int theRow, int theCount, const QModelIndex& theParent = QModelIndex());
+
 
+  /// Returns list of folders types which can not be shown empty
+  /// \param fromRoot - root document flag
+  QStringList listOfShowNotEmptyFolders(bool fromRoot = true) const;
 
-  Config_DataModelReader myXMLReader;
+  Config_DataModelReader* myXMLReader;
 };
 
 #endif
\ No newline at end of file