Wed, 10 Apr 2024 16:45:06 +0200
General
- Changed code from using `QFileSystemWatcher` to our own implementation (`EricFileSystemWatcher`) based on the `watchdog` Python package in order to get more fine grained control over the reported changes.
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1 | # -*- coding: utf-8 -*- |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2 | |
10439
21c28b0f9e41
Updated copyright for 2024.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10433
diff
changeset
|
3 | # Copyright (c) 2006 - 2024 Detlev Offenbach <detlev@die-offenbachs.de> |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
4 | # |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
5 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
6 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
7 | Module implementing the browser model. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
8 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
9 | |
9473
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9413
diff
changeset
|
10 | import contextlib |
10470
cd7bfd539ac9
Changed the browser item types to an enum in BrowserModel and ProjectBrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10468
diff
changeset
|
11 | import enum |
910
dc2436a9e2a1
Added capability to filter out unwanted items in the file browsers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
12 | import fnmatch |
3358
57af7e9fda48
Finished to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3357
diff
changeset
|
13 | import json |
9473
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9413
diff
changeset
|
14 | import os |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
15 | |
8318
962bce857696
Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
16 | from PyQt6.QtCore import ( |
9473
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9413
diff
changeset
|
17 | QAbstractItemModel, |
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9413
diff
changeset
|
18 | QCoreApplication, |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
19 | QDir, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
20 | QModelIndex, |
9473
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9413
diff
changeset
|
21 | QProcess, |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
22 | Qt, |
7264
bedbe458d792
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7249
diff
changeset
|
23 | ) |
9473
3f23dbf37dbe
Resorted the import statements using isort.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9413
diff
changeset
|
24 | from PyQt6.QtGui import QFont, QImageReader |
8318
962bce857696
Replaced all imports of PyQt5 to PyQt6 and started to replace code using obsoleted methods and adapt to the PyQt6 enum usage.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8312
diff
changeset
|
25 | from PyQt6.QtWidgets import QApplication |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
26 | |
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9612
diff
changeset
|
27 | from eric7 import Preferences |
10679 | 28 | from eric7.EricCore import EricFileSystemWatcher |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9297
diff
changeset
|
29 | from eric7.EricGui import EricPixmapCache |
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9612
diff
changeset
|
30 | from eric7.SystemUtilities import FileSystemUtilities |
9612
93b496cc3c88
Class Browsers
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9609
diff
changeset
|
31 | from eric7.Utilities import ClassBrowsers |
9482
a2bc06a54d9d
Corrected/acknowledged some bad import style and removed some obsolete code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9473
diff
changeset
|
32 | from eric7.Utilities.ClassBrowsers import ClbrBaseClasses |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
33 | |
10470
cd7bfd539ac9
Changed the browser item types to an enum in BrowserModel and ProjectBrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10468
diff
changeset
|
34 | |
cd7bfd539ac9
Changed the browser item types to an enum in BrowserModel and ProjectBrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10468
diff
changeset
|
35 | class BrowserItemType(enum.Enum): |
cd7bfd539ac9
Changed the browser item types to an enum in BrowserModel and ProjectBrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10468
diff
changeset
|
36 | """ |
cd7bfd539ac9
Changed the browser item types to an enum in BrowserModel and ProjectBrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10468
diff
changeset
|
37 | Class defining the various browser item types. |
cd7bfd539ac9
Changed the browser item types to an enum in BrowserModel and ProjectBrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10468
diff
changeset
|
38 | """ |
cd7bfd539ac9
Changed the browser item types to an enum in BrowserModel and ProjectBrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10468
diff
changeset
|
39 | |
cd7bfd539ac9
Changed the browser item types to an enum in BrowserModel and ProjectBrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10468
diff
changeset
|
40 | # Base types used everywhere |
cd7bfd539ac9
Changed the browser item types to an enum in BrowserModel and ProjectBrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10468
diff
changeset
|
41 | Root = 0 |
cd7bfd539ac9
Changed the browser item types to an enum in BrowserModel and ProjectBrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10468
diff
changeset
|
42 | SimpleDirectory = 1 |
cd7bfd539ac9
Changed the browser item types to an enum in BrowserModel and ProjectBrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10468
diff
changeset
|
43 | Directory = 2 |
cd7bfd539ac9
Changed the browser item types to an enum in BrowserModel and ProjectBrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10468
diff
changeset
|
44 | SysPath = 3 |
cd7bfd539ac9
Changed the browser item types to an enum in BrowserModel and ProjectBrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10468
diff
changeset
|
45 | File = 4 |
cd7bfd539ac9
Changed the browser item types to an enum in BrowserModel and ProjectBrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10468
diff
changeset
|
46 | Class = 5 |
cd7bfd539ac9
Changed the browser item types to an enum in BrowserModel and ProjectBrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10468
diff
changeset
|
47 | Method = 6 |
cd7bfd539ac9
Changed the browser item types to an enum in BrowserModel and ProjectBrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10468
diff
changeset
|
48 | Attributes = 7 |
cd7bfd539ac9
Changed the browser item types to an enum in BrowserModel and ProjectBrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10468
diff
changeset
|
49 | Attribute = 8 |
cd7bfd539ac9
Changed the browser item types to an enum in BrowserModel and ProjectBrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10468
diff
changeset
|
50 | Coding = 9 |
cd7bfd539ac9
Changed the browser item types to an enum in BrowserModel and ProjectBrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10468
diff
changeset
|
51 | Imports = 10 |
cd7bfd539ac9
Changed the browser item types to an enum in BrowserModel and ProjectBrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10468
diff
changeset
|
52 | Import = 11 |
cd7bfd539ac9
Changed the browser item types to an enum in BrowserModel and ProjectBrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10468
diff
changeset
|
53 | |
cd7bfd539ac9
Changed the browser item types to an enum in BrowserModel and ProjectBrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10468
diff
changeset
|
54 | # Types used by the project browser model |
cd7bfd539ac9
Changed the browser item types to an enum in BrowserModel and ProjectBrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10468
diff
changeset
|
55 | PbSimpleDirectory = 100 |
cd7bfd539ac9
Changed the browser item types to an enum in BrowserModel and ProjectBrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10468
diff
changeset
|
56 | PbDirectory = 101 |
cd7bfd539ac9
Changed the browser item types to an enum in BrowserModel and ProjectBrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10468
diff
changeset
|
57 | PbFile = 102 |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
910
diff
changeset
|
58 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
59 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
60 | class BrowserModel(QAbstractItemModel): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
61 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
62 | Class implementing the browser model. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
63 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
64 | |
2613
0799eea6feba
Fixed a little issue with subclassing BrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2409
diff
changeset
|
65 | def __init__(self, parent=None, nopopulate=False): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
66 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
67 | Constructor |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
68 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
69 | @param parent reference to parent object |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
70 | @type QObject |
7900
72b88fb20261
Corrected the use of '@keyparam' in the source documentation.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7781
diff
changeset
|
71 | @param nopopulate flag indicating to not populate the model |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
72 | @type bool |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
73 | """ |
8218
7c09585bd960
Applied some more code simplifications suggested by the new Simplify checker (super(Foo, self) => super()).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8217
diff
changeset
|
74 | super().__init__(parent) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
75 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
76 | self.progDir = None |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
77 | |
3357
2390df6f42ba
Started to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
78 | self.__sysPathInterpreter = "" |
2390df6f42ba
Started to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
79 | self.__sysPathItem = None |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
80 | |
2613
0799eea6feba
Fixed a little issue with subclassing BrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2409
diff
changeset
|
81 | if not nopopulate: |
10679 | 82 | self.watchedDirItems = {} |
7677
d4d33990b355
File Browser: changed it to react upon changed files if their contents is shown
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7635
diff
changeset
|
83 | self.watchedFileItems = {} |
10679 | 84 | watcher = EricFileSystemWatcher.instance() |
85 | watcher.directoryCreated.connect(lambda x: self.entryCreated(x, isDir=True)) | |
86 | watcher.directoryDeleted.connect(lambda x: self.entryDeleted(x, isDir=True)) | |
87 | watcher.fileCreated.connect(lambda x: self.entryCreated(x, isDir=False)) | |
88 | watcher.fileDeleted.connect(lambda x: self.entryDeleted(x, isDir=False)) | |
89 | watcher.fileModified.connect(self.fileChanged) | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
90 | |
3656
441956d8fce5
Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3604
diff
changeset
|
91 | rootData = QCoreApplication.translate("BrowserModel", "Name") |
2613
0799eea6feba
Fixed a little issue with subclassing BrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2409
diff
changeset
|
92 | self.rootItem = BrowserItem(None, rootData) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
93 | |
2613
0799eea6feba
Fixed a little issue with subclassing BrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2409
diff
changeset
|
94 | self.__populateModel() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
95 | |
5656
9c21b2746218
Fixed a few code style issues related to the usage of class instances for default arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5624
diff
changeset
|
96 | def columnCount(self, parent=None): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
97 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
98 | Public method to get the number of columns. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
99 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
100 | @param parent index of parent item |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
101 | @type QModelIndex |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
102 | @return number of columns |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
103 | @rtype int |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
104 | """ |
5656
9c21b2746218
Fixed a few code style issues related to the usage of class instances for default arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5624
diff
changeset
|
105 | if parent is None: |
9c21b2746218
Fixed a few code style issues related to the usage of class instances for default arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5624
diff
changeset
|
106 | parent = QModelIndex() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
107 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
108 | item = parent.internalPointer() if parent.isValid() else self.rootItem |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
109 | |
10378
cbbcecf9b25e
Changed code to cope with a changed behavior of Qt 6.1.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10373
diff
changeset
|
110 | return item.columnCount() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
111 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
112 | def data(self, index, role): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
113 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
114 | Public method to get data of an item. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
115 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
116 | @param index index of the data to retrieve |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
117 | @type QModelIndex |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
118 | @param role role of data |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
119 | @type Qt.ItemDataRole |
7
c679fb30c8f3
Change code dealing with QVariant (and QSettings) to use the PyQt4 QVariant v2 API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
120 | @return requested data |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
121 | @rtype Any |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
122 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
123 | if not index.isValid(): |
7
c679fb30c8f3
Change code dealing with QVariant (and QSettings) to use the PyQt4 QVariant v2 API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
124 | return None |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
125 | |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8131
diff
changeset
|
126 | if role == Qt.ItemDataRole.DisplayRole: |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
127 | item = index.internalPointer() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
128 | if index.column() < item.columnCount(): |
7
c679fb30c8f3
Change code dealing with QVariant (and QSettings) to use the PyQt4 QVariant v2 API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
129 | return item.data(index.column()) |
7264
bedbe458d792
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7249
diff
changeset
|
130 | elif ( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
131 | index.column() == item.columnCount() |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
132 | and index.column() < self.columnCount(self.parent(index)) |
7264
bedbe458d792
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7249
diff
changeset
|
133 | ): |
3012
d177226027e2
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2965
diff
changeset
|
134 | # This is for the case where an item under a multi-column |
d177226027e2
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2965
diff
changeset
|
135 | # parent doesn't have a value for all the columns |
7
c679fb30c8f3
Change code dealing with QVariant (and QSettings) to use the PyQt4 QVariant v2 API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
136 | return "" |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8131
diff
changeset
|
137 | elif role == Qt.ItemDataRole.DecorationRole: |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
138 | if index.column() == 0: |
7
c679fb30c8f3
Change code dealing with QVariant (and QSettings) to use the PyQt4 QVariant v2 API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
139 | return index.internalPointer().getIcon() |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8131
diff
changeset
|
140 | elif role == Qt.ItemDataRole.FontRole: |
103
59137afca666
Added code to indicate directories and files being symbolic links.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
15
diff
changeset
|
141 | item = index.internalPointer() |
59137afca666
Added code to indicate directories and files being symbolic links.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
15
diff
changeset
|
142 | if item.isSymlink(): |
59137afca666
Added code to indicate directories and files being symbolic links.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
15
diff
changeset
|
143 | font = QFont(QApplication.font("QTreeView")) |
59137afca666
Added code to indicate directories and files being symbolic links.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
15
diff
changeset
|
144 | font.setItalic(True) |
59137afca666
Added code to indicate directories and files being symbolic links.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
15
diff
changeset
|
145 | return font |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
146 | |
7
c679fb30c8f3
Change code dealing with QVariant (and QSettings) to use the PyQt4 QVariant v2 API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
147 | return None |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
148 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
149 | def flags(self, index): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
150 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
151 | Public method to get the item flags. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
152 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
153 | @param index index of the data to retrieve |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
154 | @type QModelIndex |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
155 | @return requested flags |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
156 | @rtype Qt.ItemFlags |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
157 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
158 | if not index.isValid(): |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8131
diff
changeset
|
159 | return Qt.ItemFlag.ItemIsEnabled |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
160 | |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8131
diff
changeset
|
161 | return Qt.ItemFlag.ItemIsEnabled | Qt.ItemFlag.ItemIsSelectable |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
162 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
163 | def headerData(self, section, orientation, role=Qt.ItemDataRole.DisplayRole): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
164 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
165 | Public method to get the header data. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
166 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
167 | @param section number of section to get data for |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
168 | @type int |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
169 | @param orientation header orientation |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
170 | @type Qt.Orientation |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
171 | @param role role of data |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
172 | @type Qt.ItemDataRole |
7
c679fb30c8f3
Change code dealing with QVariant (and QSettings) to use the PyQt4 QVariant v2 API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
173 | @return requested header data |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
174 | @rtype Any |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
175 | """ |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8131
diff
changeset
|
176 | if ( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
177 | orientation == Qt.Orientation.Horizontal |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
178 | and role == Qt.ItemDataRole.DisplayRole |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8131
diff
changeset
|
179 | ): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
180 | if section >= self.rootItem.columnCount(): |
7
c679fb30c8f3
Change code dealing with QVariant (and QSettings) to use the PyQt4 QVariant v2 API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
181 | return "" |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
182 | else: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
183 | return self.rootItem.data(section) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
184 | |
7
c679fb30c8f3
Change code dealing with QVariant (and QSettings) to use the PyQt4 QVariant v2 API.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
0
diff
changeset
|
185 | return None |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
186 | |
5656
9c21b2746218
Fixed a few code style issues related to the usage of class instances for default arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5624
diff
changeset
|
187 | def index(self, row, column, parent=None): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
188 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
189 | Public method to create an index. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
190 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
191 | @param row row number of the new index |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
192 | @type int |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
193 | @param column column number of the new index |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
194 | @type int |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
195 | @param parent index of parent item |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
196 | @type QModelIndex |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
197 | @return index object |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
198 | @rtype QModelIndex |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
199 | """ |
5656
9c21b2746218
Fixed a few code style issues related to the usage of class instances for default arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5624
diff
changeset
|
200 | if parent is None: |
9c21b2746218
Fixed a few code style issues related to the usage of class instances for default arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5624
diff
changeset
|
201 | parent = QModelIndex() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
202 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
910
diff
changeset
|
203 | # The model/view framework considers negative values out-of-bounds, |
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
910
diff
changeset
|
204 | # however in python they work when indexing into lists. So make sure |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
205 | # we return an invalid index for out-of-bounds row/col |
7264
bedbe458d792
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7249
diff
changeset
|
206 | if ( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
207 | row < 0 |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
208 | or column < 0 |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
209 | or row >= self.rowCount(parent) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
210 | or column >= self.columnCount(parent) |
7264
bedbe458d792
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7249
diff
changeset
|
211 | ): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
212 | return QModelIndex() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
213 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
214 | parentItem = parent.internalPointer() if parent.isValid() else self.rootItem |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
215 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
216 | try: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
217 | if not parentItem.isPopulated(): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
218 | self.populateItem(parentItem) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
219 | childItem = parentItem.child(row) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
220 | except IndexError: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
221 | childItem = None |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
222 | if childItem: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
223 | return self.createIndex(row, column, childItem) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
224 | else: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
225 | return QModelIndex() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
226 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
227 | def parent(self, index): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
228 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
229 | Public method to get the index of the parent object. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
230 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
231 | @param index index of the item |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
232 | @type QModelIndex |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
233 | @return index of parent item |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
234 | @rtype QModelIndex |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
235 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
236 | if not index.isValid(): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
237 | return QModelIndex() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
238 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
239 | childItem = index.internalPointer() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
240 | parentItem = childItem.parent() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
241 | |
7690
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7678
diff
changeset
|
242 | if parentItem is None or parentItem == self.rootItem: |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
243 | return QModelIndex() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
244 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
245 | return self.createIndex(parentItem.row(), 0, parentItem) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
246 | |
5656
9c21b2746218
Fixed a few code style issues related to the usage of class instances for default arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5624
diff
changeset
|
247 | def rowCount(self, parent=None): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
248 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
249 | Public method to get the number of rows. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
250 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
251 | @param parent index of parent item |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
252 | @type QModelIndex |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
253 | @return number of rows |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
254 | @rtype int |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
255 | """ |
5656
9c21b2746218
Fixed a few code style issues related to the usage of class instances for default arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5624
diff
changeset
|
256 | if parent is None: |
9c21b2746218
Fixed a few code style issues related to the usage of class instances for default arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5624
diff
changeset
|
257 | parent = QModelIndex() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
258 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
259 | # Only the first column should have children |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
260 | if parent.column() > 0: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
261 | return 0 |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
262 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
263 | if not parent.isValid(): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
264 | parentItem = self.rootItem |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
265 | else: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
266 | parentItem = parent.internalPointer() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
267 | if not parentItem.isPopulated(): # lazy population |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
268 | self.populateItem(parentItem) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
269 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
270 | return parentItem.childCount() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
271 | |
5656
9c21b2746218
Fixed a few code style issues related to the usage of class instances for default arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5624
diff
changeset
|
272 | def hasChildren(self, parent=None): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
273 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
274 | Public method to check for the presence of child items. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
275 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
276 | We always return True for normal items in order to do lazy |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
277 | population of the tree. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
278 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
279 | @param parent index of parent item |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
280 | @type QModelIndex |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
281 | @return flag indicating the presence of child items |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
282 | @rtype bool |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
283 | """ |
5656
9c21b2746218
Fixed a few code style issues related to the usage of class instances for default arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5624
diff
changeset
|
284 | if parent is None: |
9c21b2746218
Fixed a few code style issues related to the usage of class instances for default arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5624
diff
changeset
|
285 | parent = QModelIndex() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
286 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
287 | # Only the first column should have children |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
288 | if parent.column() > 0: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
289 | return 0 |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
290 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
291 | if not parent.isValid(): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
292 | return self.rootItem.childCount() > 0 |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
293 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
294 | if parent.internalPointer().isLazyPopulated(): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
295 | return True |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
296 | else: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
297 | return parent.internalPointer().childCount() > 0 |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
298 | |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
299 | def clear(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
300 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
301 | Public method to clear the model. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
302 | """ |
3656
441956d8fce5
Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3604
diff
changeset
|
303 | self.beginResetModel() |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
304 | self.rootItem.removeChildren() |
3656
441956d8fce5
Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3604
diff
changeset
|
305 | self.endResetModel() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
306 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
307 | def item(self, index): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
308 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
309 | Public method to get a reference to an item. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
310 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
311 | @param index index of the data to retrieve |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
312 | @type QModelIndex |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
313 | @return requested item reference |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
314 | @rtype BrowserItem |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
315 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
316 | if not index.isValid(): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
317 | return None |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
318 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
319 | return index.internalPointer() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
320 | |
231
2e4eb047ae93
Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
103
diff
changeset
|
321 | def _addWatchedItem(self, itm): |
2e4eb047ae93
Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
103
diff
changeset
|
322 | """ |
2e4eb047ae93
Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
103
diff
changeset
|
323 | Protected method to watch an item. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
324 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
325 | @param itm item to be watched |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
326 | @type BrowserDirectoryItem |
231
2e4eb047ae93
Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
103
diff
changeset
|
327 | """ |
2e4eb047ae93
Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
103
diff
changeset
|
328 | if isinstance(itm, BrowserDirectoryItem): |
2e4eb047ae93
Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
103
diff
changeset
|
329 | dirName = itm.dirName() |
7264
bedbe458d792
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7249
diff
changeset
|
330 | if ( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
331 | dirName != "" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
332 | and not dirName.startswith("//") |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
333 | and not dirName.startswith("\\\\") |
7264
bedbe458d792
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7249
diff
changeset
|
334 | ): |
10679 | 335 | EricFileSystemWatcher.instance().addPath(dirName) |
336 | if dirName in self.watchedDirItems: | |
337 | if itm not in self.watchedDirItems[dirName]: | |
338 | self.watchedDirItems[dirName].append(itm) | |
232
0ee8be384de2
Extended last change to deal with multiple items having the same directory name.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
231
diff
changeset
|
339 | else: |
10679 | 340 | self.watchedDirItems[dirName] = [itm] |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
341 | |
231
2e4eb047ae93
Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
103
diff
changeset
|
342 | def _removeWatchedItem(self, itm): |
2e4eb047ae93
Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
103
diff
changeset
|
343 | """ |
2e4eb047ae93
Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
103
diff
changeset
|
344 | Protected method to remove a watched item. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
345 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
346 | @param itm item to be removed |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
347 | @type BrowserDirectoryItem |
231
2e4eb047ae93
Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
103
diff
changeset
|
348 | """ |
2e4eb047ae93
Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
103
diff
changeset
|
349 | if isinstance(itm, BrowserDirectoryItem): |
2e4eb047ae93
Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
103
diff
changeset
|
350 | dirName = itm.dirName() |
10642
fbf61874518a
Made two small modifications to BrowserModel to ignore some exceptions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10595
diff
changeset
|
351 | with contextlib.suppress(KeyError): |
fbf61874518a
Made two small modifications to BrowserModel to ignore some exceptions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10595
diff
changeset
|
352 | with contextlib.suppress(ValueError): |
10679 | 353 | self.watchedDirItems[dirName].remove(itm) |
354 | if len(self.watchedDirItems[dirName]) == 0: | |
355 | del self.watchedDirItems[dirName] | |
356 | EricFileSystemWatcher.instance().removePath(dirName) | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
357 | |
10679 | 358 | def entryCreated(self, path, isDir=False): |
231
2e4eb047ae93
Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
103
diff
changeset
|
359 | """ |
10679 | 360 | Public method to handle the creation of a file or directory. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
361 | |
10679 | 362 | @param path path of the created file or directory |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
363 | @type str |
10679 | 364 | @param isDir flag indicating a created directory (defaults to False) |
365 | @type bool (optional) | |
231
2e4eb047ae93
Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
103
diff
changeset
|
366 | """ |
10679 | 367 | parentPath = os.path.dirname(path) |
368 | if parentPath not in self.watchedDirItems: | |
231
2e4eb047ae93
Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
103
diff
changeset
|
369 | # just ignore the situation we don't have a reference to the item |
2e4eb047ae93
Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
103
diff
changeset
|
370 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
371 | |
10679 | 372 | for itm in self.watchedDirItems[parentPath]: |
373 | cnt = itm.childCount() | |
374 | self.beginInsertRows(self.createIndex(itm.row(), 0, itm), cnt, cnt) | |
375 | node = ( | |
376 | BrowserDirectoryItem( | |
377 | itm, | |
378 | FileSystemUtilities.toNativeSeparators(path), | |
379 | False, | |
380 | ) | |
381 | if isDir | |
382 | else BrowserFileItem( | |
383 | itm, | |
384 | FileSystemUtilities.toNativeSeparators(path), | |
385 | ) | |
386 | ) | |
387 | self._addItem(node, itm) | |
388 | self.endInsertRows() | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
389 | |
10679 | 390 | def entryDeleted(self, path, isDir=False): # noqa: U100 |
391 | """ | |
392 | Public method to handle the deletion of a file or directory. | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
393 | |
10679 | 394 | @param path path of the deleted file or directory |
395 | @type str | |
396 | @param isDir flag indicating a deleted directory (defaults to False) | |
397 | @type bool (optional) | |
398 | """ | |
399 | parentPath = os.path.dirname(path) | |
400 | if parentPath not in self.watchedDirItems: | |
401 | # just ignore the situation we don't have a reference to the item | |
402 | return | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
403 | |
10679 | 404 | for itm in self.watchedDirItems[parentPath]: |
405 | for row in range(itm.childCount() - 1, -1, -1): | |
406 | child = itm.child(row) | |
407 | if child.name() == path: | |
233
9d2677615a3d
Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
232
diff
changeset
|
408 | self._removeWatchedItem(child) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
409 | self.beginRemoveRows(self.createIndex(itm.row(), 0, itm), row, row) |
233
9d2677615a3d
Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
232
diff
changeset
|
410 | itm.removeChild(child) |
9d2677615a3d
Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
232
diff
changeset
|
411 | self.endRemoveRows() |
10679 | 412 | break |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
413 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
414 | def __populateModel(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
415 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
416 | Private method to populate the browser model. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
417 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
418 | self.toplevelDirs = [] |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
419 | tdp = Preferences.getSettings().value("BrowserModel/ToplevelDirs") |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
420 | if tdp: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
421 | self.toplevelDirs = tdp |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
422 | else: |
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9612
diff
changeset
|
423 | self.toplevelDirs.append( |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9612
diff
changeset
|
424 | FileSystemUtilities.toNativeSeparators(QDir.homePath()) |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9612
diff
changeset
|
425 | ) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
426 | for d in QDir.drives(): |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
427 | self.toplevelDirs.append( |
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9612
diff
changeset
|
428 | FileSystemUtilities.toNativeSeparators(d.absoluteFilePath()) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
429 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
430 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
431 | for d in self.toplevelDirs: |
233
9d2677615a3d
Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
232
diff
changeset
|
432 | itm = BrowserDirectoryItem(self.rootItem, d) |
9d2677615a3d
Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
232
diff
changeset
|
433 | self._addItem(itm, self.rootItem) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
434 | |
3357
2390df6f42ba
Started to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
435 | def interpreterChanged(self, interpreter): |
2390df6f42ba
Started to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
436 | """ |
2390df6f42ba
Started to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
437 | Public method to handle a change of the debug client's interpreter. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
438 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
439 | @param interpreter interpreter of the debug client |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
440 | @type str |
3357
2390df6f42ba
Started to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
441 | """ |
2390df6f42ba
Started to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
442 | if interpreter and "python" in interpreter.lower(): |
2390df6f42ba
Started to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
443 | if interpreter.endswith("w.exe"): |
2390df6f42ba
Started to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
444 | interpreter = interpreter.replace("w.exe", ".exe") |
2390df6f42ba
Started to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
445 | if self.__sysPathInterpreter != interpreter: |
2390df6f42ba
Started to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
446 | self.__sysPathInterpreter = interpreter |
2390df6f42ba
Started to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
447 | # step 1: remove sys.path entry |
2390df6f42ba
Started to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
448 | if self.__sysPathItem is not None: |
2390df6f42ba
Started to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
449 | self.beginRemoveRows( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
450 | QModelIndex(), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
451 | self.__sysPathItem.row(), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
452 | self.__sysPathItem.row(), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
453 | ) |
3357
2390df6f42ba
Started to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
454 | self.rootItem.removeChild(self.__sysPathItem) |
2390df6f42ba
Started to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
455 | self.endRemoveRows() |
2390df6f42ba
Started to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
456 | self.__sysPathItem = None |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
457 | |
3357
2390df6f42ba
Started to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
458 | if self.__sysPathInterpreter: |
2390df6f42ba
Started to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
459 | # step 2: add a new one |
2390df6f42ba
Started to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
460 | self.__sysPathItem = BrowserSysPathItem(self.rootItem) |
2390df6f42ba
Started to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
461 | self.addItem(self.__sysPathItem) |
2390df6f42ba
Started to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
462 | else: |
2390df6f42ba
Started to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
463 | # remove sys.path entry |
2390df6f42ba
Started to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
464 | if self.__sysPathItem is not None: |
2390df6f42ba
Started to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
465 | self.beginRemoveRows( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
466 | QModelIndex(), self.__sysPathItem.row(), self.__sysPathItem.row() |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
467 | ) |
3357
2390df6f42ba
Started to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
468 | self.rootItem.removeChild(self.__sysPathItem) |
2390df6f42ba
Started to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
469 | self.endRemoveRows() |
2390df6f42ba
Started to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
470 | self.__sysPathItem = None |
2390df6f42ba
Started to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3160
diff
changeset
|
471 | self.__sysPathInterpreter = "" |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
472 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
473 | def programChange(self, dirname): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
474 | """ |
3012
d177226027e2
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2965
diff
changeset
|
475 | Public method to change the entry for the directory of file being |
d177226027e2
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2965
diff
changeset
|
476 | debugged. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
477 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
478 | @param dirname name of the directory containing the file |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
479 | @type str |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
480 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
481 | if self.progDir: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
482 | if dirname == self.progDir.dirName(): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
483 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
484 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
485 | # remove old entry |
231
2e4eb047ae93
Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
103
diff
changeset
|
486 | self._removeWatchedItem(self.progDir) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
487 | self.beginRemoveRows(QModelIndex(), self.progDir.row(), self.progDir.row()) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
488 | self.rootItem.removeChild(self.progDir) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
489 | self.endRemoveRows() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
490 | self.progDir = None |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
491 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
492 | itm = BrowserDirectoryItem(self.rootItem, dirname) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
493 | self.addItem(itm) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
494 | self.progDir = itm |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
495 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
496 | def addTopLevelDir(self, dirname): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
497 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
498 | Public method to add a new toplevel directory. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
499 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
500 | @param dirname name of the new toplevel directory |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
501 | @type str |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
502 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
503 | if dirname not in self.toplevelDirs: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
504 | itm = BrowserDirectoryItem(self.rootItem, dirname) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
505 | self.addItem(itm) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
506 | self.toplevelDirs.append(itm.dirName()) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
507 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
508 | def removeToplevelDir(self, index): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
509 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
510 | Public method to remove a toplevel directory. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
511 | |
3012
d177226027e2
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2965
diff
changeset
|
512 | @param index index of the toplevel directory to be removed |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
513 | @type QModelIndex |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
514 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
515 | if not index.isValid(): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
516 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
517 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
518 | item = index.internalPointer() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
519 | self.beginRemoveRows(index.parent(), index.row(), index.row()) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
520 | self.rootItem.removeChild(item) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
521 | self.endRemoveRows() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
522 | |
10642
fbf61874518a
Made two small modifications to BrowserModel to ignore some exceptions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10595
diff
changeset
|
523 | with contextlib.suppress(ValueError): |
fbf61874518a
Made two small modifications to BrowserModel to ignore some exceptions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10595
diff
changeset
|
524 | self.toplevelDirs.remove(item.dirName()) |
231
2e4eb047ae93
Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
103
diff
changeset
|
525 | self._removeWatchedItem(item) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
526 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
527 | def saveToplevelDirs(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
528 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
529 | Public slot to save the toplevel directories. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
530 | """ |
8637
394377638256
Replaced the direct access to 'Preferences.Prefs.settings' with 'Preferences.getSettings()'.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8318
diff
changeset
|
531 | Preferences.getSettings().setValue( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
532 | "BrowserModel/ToplevelDirs", self.toplevelDirs |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
533 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
534 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
535 | def _addItem(self, itm, parentItem): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
536 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
537 | Protected slot to add an item. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
538 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
539 | @param itm reference to item to add |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
540 | @type BrowserItem |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
541 | @param parentItem reference to item to add to |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
542 | @type BrowserItem |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
543 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
544 | parentItem.appendChild(itm) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
545 | |
5656
9c21b2746218
Fixed a few code style issues related to the usage of class instances for default arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5624
diff
changeset
|
546 | def addItem(self, itm, parent=None): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
547 | """ |
3591
2f2a4a76dd22
Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3525
diff
changeset
|
548 | Public slot to add an item. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
549 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
550 | @param itm item to add |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
551 | @type BrowserItem |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
552 | @param parent index of parent item |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
553 | @type QModelIndex |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
554 | """ |
5656
9c21b2746218
Fixed a few code style issues related to the usage of class instances for default arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5624
diff
changeset
|
555 | if parent is None: |
9c21b2746218
Fixed a few code style issues related to the usage of class instances for default arguments.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5624
diff
changeset
|
556 | parent = QModelIndex() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
557 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
558 | parentItem = parent.internalPointer() if parent.isValid() else self.rootItem |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
559 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
560 | cnt = parentItem.childCount() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
561 | self.beginInsertRows(parent, cnt, cnt) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
562 | self._addItem(itm, parentItem) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
563 | self.endInsertRows() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
564 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
910
diff
changeset
|
565 | def populateItem(self, parentItem, repopulate=False): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
566 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
567 | Public method to populate an item's subtree. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
568 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
569 | @param parentItem reference to the item to be populated |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
570 | @type BrowserItem |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
571 | @param repopulate flag indicating a repopulation |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
572 | @type bool |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
573 | """ |
10470
cd7bfd539ac9
Changed the browser item types to an enum in BrowserModel and ProjectBrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10468
diff
changeset
|
574 | if parentItem.type() == BrowserItemType.Directory: |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
575 | self.populateDirectoryItem(parentItem, repopulate) |
10470
cd7bfd539ac9
Changed the browser item types to an enum in BrowserModel and ProjectBrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10468
diff
changeset
|
576 | elif parentItem.type() == BrowserItemType.SysPath: |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
577 | self.populateSysPathItem(parentItem, repopulate) |
10470
cd7bfd539ac9
Changed the browser item types to an enum in BrowserModel and ProjectBrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10468
diff
changeset
|
578 | elif parentItem.type() == BrowserItemType.File: |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
579 | self.populateFileItem(parentItem, repopulate) |
10470
cd7bfd539ac9
Changed the browser item types to an enum in BrowserModel and ProjectBrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10468
diff
changeset
|
580 | elif parentItem.type() == BrowserItemType.Class: |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
581 | self.populateClassItem(parentItem, repopulate) |
10470
cd7bfd539ac9
Changed the browser item types to an enum in BrowserModel and ProjectBrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10468
diff
changeset
|
582 | elif parentItem.type() == BrowserItemType.Method: |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
583 | self.populateMethodItem(parentItem, repopulate) |
10470
cd7bfd539ac9
Changed the browser item types to an enum in BrowserModel and ProjectBrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10468
diff
changeset
|
584 | elif parentItem.type() == BrowserItemType.Attributes: |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
585 | self.populateClassAttributesItem(parentItem, repopulate) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
586 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
910
diff
changeset
|
587 | def populateDirectoryItem(self, parentItem, repopulate=False): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
588 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
589 | Public method to populate a directory item's subtree. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
590 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
591 | @param parentItem reference to the directory item to be populated |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
592 | @type BrowserDirectoryItem |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
593 | @param repopulate flag indicating a repopulation |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
594 | @type bool |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
595 | """ |
233
9d2677615a3d
Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
232
diff
changeset
|
596 | self._addWatchedItem(parentItem) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
597 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
598 | qdir = QDir(parentItem.dirName()) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
599 | |
9297
c1c808e65211
Fixed an issue in the browser model causing hidden files to be always ignored (see Issue 440).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
600 | dirFilter = ( |
c1c808e65211
Fixed an issue in the browser model causing hidden files to be always ignored (see Issue 440).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
601 | QDir.Filter.AllEntries | QDir.Filter.NoDotAndDotDot | QDir.Filter.Hidden |
c1c808e65211
Fixed an issue in the browser model causing hidden files to be always ignored (see Issue 440).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9221
diff
changeset
|
602 | ) |
5604
b047181a4a33
Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5587
diff
changeset
|
603 | entryInfoList = qdir.entryInfoList(dirFilter) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
604 | if len(entryInfoList) > 0: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
605 | if repopulate: |
3012
d177226027e2
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2965
diff
changeset
|
606 | self.beginInsertRows( |
d177226027e2
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2965
diff
changeset
|
607 | self.createIndex(parentItem.row(), 0, parentItem), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
608 | 0, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
609 | len(entryInfoList) - 1, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
610 | ) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
611 | for f in entryInfoList: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
612 | if f.isDir(): |
3030
4a0a82ddd9d2
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3012
diff
changeset
|
613 | node = BrowserDirectoryItem( |
4a0a82ddd9d2
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3012
diff
changeset
|
614 | parentItem, |
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9612
diff
changeset
|
615 | FileSystemUtilities.toNativeSeparators(f.absoluteFilePath()), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
616 | False, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
617 | ) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
618 | else: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
619 | fileFilters = Preferences.getUI("BrowsersFileFilters").split(";") |
910
dc2436a9e2a1
Added capability to filter out unwanted items in the file browsers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
620 | if fileFilters: |
dc2436a9e2a1
Added capability to filter out unwanted items in the file browsers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
621 | fn = f.fileName() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
622 | if any(fnmatch.fnmatch(fn, ff.strip()) for ff in fileFilters): |
910
dc2436a9e2a1
Added capability to filter out unwanted items in the file browsers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
791
diff
changeset
|
623 | continue |
3030
4a0a82ddd9d2
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3012
diff
changeset
|
624 | node = BrowserFileItem( |
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9612
diff
changeset
|
625 | parentItem, |
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9612
diff
changeset
|
626 | FileSystemUtilities.toNativeSeparators(f.absoluteFilePath()), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
627 | ) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
628 | self._addItem(node, parentItem) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
629 | if repopulate: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
630 | self.endInsertRows() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
631 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
910
diff
changeset
|
632 | def populateSysPathItem(self, parentItem, repopulate=False): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
633 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
634 | Public method to populate a sys.path item's subtree. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
635 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
636 | @param parentItem reference to the sys.path item to be populated |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
637 | @type BrowserSysPathItem |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
638 | @param repopulate flag indicating a repopulation |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
639 | @type bool |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
640 | """ |
3358
57af7e9fda48
Finished to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3357
diff
changeset
|
641 | if self.__sysPathInterpreter: |
57af7e9fda48
Finished to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3357
diff
changeset
|
642 | script = "import sys, json; print(json.dumps(sys.path))" |
57af7e9fda48
Finished to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3357
diff
changeset
|
643 | proc = QProcess() |
57af7e9fda48
Finished to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3357
diff
changeset
|
644 | proc.start(self.__sysPathInterpreter, ["-c", script]) |
57af7e9fda48
Finished to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3357
diff
changeset
|
645 | finished = proc.waitForFinished(3000) |
57af7e9fda48
Finished to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3357
diff
changeset
|
646 | if finished: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
647 | procOutput = str( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
648 | proc.readAllStandardOutput(), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
649 | Preferences.getSystem("IOEncoding"), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
650 | "replace", |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
651 | ) |
3358
57af7e9fda48
Finished to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3357
diff
changeset
|
652 | syspath = [p for p in json.loads(procOutput) if p] |
57af7e9fda48
Finished to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3357
diff
changeset
|
653 | if len(syspath) > 0: |
57af7e9fda48
Finished to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3357
diff
changeset
|
654 | if repopulate: |
57af7e9fda48
Finished to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3357
diff
changeset
|
655 | self.beginInsertRows( |
57af7e9fda48
Finished to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3357
diff
changeset
|
656 | self.createIndex(parentItem.row(), 0, parentItem), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
657 | 0, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
658 | len(syspath) - 1, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
659 | ) |
3358
57af7e9fda48
Finished to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3357
diff
changeset
|
660 | for p in syspath: |
8260
2161475d9639
Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
661 | node = ( |
2161475d9639
Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
662 | BrowserDirectoryItem(parentItem, p) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
663 | if os.path.isdir(p) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
664 | else BrowserFileItem(parentItem, p) |
8260
2161475d9639
Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8243
diff
changeset
|
665 | ) |
3358
57af7e9fda48
Finished to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3357
diff
changeset
|
666 | self._addItem(node, parentItem) |
57af7e9fda48
Finished to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3357
diff
changeset
|
667 | if repopulate: |
57af7e9fda48
Finished to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3357
diff
changeset
|
668 | self.endInsertRows() |
57af7e9fda48
Finished to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3357
diff
changeset
|
669 | else: |
57af7e9fda48
Finished to change the file browser model such, that the sys.path entry is dependent on the running interpreter.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3357
diff
changeset
|
670 | proc.kill() |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
671 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
910
diff
changeset
|
672 | def populateFileItem(self, parentItem, repopulate=False): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
673 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
674 | Public method to populate a file item's subtree. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
675 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
676 | @param parentItem reference to the file item to be populated |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
677 | @type BrowserFileItem |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
678 | @param repopulate flag indicating a repopulation |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
679 | @type bool |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
680 | """ |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9297
diff
changeset
|
681 | from eric7.Utilities import ClassBrowsers |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
682 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
683 | moduleName = parentItem.moduleName() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
684 | fileName = parentItem.fileName() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
685 | try: |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9297
diff
changeset
|
686 | dictionary = ClassBrowsers.readmodule( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
687 | moduleName, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
688 | [parentItem.dirName()], |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
689 | parentItem.isPython3File() or parentItem.isCythonFile(), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
690 | ) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
691 | except ImportError: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
692 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
693 | |
10468
fcae57045733
Editor, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
diff
changeset
|
694 | if bool(dictionary): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
695 | if repopulate: |
10468
fcae57045733
Editor, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
diff
changeset
|
696 | last = len(dictionary) - 1 |
fcae57045733
Editor, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
diff
changeset
|
697 | if "@@Coding@@" in dictionary and not Preferences.getUI( |
fcae57045733
Editor, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
diff
changeset
|
698 | "BrowserShowCoding" |
fcae57045733
Editor, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
diff
changeset
|
699 | ): |
7757
1f9f35f9be6d
File Browser, Project Source Browser, Editor Outline: added option to suppress the source code encoding line.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7708
diff
changeset
|
700 | last -= 1 |
3012
d177226027e2
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2965
diff
changeset
|
701 | self.beginInsertRows( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
702 | self.createIndex(parentItem.row(), 0, parentItem), 0, last |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
703 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
704 | |
10468
fcae57045733
Editor, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
diff
changeset
|
705 | for key in dictionary: |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
706 | if key.startswith("@@"): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
707 | # special treatment done later |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
708 | continue |
5604
b047181a4a33
Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5587
diff
changeset
|
709 | cl = dictionary[key] |
8243
cc717c2ae956
Applied some more code simplifications suggested by the new Simplify checker (Y105: use contextlib.suppress) (batch 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8235
diff
changeset
|
710 | with contextlib.suppress(AttributeError): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
711 | if cl.module == moduleName: |
10588
8edb63666f73
Fixed an issue causing the editor outline model and the browser model to fail because of referencing a variable before it was created.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10517
diff
changeset
|
712 | if isinstance( |
8edb63666f73
Fixed an issue causing the editor outline model and the browser model to fail because of referencing a variable before it was created.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10517
diff
changeset
|
713 | cl, (ClbrBaseClasses.Class, ClbrBaseClasses.Module) |
8edb63666f73
Fixed an issue causing the editor outline model and the browser model to fail because of referencing a variable before it was created.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10517
diff
changeset
|
714 | ): |
10468
fcae57045733
Editor, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
diff
changeset
|
715 | node = BrowserClassItem(parentItem, cl, fileName) |
fcae57045733
Editor, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
diff
changeset
|
716 | elif isinstance(cl, ClbrBaseClasses.Function): |
fcae57045733
Editor, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
diff
changeset
|
717 | node = BrowserMethodItem(parentItem, cl, fileName) |
10588
8edb63666f73
Fixed an issue causing the editor outline model and the browser model to fail because of referencing a variable before it was created.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10517
diff
changeset
|
718 | else: |
8edb63666f73
Fixed an issue causing the editor outline model and the browser model to fail because of referencing a variable before it was created.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10517
diff
changeset
|
719 | node = None |
8edb63666f73
Fixed an issue causing the editor outline model and the browser model to fail because of referencing a variable before it was created.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10517
diff
changeset
|
720 | if node: |
8edb63666f73
Fixed an issue causing the editor outline model and the browser model to fail because of referencing a variable before it was created.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10517
diff
changeset
|
721 | self._addItem(node, parentItem) |
10468
fcae57045733
Editor, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
diff
changeset
|
722 | if "@@Coding@@" in dictionary and Preferences.getUI("BrowserShowCoding"): |
3030
4a0a82ddd9d2
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3012
diff
changeset
|
723 | node = BrowserCodingItem( |
4a0a82ddd9d2
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3012
diff
changeset
|
724 | parentItem, |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
725 | QCoreApplication.translate("BrowserModel", "Coding: {0}").format( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
726 | dictionary["@@Coding@@"].coding |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
727 | ), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
728 | dictionary["@@Coding@@"].linenumber, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
729 | ) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
730 | self._addItem(node, parentItem) |
10468
fcae57045733
Editor, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
diff
changeset
|
731 | if "@@Globals@@" in dictionary: |
4529
6becda664299
Extended Tobias' change to include the Globals item as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4183
diff
changeset
|
732 | node = BrowserGlobalsItem( |
3030
4a0a82ddd9d2
Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3012
diff
changeset
|
733 | parentItem, |
5604
b047181a4a33
Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5587
diff
changeset
|
734 | dictionary["@@Globals@@"].globals, |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
735 | QCoreApplication.translate("BrowserModel", "Globals"), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
736 | ) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
737 | self._addItem(node, parentItem) |
10468
fcae57045733
Editor, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
diff
changeset
|
738 | if "@@Import@@" in dictionary or "@@ImportFrom@@" in dictionary: |
4183
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
739 | node = BrowserImportsItem( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
740 | parentItem, QCoreApplication.translate("BrowserModel", "Imports") |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
741 | ) |
4183
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
742 | self._addItem(node, parentItem) |
10468
fcae57045733
Editor, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
diff
changeset
|
743 | if "@@Import@@" in dictionary: |
7264
bedbe458d792
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7249
diff
changeset
|
744 | for importedModule in ( |
bedbe458d792
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7249
diff
changeset
|
745 | dictionary["@@Import@@"].getImports().values() |
bedbe458d792
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7249
diff
changeset
|
746 | ): |
4183
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
747 | m_node = BrowserImportItem( |
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
748 | node, |
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
749 | importedModule.importedModuleName, |
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
750 | importedModule.file, |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
751 | importedModule.linenos, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
752 | ) |
4183
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
753 | self._addItem(m_node, node) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
754 | for ( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
755 | importedName, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
756 | linenos, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
757 | ) in importedModule.importedNames.items(): |
4183
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
758 | mn_node = BrowserImportItem( |
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
759 | m_node, |
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
760 | importedName, |
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
761 | importedModule.file, |
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
762 | linenos, |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
763 | isModule=False, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
764 | ) |
4183
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
765 | self._addItem(mn_node, m_node) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
766 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
767 | if repopulate: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
768 | self.endInsertRows() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
769 | |
3440
ddcce63ab5cc
Fixed a refreshing issue in the browser model.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3358
diff
changeset
|
770 | parentItem._populated = True |
7690
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7678
diff
changeset
|
771 | if ( |
10470
cd7bfd539ac9
Changed the browser item types to an enum in BrowserModel and ProjectBrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10468
diff
changeset
|
772 | parentItem.type_ == BrowserItemType.File |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
773 | and fileName not in self.watchedFileItems |
7678
285c786c4a9c
BrowserModel: fixed an issue introduced by the last change.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7677
diff
changeset
|
774 | ): |
285c786c4a9c
BrowserModel: fixed an issue introduced by the last change.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7677
diff
changeset
|
775 | # watch the file only in the file browser not the project viewer |
10679 | 776 | watcher = EricFileSystemWatcher.instance() |
777 | watcher.addPath(fileName) | |
7677
d4d33990b355
File Browser: changed it to react upon changed files if their contents is shown
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7635
diff
changeset
|
778 | self.watchedFileItems[fileName] = parentItem |
d4d33990b355
File Browser: changed it to react upon changed files if their contents is shown
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7635
diff
changeset
|
779 | |
d4d33990b355
File Browser: changed it to react upon changed files if their contents is shown
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7635
diff
changeset
|
780 | def repopulateFileItem(self, itm): |
d4d33990b355
File Browser: changed it to react upon changed files if their contents is shown
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7635
diff
changeset
|
781 | """ |
d4d33990b355
File Browser: changed it to react upon changed files if their contents is shown
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7635
diff
changeset
|
782 | Public method to repopulate a file item. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
783 | |
7677
d4d33990b355
File Browser: changed it to react upon changed files if their contents is shown
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7635
diff
changeset
|
784 | @param itm reference to the item to be repopulated |
d4d33990b355
File Browser: changed it to react upon changed files if their contents is shown
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7635
diff
changeset
|
785 | @type BrowserFileItem |
d4d33990b355
File Browser: changed it to react upon changed files if their contents is shown
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7635
diff
changeset
|
786 | """ |
d4d33990b355
File Browser: changed it to react upon changed files if their contents is shown
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7635
diff
changeset
|
787 | if isinstance(itm, BrowserFileItem) and itm.isLazyPopulated(): |
d4d33990b355
File Browser: changed it to react upon changed files if their contents is shown
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7635
diff
changeset
|
788 | if not itm.isPopulated(): |
d4d33990b355
File Browser: changed it to react upon changed files if their contents is shown
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7635
diff
changeset
|
789 | # item is not populated yet, nothing to do |
d4d33990b355
File Browser: changed it to react upon changed files if their contents is shown
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7635
diff
changeset
|
790 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
791 | |
7677
d4d33990b355
File Browser: changed it to react upon changed files if their contents is shown
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7635
diff
changeset
|
792 | if itm.childCount(): |
d4d33990b355
File Browser: changed it to react upon changed files if their contents is shown
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7635
diff
changeset
|
793 | index = self.createIndex(itm.row(), 0, itm) |
d4d33990b355
File Browser: changed it to react upon changed files if their contents is shown
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7635
diff
changeset
|
794 | self.beginRemoveRows(index, 0, itm.childCount() - 1) |
d4d33990b355
File Browser: changed it to react upon changed files if their contents is shown
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7635
diff
changeset
|
795 | itm.removeChildren() |
d4d33990b355
File Browser: changed it to react upon changed files if their contents is shown
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7635
diff
changeset
|
796 | self.endRemoveRows() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
797 | |
7677
d4d33990b355
File Browser: changed it to react upon changed files if their contents is shown
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7635
diff
changeset
|
798 | self.populateFileItem(itm, True) |
d4d33990b355
File Browser: changed it to react upon changed files if their contents is shown
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7635
diff
changeset
|
799 | |
d4d33990b355
File Browser: changed it to react upon changed files if their contents is shown
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7635
diff
changeset
|
800 | def fileChanged(self, fileName): |
d4d33990b355
File Browser: changed it to react upon changed files if their contents is shown
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7635
diff
changeset
|
801 | """ |
d4d33990b355
File Browser: changed it to react upon changed files if their contents is shown
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7635
diff
changeset
|
802 | Public method to react upon file changes. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
803 | |
7677
d4d33990b355
File Browser: changed it to react upon changed files if their contents is shown
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7635
diff
changeset
|
804 | @param fileName path of the changed file |
d4d33990b355
File Browser: changed it to react upon changed files if their contents is shown
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7635
diff
changeset
|
805 | @type str |
d4d33990b355
File Browser: changed it to react upon changed files if their contents is shown
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7635
diff
changeset
|
806 | """ |
d4d33990b355
File Browser: changed it to react upon changed files if their contents is shown
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7635
diff
changeset
|
807 | if fileName in self.watchedFileItems: |
d4d33990b355
File Browser: changed it to react upon changed files if their contents is shown
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7635
diff
changeset
|
808 | if os.path.exists(fileName): |
d4d33990b355
File Browser: changed it to react upon changed files if their contents is shown
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7635
diff
changeset
|
809 | # the file was changed |
d4d33990b355
File Browser: changed it to react upon changed files if their contents is shown
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7635
diff
changeset
|
810 | self.repopulateFileItem(self.watchedFileItems[fileName]) |
d4d33990b355
File Browser: changed it to react upon changed files if their contents is shown
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7635
diff
changeset
|
811 | else: |
d4d33990b355
File Browser: changed it to react upon changed files if their contents is shown
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7635
diff
changeset
|
812 | # the file does not exist anymore |
10679 | 813 | watcher = EricFileSystemWatcher.instance() |
814 | watcher.removePath(fileName) | |
7677
d4d33990b355
File Browser: changed it to react upon changed files if their contents is shown
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7635
diff
changeset
|
815 | del self.watchedFileItems[fileName] |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
816 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
910
diff
changeset
|
817 | def populateClassItem(self, parentItem, repopulate=False): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
818 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
819 | Public method to populate a class item's subtree. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
820 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
821 | @param parentItem reference to the class item to be populated |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
822 | @type BrowserClassItem |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
823 | @param repopulate flag indicating a repopulation |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
824 | @type bool |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
825 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
826 | cl = parentItem.classObject() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
827 | file_ = parentItem.fileName() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
828 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
829 | if cl is None: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
830 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
831 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
832 | # build sorted list of names |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
833 | keys = [] |
10373
093dcebe5ecb
Corrected some uses of dict.keys(), dict.values() and dict.items().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10069
diff
changeset
|
834 | for name in cl.classes: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
835 | keys.append((name, "c")) |
10373
093dcebe5ecb
Corrected some uses of dict.keys(), dict.values() and dict.items().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10069
diff
changeset
|
836 | for name in cl.methods: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
837 | keys.append((name, "m")) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
838 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
839 | if len(cl.attributes): |
564
b3d966393ba9
Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
432
diff
changeset
|
840 | node = BrowserClassAttributesItem( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
841 | parentItem, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
842 | cl.attributes, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
843 | QCoreApplication.translate("BrowserModel", "Attributes"), |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
844 | ) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
845 | if repopulate: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
846 | self.addItem(node, self.createIndex(parentItem.row(), 0, parentItem)) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
847 | else: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
848 | self._addItem(node, parentItem) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
849 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
850 | if len(cl.globals): |
564
b3d966393ba9
Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
432
diff
changeset
|
851 | node = BrowserClassAttributesItem( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
852 | parentItem, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
853 | cl.globals, |
3656
441956d8fce5
Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3604
diff
changeset
|
854 | QCoreApplication.translate("BrowserModel", "Class Attributes"), |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
855 | True, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
856 | ) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
857 | if repopulate: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
858 | self.addItem(node, self.createIndex(parentItem.row(), 0, parentItem)) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
859 | else: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
860 | self._addItem(node, parentItem) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
861 | |
7690
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7678
diff
changeset
|
862 | if len(keys) > 0: |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7678
diff
changeset
|
863 | if repopulate: |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7678
diff
changeset
|
864 | self.beginInsertRows( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
865 | self.createIndex(parentItem.row(), 0, parentItem), 0, len(keys) - 1 |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
866 | ) |
7690
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7678
diff
changeset
|
867 | for key, kind in keys: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
868 | if kind == "c": |
7690
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7678
diff
changeset
|
869 | node = BrowserClassItem(parentItem, cl.classes[key], file_) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
870 | elif kind == "m": |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
871 | node = BrowserMethodItem(parentItem, cl.methods[key], file_) |
7690
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7678
diff
changeset
|
872 | self._addItem(node, parentItem) |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7678
diff
changeset
|
873 | if repopulate: |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7678
diff
changeset
|
874 | self.endInsertRows() |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
875 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
910
diff
changeset
|
876 | def populateMethodItem(self, parentItem, repopulate=False): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
877 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
878 | Public method to populate a method item's subtree. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
879 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
880 | @param parentItem reference to the method item to be populated |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
881 | @type BrowserItem |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
882 | @param repopulate flag indicating a repopulation |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
883 | @type bool |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
884 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
885 | fn = parentItem.functionObject() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
886 | file_ = parentItem.fileName() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
887 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
888 | if fn is None: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
889 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
890 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
891 | # build sorted list of names |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
892 | keys = [] |
10373
093dcebe5ecb
Corrected some uses of dict.keys(), dict.values() and dict.items().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10069
diff
changeset
|
893 | for name in fn.classes: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
894 | keys.append((name, "c")) |
10373
093dcebe5ecb
Corrected some uses of dict.keys(), dict.values() and dict.items().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10069
diff
changeset
|
895 | for name in fn.methods: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
896 | keys.append((name, "m")) |
10468
fcae57045733
Editor, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
diff
changeset
|
897 | for name in fn.attributes: |
fcae57045733
Editor, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
diff
changeset
|
898 | keys.append((name, "a")) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
899 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
900 | if len(keys) > 0: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
901 | if repopulate: |
3012
d177226027e2
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2965
diff
changeset
|
902 | self.beginInsertRows( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
903 | self.createIndex(parentItem.row(), 0, parentItem), 0, len(keys) - 1 |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
904 | ) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
905 | for key, kind in keys: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
906 | if kind == "c": |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
907 | node = BrowserClassItem(parentItem, fn.classes[key], file_) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
908 | elif kind == "m": |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
909 | node = BrowserMethodItem(parentItem, fn.methods[key], file_) |
10468
fcae57045733
Editor, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
diff
changeset
|
910 | elif kind == "a": |
fcae57045733
Editor, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
diff
changeset
|
911 | node = BrowserClassAttributeItem(parentItem, fn.attributes[key]) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
912 | self._addItem(node, parentItem) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
913 | if repopulate: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
914 | self.endInsertRows() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
915 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
910
diff
changeset
|
916 | def populateClassAttributesItem(self, parentItem, repopulate=False): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
917 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
918 | Public method to populate a class attributes item's subtree. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
919 | |
3012
d177226027e2
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2965
diff
changeset
|
920 | @param parentItem reference to the class attributes item to be |
d177226027e2
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2965
diff
changeset
|
921 | populated |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
922 | @type BrowserClassAttributesItem |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
923 | @param repopulate flag indicating a repopulation |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
924 | @type bool |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
925 | """ |
1227
c5db073a124f
Added support for class attributes, class methods and static methods to the class browsers and the source documentor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1131
diff
changeset
|
926 | classAttributes = parentItem.isClassAttributes() |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
927 | attributes = parentItem.attributes() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
928 | if not attributes: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
929 | return |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
930 | |
10373
093dcebe5ecb
Corrected some uses of dict.keys(), dict.values() and dict.items().
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10069
diff
changeset
|
931 | keys = list(attributes) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
932 | if len(keys) > 0: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
933 | if repopulate: |
3012
d177226027e2
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2965
diff
changeset
|
934 | self.beginInsertRows( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
935 | self.createIndex(parentItem.row(), 0, parentItem), 0, len(keys) - 1 |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
936 | ) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
937 | for key in keys: |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
938 | node = BrowserClassAttributeItem( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
939 | parentItem, attributes[key], classAttributes |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
940 | ) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
941 | self._addItem(node, parentItem) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
942 | if repopulate: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
943 | self.endInsertRows() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
944 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
910
diff
changeset
|
945 | |
8207
d359172d11be
Applied some more code simplifications suggested by the new Simplify checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8143
diff
changeset
|
946 | class BrowserItem: |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
947 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
948 | Class implementing the data structure for browser items. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
949 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
950 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
951 | def __init__(self, parent, data): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
952 | """ |
3591
2f2a4a76dd22
Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3525
diff
changeset
|
953 | Constructor |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
954 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
955 | @param parent reference to the parent item |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
956 | @type BrowserItem |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
957 | @param data single data of the item |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
958 | @type Any |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
959 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
960 | self.childItems = [] |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
961 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
962 | self.parentItem = parent |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
963 | self.itemData = [data] |
10470
cd7bfd539ac9
Changed the browser item types to an enum in BrowserModel and ProjectBrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10468
diff
changeset
|
964 | self.type_ = BrowserItemType.Root |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9297
diff
changeset
|
965 | self.icon = EricPixmapCache.getIcon("empty") |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
966 | self._populated = True |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
967 | self._lazyPopulation = False |
103
59137afca666
Added code to indicate directories and files being symbolic links.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
15
diff
changeset
|
968 | self.symlink = False |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
969 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
970 | def appendChild(self, child): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
971 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
972 | Public method to add a child to this item. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
973 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
974 | @param child reference to the child item to add |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
975 | @type BrowserItem |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
976 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
977 | self.childItems.append(child) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
978 | self._populated = True |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
979 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
980 | def removeChild(self, child): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
981 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
982 | Public method to remove a child. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
983 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
984 | @param child reference to the child to remove |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
985 | @type BrowserItem |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
986 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
987 | self.childItems.remove(child) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
988 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
989 | def removeChildren(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
990 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
991 | Public method to remove all children. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
992 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
993 | self.childItems = [] |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
994 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
995 | def child(self, row): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
996 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
997 | Public method to get a child id. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
998 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
999 | @param row number of child to get the id of |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1000 | @type int |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1001 | @return reference to the child item |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1002 | @rtype BrowserItem |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1003 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1004 | return self.childItems[row] |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1005 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1006 | def children(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1007 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1008 | Public method to get the ids of all child items. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1009 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1010 | @return references to all child items |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1011 | @rtype list of BrowserItem |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1012 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1013 | return self.childItems[:] |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1014 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1015 | def childCount(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1016 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1017 | Public method to get the number of available child items. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1018 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1019 | @return number of child items |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1020 | @rtype int |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1021 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1022 | return len(self.childItems) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1023 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1024 | def columnCount(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1025 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1026 | Public method to get the number of available data items. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1027 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1028 | @return number of data items |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1029 | @rtype int |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1030 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1031 | return len(self.itemData) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1032 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1033 | def data(self, column): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1034 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1035 | Public method to get a specific data item. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1036 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1037 | @param column number of the requested data item |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1038 | @type int |
2965
d133c7edd88a
Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2779
diff
changeset
|
1039 | @return stored data item |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1040 | @rtype Any |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1041 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1042 | try: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1043 | return self.itemData[column] |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1044 | except IndexError: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1045 | return "" |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1046 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1047 | def parent(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1048 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1049 | Public method to get the reference to the parent item. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1050 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1051 | @return reference to the parent item |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1052 | @rtype BrowserItem |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1053 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1054 | return self.parentItem |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1055 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1056 | def row(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1057 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1058 | Public method to get the row number of this item. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1059 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1060 | @return row number |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1061 | @rtype int |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1062 | """ |
7581
692838bf5d11
BrowserModel: return row 0 for a BrowserItem, if it cannot be found in the parent's list of children.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7533
diff
changeset
|
1063 | try: |
692838bf5d11
BrowserModel: return row 0 for a BrowserItem, if it cannot be found in the parent's list of children.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7533
diff
changeset
|
1064 | return self.parentItem.childItems.index(self) |
692838bf5d11
BrowserModel: return row 0 for a BrowserItem, if it cannot be found in the parent's list of children.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7533
diff
changeset
|
1065 | except ValueError: |
692838bf5d11
BrowserModel: return row 0 for a BrowserItem, if it cannot be found in the parent's list of children.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7533
diff
changeset
|
1066 | return 0 |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1067 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1068 | def type(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1069 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1070 | Public method to get the item type. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1071 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1072 | @return type of the item |
10470
cd7bfd539ac9
Changed the browser item types to an enum in BrowserModel and ProjectBrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10468
diff
changeset
|
1073 | @rtype BrowserItemType |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1074 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1075 | return self.type_ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1076 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1077 | def isPublic(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1078 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1079 | Public method returning the public visibility status. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1080 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1081 | @return flag indicating public visibility |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1082 | @rtype bool |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1083 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1084 | return True |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1085 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1086 | def getIcon(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1087 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1088 | Public method to get the items icon. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1089 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1090 | @return the icon |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1091 | @rtype QIcon |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1092 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1093 | return self.icon |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1094 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1095 | def isPopulated(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1096 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1097 | Public method to chek, if this item is populated. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1098 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1099 | @return population status |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1100 | @rtype bool |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1101 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1102 | return self._populated |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1103 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1104 | def isLazyPopulated(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1105 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1106 | Public method to check, if this item should be populated lazyly. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1107 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1108 | @return lazy population flag |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1109 | @rtype bool |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1110 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1111 | return self._lazyPopulation |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1112 | |
10069
435cc5875135
Corrected and checked some code style issues (unused function arguments).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9697
diff
changeset
|
1113 | def lessThan(self, other, column, order): # noqa: U100 |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1114 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1115 | Public method to check, if the item is less than the other one. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1116 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1117 | @param other reference to item to compare against |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1118 | @type BrowserItem |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1119 | @param column column number to use for the comparison |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1120 | @type int |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1121 | @param order sort order (for special sorting) |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1122 | @type Qt.SortOrder |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1123 | @return true, if this item is less than other |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1124 | @rtype bool |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1125 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1126 | try: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1127 | return self.itemData[column] < other.itemData[column] |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1128 | except IndexError: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1129 | return False |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1130 | |
103
59137afca666
Added code to indicate directories and files being symbolic links.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
15
diff
changeset
|
1131 | def isSymlink(self): |
59137afca666
Added code to indicate directories and files being symbolic links.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
15
diff
changeset
|
1132 | """ |
59137afca666
Added code to indicate directories and files being symbolic links.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
15
diff
changeset
|
1133 | Public method to check, if the items is a symbolic link. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1134 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1135 | @return flag indicating a symbolic link |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1136 | @rtype bool |
103
59137afca666
Added code to indicate directories and files being symbolic links.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
15
diff
changeset
|
1137 | """ |
59137afca666
Added code to indicate directories and files being symbolic links.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
15
diff
changeset
|
1138 | return self.symlink |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1139 | |
10677
6ee2e475490c
Editor Outline, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10642
diff
changeset
|
1140 | def lineno(self): |
6ee2e475490c
Editor Outline, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10642
diff
changeset
|
1141 | """ |
6ee2e475490c
Editor Outline, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10642
diff
changeset
|
1142 | Public method to return the line number of the item. |
6ee2e475490c
Editor Outline, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10642
diff
changeset
|
1143 | |
6ee2e475490c
Editor Outline, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10642
diff
changeset
|
1144 | @return line number defining the object |
6ee2e475490c
Editor Outline, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10642
diff
changeset
|
1145 | @rtype int |
6ee2e475490c
Editor Outline, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10642
diff
changeset
|
1146 | """ |
6ee2e475490c
Editor Outline, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10642
diff
changeset
|
1147 | return 0 # just a placeholder implementation |
6ee2e475490c
Editor Outline, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10642
diff
changeset
|
1148 | |
6ee2e475490c
Editor Outline, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10642
diff
changeset
|
1149 | def colOffset(self): |
6ee2e475490c
Editor Outline, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10642
diff
changeset
|
1150 | """ |
6ee2e475490c
Editor Outline, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10642
diff
changeset
|
1151 | Public method to return the column offset of the item definition. |
6ee2e475490c
Editor Outline, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10642
diff
changeset
|
1152 | |
6ee2e475490c
Editor Outline, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10642
diff
changeset
|
1153 | @return column offset defining the object |
6ee2e475490c
Editor Outline, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10642
diff
changeset
|
1154 | @rtype int |
6ee2e475490c
Editor Outline, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10642
diff
changeset
|
1155 | """ |
6ee2e475490c
Editor Outline, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10642
diff
changeset
|
1156 | return 0 # default value |
6ee2e475490c
Editor Outline, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10642
diff
changeset
|
1157 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
910
diff
changeset
|
1158 | |
10398
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1159 | class BrowserSimpleDirectoryItem(BrowserItem): |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1160 | """ |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1161 | Class implementing the data structure for browser simple directory items. |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1162 | """ |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1163 | |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1164 | def __init__(self, parent, text, path=""): |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1165 | """ |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1166 | Constructor |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1167 | |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1168 | @param parent parent item |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1169 | @type BrowserItem |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1170 | @param text text to be displayed |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1171 | @type str |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1172 | @param path path of the directory |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1173 | @type str |
10398
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1174 | """ |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1175 | BrowserItem.__init__(self, parent, text) |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1176 | |
10470
cd7bfd539ac9
Changed the browser item types to an enum in BrowserModel and ProjectBrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10468
diff
changeset
|
1177 | self.type_ = BrowserItemType.SimpleDirectory |
10398
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1178 | |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1179 | self._dirName = path |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1180 | if not os.path.isdir(self._dirName): |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1181 | self._dirName = os.path.dirname(self._dirName) |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1182 | |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1183 | if os.path.lexists(self._dirName) and os.path.islink(self._dirName): |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1184 | self.symlink = True |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1185 | self.icon = EricPixmapCache.getSymlinkIcon("dirClosed") |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1186 | else: |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1187 | self.icon = EricPixmapCache.getIcon("dirClosed") |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1188 | |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1189 | def setName(self, dinfo, full=True): # noqa: U100 |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1190 | """ |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1191 | Public method to set the directory name. |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1192 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1193 | @param dinfo dinfo is the string for the directory |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1194 | @type str |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1195 | @param full flag indicating full path name should be displayed |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1196 | @type bool |
10398
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1197 | """ |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1198 | self._dirName = os.path.abspath(dinfo) |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1199 | self.itemData[0] = os.path.basename(self._dirName) |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1200 | |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1201 | def dirName(self): |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1202 | """ |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1203 | Public method returning the directory name. |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1204 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1205 | @return directory name |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1206 | @rtype str |
10398
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1207 | """ |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1208 | return self._dirName |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1209 | |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1210 | def name(self): |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1211 | """ |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1212 | Public method to return the name of the item. |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1213 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1214 | @return name of the item |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1215 | @rtype str |
10398
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1216 | """ |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1217 | return self._dirName |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1218 | |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1219 | def lessThan(self, other, column, order): |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1220 | """ |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1221 | Public method to check, if the item is less than the other one. |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1222 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1223 | @param other reference to item to compare against |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1224 | @type BrowserItem |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1225 | @param column column number to use for the comparison |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1226 | @type int |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1227 | @param order sort order (for special sorting) |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1228 | @type Qt.SortOrder |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1229 | @return true, if this item is less than other |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1230 | @rtype bool |
10398
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1231 | """ |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1232 | if issubclass(other.__class__, BrowserFileItem) and Preferences.getUI( |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1233 | "BrowsersListFoldersFirst" |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1234 | ): |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1235 | return order == Qt.SortOrder.AscendingOrder |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1236 | |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1237 | return BrowserItem.lessThan(self, other, column, order) |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1238 | |
ef1ea18994d5
Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10378
diff
changeset
|
1239 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1240 | class BrowserDirectoryItem(BrowserItem): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1241 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1242 | Class implementing the data structure for browser directory items. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1243 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1244 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
910
diff
changeset
|
1245 | def __init__(self, parent, dinfo, full=True): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1246 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1247 | Constructor |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1248 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1249 | @param parent parent item |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1250 | @type BrowserItem |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1251 | @param dinfo dinfo is the string for the directory |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1252 | @type str |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1253 | @param full flag indicating full pathname should be displayed |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1254 | @type bool |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1255 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1256 | self._dirName = os.path.abspath(dinfo) |
8235
78e6d29eb773
Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator) (batch 3).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8227
diff
changeset
|
1257 | dn = self._dirName if full else os.path.basename(self._dirName) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1258 | BrowserItem.__init__(self, parent, dn) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1259 | |
10470
cd7bfd539ac9
Changed the browser item types to an enum in BrowserModel and ProjectBrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10468
diff
changeset
|
1260 | self.type_ = BrowserItemType.Directory |
7264
bedbe458d792
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7249
diff
changeset
|
1261 | if ( |
9624
b47dfa7a137d
Refactored the Utilities and Globals modules in order to enhance the maintainability.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9612
diff
changeset
|
1262 | not FileSystemUtilities.isDrive(self._dirName) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1263 | and os.path.lexists(self._dirName) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1264 | and os.path.islink(self._dirName) |
7264
bedbe458d792
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7249
diff
changeset
|
1265 | ): |
103
59137afca666
Added code to indicate directories and files being symbolic links.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
15
diff
changeset
|
1266 | self.symlink = True |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9297
diff
changeset
|
1267 | self.icon = EricPixmapCache.getSymlinkIcon("dirClosed") |
103
59137afca666
Added code to indicate directories and files being symbolic links.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
15
diff
changeset
|
1268 | else: |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9297
diff
changeset
|
1269 | self.icon = EricPixmapCache.getIcon("dirClosed") |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1270 | self._populated = False |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1271 | self._lazyPopulation = True |
103
59137afca666
Added code to indicate directories and files being symbolic links.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
15
diff
changeset
|
1272 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
910
diff
changeset
|
1273 | def setName(self, dinfo, full=True): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1274 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1275 | Public method to set the directory name. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1276 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1277 | @param dinfo dinfo is the string for the directory |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1278 | @type str |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1279 | @param full flag indicating full pathname should be displayed |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1280 | @type bool |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1281 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1282 | self._dirName = os.path.abspath(dinfo) |
8235
78e6d29eb773
Applied some more code simplifications suggested by the new Simplify checker (Y108: use ternary operator) (batch 3).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8227
diff
changeset
|
1283 | dn = self._dirName if full else os.path.basename(self._dirName) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1284 | self.itemData[0] = dn |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1285 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1286 | def dirName(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1287 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1288 | Public method returning the directory name. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1289 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1290 | @return directory name |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1291 | @rtype str |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1292 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1293 | return self._dirName |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1294 | |
231
2e4eb047ae93
Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
103
diff
changeset
|
1295 | def name(self): |
2e4eb047ae93
Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
103
diff
changeset
|
1296 | """ |
2e4eb047ae93
Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
103
diff
changeset
|
1297 | Public method to return the name of the item. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1298 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1299 | @return name of the item |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1300 | @rtype str |
231
2e4eb047ae93
Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
103
diff
changeset
|
1301 | """ |
2e4eb047ae93
Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
103
diff
changeset
|
1302 | return self._dirName |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1303 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1304 | def lessThan(self, other, column, order): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1305 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1306 | Public method to check, if the item is less than the other one. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1307 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1308 | @param other reference to item to compare against |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1309 | @type BrowserItem |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1310 | @param column column number to use for the comparison |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1311 | @type int |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1312 | @param order sort order (for special sorting) |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1313 | @type Qt.SortOrder |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1314 | @return true, if this item is less than other |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1315 | @rtype bool |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1316 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1317 | if issubclass(other.__class__, BrowserFileItem) and Preferences.getUI( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1318 | "BrowsersListFoldersFirst" |
8227
349308e84eeb
Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8218
diff
changeset
|
1319 | ): |
349308e84eeb
Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8218
diff
changeset
|
1320 | return order == Qt.SortOrder.AscendingOrder |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1321 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1322 | return BrowserItem.lessThan(self, other, column, order) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1323 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
910
diff
changeset
|
1324 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1325 | class BrowserSysPathItem(BrowserItem): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1326 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1327 | Class implementing the data structure for browser sys.path items. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1328 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1329 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1330 | def __init__(self, parent): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1331 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1332 | Constructor |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1333 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1334 | @param parent parent item |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1335 | @type BrowserItem |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1336 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1337 | BrowserItem.__init__(self, parent, "sys.path") |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1338 | |
10470
cd7bfd539ac9
Changed the browser item types to an enum in BrowserModel and ProjectBrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10468
diff
changeset
|
1339 | self.type_ = BrowserItemType.SysPath |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9297
diff
changeset
|
1340 | self.icon = EricPixmapCache.getIcon("filePython") |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1341 | self._populated = False |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1342 | self._lazyPopulation = True |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1343 | |
3603
cd14023a8ac1
Finished implementing functionality to save expanded file and directory entries of the project browsers to the session.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3601
diff
changeset
|
1344 | def name(self): |
cd14023a8ac1
Finished implementing functionality to save expanded file and directory entries of the project browsers to the session.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3601
diff
changeset
|
1345 | """ |
cd14023a8ac1
Finished implementing functionality to save expanded file and directory entries of the project browsers to the session.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3601
diff
changeset
|
1346 | Public method to return the name of the item. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1347 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1348 | @return name of the item |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1349 | @rtype str |
3603
cd14023a8ac1
Finished implementing functionality to save expanded file and directory entries of the project browsers to the session.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3601
diff
changeset
|
1350 | """ |
cd14023a8ac1
Finished implementing functionality to save expanded file and directory entries of the project browsers to the session.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3601
diff
changeset
|
1351 | return "sys.path" |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1352 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
910
diff
changeset
|
1353 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1354 | class BrowserFileItem(BrowserItem): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1355 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1356 | Class implementing the data structure for browser file items. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1357 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1358 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
910
diff
changeset
|
1359 | def __init__(self, parent, finfo, full=True, sourceLanguage=""): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1360 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1361 | Constructor |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1362 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1363 | @param parent parent item |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1364 | @type BrowserItem |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1365 | @param finfo the string for the file |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1366 | @type str |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1367 | @param full flag indicating full pathname should be displayed |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1368 | @type bool |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1369 | @param sourceLanguage source code language of the project |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1370 | @type str |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1371 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1372 | BrowserItem.__init__(self, parent, os.path.basename(finfo)) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1373 | |
10470
cd7bfd539ac9
Changed the browser item types to an enum in BrowserModel and ProjectBrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10468
diff
changeset
|
1374 | self.type_ = BrowserItemType.File |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1375 | self.fileext = os.path.splitext(finfo)[1].lower() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1376 | self._filename = os.path.abspath(finfo) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1377 | self._dirName = os.path.dirname(finfo) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1378 | self.sourceLanguage = sourceLanguage |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1379 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1380 | self._moduleName = "" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1381 | |
103
59137afca666
Added code to indicate directories and files being symbolic links.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
15
diff
changeset
|
1382 | pixName = "" |
7635
0cdead130a81
Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7581
diff
changeset
|
1383 | if self.isPython3File(): |
7533
88261c96484b
Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7518
diff
changeset
|
1384 | pixName = "filePython" |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1385 | self._populated = False |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1386 | self._lazyPopulation = True |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1387 | self._moduleName = os.path.basename(finfo) |
8131 | 1388 | elif self.isCythonFile(): |
1389 | pixName = "lexerCython" | |
1390 | self._populated = False | |
1391 | self._lazyPopulation = True | |
1392 | self._moduleName = os.path.basename(finfo) | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1393 | elif self.isRubyFile(): |
7533
88261c96484b
Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7518
diff
changeset
|
1394 | pixName = "fileRuby" |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1395 | self._populated = False |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1396 | self._lazyPopulation = True |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1397 | self._moduleName = os.path.basename(finfo) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1398 | elif self.isDesignerFile(): |
7533
88261c96484b
Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7518
diff
changeset
|
1399 | pixName = "fileDesigner" |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1400 | elif self.isLinguistFile(): |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1401 | if self.fileext == ".ts": |
7533
88261c96484b
Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7518
diff
changeset
|
1402 | pixName = "fileLinguist" |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1403 | else: |
7533
88261c96484b
Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7518
diff
changeset
|
1404 | pixName = "fileLinguist2" |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1405 | elif self.isResourcesFile(): |
7533
88261c96484b
Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7518
diff
changeset
|
1406 | pixName = "fileResource" |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1407 | elif self.isProjectFile(): |
7533
88261c96484b
Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7518
diff
changeset
|
1408 | pixName = "fileProject" |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1409 | elif self.isMultiProjectFile(): |
7533
88261c96484b
Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7518
diff
changeset
|
1410 | pixName = "fileMultiProject" |
2334
fc69ad77e18a
Introduced a zoom widget in the status bar of several windows.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2302
diff
changeset
|
1411 | elif self.isSvgFile(): |
7533
88261c96484b
Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7518
diff
changeset
|
1412 | pixName = "fileSvg" |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1413 | elif self.isPixmapFile(): |
7533
88261c96484b
Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7518
diff
changeset
|
1414 | pixName = "filePixmap" |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1415 | elif self.isDFile(): |
7533
88261c96484b
Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7518
diff
changeset
|
1416 | pixName = "fileD" |
2779
4d433896b6d6
Added a JavaScript parser to the file browser in order to show the structure of JavaScript files
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2769
diff
changeset
|
1417 | elif self.isJavaScriptFile(): |
7533
88261c96484b
Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7518
diff
changeset
|
1418 | pixName = "fileJavascript" |
2779
4d433896b6d6
Added a JavaScript parser to the file browser in order to show the structure of JavaScript files
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2769
diff
changeset
|
1419 | self._populated = False |
7192
a22eee00b052
Started removing runtime support for Python2 and PyQt4.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
6942
diff
changeset
|
1420 | self._lazyPopulation = True |
2779
4d433896b6d6
Added a JavaScript parser to the file browser in order to show the structure of JavaScript files
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2769
diff
changeset
|
1421 | self._moduleName = os.path.basename(finfo) |
8282 | 1422 | elif self.isEricGraphicsFile(): |
1423 | pixName = "fileUML" | |
9612
93b496cc3c88
Class Browsers
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9609
diff
changeset
|
1424 | elif self.isParsableFile(): |
93b496cc3c88
Class Browsers
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9609
diff
changeset
|
1425 | pixName = ClassBrowsers.getIcon(self._filename) |
93b496cc3c88
Class Browsers
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9609
diff
changeset
|
1426 | self._populated = False |
93b496cc3c88
Class Browsers
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9609
diff
changeset
|
1427 | self._lazyPopulation = True |
93b496cc3c88
Class Browsers
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9609
diff
changeset
|
1428 | self._moduleName = os.path.basename(finfo) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1429 | else: |
7533
88261c96484b
Removed the '.png' extension from all call to get an icon or a pixmap from the PixmapCache because this is not needed anymore.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7518
diff
changeset
|
1430 | pixName = "fileMisc" |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1431 | |
103
59137afca666
Added code to indicate directories and files being symbolic links.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
15
diff
changeset
|
1432 | if os.path.lexists(self._filename) and os.path.islink(self._filename): |
59137afca666
Added code to indicate directories and files being symbolic links.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
15
diff
changeset
|
1433 | self.symlink = True |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9297
diff
changeset
|
1434 | self.icon = EricPixmapCache.getSymlinkIcon(pixName) |
103
59137afca666
Added code to indicate directories and files being symbolic links.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
15
diff
changeset
|
1435 | else: |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9297
diff
changeset
|
1436 | self.icon = EricPixmapCache.getIcon(pixName) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1437 | |
10069
435cc5875135
Corrected and checked some code style issues (unused function arguments).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9697
diff
changeset
|
1438 | def setName(self, finfo, full=True): # noqa: U100 |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1439 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1440 | Public method to set the directory name. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1441 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1442 | @param finfo the string for the file |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1443 | @type str |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1444 | @param full flag indicating full pathname should be displayed |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1445 | @type bool |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1446 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1447 | self._filename = os.path.abspath(finfo) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1448 | self.itemData[0] = os.path.basename(finfo) |
9612
93b496cc3c88
Class Browsers
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9609
diff
changeset
|
1449 | self.fileext = os.path.splitext(finfo)[1].lower() |
93b496cc3c88
Class Browsers
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9609
diff
changeset
|
1450 | if self.isPython3File() or self.isRubyFile() or self.isParsableFile(): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1451 | self._dirName = os.path.dirname(finfo) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1452 | self._moduleName = os.path.basename(finfo) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1453 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1454 | def fileName(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1455 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1456 | Public method returning the filename. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1457 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1458 | @return filename |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1459 | @rtype str |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1460 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1461 | return self._filename |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1462 | |
231
2e4eb047ae93
Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
103
diff
changeset
|
1463 | def name(self): |
2e4eb047ae93
Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
103
diff
changeset
|
1464 | """ |
2e4eb047ae93
Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
103
diff
changeset
|
1465 | Public method to return the name of the item. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1466 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1467 | @return name of the item |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1468 | @rtype str |
231
2e4eb047ae93
Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
103
diff
changeset
|
1469 | """ |
2e4eb047ae93
Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
103
diff
changeset
|
1470 | return self._filename |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1471 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1472 | def fileExt(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1473 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1474 | Public method returning the file extension. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1475 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1476 | @return file extension |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1477 | @rtype str |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1478 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1479 | return self.fileext |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1480 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1481 | def dirName(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1482 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1483 | Public method returning the directory name. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1484 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1485 | @return directory name |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1486 | @rtype str |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1487 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1488 | return self._dirName |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1489 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1490 | def moduleName(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1491 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1492 | Public method returning the module name. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1493 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1494 | @return module name |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1495 | @rtype str |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1496 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1497 | return self._moduleName |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1498 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1499 | def isPython3File(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1500 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1501 | Public method to check, if this file is a Python3 script. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1502 | |
8131 | 1503 | @return flag indicating a Python3 file |
1504 | @rtype bool | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1505 | """ |
9492
b3659e05a156
Changed the browser model to allow standard Python extension if none are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
1506 | return ( |
b3659e05a156
Changed the browser model to allow standard Python extension if none are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
1507 | self.fileext in Preferences.getPython("Python3Extensions") |
b3659e05a156
Changed the browser model to allow standard Python extension if none are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
1508 | or (self.fileext == "" and self.sourceLanguage == "Python3") |
b3659e05a156
Changed the browser model to allow standard Python extension if none are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
1509 | or ( |
b3659e05a156
Changed the browser model to allow standard Python extension if none are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
1510 | not Preferences.getPython("Python3Extensions") |
b3659e05a156
Changed the browser model to allow standard Python extension if none are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
1511 | and self.fileext in (".py", ".pyw") |
b3659e05a156
Changed the browser model to allow standard Python extension if none are configured.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9482
diff
changeset
|
1512 | ) |
7264
bedbe458d792
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7249
diff
changeset
|
1513 | ) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1514 | |
8131 | 1515 | def isCythonFile(self): |
1516 | """ | |
1517 | Public method to check, if this file is a Cython file. | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1518 | |
8131 | 1519 | @return flag indicating a Cython file |
1520 | @rtype bool | |
1521 | """ | |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1522 | return self.fileext in (".pyx", ".pxd", ".pxi") or ( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1523 | self.fileext == "" and self.sourceLanguage == "Cython" |
8131 | 1524 | ) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1525 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1526 | def isRubyFile(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1527 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1528 | Public method to check, if this file is a Ruby script. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1529 | |
8270
6ba3564b7161
Modernized some more code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8260
diff
changeset
|
1530 | @return flag indicating a Ruby file |
6ba3564b7161
Modernized some more code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8260
diff
changeset
|
1531 | @rtype bool |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1532 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1533 | return self.fileext == ".rb" or ( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1534 | self.fileext == "" and self.sourceLanguage == "Ruby" |
7264
bedbe458d792
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7249
diff
changeset
|
1535 | ) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1536 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1537 | def isDesignerFile(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1538 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1539 | Public method to check, if this file is a Qt-Designer file. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1540 | |
8270
6ba3564b7161
Modernized some more code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8260
diff
changeset
|
1541 | @return flag indicating a Qt-Designer file |
6ba3564b7161
Modernized some more code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8260
diff
changeset
|
1542 | @rtype bool |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1543 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1544 | return self.fileext == ".ui" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1545 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1546 | def isLinguistFile(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1547 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1548 | Public method to check, if this file is a Qt-Linguist file. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1549 | |
8270
6ba3564b7161
Modernized some more code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8260
diff
changeset
|
1550 | @return flag indicating a Qt-Linguist file |
6ba3564b7161
Modernized some more code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8260
diff
changeset
|
1551 | @rtype bool |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1552 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1553 | return self.fileext in [".ts", ".qm"] |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1554 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1555 | def isResourcesFile(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1556 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1557 | Public method to check, if this file is a Qt-Resources file. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1558 | |
8270
6ba3564b7161
Modernized some more code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8260
diff
changeset
|
1559 | @return flag indicating a Qt-Resources file |
6ba3564b7161
Modernized some more code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8260
diff
changeset
|
1560 | @rtype bool |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1561 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1562 | return self.fileext == ".qrc" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1563 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1564 | def isProjectFile(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1565 | """ |
15
f6ccc31d6e72
Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
13
diff
changeset
|
1566 | Public method to check, if this file is an eric project file. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1567 | |
8270
6ba3564b7161
Modernized some more code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8260
diff
changeset
|
1568 | @return flag indicating an eric project file |
6ba3564b7161
Modernized some more code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8260
diff
changeset
|
1569 | @rtype bool |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1570 | """ |
10595
59579e8aff98
Removed support for the deprecated eric-ide specific XML file formats.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10588
diff
changeset
|
1571 | return self.fileext in (".epj",) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1572 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1573 | def isMultiProjectFile(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1574 | """ |
15
f6ccc31d6e72
Started to rename stuff for eric5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
13
diff
changeset
|
1575 | Public method to check, if this file is an eric multi project file. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1576 | |
8270
6ba3564b7161
Modernized some more code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8260
diff
changeset
|
1577 | @return flag indicating an eric project file |
6ba3564b7161
Modernized some more code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8260
diff
changeset
|
1578 | @rtype bool |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1579 | """ |
10595
59579e8aff98
Removed support for the deprecated eric-ide specific XML file formats.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10588
diff
changeset
|
1580 | return self.fileext in (".emj",) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1581 | |
2779
4d433896b6d6
Added a JavaScript parser to the file browser in order to show the structure of JavaScript files
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2769
diff
changeset
|
1582 | def isJavaScriptFile(self): |
4d433896b6d6
Added a JavaScript parser to the file browser in order to show the structure of JavaScript files
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2769
diff
changeset
|
1583 | """ |
4d433896b6d6
Added a JavaScript parser to the file browser in order to show the structure of JavaScript files
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2769
diff
changeset
|
1584 | Public method to check, if this file is a JavaScript file. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1585 | |
8270
6ba3564b7161
Modernized some more code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8260
diff
changeset
|
1586 | @return flag indicating a JavaScript file |
6ba3564b7161
Modernized some more code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8260
diff
changeset
|
1587 | @rtype bool |
2779
4d433896b6d6
Added a JavaScript parser to the file browser in order to show the structure of JavaScript files
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2769
diff
changeset
|
1588 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1589 | return self.fileext == ".js" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1590 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1591 | def isPixmapFile(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1592 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1593 | Public method to check, if this file is a pixmap file. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1594 | |
8270
6ba3564b7161
Modernized some more code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8260
diff
changeset
|
1595 | @return flag indicating a pixmap file |
6ba3564b7161
Modernized some more code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8260
diff
changeset
|
1596 | @rtype bool |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1597 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1598 | return self.fileext[1:] in QImageReader.supportedImageFormats() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1599 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1600 | def isSvgFile(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1601 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1602 | Public method to check, if this file is a SVG file. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1603 | |
8270
6ba3564b7161
Modernized some more code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8260
diff
changeset
|
1604 | @return flag indicating a SVG file |
6ba3564b7161
Modernized some more code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8260
diff
changeset
|
1605 | @rtype bool |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1606 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1607 | return self.fileext == ".svg" |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1608 | |
9697
cdaa3cc805f7
Started implementing a PDF viewer tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
1609 | def isPdfFile(self): |
cdaa3cc805f7
Started implementing a PDF viewer tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
1610 | """ |
cdaa3cc805f7
Started implementing a PDF viewer tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
1611 | Public method to check, if this file is a PDF file. |
cdaa3cc805f7
Started implementing a PDF viewer tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
1612 | |
cdaa3cc805f7
Started implementing a PDF viewer tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
1613 | @return flag indicating a PDF file |
cdaa3cc805f7
Started implementing a PDF viewer tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
1614 | @rtype bool |
cdaa3cc805f7
Started implementing a PDF viewer tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
1615 | """ |
cdaa3cc805f7
Started implementing a PDF viewer tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
1616 | return self.fileext == ".pdf" |
cdaa3cc805f7
Started implementing a PDF viewer tool.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9653
diff
changeset
|
1617 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1618 | def isDFile(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1619 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1620 | Public method to check, if this file is a D file. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1621 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1622 | @return flag indicating a D file |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1623 | @rtype bool |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1624 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1625 | return self.fileext in [".d", ".di"] or ( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1626 | self.fileext == "" and self.sourceLanguage == "D" |
7264
bedbe458d792
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7249
diff
changeset
|
1627 | ) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1628 | |
8270
6ba3564b7161
Modernized some more code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8260
diff
changeset
|
1629 | def isEricGraphicsFile(self): |
6ba3564b7161
Modernized some more code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8260
diff
changeset
|
1630 | """ |
6ba3564b7161
Modernized some more code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8260
diff
changeset
|
1631 | Public method to check, if this is an eric graphics file. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1632 | |
8270
6ba3564b7161
Modernized some more code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8260
diff
changeset
|
1633 | @return flag indicating an eric graphics file |
6ba3564b7161
Modernized some more code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8260
diff
changeset
|
1634 | @rtype bool |
6ba3564b7161
Modernized some more code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8260
diff
changeset
|
1635 | """ |
10595
59579e8aff98
Removed support for the deprecated eric-ide specific XML file formats.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10588
diff
changeset
|
1636 | return self.fileext in (".egj",) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1637 | |
9612
93b496cc3c88
Class Browsers
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9609
diff
changeset
|
1638 | def isParsableFile(self): |
93b496cc3c88
Class Browsers
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9609
diff
changeset
|
1639 | """ |
93b496cc3c88
Class Browsers
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9609
diff
changeset
|
1640 | Public method to check, if the file is supported by class browsers. |
93b496cc3c88
Class Browsers
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9609
diff
changeset
|
1641 | |
93b496cc3c88
Class Browsers
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9609
diff
changeset
|
1642 | @return flag indicating a supported file |
93b496cc3c88
Class Browsers
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9609
diff
changeset
|
1643 | @rtype bool |
93b496cc3c88
Class Browsers
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9609
diff
changeset
|
1644 | """ |
93b496cc3c88
Class Browsers
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9609
diff
changeset
|
1645 | return ClassBrowsers.isSupportedType(self.fileext) |
93b496cc3c88
Class Browsers
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9609
diff
changeset
|
1646 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1647 | def lessThan(self, other, column, order): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1648 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1649 | Public method to check, if the item is less than the other one. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1650 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1651 | @param other reference to item to compare against |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1652 | @type BrowserItem |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1653 | @param column column number to use for the comparison |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1654 | @type int |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1655 | @param order sort order (for special sorting) |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1656 | @type Qt.SortOrder |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1657 | @return true, if this item is less than other |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1658 | @rtype bool |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1659 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1660 | if not issubclass(other.__class__, BrowserFileItem) and Preferences.getUI( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1661 | "BrowsersListFoldersFirst" |
8227
349308e84eeb
Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8218
diff
changeset
|
1662 | ): |
349308e84eeb
Applied some more code simplifications suggested by the new Simplify checker (Y102: use single if) (batch 2).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8218
diff
changeset
|
1663 | return order == Qt.SortOrder.DescendingOrder |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1664 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1665 | if issubclass(other.__class__, BrowserFileItem): |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1666 | sinit = os.path.basename(self._filename).startswith("__init__.py") |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1667 | oinit = os.path.basename(other.fileName()).startswith("__init__.py") |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1668 | if sinit and not oinit: |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8131
diff
changeset
|
1669 | return order == Qt.SortOrder.AscendingOrder |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1670 | if not sinit and oinit: |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8131
diff
changeset
|
1671 | return order == Qt.SortOrder.DescendingOrder |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1672 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1673 | return BrowserItem.lessThan(self, other, column, order) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1674 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
910
diff
changeset
|
1675 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1676 | class BrowserClassItem(BrowserItem): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1677 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1678 | Class implementing the data structure for browser class items. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1679 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1680 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1681 | def __init__(self, parent, cl, filename): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1682 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1683 | Constructor |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1684 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1685 | @param parent parent item |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1686 | @type BrowserItem |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1687 | @param cl Class object to be shown |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1688 | @type Class |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1689 | @param filename file name of the file defining this class |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1690 | @type str |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1691 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1692 | name = cl.name |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1693 | if hasattr(cl, "super") and cl.super: |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1694 | supers = [] |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1695 | for sup in cl.super: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1696 | try: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1697 | sname = sup.name |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1698 | if sup.module != cl.module: |
432
497e188ee86e
Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
405
diff
changeset
|
1699 | sname = "{0}.{1}".format(sup.module, sname) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1700 | except AttributeError: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1701 | sname = sup |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1702 | supers.append(sname) |
8217
385f60c94548
Applied some more code simplifications suggested by the new Simplify checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8207
diff
changeset
|
1703 | name += "({0})".format(", ".join(supers)) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1704 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1705 | BrowserItem.__init__(self, parent, name) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1706 | |
10470
cd7bfd539ac9
Changed the browser item types to an enum in BrowserModel and ProjectBrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10468
diff
changeset
|
1707 | self.type_ = BrowserItemType.Class |
3601
236578b22511
Continued implementing functionality to save expanded file and directory entries of the project browsers to the session.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3591
diff
changeset
|
1708 | self._name = name |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1709 | self._classObject = cl |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1710 | self._filename = filename |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1711 | |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9297
diff
changeset
|
1712 | self.isfunction = isinstance(self._classObject, ClbrBaseClasses.Function) |
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9297
diff
changeset
|
1713 | self.ismodule = isinstance(self._classObject, ClbrBaseClasses.Module) |
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9297
diff
changeset
|
1714 | self.isenum = isinstance(self._classObject, ClbrBaseClasses.Enum) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1715 | if self.isfunction: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1716 | if cl.isPrivate(): |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9297
diff
changeset
|
1717 | self.icon = EricPixmapCache.getIcon("method_private") |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1718 | elif cl.isProtected(): |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9297
diff
changeset
|
1719 | self.icon = EricPixmapCache.getIcon("method_protected") |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1720 | else: |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9297
diff
changeset
|
1721 | self.icon = EricPixmapCache.getIcon("method") |
432
497e188ee86e
Did some more string format conversions.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
405
diff
changeset
|
1722 | self.itemData[0] = "{0}({1})".format( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1723 | name, ", ".join(self._classObject.parameters) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1724 | ) |
3966
969a3d41c402
Added code to correctly parse Python methods/functions containing return annotations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3656
diff
changeset
|
1725 | if self._classObject.annotation: |
969a3d41c402
Added code to correctly parse Python methods/functions containing return annotations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3656
diff
changeset
|
1726 | self.itemData[0] = "{0} {1}".format( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1727 | self.itemData[0], self._classObject.annotation |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1728 | ) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1729 | # - if no defaults are wanted |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1730 | # - ....format(name, |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1731 | # - ", ".join([e.split('=')[0].strip() |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1732 | # - for e in self._classObject.parameters])) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1733 | elif self.ismodule: |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9297
diff
changeset
|
1734 | self.icon = EricPixmapCache.getIcon("module") |
5977
8a0ec75b0f73
Finished adding support for Google protobuf protocol and gRPC files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
5968
diff
changeset
|
1735 | elif self.isenum: |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9297
diff
changeset
|
1736 | self.icon = EricPixmapCache.getIcon("attribute") |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1737 | else: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1738 | if cl.isPrivate(): |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9297
diff
changeset
|
1739 | self.icon = EricPixmapCache.getIcon("class_private") |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1740 | elif cl.isProtected(): |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9297
diff
changeset
|
1741 | self.icon = EricPixmapCache.getIcon("class_protected") |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1742 | else: |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9297
diff
changeset
|
1743 | self.icon = EricPixmapCache.getIcon("class") |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1744 | if self._classObject and ( |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1745 | self._classObject.methods |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1746 | or self._classObject.classes |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1747 | or self._classObject.attributes |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1748 | or self._classObject.globals |
7264
bedbe458d792
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7249
diff
changeset
|
1749 | ): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1750 | self._populated = False |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1751 | self._lazyPopulation = True |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1752 | |
3603
cd14023a8ac1
Finished implementing functionality to save expanded file and directory entries of the project browsers to the session.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3601
diff
changeset
|
1753 | def name(self): |
cd14023a8ac1
Finished implementing functionality to save expanded file and directory entries of the project browsers to the session.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3601
diff
changeset
|
1754 | """ |
cd14023a8ac1
Finished implementing functionality to save expanded file and directory entries of the project browsers to the session.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3601
diff
changeset
|
1755 | Public method to return the name of the item. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1756 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1757 | @return name of the item |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1758 | @rtype str |
3603
cd14023a8ac1
Finished implementing functionality to save expanded file and directory entries of the project browsers to the session.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3601
diff
changeset
|
1759 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1760 | return "{0}@@{1}".format(self._filename, self.lineno()) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1761 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1762 | def fileName(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1763 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1764 | Public method returning the filename. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1765 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1766 | @return filename |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1767 | @rtype str |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1768 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1769 | return self._filename |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1770 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1771 | def classObject(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1772 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1773 | Public method returning the class object. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1774 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1775 | @return reference to the class object |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1776 | @rtype Class |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1777 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1778 | return self._classObject |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1779 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1780 | def lineno(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1781 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1782 | Public method returning the line number defining this object. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1783 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1784 | @return line number defining the object |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1785 | @rtype int |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1786 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1787 | return self._classObject.lineno |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1788 | |
2769
8cbebde7a984
Added support to highlight the current class/method name of the current editor to the project sources viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2613
diff
changeset
|
1789 | def boundaries(self): |
8cbebde7a984
Added support to highlight the current class/method name of the current editor to the project sources viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2613
diff
changeset
|
1790 | """ |
8cbebde7a984
Added support to highlight the current class/method name of the current editor to the project sources viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2613
diff
changeset
|
1791 | Public method returning the boundaries of the method definition. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1792 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1793 | @return tuple with start end end line number |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1794 | @rtype tuple of (int, int) |
2769
8cbebde7a984
Added support to highlight the current class/method name of the current editor to the project sources viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2613
diff
changeset
|
1795 | """ |
8cbebde7a984
Added support to highlight the current class/method name of the current editor to the project sources viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2613
diff
changeset
|
1796 | return (self._classObject.lineno, self._classObject.endlineno) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1797 | |
10677
6ee2e475490c
Editor Outline, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10642
diff
changeset
|
1798 | def colOffset(self): |
6ee2e475490c
Editor Outline, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10642
diff
changeset
|
1799 | """ |
6ee2e475490c
Editor Outline, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10642
diff
changeset
|
1800 | Public method to return the column offset of the item definition. |
6ee2e475490c
Editor Outline, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10642
diff
changeset
|
1801 | |
6ee2e475490c
Editor Outline, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10642
diff
changeset
|
1802 | @return column offset defining the object |
6ee2e475490c
Editor Outline, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10642
diff
changeset
|
1803 | @rtype int |
6ee2e475490c
Editor Outline, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10642
diff
changeset
|
1804 | """ |
6ee2e475490c
Editor Outline, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10642
diff
changeset
|
1805 | return self._classObject.coloffset |
6ee2e475490c
Editor Outline, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10642
diff
changeset
|
1806 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1807 | def lessThan(self, other, column, order): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1808 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1809 | Public method to check, if the item is less than the other one. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1810 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1811 | @param other reference to item to compare against |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1812 | @type BrowserItem |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1813 | @param column column number to use for the comparison |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1814 | @type int |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1815 | @param order sort order (for special sorting) |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1816 | @type Qt.SortOrder |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1817 | @return true, if this item is less than other |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1818 | @rtype bool |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1819 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1820 | if issubclass(other.__class__, (BrowserCodingItem, BrowserClassAttributesItem)): |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8131
diff
changeset
|
1821 | return order == Qt.SortOrder.DescendingOrder |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1822 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1823 | if Preferences.getUI("BrowsersListContentsByOccurrence") and column == 0: |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8131
diff
changeset
|
1824 | if order == Qt.SortOrder.AscendingOrder: |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1825 | return self.lineno() < other.lineno() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1826 | else: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1827 | return self.lineno() > other.lineno() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1828 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1829 | return BrowserItem.lessThan(self, other, column, order) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1830 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1831 | def isPublic(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1832 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1833 | Public method returning the public visibility status. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1834 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1835 | @return flag indicating public visibility |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1836 | @rtype bool |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1837 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1838 | return self._classObject.isPublic() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1839 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
910
diff
changeset
|
1840 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1841 | class BrowserMethodItem(BrowserItem): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1842 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1843 | Class implementing the data structure for browser method items. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1844 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1845 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1846 | def __init__(self, parent, fn, filename): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1847 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1848 | Constructor |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1849 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1850 | @param parent parent item |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1851 | @type BrowserItem |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1852 | @param fn Function object to be shown |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1853 | @type Function |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1854 | @param filename filename of the file defining this class |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1855 | @type str |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1856 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1857 | name = fn.name |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1858 | BrowserItem.__init__(self, parent, name) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1859 | |
10470
cd7bfd539ac9
Changed the browser item types to an enum in BrowserModel and ProjectBrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10468
diff
changeset
|
1860 | self.type_ = BrowserItemType.Method |
3601
236578b22511
Continued implementing functionality to save expanded file and directory entries of the project browsers to the session.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3591
diff
changeset
|
1861 | self._name = name |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1862 | self._functionObject = fn |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1863 | self._filename = filename |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9297
diff
changeset
|
1864 | if self._functionObject.modifier == ClbrBaseClasses.Function.Static: |
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9297
diff
changeset
|
1865 | self.icon = EricPixmapCache.getIcon("method_static") |
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9297
diff
changeset
|
1866 | elif self._functionObject.modifier == ClbrBaseClasses.Function.Class: |
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9297
diff
changeset
|
1867 | self.icon = EricPixmapCache.getIcon("method_class") |
1227
c5db073a124f
Added support for class attributes, class methods and static methods to the class browsers and the source documentor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1131
diff
changeset
|
1868 | elif self._functionObject.isPrivate(): |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9297
diff
changeset
|
1869 | self.icon = EricPixmapCache.getIcon("method_private") |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1870 | elif self._functionObject.isProtected(): |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9297
diff
changeset
|
1871 | self.icon = EricPixmapCache.getIcon("method_protected") |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1872 | else: |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9297
diff
changeset
|
1873 | self.icon = EricPixmapCache.getIcon("method") |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
910
diff
changeset
|
1874 | self.itemData[0] = "{0}({1})".format( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1875 | name, ", ".join(self._functionObject.parameters) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1876 | ) |
3966
969a3d41c402
Added code to correctly parse Python methods/functions containing return annotations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3656
diff
changeset
|
1877 | if self._functionObject.annotation: |
969a3d41c402
Added code to correctly parse Python methods/functions containing return annotations.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3656
diff
changeset
|
1878 | self.itemData[0] = "{0} {1}".format( |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1879 | self.itemData[0], self._functionObject.annotation |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1880 | ) |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1881 | # if no defaults are wanted |
3012
d177226027e2
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2965
diff
changeset
|
1882 | # ....format(name, |
d177226027e2
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2965
diff
changeset
|
1883 | # ", ".join([e.split('=')[0].strip() |
d177226027e2
Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2965
diff
changeset
|
1884 | # for e in self._functionObject.parameters])) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1885 | if self._functionObject and ( |
10468
fcae57045733
Editor, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
diff
changeset
|
1886 | self._functionObject.methods |
fcae57045733
Editor, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
diff
changeset
|
1887 | or self._functionObject.classes |
fcae57045733
Editor, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10439
diff
changeset
|
1888 | or self._functionObject.attributes |
7264
bedbe458d792
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7249
diff
changeset
|
1889 | ): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1890 | self._populated = False |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1891 | self._lazyPopulation = True |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1892 | |
3603
cd14023a8ac1
Finished implementing functionality to save expanded file and directory entries of the project browsers to the session.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3601
diff
changeset
|
1893 | def name(self): |
cd14023a8ac1
Finished implementing functionality to save expanded file and directory entries of the project browsers to the session.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3601
diff
changeset
|
1894 | """ |
cd14023a8ac1
Finished implementing functionality to save expanded file and directory entries of the project browsers to the session.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3601
diff
changeset
|
1895 | Public method to return the name of the item. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1896 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1897 | @return name of the item |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1898 | @rtype str |
3603
cd14023a8ac1
Finished implementing functionality to save expanded file and directory entries of the project browsers to the session.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3601
diff
changeset
|
1899 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1900 | return "{0}@@{1}".format(self._filename, self.lineno()) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1901 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1902 | def fileName(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1903 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1904 | Public method returning the filename. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1905 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1906 | @return filename |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1907 | @rtype str |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1908 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1909 | return self._filename |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1910 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1911 | def functionObject(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1912 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1913 | Public method returning the function object. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1914 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1915 | @return reference to the function object |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1916 | @rtype Function |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1917 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1918 | return self._functionObject |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1919 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1920 | def lineno(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1921 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1922 | Public method returning the line number defining this object. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1923 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1924 | @return line number defining the object |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1925 | @rtype int |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1926 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1927 | return self._functionObject.lineno |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1928 | |
2769
8cbebde7a984
Added support to highlight the current class/method name of the current editor to the project sources viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2613
diff
changeset
|
1929 | def boundaries(self): |
8cbebde7a984
Added support to highlight the current class/method name of the current editor to the project sources viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2613
diff
changeset
|
1930 | """ |
8cbebde7a984
Added support to highlight the current class/method name of the current editor to the project sources viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2613
diff
changeset
|
1931 | Public method returning the boundaries of the method definition. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1932 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1933 | @return tuple with start end end line number |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1934 | @rtype tuple of (int, int) |
2769
8cbebde7a984
Added support to highlight the current class/method name of the current editor to the project sources viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2613
diff
changeset
|
1935 | """ |
8cbebde7a984
Added support to highlight the current class/method name of the current editor to the project sources viewer.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
2613
diff
changeset
|
1936 | return (self._functionObject.lineno, self._functionObject.endlineno) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1937 | |
10677
6ee2e475490c
Editor Outline, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10642
diff
changeset
|
1938 | def colOffset(self): |
6ee2e475490c
Editor Outline, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10642
diff
changeset
|
1939 | """ |
6ee2e475490c
Editor Outline, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10642
diff
changeset
|
1940 | Public method to return the column offset of the item definition. |
6ee2e475490c
Editor Outline, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10642
diff
changeset
|
1941 | |
6ee2e475490c
Editor Outline, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10642
diff
changeset
|
1942 | @return column offset defining the object |
6ee2e475490c
Editor Outline, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10642
diff
changeset
|
1943 | @rtype int |
6ee2e475490c
Editor Outline, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10642
diff
changeset
|
1944 | """ |
6ee2e475490c
Editor Outline, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10642
diff
changeset
|
1945 | return self._functionObject.coloffset |
6ee2e475490c
Editor Outline, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10642
diff
changeset
|
1946 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1947 | def lessThan(self, other, column, order): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1948 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1949 | Public method to check, if the item is less than the other one. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1950 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1951 | @param other reference to item to compare against |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1952 | @type BrowserItem |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1953 | @param column column number to use for the comparison |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1954 | @type int |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1955 | @param order sort order (for special sorting) |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1956 | @type Qt.SortOrder |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1957 | @return true, if this item is less than other |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1958 | @rtype bool |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1959 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1960 | if issubclass(other.__class__, BrowserMethodItem): |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1961 | if self._name.startswith("__init__"): |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8131
diff
changeset
|
1962 | return order == Qt.SortOrder.AscendingOrder |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1963 | if other._name.startswith("__init__"): |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8131
diff
changeset
|
1964 | return order == Qt.SortOrder.DescendingOrder |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1965 | elif issubclass(other.__class__, BrowserClassAttributesItem): |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8131
diff
changeset
|
1966 | return order == Qt.SortOrder.DescendingOrder |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1967 | |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1968 | if Preferences.getUI("BrowsersListContentsByOccurrence") and column == 0: |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8131
diff
changeset
|
1969 | if order == Qt.SortOrder.AscendingOrder: |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1970 | return self.lineno() < other.lineno() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1971 | else: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1972 | return self.lineno() > other.lineno() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1973 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1974 | return BrowserItem.lessThan(self, other, column, order) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1975 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1976 | def isPublic(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1977 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1978 | Public method returning the public visibility status. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1979 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1980 | @return flag indicating public visibility |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1981 | @rtype bool |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1982 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1983 | return self._functionObject.isPublic() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1984 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
910
diff
changeset
|
1985 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1986 | class BrowserClassAttributesItem(BrowserItem): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1987 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1988 | Class implementing the data structure for browser class attributes items. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1989 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1990 | |
1227
c5db073a124f
Added support for class attributes, class methods and static methods to the class browsers and the source documentor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1131
diff
changeset
|
1991 | def __init__(self, parent, attributes, text, isClass=False): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1992 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1993 | Constructor |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
1994 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1995 | @param parent parent item |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1996 | @type BrowserItem |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
1997 | @param attributes list of attributes |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1998 | @type list of Attribute |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
1999 | @param text text to be shown by this item |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2000 | @type str |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2001 | @param isClass flag indicating class attributes |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2002 | @type bool |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2003 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2004 | BrowserItem.__init__(self, parent, text) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2005 | |
10470
cd7bfd539ac9
Changed the browser item types to an enum in BrowserModel and ProjectBrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10468
diff
changeset
|
2006 | self.type_ = BrowserItemType.Attributes |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2007 | self._attributes = attributes.copy() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2008 | self._populated = False |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2009 | self._lazyPopulation = True |
1227
c5db073a124f
Added support for class attributes, class methods and static methods to the class browsers and the source documentor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1131
diff
changeset
|
2010 | if isClass: |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9297
diff
changeset
|
2011 | self.icon = EricPixmapCache.getIcon("attributes_class") |
1227
c5db073a124f
Added support for class attributes, class methods and static methods to the class browsers and the source documentor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1131
diff
changeset
|
2012 | else: |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9297
diff
changeset
|
2013 | self.icon = EricPixmapCache.getIcon("attributes") |
1227
c5db073a124f
Added support for class attributes, class methods and static methods to the class browsers and the source documentor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1131
diff
changeset
|
2014 | self.__isClass = isClass |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2015 | |
3604
919ebd27fa78
Extended the recent addition a little bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3603
diff
changeset
|
2016 | def name(self): |
919ebd27fa78
Extended the recent addition a little bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3603
diff
changeset
|
2017 | """ |
919ebd27fa78
Extended the recent addition a little bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3603
diff
changeset
|
2018 | Public method to return the name of the item. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2019 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2020 | @return name of the item |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2021 | @rtype str |
3604
919ebd27fa78
Extended the recent addition a little bit.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
3603
diff
changeset
|
2022 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2023 | return "{0}@@{1}".format(self.parentItem.name(), self.data(0)) |
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2024 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2025 | def attributes(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2026 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2027 | Public method returning the attribute list. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2028 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2029 | @return reference to the list of attributes |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2030 | @rtype list of Attribute |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2031 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2032 | return self._attributes |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2033 | |
1227
c5db073a124f
Added support for class attributes, class methods and static methods to the class browsers and the source documentor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1131
diff
changeset
|
2034 | def isClassAttributes(self): |
c5db073a124f
Added support for class attributes, class methods and static methods to the class browsers and the source documentor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1131
diff
changeset
|
2035 | """ |
c5db073a124f
Added support for class attributes, class methods and static methods to the class browsers and the source documentor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1131
diff
changeset
|
2036 | Public method returning the attributes type. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2037 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2038 | @return flag indicating class attributes |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2039 | @rtype bool |
1227
c5db073a124f
Added support for class attributes, class methods and static methods to the class browsers and the source documentor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1131
diff
changeset
|
2040 | """ |
c5db073a124f
Added support for class attributes, class methods and static methods to the class browsers and the source documentor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1131
diff
changeset
|
2041 | return self.__isClass |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2042 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2043 | def lessThan(self, other, column, order): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2044 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2045 | Public method to check, if the item is less than the other one. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2046 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2047 | @param other reference to item to compare against |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2048 | @type BrowserItem |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2049 | @param column column number to use for the comparison |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2050 | @type int |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2051 | @param order sort order (for special sorting) |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2052 | @type Qt.SortOrder |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2053 | @return true, if this item is less than other |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2054 | @rtype bool |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2055 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2056 | if issubclass(other.__class__, BrowserCodingItem): |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8131
diff
changeset
|
2057 | return order == Qt.SortOrder.DescendingOrder |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2058 | elif issubclass(other.__class__, (BrowserClassItem, BrowserMethodItem)): |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8131
diff
changeset
|
2059 | return order == Qt.SortOrder.AscendingOrder |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2060 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2061 | return BrowserItem.lessThan(self, other, column, order) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2062 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
910
diff
changeset
|
2063 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2064 | class BrowserClassAttributeItem(BrowserItem): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2065 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2066 | Class implementing the data structure for browser class attribute items. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2067 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2068 | |
1227
c5db073a124f
Added support for class attributes, class methods and static methods to the class browsers and the source documentor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1131
diff
changeset
|
2069 | def __init__(self, parent, attribute, isClass=False): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2070 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2071 | Constructor |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2072 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2073 | @param parent parent item |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2074 | @type BrowserItem |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2075 | @param attribute reference to the attribute object |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2076 | @type Attribute |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2077 | @param isClass flag indicating a class attribute |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2078 | @type bool |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2079 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2080 | BrowserItem.__init__(self, parent, attribute.name) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2081 | |
10470
cd7bfd539ac9
Changed the browser item types to an enum in BrowserModel and ProjectBrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10468
diff
changeset
|
2082 | self.type_ = BrowserItemType.Attribute |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2083 | self._attributeObject = attribute |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2084 | self.__public = attribute.isPublic() |
1227
c5db073a124f
Added support for class attributes, class methods and static methods to the class browsers and the source documentor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1131
diff
changeset
|
2085 | if isClass: |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9297
diff
changeset
|
2086 | self.icon = EricPixmapCache.getIcon("attribute_class") |
1227
c5db073a124f
Added support for class attributes, class methods and static methods to the class browsers and the source documentor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1131
diff
changeset
|
2087 | elif attribute.isPrivate(): |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9297
diff
changeset
|
2088 | self.icon = EricPixmapCache.getIcon("attribute_private") |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2089 | elif attribute.isProtected(): |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9297
diff
changeset
|
2090 | self.icon = EricPixmapCache.getIcon("attribute_protected") |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2091 | else: |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9297
diff
changeset
|
2092 | self.icon = EricPixmapCache.getIcon("attribute") |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2093 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2094 | def isPublic(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2095 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2096 | Public method returning the public visibility status. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2097 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2098 | @return flag indicating public visibility |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2099 | @rtype bool |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2100 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2101 | return self.__public |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2102 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2103 | def attributeObject(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2104 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2105 | Public method returning the class object. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2106 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2107 | @return reference to the class object |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2108 | @rtype Class |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2109 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2110 | return self._attributeObject |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2111 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2112 | def fileName(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2113 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2114 | Public method returning the filename. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2115 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2116 | @return filename |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2117 | @rtype str |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2118 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2119 | return self._attributeObject.file |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2120 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2121 | def lineno(self): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2122 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2123 | Public method returning the line number defining this object. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2124 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2125 | @return line number defining the object |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2126 | @rtype int |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2127 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2128 | return self._attributeObject.lineno |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2129 | |
1303
6018d7ac3aec
Added context menu for attributes to the file browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1227
diff
changeset
|
2130 | def linenos(self): |
6018d7ac3aec
Added context menu for attributes to the file browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1227
diff
changeset
|
2131 | """ |
6018d7ac3aec
Added context menu for attributes to the file browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1227
diff
changeset
|
2132 | Public method returning the line numbers this object is assigned to. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2133 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2134 | @return line number the object is assigned to |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2135 | @rtype list of int |
1303
6018d7ac3aec
Added context menu for attributes to the file browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1227
diff
changeset
|
2136 | """ |
6018d7ac3aec
Added context menu for attributes to the file browser.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
1227
diff
changeset
|
2137 | return self._attributeObject.linenos[:] |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2138 | |
10677
6ee2e475490c
Editor Outline, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10642
diff
changeset
|
2139 | def colOffset(self): |
6ee2e475490c
Editor Outline, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10642
diff
changeset
|
2140 | """ |
6ee2e475490c
Editor Outline, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10642
diff
changeset
|
2141 | Public method to return the column offset of the item definition. |
6ee2e475490c
Editor Outline, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10642
diff
changeset
|
2142 | |
6ee2e475490c
Editor Outline, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10642
diff
changeset
|
2143 | @return column offset defining the object |
6ee2e475490c
Editor Outline, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10642
diff
changeset
|
2144 | @rtype int |
6ee2e475490c
Editor Outline, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10642
diff
changeset
|
2145 | """ |
6ee2e475490c
Editor Outline, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10642
diff
changeset
|
2146 | return self._attributeObject.coloffset |
6ee2e475490c
Editor Outline, File Browser, Project Browser
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10642
diff
changeset
|
2147 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2148 | def lessThan(self, other, column, order): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2149 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2150 | Public method to check, if the item is less than the other one. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2151 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2152 | @param other reference to item to compare against |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2153 | @type BrowserItem |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2154 | @param column column number to use for the comparison |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2155 | @type int |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2156 | @param order sort order (for special sorting) |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2157 | @type Qt.SortOrder |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2158 | @return true, if this item is less than other |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2159 | @rtype bool |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2160 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2161 | if Preferences.getUI("BrowsersListContentsByOccurrence") and column == 0: |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8131
diff
changeset
|
2162 | if order == Qt.SortOrder.AscendingOrder: |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2163 | return self.lineno() < other.lineno() |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2164 | else: |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2165 | return self.lineno() > other.lineno() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2166 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2167 | return BrowserItem.lessThan(self, other, column, order) |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2168 | |
945
8cd4d08fa9f6
Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
910
diff
changeset
|
2169 | |
4529
6becda664299
Extended Tobias' change to include the Globals item as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4183
diff
changeset
|
2170 | class BrowserGlobalsItem(BrowserClassAttributesItem): |
6becda664299
Extended Tobias' change to include the Globals item as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4183
diff
changeset
|
2171 | """ |
6becda664299
Extended Tobias' change to include the Globals item as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4183
diff
changeset
|
2172 | Class implementing the data structure for browser globals items. |
6becda664299
Extended Tobias' change to include the Globals item as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4183
diff
changeset
|
2173 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2174 | |
4538
cbff7269b187
Little correction to the BrowserGlobalsItem constructor.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4529
diff
changeset
|
2175 | def __init__(self, parent, attributes, text): |
4529
6becda664299
Extended Tobias' change to include the Globals item as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4183
diff
changeset
|
2176 | """ |
6becda664299
Extended Tobias' change to include the Globals item as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4183
diff
changeset
|
2177 | Constructor |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2178 | |
4529
6becda664299
Extended Tobias' change to include the Globals item as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4183
diff
changeset
|
2179 | @param parent parent item |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2180 | @type BrowserItem |
4529
6becda664299
Extended Tobias' change to include the Globals item as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4183
diff
changeset
|
2181 | @param attributes list of attributes |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2182 | @type list of Attribute |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2183 | @param text text to be shown by this item |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2184 | @type str |
4529
6becda664299
Extended Tobias' change to include the Globals item as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4183
diff
changeset
|
2185 | """ |
6becda664299
Extended Tobias' change to include the Globals item as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4183
diff
changeset
|
2186 | BrowserClassAttributesItem.__init__(self, parent, attributes, text) |
6becda664299
Extended Tobias' change to include the Globals item as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4183
diff
changeset
|
2187 | |
6becda664299
Extended Tobias' change to include the Globals item as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4183
diff
changeset
|
2188 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2189 | class BrowserCodingItem(BrowserItem): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2190 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2191 | Class implementing the data structure for browser coding items. |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2192 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2193 | |
7690
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7678
diff
changeset
|
2194 | def __init__(self, parent, text, linenumber): |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2195 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2196 | Constructor |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2197 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2198 | @param parent parent item |
7690
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7678
diff
changeset
|
2199 | @type BrowserItem |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7678
diff
changeset
|
2200 | @param text text to be shown by this item |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7678
diff
changeset
|
2201 | @type str |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7678
diff
changeset
|
2202 | @param linenumber line number of the coding line |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7678
diff
changeset
|
2203 | @type int |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2204 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2205 | BrowserItem.__init__(self, parent, text) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2206 | |
10470
cd7bfd539ac9
Changed the browser item types to an enum in BrowserModel and ProjectBrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10468
diff
changeset
|
2207 | self.type_ = BrowserItemType.Coding |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9297
diff
changeset
|
2208 | self.icon = EricPixmapCache.getIcon("textencoding") |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2209 | |
7690
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7678
diff
changeset
|
2210 | self.__lineno = linenumber |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2211 | |
7690
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7678
diff
changeset
|
2212 | def lineno(self): |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7678
diff
changeset
|
2213 | """ |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7678
diff
changeset
|
2214 | Public method returning the line number of the coding line. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2215 | |
7690
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7678
diff
changeset
|
2216 | @return line number defining the coding line |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7678
diff
changeset
|
2217 | @rtype int |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7678
diff
changeset
|
2218 | """ |
a59680062837
Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7678
diff
changeset
|
2219 | return self.__lineno |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2220 | |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2221 | def lessThan(self, other, column, order): |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2222 | """ |
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2223 | Public method to check, if the item is less than the other one. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2224 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2225 | @param other reference to item to compare against |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2226 | @type BrowserItem |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2227 | @param column column number to use for the comparison |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2228 | @type int |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2229 | @param order sort order (for special sorting) |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2230 | @type Qt.SortOrder |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2231 | @return true, if this item is less than other |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2232 | @rtype bool |
0
de9c2efb9d02
Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff
changeset
|
2233 | """ |
7264
bedbe458d792
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7249
diff
changeset
|
2234 | if issubclass( |
bedbe458d792
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7249
diff
changeset
|
2235 | other.__class__, |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2236 | (BrowserClassItem, BrowserClassAttributesItem, BrowserImportItem), |
7264
bedbe458d792
Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
7249
diff
changeset
|
2237 | ): |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8131
diff
changeset
|
2238 | return order == Qt.SortOrder.AscendingOrder |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2239 | |
4183
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2240 | return BrowserItem.lessThan(self, other, column, order) |
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2241 | |
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2242 | |
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2243 | class BrowserImportsItem(BrowserItem): |
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2244 | """ |
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2245 | Class implementing the data structure for browser import items. |
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2246 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2247 | |
4183
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2248 | def __init__(self, parent, text): |
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2249 | """ |
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2250 | Constructor |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2251 | |
4183
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2252 | @param parent parent item |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2253 | @type BrowserItem |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2254 | @param text text to be shown by this item |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2255 | @type str |
4183
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2256 | """ |
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2257 | BrowserItem.__init__(self, parent, text) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2258 | |
10470
cd7bfd539ac9
Changed the browser item types to an enum in BrowserModel and ProjectBrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10468
diff
changeset
|
2259 | self.type_ = BrowserItemType.Imports |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9297
diff
changeset
|
2260 | self.icon = EricPixmapCache.getIcon("imports") |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2261 | |
4183
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2262 | def lessThan(self, other, column, order): |
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2263 | """ |
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2264 | Public method to check, if the item is less than the other one. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2265 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2266 | @param other reference to item to compare against |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2267 | @type BrowserItem |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2268 | @param column column number to use for the comparison |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2269 | @type int |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2270 | @param order sort order (for special sorting) |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2271 | @type Qt.SortOrder |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2272 | @return true, if this item is less than other |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2273 | @rtype bool |
4183
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2274 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2275 | if issubclass(other.__class__, (BrowserClassItem, BrowserClassAttributesItem)): |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8131
diff
changeset
|
2276 | return order == Qt.SortOrder.AscendingOrder |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2277 | |
608
d8fea1e76975
Removed capability to write compressed project (and related) files.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
564
diff
changeset
|
2278 | return BrowserItem.lessThan(self, other, column, order) |
4183
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2279 | |
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2280 | |
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2281 | class BrowserImportItem(BrowserItem): |
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2282 | """ |
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2283 | Class implementing the data structure for browser imported module and |
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2284 | imported names items. |
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2285 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2286 | |
4183
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2287 | def __init__(self, parent, text, filename, lineNumbers, isModule=True): |
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2288 | """ |
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2289 | Constructor |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2290 | |
4183
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2291 | @param parent parent item |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2292 | @type BrowserItem |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2293 | @param text text to be shown by this item |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2294 | @type str |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2295 | @param filename name of the file |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2296 | @type str |
4183
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2297 | @param lineNumbers list of line numbers of the import statement |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2298 | @type list of int |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2299 | @param isModule flag indicating a module item entry |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2300 | @type bool |
4183
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2301 | """ |
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2302 | BrowserItem.__init__(self, parent, text) |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2303 | |
4183
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2304 | self.__filename = filename |
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2305 | self.__linenos = lineNumbers[:] |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2306 | |
10470
cd7bfd539ac9
Changed the browser item types to an enum in BrowserModel and ProjectBrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10468
diff
changeset
|
2307 | self.type_ = BrowserItemType.Import |
4183
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2308 | if isModule: |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9297
diff
changeset
|
2309 | self.icon = EricPixmapCache.getIcon("importedModule") |
4183
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2310 | else: |
9413
80c06d472826
Changed the eric7 import statements to include the package name (i.e. eric7) in order to not fiddle with sys.path.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9297
diff
changeset
|
2311 | self.icon = EricPixmapCache.getIcon("importedName") |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2312 | |
4183
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2313 | def fileName(self): |
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2314 | """ |
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2315 | Public method returning the filename. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2316 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2317 | @return filename |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2318 | @rtype str |
4183
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2319 | """ |
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2320 | return self.__filename |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2321 | |
4183
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2322 | def lineno(self): |
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2323 | """ |
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2324 | Public method returning the line number of the first import. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2325 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2326 | @return line number of the first import |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2327 | @rtype int |
4183
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2328 | """ |
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2329 | return self.__linenos[0] |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2330 | |
4183
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2331 | def linenos(self): |
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2332 | """ |
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2333 | Public method returning the line numbers of all imports. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2334 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2335 | @return line numbers of all imports |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2336 | @rtype list of int |
4183
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2337 | """ |
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2338 | return self.__linenos[:] |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2339 | |
4183
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2340 | def lessThan(self, other, column, order): |
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2341 | """ |
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2342 | Public method to check, if the item is less than the other one. |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2343 | |
10433
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2344 | @param other reference to item to compare against |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2345 | @type BrowserItem |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2346 | @param column column number to use for the comparison |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2347 | @type int |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2348 | @param order sort order (for special sorting) |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2349 | @type Qt.SortOrder |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2350 | @return true, if this item is less than other |
328f3ec4b77a
Converted some source code documentation to the new style.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
10398
diff
changeset
|
2351 | @rtype bool |
4183
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2352 | """ |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2353 | if Preferences.getUI("BrowsersListContentsByOccurrence") and column == 0: |
8143
2c730d5fd177
Changed the use of PyQt enums because the way they were used previously is deprecated since two years and replaced some deprecated Qt stuff.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
8131
diff
changeset
|
2354 | if order == Qt.SortOrder.AscendingOrder: |
4183
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2355 | return self.lineno() < other.lineno() |
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2356 | else: |
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2357 | return self.lineno() > other.lineno() |
9221
bf71ee032bb4
Reformatted the source code using the 'Black' utility.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
9209
diff
changeset
|
2358 | |
4183
856ba07de877
Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
4107
diff
changeset
|
2359 | return BrowserItem.lessThan(self, other, column, order) |