12 import re |
12 import re |
13 |
13 |
14 from PyQt6.QtCore import QDir, QFileSystemWatcher, QModelIndex, Qt, pyqtSignal |
14 from PyQt6.QtCore import QDir, QFileSystemWatcher, QModelIndex, Qt, pyqtSignal |
15 from PyQt6.QtGui import QColor |
15 from PyQt6.QtGui import QColor |
16 |
16 |
17 from eric7 import Preferences, Utilities |
17 from eric7 import Preferences |
18 from eric7.EricGui import EricPixmapCache |
18 from eric7.EricGui import EricPixmapCache |
|
19 from eric7.SystemUtilities import FileSystemUtilities |
19 from eric7.UI.BrowserModel import ( |
20 from eric7.UI.BrowserModel import ( |
20 BrowserDirectoryItem, |
21 BrowserDirectoryItem, |
21 BrowserFileItem, |
22 BrowserFileItem, |
22 BrowserItem, |
23 BrowserItem, |
23 BrowserModel, |
24 BrowserModel, |
363 |
364 |
364 for f in entryInfoList: |
365 for f in entryInfoList: |
365 node = ( |
366 node = ( |
366 ProjectBrowserDirectoryItem( |
367 ProjectBrowserDirectoryItem( |
367 parentItem, |
368 parentItem, |
368 Utilities.toNativeSeparators(f.absoluteFilePath()), |
369 FileSystemUtilities.toNativeSeparators(f.absoluteFilePath()), |
369 parentItem.getProjectTypes()[0], |
370 parentItem.getProjectTypes()[0], |
370 False, |
371 False, |
371 ) |
372 ) |
372 if f.isDir() |
373 if f.isDir() |
373 else ProjectBrowserFileItem( |
374 else ProjectBrowserFileItem( |
374 parentItem, |
375 parentItem, |
375 Utilities.toNativeSeparators(f.absoluteFilePath()), |
376 FileSystemUtilities.toNativeSeparators(f.absoluteFilePath()), |
376 parentItem.getProjectTypes()[0], |
377 parentItem.getProjectTypes()[0], |
377 ) |
378 ) |
378 ) |
379 ) |
379 if self.project.vcs is not None: |
380 if self.project.vcs is not None: |
380 fname = f.absoluteFilePath() |
381 fname = f.absoluteFilePath() |
709 entryInfoList = qdir.entryInfoList(fileFilter) |
710 entryInfoList = qdir.entryInfoList(fileFilter) |
710 |
711 |
711 # step 1: check for new entries |
712 # step 1: check for new entries |
712 children = itm.children() |
713 children = itm.children() |
713 for f in entryInfoList: |
714 for f in entryInfoList: |
714 fpath = Utilities.toNativeSeparators(f.absoluteFilePath()) |
715 fpath = FileSystemUtilities.toNativeSeparators(f.absoluteFilePath()) |
715 childFound = False |
716 childFound = False |
716 for child in children: |
717 for child in children: |
717 if child.name() == fpath: |
718 if child.name() == fpath: |
718 childFound = True |
719 childFound = True |
719 children.remove(child) |
720 children.remove(child) |
724 cnt = itm.childCount() |
725 cnt = itm.childCount() |
725 self.beginInsertRows(self.createIndex(itm.row(), 0, itm), cnt, cnt) |
726 self.beginInsertRows(self.createIndex(itm.row(), 0, itm), cnt, cnt) |
726 node = ( |
727 node = ( |
727 ProjectBrowserDirectoryItem( |
728 ProjectBrowserDirectoryItem( |
728 itm, |
729 itm, |
729 Utilities.toNativeSeparators(f.absoluteFilePath()), |
730 FileSystemUtilities.toNativeSeparators(f.absoluteFilePath()), |
730 itm.getProjectTypes()[0], |
731 itm.getProjectTypes()[0], |
731 False, |
732 False, |
732 ) |
733 ) |
733 if f.isDir() |
734 if f.isDir() |
734 else ProjectBrowserFileItem( |
735 else ProjectBrowserFileItem( |
735 itm, |
736 itm, |
736 Utilities.toNativeSeparators(f.absoluteFilePath()), |
737 FileSystemUtilities.toNativeSeparators(f.absoluteFilePath()), |
737 itm.getProjectTypes()[0], |
738 itm.getProjectTypes()[0], |
738 ) |
739 ) |
739 ) |
740 ) |
740 self._addItem(node, itm) |
741 self._addItem(node, itm) |
741 if self.project.vcs is not None: |
742 if self.project.vcs is not None: |
749 |
750 |
750 # step 2: check for removed entries |
751 # step 2: check for removed entries |
751 if len(entryInfoList) != itm.childCount(): |
752 if len(entryInfoList) != itm.childCount(): |
752 for row in range(oldCnt - 1, -1, -1): |
753 for row in range(oldCnt - 1, -1, -1): |
753 child = itm.child(row) |
754 child = itm.child(row) |
754 childname = Utilities.fromNativeSeparators(child.name()) |
755 childname = FileSystemUtilities.fromNativeSeparators(child.name()) |
755 entryFound = False |
756 entryFound = False |
756 for f in entryInfoList: |
757 for f in entryInfoList: |
757 if f.absoluteFilePath() == childname: |
758 if f.absoluteFilePath() == childname: |
758 entryFound = True |
759 entryFound = True |
759 entryInfoList.remove(f) |
760 entryInfoList.remove(f) |