Salome HOME
updated copyright message
[modules/shaper.git] / src / XGUI / XGUI_DataModel.h
index df3984e58e6bf49acb238e5f22ec504b147d7068..0c56b2f1c826005e793c3738553453fc536d7642 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2019  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2023  CEA, EDF
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -132,18 +132,20 @@ 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, int theColumn = 1) const;
+  /// Returns true if a model can accept a drop of the data (used for drag and drop functionality).
+  virtual bool canDropMimeData(const QMimeData *theData, Qt::DropAction theAction,
+                               int theRow, int theColumn, const QModelIndex &theParent) const override;
 
-  /// Returns last history object index
-  //virtual QModelIndex lastHistoryIndex() const;
+  /// Converts the dragged items information into mime data format (to be encoded in dropMimeData)
+  virtual QMimeData* mimeData(const QModelIndexList &indexes) const override;
 
-  /// Initialises XML data model reader. It must be initialised before DataModel using.
-  //void setXMLReader(Config_DataModelReader* theReader) { myXMLReader = theReader; }
+  /// Performs a drag and drop of Part feature operation when it is droped.
+  virtual bool dropMimeData(const QMimeData *theData, Qt::DropAction theAction,
+                            int theRow, int theColumn, const QModelIndex &theParent) override;
 
-  /// Do not processing anymore events of model loop
-  //bool blockEventsProcessing(const bool theState);
+  /// Returns an index which is root of the given document
+  /// \param theDoc a document
+  QModelIndex documentRootIndex(DocumentPtr theDoc, int theColumn = 1) const;
 
   /// Returns true if the data model item has Hidden visual state
   /// \param theIndex a tree model item
@@ -167,6 +169,12 @@ public:
   /// \param thCol a column
   QModelIndex getIndex(ModuleBase_ITreeNode* theNode, int thCol) const;
 
+  /// Allows to support drag and drop of some model items
+  virtual Qt::DropActions supportedDropActions() const override
+  {
+    return Qt::MoveAction;
+  }
+
 signals:
   /// Signal send before tree rebuild
   void beforeTreeRebuild();
@@ -186,69 +194,8 @@ private:
 
   void updateSubTree(ModuleBase_ITreeNode* theParent);
 
-  /// Find a root index which contains objects of the given document
-  /// \param theDoc the document object
-  //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.
-  /// \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) const;
-
-  /// 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;
-
-  //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;
 
   ModuleBase_ITreeNode* myRoot;
 };