// Check that new folders could appear
QStringList aNotEmptyFolders = listOfShowNotEmptyFolders();
foreach (QString aNotEmptyFolder, aNotEmptyFolders) {
- if ((aNotEmptyFolder.toStdString() == aObjType) && (aRootDoc->size(aObjType) == 1))
+ if ((aNotEmptyFolder.toStdString() == aObjType) && (aRootDoc->size(aObjType) > 0)) {
// Appears first object in folder which can not be shown empty
- insertRow(myXMLReader->rootFolderId(aObjType));
+ if (!hasShownFolder(aRootDoc, aNotEmptyFolder)) {
+ insertRow(myXMLReader->rootFolderId(aObjType));
+ addShownFolder(aRootDoc, aNotEmptyFolder);
+ }
+ }
}
// Insert new object
int aRow = aRootDoc->size(aObjType) - 1;
// Check that new folders could appear
QStringList aNotEmptyFolders = listOfShowNotEmptyFolders(false);
foreach (QString aNotEmptyFolder, aNotEmptyFolders) {
- if ((aNotEmptyFolder.toStdString() == aObjType) && (aDoc->size(aObjType) == 1))
+ if ((aNotEmptyFolder.toStdString() == aObjType) && (aDoc->size(aObjType) > 0)) {
// Appears first object in folder which can not be shown empty
- insertRow(myXMLReader->subFolderId(aObjType), aDocRoot);
- }
+ if (!hasShownFolder(aDoc, aNotEmptyFolder)) {
+ insertRow(myXMLReader->subFolderId(aObjType), aDocRoot);
+ addShownFolder(aDoc, aNotEmptyFolder);
+ }
+ }
+ }
int aRow = aDoc->index(aObject);
if (aRow != -1) {
int aNbSubFolders = foldersCount(aDoc.get());
if ((aNotEmptyFolder.toStdString() == aGroup) && (aRootDoc->size(aGroup) == 0)) {
// Appears first object in folder which can not be shown empty
removeRow(myXMLReader->rootFolderId(aGroup));
+ removeShownFolder(aRootDoc, aNotEmptyFolder);
//rebuildBranch(0, aNbFolders + aDoc->size(myXMLReader->rootType()));
break;
}
if ((aNotEmptyFolder.toStdString() == aGroup) && (aSize == 0)) {
// Appears first object in folder which can not be shown empty
removeRow(myXMLReader->subFolderId(aGroup), aDocRoot);
+ removeShownFolder(aDoc, aNotEmptyFolder);
//rebuildBranch(0, aNbSubFolders + aDoc->size(myXMLReader->subType()), aDocRoot);
break;
}
/// \param fromRoot - root document flag
QStringList listOfShowNotEmptyFolders(bool fromRoot = true) 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;
+ QMap<DocumentPtr, QStringList> myShownFolders;
//bool myIsEventsProcessingBlocked;
};