diff options
author | PatelVatsalB21 | 2022-07-05 10:26:31 +0530 |
---|---|---|
committer | PatelVatsalB21 | 2022-07-05 10:26:31 +0530 |
commit | 7fc799678827cc90b91d85498d8a5adee3b73c2a (patch) | |
tree | 0c11c950955619fafc4b66795e21ba7f94297916 /src/frontEnd/ProjectExplorer.py | |
parent | 49efba6b6844f0c90f48159dfcdab84804e3df02 (diff) | |
download | eSim-7fc799678827cc90b91d85498d8a5adee3b73c2a.tar.gz eSim-7fc799678827cc90b91d85498d8a5adee3b73c2a.tar.bz2 eSim-7fc799678827cc90b91d85498d8a5adee3b73c2a.zip |
Resolved Project Files Refresh Problem
Diffstat (limited to 'src/frontEnd/ProjectExplorer.py')
-rwxr-xr-x | src/frontEnd/ProjectExplorer.py | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/frontEnd/ProjectExplorer.py b/src/frontEnd/ProjectExplorer.py index 456276c8..bacb569c 100755 --- a/src/frontEnd/ProjectExplorer.py +++ b/src/frontEnd/ProjectExplorer.py @@ -69,13 +69,20 @@ class ProjectExplorer(QtWidgets.QWidget): parentnode, [files, os.path.join(parents, files)] ) self.window.addWidget(self.treewidget) - + self.treewidget.expanded.connect(self.refreshInstant) self.treewidget.doubleClicked.connect(self.openProject) self.treewidget.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self.treewidget.customContextMenuRequested.connect(self.openMenu) self.setLayout(self.window) self.show() + def refreshInstant(self): + for i in range(self.treewidget.topLevelItemCount()): + if(self.treewidget.topLevelItem(i).isExpanded()): + index = self.treewidget.indexFromItem( + self.treewidget.topLevelItem(i)) + self.refreshProject(indexItem=index) + def addTreeNode(self, parents, children): os.path.join(parents) pathlist = parents.split(os.sep) @@ -137,6 +144,7 @@ class ProjectExplorer(QtWidgets.QWidget): self.save = QtWidgets.QPushButton('Save and Exit') self.save.setDisabled(True) self.windowgrid = QtWidgets.QGridLayout() + self.refreshProject(self.filePath) if (os.path.isfile(str(self.filePath))): self.fopen = open(str(self.filePath), 'r') @@ -202,25 +210,31 @@ class ProjectExplorer(QtWidgets.QWidget): json.dump(self.obj_appconfig.project_explorer, open(self.obj_appconfig.dictPath["path"], 'w')) - def refreshProject(self, filePath=None): + def refreshProject(self, filePath=None, indexItem=None): """ This function refresh the project in explorer area by right \ clicking on project and selecting refresh option. """ if not filePath or filePath is None: - self.indexItem = self.treewidget.currentIndex() + if indexItem is None: + self.indexItem = self.treewidget.currentIndex() + else: + self.indexItem = indexItem + filePath = str( self.indexItem.sibling(self.indexItem.row(), 1).data() ) if os.path.exists(filePath): filelistnew = os.listdir(os.path.join(filePath)) - parentnode = self.treewidget.currentItem() + if indexItem is None: + parentnode = self.treewidget.currentItem() + else: + parentnode = self.treewidget.itemFromIndex(self.indexItem) count = parentnode.childCount() for i in range(count): - for items in self.treewidget.selectedItems(): - items.removeChild(items.child(0)) + parentnode.removeChild(parentnode.child(0)) for files in filelistnew: QtWidgets.QTreeWidgetItem( parentnode, [files, os.path.join(filePath, files)] |