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 |
17 from eric7 import Preferences |
18 from eric7.EricGui import EricPixmapCache |
|
19 from eric7.SystemUtilities import FileSystemUtilities |
18 from eric7.SystemUtilities import FileSystemUtilities |
20 from eric7.UI.BrowserModel import ( |
19 from eric7.UI.BrowserModel import ( |
21 BrowserDirectoryItem, |
20 BrowserDirectoryItem, |
22 BrowserFileItem, |
21 BrowserFileItem, |
23 BrowserItem, |
22 BrowserItem, |
24 BrowserModel, |
23 BrowserModel, |
|
24 BrowserSimpleDirectoryItem, |
25 ) |
25 ) |
26 from eric7.Utilities import ModuleParser |
26 from eric7.Utilities import ModuleParser |
27 |
27 |
28 ProjectBrowserItemSimpleDirectory = 100 |
28 ProjectBrowserItemSimpleDirectory = 100 |
29 ProjectBrowserItemDirectory = 101 |
29 ProjectBrowserItemDirectory = 101 |
113 @param parent parent item |
115 @param parent parent item |
114 @param projectType type of file/directory in the project |
116 @param projectType type of file/directory in the project |
115 @param text text to be displayed (string) |
117 @param text text to be displayed (string) |
116 @param path path of the directory (string) |
118 @param path path of the directory (string) |
117 """ |
119 """ |
118 BrowserItem.__init__(self, parent, text) |
120 BrowserSimpleDirectoryItem.__init__(self, parent, text, path=path) |
119 ProjectBrowserItemMixin.__init__(self, projectType) |
121 ProjectBrowserItemMixin.__init__(self, projectType) |
120 |
122 |
121 self._dirName = path |
|
122 if not os.path.isdir(self._dirName): |
|
123 self._dirName = os.path.dirname(self._dirName) |
|
124 |
|
125 self.type_ = ProjectBrowserItemSimpleDirectory |
123 self.type_ = ProjectBrowserItemSimpleDirectory |
126 if os.path.lexists(self._dirName) and os.path.islink(self._dirName): |
|
127 self.symlink = True |
|
128 self.icon = EricPixmapCache.getSymlinkIcon("dirClosed") |
|
129 else: |
|
130 self.icon = EricPixmapCache.getIcon("dirClosed") |
|
131 |
|
132 def setName(self, dinfo, full=True): # noqa: U100 |
|
133 """ |
|
134 Public method to set the directory name. |
|
135 |
|
136 @param dinfo dinfo is the string for the directory (string) |
|
137 @param full flag indicating full path name should be displayed (boolean) |
|
138 """ |
|
139 self._dirName = os.path.abspath(dinfo) |
|
140 self.itemData[0] = os.path.basename(self._dirName) |
|
141 |
|
142 def dirName(self): |
|
143 """ |
|
144 Public method returning the directory name. |
|
145 |
|
146 @return directory name (string) |
|
147 """ |
|
148 return self._dirName |
|
149 |
|
150 def name(self): |
|
151 """ |
|
152 Public method to return the name of the item. |
|
153 |
|
154 @return name of the item (string) |
|
155 """ |
|
156 return self._dirName |
|
157 |
|
158 def lessThan(self, other, column, order): |
|
159 """ |
|
160 Public method to check, if the item is less than the other one. |
|
161 |
|
162 @param other reference to item to compare against (BrowserItem) |
|
163 @param column column number to use for the comparison (integer) |
|
164 @param order sort order (Qt.SortOrder) (for special sorting) |
|
165 @return true, if this item is less than other (boolean) |
|
166 """ |
|
167 if issubclass(other.__class__, BrowserFileItem) and Preferences.getUI( |
|
168 "BrowsersListFoldersFirst" |
|
169 ): |
|
170 return order == Qt.SortOrder.AscendingOrder |
|
171 |
|
172 return BrowserItem.lessThan(self, other, column, order) |
|
173 |
124 |
174 |
125 |
175 class ProjectBrowserDirectoryItem(BrowserDirectoryItem, ProjectBrowserItemMixin): |
126 class ProjectBrowserDirectoryItem(BrowserDirectoryItem, ProjectBrowserItemMixin): |
176 """ |
127 """ |
177 Class implementing the data structure for project browser directory items. |
128 Class implementing the data structure for project browser directory items. |