eric6/UI/BrowserModel.py

Wed, 30 Dec 2020 11:00:44 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 30 Dec 2020 11:00:44 +0100
branch
maintenance
changeset 7924
8a96736d465e
parent 7781
607a6098cb44
child 8043
0acf98cd089a
permissions
-rw-r--r--

Updated copyright for 2021.

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
7924
8a96736d465e Updated copyright for 2021.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7781
diff changeset
3 # Copyright (c) 2006 - 2021 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
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
10 import os
910
dc2436a9e2a1 Added capability to filter out unwanted items in the file browsers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
11 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
12 import json
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
13
7264
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
14 from PyQt5.QtCore import (
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
15 QDir, QModelIndex, QAbstractItemModel, QFileSystemWatcher, Qt, QProcess,
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
16 QCoreApplication
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
17 )
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3604
diff changeset
18 from PyQt5.QtGui import QImageReader, QFont
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3604
diff changeset
19 from PyQt5.QtWidgets import QApplication
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
20
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
21 import UI.PixmapCache
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
22 import Preferences
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
23 import Utilities
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
24
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 910
diff changeset
25 BrowserItemRoot = 0
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 910
diff changeset
26 BrowserItemDirectory = 1
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 910
diff changeset
27 BrowserItemSysPath = 2
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 910
diff changeset
28 BrowserItemFile = 3
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 910
diff changeset
29 BrowserItemClass = 4
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 910
diff changeset
30 BrowserItemMethod = 5
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
31 BrowserItemAttributes = 6
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 910
diff changeset
32 BrowserItemAttribute = 7
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 910
diff changeset
33 BrowserItemCoding = 8
4183
856ba07de877 Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4107
diff changeset
34 BrowserItemImports = 9
856ba07de877 Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4107
diff changeset
35 BrowserItemImport = 10
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 910
diff changeset
36
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
37
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
38 class BrowserModel(QAbstractItemModel):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
39 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
40 Class implementing the browser model.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
41 """
2613
0799eea6feba Fixed a little issue with subclassing BrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
42 def __init__(self, parent=None, nopopulate=False):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
43 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
44 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
45
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
46 @param parent reference to parent object (QObject)
3012
d177226027e2 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
47 @keyparam nopopulate flag indicating to not populate the model
d177226027e2 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
48 (boolean)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
49 """
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2409
diff changeset
50 super(BrowserModel, self).__init__(parent)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
51
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
52 self.progDir = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
53
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
54 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
55 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
56
2613
0799eea6feba Fixed a little issue with subclassing BrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
57 if not nopopulate:
7518
6dea4abd3097 Project: fixed some issue renaming files and directories via the active VCS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
58 self.watchedItems = {}
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
59 self.watchedFileItems = {}
7518
6dea4abd3097 Project: fixed some issue renaming files and directories via the active VCS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
60 self.watcher = QFileSystemWatcher(self)
6dea4abd3097 Project: fixed some issue renaming files and directories via the active VCS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
61 self.watcher.directoryChanged.connect(self.directoryChanged)
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
62 self.watcher.fileChanged.connect(self.fileChanged)
7518
6dea4abd3097 Project: fixed some issue renaming files and directories via the active VCS.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7360
diff changeset
63
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3604
diff changeset
64 rootData = QCoreApplication.translate("BrowserModel", "Name")
2613
0799eea6feba Fixed a little issue with subclassing BrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
65 self.rootItem = BrowserItem(None, rootData)
0799eea6feba Fixed a little issue with subclassing BrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
66
0799eea6feba Fixed a little issue with subclassing BrowserModel.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2409
diff changeset
67 self.__populateModel()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
68
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
69 def columnCount(self, parent=None):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
70 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
71 Public method to get the number of columns.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
72
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
73 @param parent index of parent item (QModelIndex)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
74 @return number of columns (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
75 """
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
76 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
77 parent = QModelIndex()
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
78
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
79 if parent.isValid():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
80 item = parent.internalPointer()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
81 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
82 item = self.rootItem
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
83
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
84 return item.columnCount() + 1
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
85
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
86 def data(self, index, role):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
87 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
88 Public method to get data of an item.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
89
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
90 @param index index of the data to retrieve (QModelIndex)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
91 @param role role of data (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
92 @return requested data
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
93 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
94 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
95 return None
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
96
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
97 if role == Qt.DisplayRole:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
98 item = index.internalPointer()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
99 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
100 return item.data(index.column())
7264
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
101 elif (
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
102 index.column() == item.columnCount() and
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
103 index.column() < self.columnCount(self.parent(index))
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
104 ):
3012
d177226027e2 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
105 # 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
106 # 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
107 return ""
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
108 elif role == Qt.DecorationRole:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
109 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
110 return index.internalPointer().getIcon()
103
59137afca666 Added code to indicate directories and files being symbolic links.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 15
diff changeset
111 elif role == Qt.FontRole:
59137afca666 Added code to indicate directories and files being symbolic links.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 15
diff changeset
112 item = index.internalPointer()
59137afca666 Added code to indicate directories and files being symbolic links.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 15
diff changeset
113 if item.isSymlink():
59137afca666 Added code to indicate directories and files being symbolic links.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 15
diff changeset
114 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
115 font.setItalic(True)
59137afca666 Added code to indicate directories and files being symbolic links.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 15
diff changeset
116 return font
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
117
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
118 return None
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
119
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
120 def flags(self, index):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
121 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
122 Public method to get the item flags.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
123
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
124 @param index index of the data to retrieve (QModelIndex)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
125 @return requested flags (Qt.ItemFlags)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
126 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
127 if not index.isValid():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
128 return Qt.ItemIsEnabled
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
129
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
130 return Qt.ItemIsEnabled | Qt.ItemIsSelectable
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
131
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 910
diff changeset
132 def headerData(self, section, orientation, role=Qt.DisplayRole):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
133 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
134 Public method to get the header data.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
135
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
136 @param section number of section to get data for (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
137 @param orientation header orientation (Qt.Orientation)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
138 @param role role of data (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
139 @return requested header data
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
140 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
141 if orientation == Qt.Horizontal and role == Qt.DisplayRole:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
142 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
143 return ""
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
144 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
145 return self.rootItem.data(section)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
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
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
148
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
149 def index(self, row, column, parent=None):
0
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 create an index.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
152
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
153 @param row row number of the new index (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
154 @param column column number of the new index (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
155 @param parent index of parent item (QModelIndex)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
156 @return index object (QModelIndex)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
157 """
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
158 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
159 parent = QModelIndex()
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
160
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 910
diff changeset
161 # 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
162 # 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
163 # 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
164 if (
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
165 row < 0 or
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
166 column < 0 or
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
167 row >= self.rowCount(parent) or
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
168 column >= self.columnCount(parent)
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
169 ):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
170 return QModelIndex()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
171
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
172 if not parent.isValid():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
173 parentItem = self.rootItem
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
174 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
175 parentItem = parent.internalPointer()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
176
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
177 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
178 if not parentItem.isPopulated():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
179 self.populateItem(parentItem)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
180 childItem = parentItem.child(row)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
181 except IndexError:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
182 childItem = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
183 if childItem:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
184 return self.createIndex(row, column, childItem)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
185 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
186 return QModelIndex()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
187
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
188 def parent(self, index):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
189 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
190 Public method to get the index of the parent object.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
191
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
192 @param index index of the item (QModelIndex)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
193 @return index of parent item (QModelIndex)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
194 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
195 if not index.isValid():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
196 return QModelIndex()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
197
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
198 childItem = index.internalPointer()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
199 parentItem = childItem.parent()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
200
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7678
diff changeset
201 if parentItem is None or parentItem == self.rootItem:
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
202 return QModelIndex()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
203
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
204 return self.createIndex(parentItem.row(), 0, parentItem)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
205
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
206 def rowCount(self, parent=None):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
207 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
208 Public method to get the number of rows.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
209
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
210 @param parent index of parent item (QModelIndex)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
211 @return number of rows (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
212 """
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
213 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
214 parent = QModelIndex()
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
215
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
216 # Only the first column should have children
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
217 if parent.column() > 0:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
218 return 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
219
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
220 if not parent.isValid():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
221 parentItem = self.rootItem
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
222 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
223 parentItem = parent.internalPointer()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
224 if not parentItem.isPopulated(): # lazy population
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
225 self.populateItem(parentItem)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
226
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
227 return parentItem.childCount()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
228
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
229 def hasChildren(self, parent=None):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
230 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
231 Public method to check for the presence of child items.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
232
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
233 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
234 population of the tree.
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 @param parent index of parent item (QModelIndex)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
237 @return flag indicating the presence of child items (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
238 """
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
239 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
240 parent = QModelIndex()
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
241
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
242 # Only the first column should have children
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
243 if parent.column() > 0:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
244 return 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
245
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
246 if not parent.isValid():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
247 return self.rootItem.childCount() > 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 if parent.internalPointer().isLazyPopulated():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
250 return True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
251 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
252 return parent.internalPointer().childCount() > 0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
253
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
254 def clear(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
255 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
256 Public method to clear the model.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
257 """
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3604
diff changeset
258 self.beginResetModel()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
259 self.rootItem.removeChildren()
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3604
diff changeset
260 self.endResetModel()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
261
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
262 def item(self, index):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
263 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
264 Public method to get a reference to an item.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
265
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
266 @param index index of the data to retrieve (QModelIndex)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
267 @return requested item reference (BrowserItem)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
268 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
269 if not index.isValid():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
270 return None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
271
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
272 return index.internalPointer()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
273
231
2e4eb047ae93 Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 103
diff changeset
274 def _addWatchedItem(self, itm):
2e4eb047ae93 Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 103
diff changeset
275 """
2e4eb047ae93 Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 103
diff changeset
276 Protected method to watch an item.
2e4eb047ae93 Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 103
diff changeset
277
2e4eb047ae93 Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 103
diff changeset
278 @param itm item to be watched (BrowserDirectoryItem)
2e4eb047ae93 Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 103
diff changeset
279 """
2e4eb047ae93 Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 103
diff changeset
280 if isinstance(itm, BrowserDirectoryItem):
2e4eb047ae93 Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 103
diff changeset
281 dirName = itm.dirName()
7264
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
282 if (
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
283 dirName != "" and
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
284 not dirName.startswith("//") and
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
285 not dirName.startswith("\\\\")
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
286 ):
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
287 if dirName not in self.watcher.directories():
0ee8be384de2 Extended last change to deal with multiple items having the same directory name.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 231
diff changeset
288 self.watcher.addPath(dirName)
233
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
289 if dirName in self.watchedItems:
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
290 if itm not in self.watchedItems[dirName]:
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
291 self.watchedItems[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
292 else:
0ee8be384de2 Extended last change to deal with multiple items having the same directory name.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 231
diff changeset
293 self.watchedItems[dirName] = [itm]
231
2e4eb047ae93 Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 103
diff changeset
294
2e4eb047ae93 Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 103
diff changeset
295 def _removeWatchedItem(self, itm):
2e4eb047ae93 Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 103
diff changeset
296 """
2e4eb047ae93 Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 103
diff changeset
297 Protected method to remove a watched item.
2e4eb047ae93 Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 103
diff changeset
298
2e4eb047ae93 Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 103
diff changeset
299 @param itm item to be removed (BrowserDirectoryItem)
2e4eb047ae93 Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 103
diff changeset
300 """
2e4eb047ae93 Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 103
diff changeset
301 if isinstance(itm, BrowserDirectoryItem):
2e4eb047ae93 Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 103
diff changeset
302 dirName = itm.dirName()
233
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
303 if dirName in self.watchedItems:
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
304 if itm in self.watchedItems[dirName]:
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
305 self.watchedItems[dirName].remove(itm)
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
306 if len(self.watchedItems[dirName]) == 0:
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
307 del self.watchedItems[dirName]
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
308 self.watcher.removePath(dirName)
231
2e4eb047ae93 Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 103
diff changeset
309
233
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
310 def directoryChanged(self, path):
231
2e4eb047ae93 Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 103
diff changeset
311 """
233
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
312 Public slot to handle the directoryChanged signal of the watcher.
231
2e4eb047ae93 Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 103
diff changeset
313
2e4eb047ae93 Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 103
diff changeset
314 @param path path of the directory (string)
2e4eb047ae93 Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 103
diff changeset
315 """
2e4eb047ae93 Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 103
diff changeset
316 if path not in self.watchedItems:
2e4eb047ae93 Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 103
diff changeset
317 # 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
318 return
2e4eb047ae93 Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 103
diff changeset
319
405
374066392929 Added code to show hidden files in the various browsers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 233
diff changeset
320 if Preferences.getUI("BrowsersListHiddenFiles"):
5604
b047181a4a33 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5587
diff changeset
321 dirFilter = QDir.Filters(
3012
d177226027e2 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
322 QDir.AllEntries | QDir.Hidden | QDir.NoDotAndDotDot)
405
374066392929 Added code to show hidden files in the various browsers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 233
diff changeset
323 else:
5604
b047181a4a33 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5587
diff changeset
324 dirFilter = QDir.Filters(
b047181a4a33 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5587
diff changeset
325 QDir.AllEntries | QDir.NoDot | QDir.NoDotDot)
405
374066392929 Added code to show hidden files in the various browsers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 233
diff changeset
326
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
327 for itm in self.watchedItems[path]:
233
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
328 oldCnt = itm.childCount()
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
329
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
330 qdir = QDir(itm.dirName())
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
331
5604
b047181a4a33 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5587
diff changeset
332 entryInfoList = qdir.entryInfoList(dirFilter)
233
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
333
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
334 # step 1: check for new entries
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
335 children = itm.children()
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
336 for f in entryInfoList:
1785
9c6d23391248 Fixed an issue in the ProjectBrowserModel and BrowserModel classes occuring on Windows systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
337 fpath = Utilities.toNativeSeparators(f.absoluteFilePath())
233
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
338 childFound = False
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
339 for child in children:
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
340 if child.name() == fpath:
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
341 childFound = True
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
342 children.remove(child)
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
343 break
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
344 if childFound:
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
345 continue
231
2e4eb047ae93 Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 103
diff changeset
346
233
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
347 cnt = itm.childCount()
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3012
diff changeset
348 self.beginInsertRows(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3012
diff changeset
349 self.createIndex(itm.row(), 0, itm), cnt, cnt)
233
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
350 if f.isDir():
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3012
diff changeset
351 node = BrowserDirectoryItem(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3012
diff changeset
352 itm,
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 910
diff changeset
353 Utilities.toNativeSeparators(f.absoluteFilePath()),
233
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
354 False)
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
355 else:
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3012
diff changeset
356 node = BrowserFileItem(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3012
diff changeset
357 itm,
233
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
358 Utilities.toNativeSeparators(f.absoluteFilePath()))
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
359 self._addItem(node, itm)
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
360 self.endInsertRows()
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
361
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
362 # step 2: check for removed entries
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
363 if len(entryInfoList) != itm.childCount():
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
364 for row in range(oldCnt - 1, -1, -1):
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
365 child = itm.child(row)
1785
9c6d23391248 Fixed an issue in the ProjectBrowserModel and BrowserModel classes occuring on Windows systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
366 childname = Utilities.fromNativeSeparators(child.name())
233
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
367 entryFound = False
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
368 for f in entryInfoList:
1785
9c6d23391248 Fixed an issue in the ProjectBrowserModel and BrowserModel classes occuring on Windows systems.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1509
diff changeset
369 if f.absoluteFilePath() == childname:
233
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
370 entryFound = True
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
371 entryInfoList.remove(f)
231
2e4eb047ae93 Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 103
diff changeset
372 break
233
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
373 if entryFound:
231
2e4eb047ae93 Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 103
diff changeset
374 continue
2e4eb047ae93 Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 103
diff changeset
375
233
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
376 self._removeWatchedItem(child)
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3012
diff changeset
377 self.beginRemoveRows(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3012
diff changeset
378 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
379 itm.removeChild(child)
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
380 self.endRemoveRows()
231
2e4eb047ae93 Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 103
diff changeset
381
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
382 def __populateModel(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
383 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
384 Private method to populate the browser model.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
385 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
386 self.toplevelDirs = []
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
387 tdp = Preferences.Prefs.settings.value('BrowserModel/ToplevelDirs')
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
388 if tdp:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
389 self.toplevelDirs = tdp
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
390 else:
3012
d177226027e2 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
391 self.toplevelDirs.append(
d177226027e2 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
392 Utilities.toNativeSeparators(QDir.homePath()))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
393 for d in QDir.drives():
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 432
diff changeset
394 self.toplevelDirs.append(Utilities.toNativeSeparators(
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
395 d.absoluteFilePath()))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
396
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
397 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
398 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
399 self._addItem(itm, self.rootItem)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
400
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
401 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
402 """
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
403 Public method to handle a change of the debug client's 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
404
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
405 @param interpreter interpreter of the debug client (string)
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
406 """
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
407 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
408 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
409 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
410 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
411 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
412 # 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
413 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
414 self.beginRemoveRows(
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
415 QModelIndex(), self.__sysPathItem.row(),
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
416 self.__sysPathItem.row())
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
417 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
418 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
419 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
420
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
421 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
422 # 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
423 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
424 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
425 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
426 # 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
427 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
428 self.beginRemoveRows(
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
429 QModelIndex(), self.__sysPathItem.row(),
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
430 self.__sysPathItem.row())
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
431 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
432 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
433 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
434 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
435
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
436 def programChange(self, dirname):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
437 """
3012
d177226027e2 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
438 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
439 debugged.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
440
231
2e4eb047ae93 Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 103
diff changeset
441 @param dirname name of the directory containing the file (string)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
442 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
443 if self.progDir:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
444 if dirname == self.progDir.dirName():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
445 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
446
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
447 # remove old entry
231
2e4eb047ae93 Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 103
diff changeset
448 self._removeWatchedItem(self.progDir)
3012
d177226027e2 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
449 self.beginRemoveRows(
d177226027e2 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
450 QModelIndex(), self.progDir.row(), self.progDir.row())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
451 self.rootItem.removeChild(self.progDir)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
452 self.endRemoveRows()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
453 self.progDir = None
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
454
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
455 itm = BrowserDirectoryItem(self.rootItem, dirname)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
456 self.addItem(itm)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
457 self.progDir = itm
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
458
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
459 def addTopLevelDir(self, dirname):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
460 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
461 Public method to add a new toplevel directory.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
462
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
463 @param dirname name of the new toplevel directory (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
464 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
465 if dirname not in self.toplevelDirs:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
466 itm = BrowserDirectoryItem(self.rootItem, dirname)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
467 self.addItem(itm)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
468 self.toplevelDirs.append(itm.dirName())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
469
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
470 def removeToplevelDir(self, index):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
471 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
472 Public method to remove a toplevel directory.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
473
3012
d177226027e2 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
474 @param index index of the toplevel directory to be removed
d177226027e2 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
475 (QModelIndex)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
476 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
477 if not index.isValid():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
478 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
479
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
480 item = index.internalPointer()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
481 self.beginRemoveRows(index.parent(), index.row(), index.row())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
482 self.rootItem.removeChild(item)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
483 self.endRemoveRows()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
484
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
485 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
486 self._removeWatchedItem(item)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
487
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
488 def saveToplevelDirs(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
489 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
490 Public slot to save the toplevel directories.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
491 """
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3012
diff changeset
492 Preferences.Prefs.settings.setValue(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3012
diff changeset
493 'BrowserModel/ToplevelDirs', self.toplevelDirs)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
494
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
495 def _addItem(self, itm, parentItem):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
496 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
497 Protected slot to add an item.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
498
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
499 @param itm reference to item to add (BrowserItem)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
500 @param parentItem reference to item to add to (BrowserItem)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
501 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
502 parentItem.appendChild(itm)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
503
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
504 def addItem(self, itm, parent=None):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
505 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3525
diff changeset
506 Public slot to add an item.
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
507
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
508 @param itm item to add (BrowserItem)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
509 @param parent index of parent item (QModelIndex)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
510 """
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
511 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
512 parent = QModelIndex()
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
513
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
514 if not parent.isValid():
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
515 parentItem = self.rootItem
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
516 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
517 parentItem = parent.internalPointer()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
518
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
519 cnt = parentItem.childCount()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
520 self.beginInsertRows(parent, cnt, cnt)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
521 self._addItem(itm, parentItem)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
522 self.endInsertRows()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
523
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 910
diff changeset
524 def populateItem(self, parentItem, repopulate=False):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
525 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
526 Public method to populate an item's subtree.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
527
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
528 @param parentItem reference to the item to be populated
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
529 @param repopulate flag indicating a repopulation (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
530 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
531 if parentItem.type() == BrowserItemDirectory:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
532 self.populateDirectoryItem(parentItem, repopulate)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
533 elif parentItem.type() == BrowserItemSysPath:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
534 self.populateSysPathItem(parentItem, repopulate)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
535 elif parentItem.type() == BrowserItemFile:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
536 self.populateFileItem(parentItem, repopulate)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
537 elif parentItem.type() == BrowserItemClass:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
538 self.populateClassItem(parentItem, repopulate)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
539 elif parentItem.type() == BrowserItemMethod:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
540 self.populateMethodItem(parentItem, repopulate)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
541 elif parentItem.type() == BrowserItemAttributes:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
542 self.populateClassAttributesItem(parentItem, repopulate)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
543
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 910
diff changeset
544 def populateDirectoryItem(self, parentItem, repopulate=False):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
545 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
546 Public method to populate a directory item's subtree.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
547
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
548 @param parentItem reference to the directory item to be populated
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
549 @param repopulate flag indicating a repopulation (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
550 """
233
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
551 self._addWatchedItem(parentItem)
9d2677615a3d Fixed a few issues with the automatic update code.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 232
diff changeset
552
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
553 qdir = QDir(parentItem.dirName())
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
554
405
374066392929 Added code to show hidden files in the various browsers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 233
diff changeset
555 if Preferences.getUI("BrowsersListHiddenFiles"):
5604
b047181a4a33 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5587
diff changeset
556 dirFilter = QDir.Filters(
3012
d177226027e2 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
557 QDir.AllEntries | QDir.Hidden | QDir.NoDotAndDotDot)
405
374066392929 Added code to show hidden files in the various browsers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 233
diff changeset
558 else:
5604
b047181a4a33 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5587
diff changeset
559 dirFilter = QDir.Filters(
b047181a4a33 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5587
diff changeset
560 QDir.AllEntries | QDir.NoDot | QDir.NoDotDot)
b047181a4a33 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5587
diff changeset
561 entryInfoList = qdir.entryInfoList(dirFilter)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
562 if len(entryInfoList) > 0:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
563 if repopulate:
3012
d177226027e2 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
564 self.beginInsertRows(
d177226027e2 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
565 self.createIndex(parentItem.row(), 0, parentItem),
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
566 0, len(entryInfoList) - 1)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
567 for f in entryInfoList:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
568 if f.isDir():
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3012
diff changeset
569 node = BrowserDirectoryItem(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3012
diff changeset
570 parentItem,
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 910
diff changeset
571 Utilities.toNativeSeparators(f.absoluteFilePath()),
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
572 False)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
573 else:
7264
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
574 fileFilters = Preferences.getUI(
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
575 "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
576 if fileFilters:
dc2436a9e2a1 Added capability to filter out unwanted items in the file browsers.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 791
diff changeset
577 fn = f.fileName()
5604
b047181a4a33 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5587
diff changeset
578 if any(fnmatch.fnmatch(fn, ff.strip())
b047181a4a33 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5587
diff changeset
579 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
580 continue
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3012
diff changeset
581 node = BrowserFileItem(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3012
diff changeset
582 parentItem,
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
583 Utilities.toNativeSeparators(f.absoluteFilePath()))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
584 self._addItem(node, parentItem)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
585 if repopulate:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
586 self.endInsertRows()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
587
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 910
diff changeset
588 def populateSysPathItem(self, parentItem, repopulate=False):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
589 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
590 Public method to populate a sys.path item's subtree.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
591
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
592 @param parentItem reference to the sys.path item to be populated
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
593 @param repopulate flag indicating a repopulation (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
594 """
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
595 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
596 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
597 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
598 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
599 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
600 if finished:
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
601 procOutput = str(proc.readAllStandardOutput(),
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
602 Preferences.getSystem("IOEncoding"),
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
603 'replace')
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
604 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
605 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
606 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
607 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
608 self.createIndex(parentItem.row(), 0, 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
609 0, len(syspath) - 1)
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
610 for p in syspath:
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
611 if os.path.isdir(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
612 node = BrowserDirectoryItem(parentItem, 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
613 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
614 node = BrowserFileItem(parentItem, 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
615 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
616 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
617 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
618 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
619 proc.kill()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
620
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 910
diff changeset
621 def populateFileItem(self, parentItem, repopulate=False):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
622 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
623 Public method to populate a file item's subtree.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
624
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
625 @param parentItem reference to the file item to be populated
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
626 @param repopulate flag indicating a repopulation (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
627 """
2409
df3820f08247 Continued implementing the delayed import.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2334
diff changeset
628 import Utilities.ClassBrowsers
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
629 moduleName = parentItem.moduleName()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
630 fileName = parentItem.fileName()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
631 try:
5604
b047181a4a33 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5587
diff changeset
632 dictionary = Utilities.ClassBrowsers.readmodule(
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 910
diff changeset
633 moduleName, [parentItem.dirName()],
7635
0cdead130a81 Removed support for Python2 and removed support for Qt4 (PyQt4 and pyside).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7581
diff changeset
634 parentItem.isPython3File())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
635 except ImportError:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
636 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
637
5604
b047181a4a33 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5587
diff changeset
638 keys = list(dictionary.keys())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
639 if len(keys) > 0:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
640 if repopulate:
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
641 last = len(keys) - 1
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
642 if (
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
643 "@@Coding@@" in keys and
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
644 not Preferences.getUI("BrowserShowCoding")
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
645 ):
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
646 last -= 1
3012
d177226027e2 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
647 self.beginInsertRows(
d177226027e2 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
648 self.createIndex(parentItem.row(), 0, parentItem),
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
649 0, last)
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
650
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
651 for key in keys:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
652 if key.startswith("@@"):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
653 # special treatment done later
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
654 continue
5604
b047181a4a33 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5587
diff changeset
655 cl = dictionary[key]
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
656 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
657 if cl.module == moduleName:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
658 node = BrowserClassItem(parentItem, cl, fileName)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
659 self._addItem(node, parentItem)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
660 except AttributeError:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
661 pass
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
662 if "@@Coding@@" in keys and Preferences.getUI("BrowserShowCoding"):
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3012
diff changeset
663 node = BrowserCodingItem(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3012
diff changeset
664 parentItem,
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3604
diff changeset
665 QCoreApplication.translate("BrowserModel", "Coding: {0}")
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7678
diff changeset
666 .format(dictionary["@@Coding@@"].coding),
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7678
diff changeset
667 dictionary["@@Coding@@"].linenumber)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
668 self._addItem(node, parentItem)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
669 if "@@Globals@@" in keys:
4529
6becda664299 Extended Tobias' change to include the Globals item as well.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4183
diff changeset
670 node = BrowserGlobalsItem(
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3012
diff changeset
671 parentItem,
5604
b047181a4a33 Continued fixing code style issues detected by the extended style checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 5587
diff changeset
672 dictionary["@@Globals@@"].globals,
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3604
diff changeset
673 QCoreApplication.translate("BrowserModel", "Globals"))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
674 self._addItem(node, parentItem)
4183
856ba07de877 Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4107
diff changeset
675 if "@@Import@@" in keys or "@@ImportFrom@@" in keys:
856ba07de877 Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4107
diff changeset
676 node = BrowserImportsItem(
856ba07de877 Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4107
diff changeset
677 parentItem,
856ba07de877 Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4107
diff changeset
678 QCoreApplication.translate("BrowserModel", "Imports"))
856ba07de877 Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4107
diff changeset
679 self._addItem(node, parentItem)
856ba07de877 Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4107
diff changeset
680 if "@@Import@@" in keys:
7264
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
681 for importedModule in (
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
682 dictionary["@@Import@@"].getImports().values()
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
683 ):
4183
856ba07de877 Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4107
diff changeset
684 m_node = BrowserImportItem(
856ba07de877 Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4107
diff changeset
685 node,
856ba07de877 Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4107
diff changeset
686 importedModule.importedModuleName,
856ba07de877 Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4107
diff changeset
687 importedModule.file,
856ba07de877 Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4107
diff changeset
688 importedModule.linenos)
856ba07de877 Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4107
diff changeset
689 self._addItem(m_node, node)
7264
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
690 for importedName, linenos in (
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
691 importedModule.importedNames.items()
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
692 ):
4183
856ba07de877 Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4107
diff changeset
693 mn_node = BrowserImportItem(
856ba07de877 Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4107
diff changeset
694 m_node,
856ba07de877 Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4107
diff changeset
695 importedName,
856ba07de877 Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4107
diff changeset
696 importedModule.file,
856ba07de877 Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4107
diff changeset
697 linenos,
856ba07de877 Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4107
diff changeset
698 isModule=False)
856ba07de877 Added capability to show imports of a Python script.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4107
diff changeset
699 self._addItem(mn_node, m_node)
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
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
701 if repopulate:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
702 self.endInsertRows()
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
703
3440
ddcce63ab5cc Fixed a refreshing issue in the browser model.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3358
diff changeset
704 parentItem._populated = True
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7678
diff changeset
705 if (
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7678
diff changeset
706 parentItem.type_ == BrowserItemFile and
7678
285c786c4a9c BrowserModel: fixed an issue introduced by the last change.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7677
diff changeset
707 fileName not in self.watchedFileItems
285c786c4a9c BrowserModel: fixed an issue introduced by the last change.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7677
diff changeset
708 ):
285c786c4a9c BrowserModel: fixed an issue introduced by the last change.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7677
diff changeset
709 # watch the file only in the file browser not the project viewer
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
710 self.watcher.addPath(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
711 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
712
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
713 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
714 """
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
715 Public method to repopulate a file item.
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
716
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
717 @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
718 @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
719 """
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
720 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
721 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
722 # 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
723 return
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
724
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
725 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
726 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
727 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
728 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
729 self.endRemoveRows()
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
730
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
731 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
732
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
733 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
734 """
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
735 Public method to react upon file changes.
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
736
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
737 @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
738 @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
739 """
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
740 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
741 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
742 # 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
743 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
744 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
745 # the file does not exist anymore
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
746 del self.watchedFileItems[fileName]
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
747
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 910
diff changeset
748 def populateClassItem(self, parentItem, repopulate=False):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
749 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
750 Public method to populate a class item's subtree.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
751
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
752 @param parentItem reference to the class item to be populated
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
753 @param repopulate flag indicating a repopulation (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
754 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
755 cl = parentItem.classObject()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
756 file_ = parentItem.fileName()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
757
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
758 if cl is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
759 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
760
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
761 # build sorted list of names
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
762 keys = []
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
763 for name in list(cl.classes.keys()):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
764 keys.append((name, 'c'))
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
765 for name in list(cl.methods.keys()):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
766 keys.append((name, 'm'))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
767
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
768 if len(cl.attributes):
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 432
diff changeset
769 node = BrowserClassAttributesItem(
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 910
diff changeset
770 parentItem, cl.attributes,
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3604
diff changeset
771 QCoreApplication.translate("BrowserModel", "Attributes"))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
772 if repopulate:
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3012
diff changeset
773 self.addItem(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3012
diff changeset
774 node, self.createIndex(parentItem.row(), 0, parentItem))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
775 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
776 self._addItem(node, parentItem)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
777
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
778 if len(cl.globals):
564
b3d966393ba9 Did some code cleanup.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 432
diff changeset
779 node = BrowserClassAttributesItem(
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 910
diff changeset
780 parentItem, cl.globals,
3656
441956d8fce5 Started porting eric5 to PyQt5.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3604
diff changeset
781 QCoreApplication.translate("BrowserModel", "Class 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
782 True)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
783 if repopulate:
3030
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3012
diff changeset
784 self.addItem(
4a0a82ddd9d2 Fixed a bunch of visible indentation issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3012
diff changeset
785 node, self.createIndex(parentItem.row(), 0, parentItem))
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
786 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
787 self._addItem(node, parentItem)
7690
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7678
diff changeset
788
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7678
diff changeset
789 if len(keys) > 0:
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7678
diff changeset
790 if repopulate:
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7678
diff changeset
791 self.beginInsertRows(
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7678
diff changeset
792 self.createIndex(parentItem.row(), 0, parentItem),
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7678
diff changeset
793 0, len(keys) - 1)
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7678
diff changeset
794 for key, kind in keys:
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7678
diff changeset
795 if kind == 'c':
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7678
diff changeset
796 node = BrowserClassItem(parentItem, cl.classes[key], file_)
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7678
diff changeset
797 elif kind == 'm':
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7678
diff changeset
798 node = BrowserMethodItem(parentItem, cl.methods[key],
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7678
diff changeset
799 file_)
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7678
diff changeset
800 self._addItem(node, parentItem)
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7678
diff changeset
801 if repopulate:
a59680062837 Continued implementing the editor outline widget.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7678
diff changeset
802 self.endInsertRows()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
803
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 910
diff changeset
804 def populateMethodItem(self, parentItem, repopulate=False):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
805 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
806 Public method to populate a method item's subtree.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
807
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
808 @param parentItem reference to the method item to be populated
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
809 @param repopulate flag indicating a repopulation (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
810 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
811 fn = parentItem.functionObject()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
812 file_ = parentItem.fileName()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
813
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
814 if fn is None:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
815 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
816
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
817 # build sorted list of names
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
818 keys = []
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
819 for name in list(fn.classes.keys()):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
820 keys.append((name, 'c'))
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
821 for name in list(fn.methods.keys()):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
822 keys.append((name, 'm'))
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
823
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
824 if len(keys) > 0:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
825 if repopulate:
3012
d177226027e2 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
826 self.beginInsertRows(
d177226027e2 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
827 self.createIndex(parentItem.row(), 0, parentItem),
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
828 0, len(keys) - 1)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
829 for key, kind in keys:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
830 if kind == 'c':
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
831 node = BrowserClassItem(parentItem, fn.classes[key], file_)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
832 elif kind == 'm':
3012
d177226027e2 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
833 node = BrowserMethodItem(parentItem, fn.methods[key],
d177226027e2 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
834 file_)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
835 self._addItem(node, parentItem)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
836 if repopulate:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
837 self.endInsertRows()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
838
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 910
diff changeset
839 def populateClassAttributesItem(self, parentItem, repopulate=False):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
840 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
841 Public method to populate a class attributes item's subtree.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
842
3012
d177226027e2 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
843 @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
844 populated
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
845 @param repopulate flag indicating a repopulation (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
846 """
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
847 classAttributes = parentItem.isClassAttributes()
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
848 attributes = parentItem.attributes()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
849 if not attributes:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
850 return
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
851
12
1d8dd9706f46 First commit after changing to Python 3.1.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7
diff changeset
852 keys = list(attributes.keys())
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
853 if len(keys) > 0:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
854 if repopulate:
3012
d177226027e2 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
855 self.beginInsertRows(
d177226027e2 Continued to shorten the code lines to max. 79 characters.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2965
diff changeset
856 self.createIndex(parentItem.row(), 0, parentItem),
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
857 0, len(keys) - 1)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
858 for key in keys:
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
859 node = BrowserClassAttributeItem(parentItem, attributes[key],
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
860 classAttributes)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
861 self._addItem(node, parentItem)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
862 if repopulate:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
863 self.endInsertRows()
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
864
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 910
diff changeset
865
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
866 class BrowserItem(object):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
867 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
868 Class implementing the data structure for browser items.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
869 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
870 def __init__(self, parent, data):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
871 """
3591
2f2a4a76dd22 Corrected a bunch of source docu issues.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 3525
diff changeset
872 Constructor
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
873
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
874 @param parent reference to the parent item
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
875 @param data single data of the item
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
876 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
877 self.childItems = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
878
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
879 self.parentItem = parent
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
880 self.itemData = [data]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
881 self.type_ = BrowserItemRoot
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
882 self.icon = UI.PixmapCache.getIcon("empty")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
883 self._populated = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
884 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
885 self.symlink = False
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
886
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
887 def appendChild(self, child):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
888 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
889 Public method to add a child to this item.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
890
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
891 @param child reference to the child item to add (BrowserItem)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
892 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
893 self.childItems.append(child)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
894 self._populated = True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
895
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
896 def removeChild(self, child):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
897 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
898 Public method to remove a child.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
899
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
900 @param child reference to the child to remove (BrowserItem)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
901 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
902 self.childItems.remove(child)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
903
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
904 def removeChildren(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
905 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
906 Public method to remove all children.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
907 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
908 self.childItems = []
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
909
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
910 def child(self, row):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
911 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
912 Public method to get a child id.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
913
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
914 @param row number of child to get the id of (integer)
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2779
diff changeset
915 @return reference to the child item (BrowserItem)
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
916 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
917 return self.childItems[row]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
918
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
919 def children(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
920 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
921 Public method to get the ids of all child items.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
922
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
923 @return references to all child items (list of BrowserItem)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
924 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
925 return self.childItems[:]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
926
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
927 def childCount(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
928 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
929 Public method to get the number of available child items.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
930
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
931 @return number of child items (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
932 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
933 return len(self.childItems)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
934
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
935 def columnCount(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
936 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
937 Public method to get the number of available data items.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
938
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
939 @return number of data items (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
940 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
941 return len(self.itemData)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
942
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
943 def data(self, column):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
944 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
945 Public method to get a specific data item.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
946
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
947 @param column number of the requested data item (integer)
2965
d133c7edd88a Continued correcting doc strings by using the new doc string checker.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 2779
diff changeset
948 @return stored data item
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
949 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
950 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
951 return self.itemData[column]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
952 except IndexError:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
953 return ""
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
954
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
955 def parent(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
956 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
957 Public method to get the reference to the parent item.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
958
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
959 @return reference to the parent item
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
960 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
961 return self.parentItem
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
962
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
963 def row(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
964 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
965 Public method to get the row number of this item.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
966
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
967 @return row number (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
968 """
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
969 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
970 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
971 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
972 return 0
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
973
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
974 def type(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
975 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
976 Public method to get the item type.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
977
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
978 @return type of the item
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
979 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
980 return self.type_
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 def isPublic(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
983 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
984 Public method returning the public visibility status.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
985
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
986 @return flag indicating public visibility (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
987 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
988 return True
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
989
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
990 def getIcon(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
991 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
992 Public method to get the items icon.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
993
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
994 @return the icon (QIcon)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
995 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
996 return self.icon
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
997
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
998 def isPopulated(self):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
999 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1000 Public method to chek, if this item is populated.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1001
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1002 @return population status (boolean)
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._populated
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1005
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1006 def isLazyPopulated(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 check, if this item should be populated lazyly.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1009
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1010 @return lazy population flag (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1011 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1012 return self._lazyPopulation
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1013
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1014 def lessThan(self, other, column, order):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1015 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1016 Public method to check, if the item is less than the other one.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1017
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1018 @param other reference to item to compare against (BrowserItem)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1019 @param column column number to use for the comparison (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1020 @param order sort order (Qt.SortOrder) (for special sorting)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1021 @return true, if this item is less than other (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1022 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1023 try:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1024 return self.itemData[column] < other.itemData[column]
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1025 except IndexError:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1026 return False
103
59137afca666 Added code to indicate directories and files being symbolic links.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 15
diff changeset
1027
59137afca666 Added code to indicate directories and files being symbolic links.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 15
diff changeset
1028 def isSymlink(self):
59137afca666 Added code to indicate directories and files being symbolic links.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 15
diff changeset
1029 """
59137afca666 Added code to indicate directories and files being symbolic links.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 15
diff changeset
1030 Public method to check, if the items is a symbolic link.
59137afca666 Added code to indicate directories and files being symbolic links.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 15
diff changeset
1031
59137afca666 Added code to indicate directories and files being symbolic links.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 15
diff changeset
1032 @return flag indicating a symbolic link (boolean)
59137afca666 Added code to indicate directories and files being symbolic links.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 15
diff changeset
1033 """
59137afca666 Added code to indicate directories and files being symbolic links.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 15
diff changeset
1034 return self.symlink
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1035
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 910
diff changeset
1036
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1037 class BrowserDirectoryItem(BrowserItem):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1038 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1039 Class implementing the data structure for browser directory items.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1040 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 910
diff changeset
1041 def __init__(self, parent, dinfo, full=True):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1042 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1043 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1044
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1045 @param parent parent item
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1046 @param dinfo dinfo is the string for the directory (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1047 @param full flag indicating full pathname should be displayed (boolean)
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 self._dirName = os.path.abspath(dinfo)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1050
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1051 if full:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1052 dn = self._dirName
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1053 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1054 dn = os.path.basename(self._dirName)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1055
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1056 BrowserItem.__init__(self, parent, dn)
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 self.type_ = BrowserItemDirectory
7264
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
1059 if (
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
1060 not Utilities.isDrive(self._dirName) and
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
1061 os.path.lexists(self._dirName) and
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
1062 os.path.islink(self._dirName)
bedbe458d792 Continued to resolve code style issue M841.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7249
diff changeset
1063 ):
103
59137afca666 Added code to indicate directories and files being symbolic links.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 15
diff changeset
1064 self.symlink = True
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
1065 self.icon = UI.PixmapCache.getSymlinkIcon("dirClosed")
103
59137afca666 Added code to indicate directories and files being symbolic links.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 15
diff changeset
1066 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
1067 self.icon = UI.PixmapCache.getIcon("dirClosed")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1068 self._populated = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1069 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
1070
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 910
diff changeset
1071 def setName(self, dinfo, full=True):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1072 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1073 Public method to set the directory name.
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 @param dinfo dinfo is the string for the directory (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1076 @param full flag indicating full pathname should be displayed (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1077 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1078 self._dirName = os.path.abspath(dinfo)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1079
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1080 if full:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1081 dn = self._dirName
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1082 else:
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1083 dn = os.path.basename(self._dirName)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1084 self.itemData[0] = dn
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1085
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1086 def dirName(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 returning the directory name.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1089
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1090 @return directory name (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1091 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1092 return self._dirName
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1093
231
2e4eb047ae93 Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 103
diff changeset
1094 def name(self):
2e4eb047ae93 Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 103
diff changeset
1095 """
2e4eb047ae93 Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 103
diff changeset
1096 Public method to return the name of the item.
2e4eb047ae93 Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 103
diff changeset
1097
2e4eb047ae93 Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 103
diff changeset
1098 @return name of the item (string)
2e4eb047ae93 Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 103
diff changeset
1099 """
2e4eb047ae93 Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 103
diff changeset
1100 return self._dirName
2e4eb047ae93 Added code to update the file browser window automatically.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 103
diff changeset
1101
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1102 def lessThan(self, other, column, order):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1103 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1104 Public method to check, if the item is less than the other one.
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 @param other reference to item to compare against (BrowserItem)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1107 @param column column number to use for the comparison (integer)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1108 @param order sort order (Qt.SortOrder) (for special sorting)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1109 @return true, if this item is less than other (boolean)
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 if issubclass(other.__class__, BrowserFileItem):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1112 if Preferences.getUI("BrowsersListFoldersFirst"):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1113 return order == Qt.AscendingOrder
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 return BrowserItem.lessThan(self, other, column, order)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1116
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 910
diff changeset
1117
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1118 class BrowserSysPathItem(BrowserItem):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1119 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1120 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
1121 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1122 def __init__(self, parent):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1123 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1124 Constructor
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 @param parent parent item
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1127 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1128 BrowserItem.__init__(self, parent, "sys.path")
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1129
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1130 self.type_ = BrowserItemSysPath
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
1131 self.icon = UI.PixmapCache.getIcon("filePython")
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1132 self._populated = False
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1133 self._lazyPopulation = True
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
1134
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
1135 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
1136 """
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
1137 Public method to return the name of the item.
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
1138
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
1139 @return name of the item (string)
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
1140 """
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
1141 return "sys.path"
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1142
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 910
diff changeset
1143
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1144 class BrowserFileItem(BrowserItem):
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1145 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1146 Class implementing the data structure for browser file items.
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1147 """
945
8cd4d08fa9f6 Made code mostly PEP 8 compliant (except all whitespace and line length).
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 910
diff changeset
1148 def __init__(self, parent, finfo, full=True, sourceLanguage=""):
0
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1149 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1150 Constructor
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1151
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1152 @param parent parent item
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1153 @param finfo the string for the file (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1154 @param full flag indicating full pathname should be displayed (boolean)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1155 @param sourceLanguage source code language of the project (string)
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1156 """
de9c2efb9d02 Started porting eric4 to Python3
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1157 BrowserItem.__init__(self,