return ModelAPI_Tools::removeFeatures(aFeatures, false);
}
+//***********************************************************************
bool removeFeatures(const std::set<FeaturePtr>& theFeatures,
const bool theFlushRedisplay)
{
return true;
}
+//***********************************************************************
// Fills the references list by all references of the feature from the references map.
// This is a recusive method to find references by next found feature in the map of references.
// \param theFeature a feature to find references
if (!aFeature.get() && anObject->groupName() == ModelAPI_ResultParameter::group()) {
aFeature = ModelAPI_Feature::feature(anObject);
}
- theFeatures.insert(aFeature);
+ if (aFeature.get())
+ theFeatures.insert(aFeature);
+ }
+}
+
+//**************************************************************
+void convertToFolders(const QObjectPtrList& theObjects,
+ std::set<FolderPtr>& theFolders)
+{
+ QObjectPtrList::const_iterator anIt = theObjects.begin(), aLast = theObjects.end();
+ for(; anIt != aLast; anIt++) {
+ ObjectPtr anObject = *anIt;
+ FolderPtr aFeature = std::dynamic_pointer_cast<ModelAPI_Folder>(anObject);
+ if (aFeature.get())
+ theFolders.insert(aFeature);
}
}
+
+//**************************************************************
QString translate(const Events_InfoMessage& theMessage)
{
QString aMessage;
#include <ModelAPI_Attribute.h>
#include <ModelAPI_Feature.h>
+#include <ModelAPI_Folder.h>
#include <TopAbs_ShapeEnum.hxx>
#include <TopoDS_Shape.hxx>
std::set<FeaturePtr>& theFeatures);
+/// Converts a list of objects to set of folders.
+/// \param theObjects a list of objects
+/// \param theFeatures an out conteiner of features
+void MODULEBASE_EXPORT convertToFolders(const QObjectPtrList& theObjects,
+ std::set<FolderPtr>& theFolders);
+
+
/// Returns translation from the given data.
/// If translation is not exists then it returns a string
/// from the info data without translation
for (aIt = aGroups.begin(); aIt != aGroups.end(); ++aIt) {
std::string aGroup = (*aIt);
if (aDoc == aRootDoc) { // If root objects
- int aRow = aRootDoc->size(aGroup);
- if (aGroup == aRootType) {
+ int aRow = aRootDoc->size(aGroup, true);
+ if ((aGroup == aRootType) || (aGroup == ModelAPI_Folder::group())) {
// Process root folder
removeRow(aRow + aNbFolders);
rebuildBranch(aNbFolders, aRow);
// Check that some folders could erased
QStringList aNotEmptyFolders = listOfShowNotEmptyFolders();
foreach (QString aNotEmptyFolder, aNotEmptyFolders) {
- if ((aNotEmptyFolder.toStdString() == aGroup) && (aRootDoc->size(aGroup) == 0)) {
+ if ((aNotEmptyFolder.toStdString() == aGroup) && (aRootDoc->size(aGroup, true) == 0)) {
// Appears first object in folder which can not be shown empty
removeRow(myXMLReader->rootFolderId(aGroup));
removeShownFolder(aRootDoc, aNotEmptyFolder);
// Remove row for sub-document
QModelIndex aDocRoot = findDocumentRootIndex(aDoc.get(), 0);
if (aDocRoot.isValid()) {
- int aRow = aDoc->size(aGroup);
+ int aRow = aDoc->size(aGroup, true);
int aNbSubFolders = foldersCount(aDoc.get());
- if (aGroup == aSubType) {
+ if ((aGroup == aSubType) || (aGroup == ModelAPI_Folder::group())) {
// List of objects under document root
removeRow(aRow + aNbSubFolders, aDocRoot);
rebuildBranch(aNbSubFolders, aRow, aDocRoot);
}
// Check that some folders could disappear
QStringList aNotEmptyFolders = listOfShowNotEmptyFolders(false);
- int aSize = aDoc->size(aGroup);
+ int aSize = aDoc->size(aGroup, true);
foreach (QString aNotEmptyFolder, aNotEmptyFolders) {
if ((aNotEmptyFolder.toStdString() == aGroup) && (aSize == 0)) {
// Appears first object in folder which can not be shown empty
}
}
} else { // If document is attached to feature
- int aNb = aRootDoc->size(ModelAPI_Feature::group());
+ int aNb = aRootDoc->size(ModelAPI_Feature::group(), true);
ObjectPtr aObj;
ResultPartPtr aPartRes;
for (int i = 0; i < aNb; i++) {
ModuleBase_Tools::convertToFeatures(anObjects, aFeatures);
ModelAPI_Tools::findAllReferences(aFeatures, aReferences);
+ std::set<FolderPtr> aFolders;
+ ModuleBase_Tools::convertToFolders(anObjects, aFolders);
+
bool aDone = false;
QString aDescription = contextMenuMgr()->action("DELETE_CMD")->text() + " %1";
aDescription = aDescription.arg(XGUI_Tools::unionOfObjectNames(anObjects, ", "));
aFeatures.insert(aFeatureRefsToDelete.begin(), aFeatureRefsToDelete.end());
aDone = ModelAPI_Tools::removeFeatures(aFeatures, false);
}
+ if (aFolders.size() > 0) {
+ std::set<FolderPtr>::const_iterator anIt = aFolders.begin(),
+ aLast = aFolders.end();
+ for (; anIt != aLast; anIt++) {
+ FolderPtr aFolder = *anIt;
+ if (aFolder.get()) {
+ DocumentPtr aDoc = aFolder->document();
+ aDoc->removeFolder(aFolder);
+ }
+ }
+ }
+
if (aDone)
operationMgr()->commitOperation();
else