Salome HOME
Issue #2521: Use Salome module icon
[modules/shaper.git] / src / XGUI / XGUI_DataModel.h
index 1ee25ad299f23b38bab0ecc45eaf4dab1312dc9c..e89546161dda5a6b3a564dcc0fe37741a607a222 100644 (file)
@@ -1,9 +1,22 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
-
-// File:        XGUI_DataModel.h
-// Created:     21 Jul 2015
-// Author:      Vitaly SMETANNIKOV
-
+// Copyright (C) 2014-2017  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or
+// email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+//
 
 #ifndef XGUI_DataModel_H
 #define XGUI_DataModel_H
@@ -17,6 +30,7 @@
 #include <QAbstractItemModel>
 
 class Config_DataModelReader;
+class XGUI_Workshop;
 
 /**\class XGUI_DataModel
  * \ingroup GUI
@@ -50,7 +64,7 @@ public:
 
   //! Returns index of the object
   //! \param theObject object to find
-  virtual QModelIndex objectIndex(const ObjectPtr theObject) const;
+  virtual QModelIndex objectIndex(const ObjectPtr theObject, int theColumn = 1) const;
 
   //! Clear internal data
   virtual void clear();
@@ -117,7 +131,7 @@ public:
 
   /// Returns an index which is root of the given document
   /// \param theDoc a document
-  QModelIndex documentRootIndex(DocumentPtr theDoc) const;
+  QModelIndex documentRootIndex(DocumentPtr theDoc, int theColumn = 1) const;
 
   /// Returns last history object index
   virtual QModelIndex lastHistoryIndex() const;
@@ -128,14 +142,25 @@ public:
   /// Do not processing anymore events of model loop
   //bool blockEventsProcessing(const bool theState);
 
+  /// Returns true if the data model item has Hidden visual state
+  /// \param theIndex a tree model item
+  /// \return boolean value
+  bool hasHiddenState(const QModelIndex& theIndex);
+
 signals:
   /// Signal about tree had been rebuilt
   void treeRebuilt();
 
 private:
+  enum VisibilityState {
+    NoneState,
+    Visible,
+    SemiVisible,
+    Hidden };
+
   /// Find a root index which contains objects of the given document
   /// \param theDoc the document object
-  QModelIndex findDocumentRootIndex(const ModelAPI_Document* theDoc) const;
+  QModelIndex findDocumentRootIndex(const ModelAPI_Document* theDoc, int aColumn = 1) const;
 
   /// Returns number of folders in document.
   /// Considered folders which has to be shown only if they are not empty.
@@ -158,13 +183,43 @@ private:
   /// \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;
 
+  int getNumberOfFolderItems(const ModelAPI_Folder* theFolder) const;
+  ObjectPtr getObjectInFolder(const ModelAPI_Folder* theFolder, int theId) const;
+
+  VisibilityState getVisibilityState(const QModelIndex& theIndex) const;
+
+  void addShownFolder(DocumentPtr theDoc, QString theFolder)
+  {
+    if (!myShownFolders.contains(theDoc)) {
+      myShownFolders[theDoc] = QStringList();
+    }
+    myShownFolders[theDoc].append(theFolder);
+  }
+
+  void removeShownFolder(DocumentPtr theDoc, QString theFolder)
+  {
+    if (myShownFolders.contains(theDoc)) {
+      myShownFolders[theDoc].removeAll(theFolder);
+      if (myShownFolders[theDoc].isEmpty())
+        myShownFolders.remove(theDoc);
+    }
+  }
+
+  bool hasShownFolder(DocumentPtr theDoc, QString theFolder) const
+  {
+    if (myShownFolders.contains(theDoc))
+      return myShownFolders[theDoc].contains(theFolder);
+    return false;
+  }
+
   Config_DataModelReader* myXMLReader;
 
+  XGUI_Workshop* myWorkshop;
+  QMap<DocumentPtr, QStringList> myShownFolders;
   //bool myIsEventsProcessingBlocked;
 };