eric6/DataViews/PyProfileDialog.py

changeset 8143
2c730d5fd177
parent 7923
91e843545d9a
child 8207
d359172d11be
equal deleted inserted replaced
8141:27f636beebad 8143:2c730d5fd177
63 63
64 @param parent parent widget (QWidget) 64 @param parent parent widget (QWidget)
65 """ 65 """
66 super(PyProfileDialog, self).__init__(parent) 66 super(PyProfileDialog, self).__init__(parent)
67 self.setupUi(self) 67 self.setupUi(self)
68 self.setWindowFlags(Qt.Window) 68 self.setWindowFlags(Qt.WindowType.Window)
69 69
70 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) 70 self.buttonBox.button(
71 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) 71 QDialogButtonBox.StandardButton.Close).setEnabled(False)
72 self.buttonBox.button(
73 QDialogButtonBox.StandardButton.Cancel).setDefault(True)
72 74
73 self.cancelled = False 75 self.cancelled = False
74 self.exclude = True 76 self.exclude = True
75 self.ericpath = os.path.dirname( 77 self.ericpath = os.path.dirname(
76 os.path.dirname(os.path.abspath(__file__))) 78 os.path.dirname(os.path.abspath(__file__)))
77 self.pyLibPath = Utilities.getPythonLibPath() 79 self.pyLibPath = Utilities.getPythonLibPath()
78 80
79 self.summaryList.headerItem().setText( 81 self.summaryList.headerItem().setText(
80 self.summaryList.columnCount(), "") 82 self.summaryList.columnCount(), "")
81 self.resultList.headerItem().setText(self.resultList.columnCount(), "") 83 self.resultList.headerItem().setText(self.resultList.columnCount(), "")
82 self.resultList.header().setSortIndicator(0, Qt.DescendingOrder) 84 self.resultList.header().setSortIndicator(
85 0, Qt.SortOrder.DescendingOrder)
83 86
84 self.__menu = QMenu(self) 87 self.__menu = QMenu(self)
85 self.filterItm = self.__menu.addAction( 88 self.filterItm = self.__menu.addAction(
86 self.tr('Exclude Python Library'), 89 self.tr('Exclude Python Library'),
87 self.__filter) 90 self.__filter)
90 self.tr('Erase Profiling Info'), self.__eraseProfile) 93 self.tr('Erase Profiling Info'), self.__eraseProfile)
91 self.__menu.addAction( 94 self.__menu.addAction(
92 self.tr('Erase Timing Info'), self.__eraseTiming) 95 self.tr('Erase Timing Info'), self.__eraseTiming)
93 self.__menu.addSeparator() 96 self.__menu.addSeparator()
94 self.__menu.addAction(self.tr('Erase All Infos'), self.__eraseAll) 97 self.__menu.addAction(self.tr('Erase All Infos'), self.__eraseAll)
95 self.resultList.setContextMenuPolicy(Qt.CustomContextMenu) 98 self.resultList.setContextMenuPolicy(
99 Qt.ContextMenuPolicy.CustomContextMenu)
96 self.resultList.customContextMenuRequested.connect( 100 self.resultList.customContextMenuRequested.connect(
97 self.__showContextMenu) 101 self.__showContextMenu)
98 self.summaryList.setContextMenuPolicy(Qt.CustomContextMenu) 102 self.summaryList.setContextMenuPolicy(
103 Qt.ContextMenuPolicy.CustomContextMenu)
99 self.summaryList.customContextMenuRequested.connect( 104 self.summaryList.customContextMenuRequested.connect(
100 self.__showContextMenu) 105 self.__showContextMenu)
101 106
102 def __createResultItem(self, calls, totalTime, totalTimePerCall, 107 def __createResultItem(self, calls, totalTime, totalTimePerCall,
103 cumulativeTime, cumulativeTimePerCall, file, line, 108 cumulativeTime, cumulativeTimePerCall, file, line,
123 file, 128 file,
124 str(line), 129 str(line),
125 functionName 130 functionName
126 ]) 131 ])
127 for col in [0, 1, 2, 3, 4, 6]: 132 for col in [0, 1, 2, 3, 4, 6]:
128 itm.setTextAlignment(col, Qt.AlignRight) 133 itm.setTextAlignment(col, Qt.AlignmentFlag.AlignRight)
129 134
130 def __createSummaryItem(self, label, contents): 135 def __createSummaryItem(self, label, contents):
131 """ 136 """
132 Private method to create an entry in the summary list. 137 Private method to create an entry in the summary list.
133 138
134 @param label text of the first column (string) 139 @param label text of the first column (string)
135 @param contents text of the second column (string) 140 @param contents text of the second column (string)
136 """ 141 """
137 itm = QTreeWidgetItem(self.summaryList, [label, contents]) 142 itm = QTreeWidgetItem(self.summaryList, [label, contents])
138 itm.setTextAlignment(1, Qt.AlignRight) 143 itm.setTextAlignment(1, Qt.AlignmentFlag.AlignRight)
139 144
140 def __resortResultList(self): 145 def __resortResultList(self):
141 """ 146 """
142 Private method to resort the tree. 147 Private method to resort the tree.
143 """ 148 """
260 """ 265 """
261 Private slot called when the action finished or the user pressed the 266 Private slot called when the action finished or the user pressed the
262 button. 267 button.
263 """ 268 """
264 self.cancelled = True 269 self.cancelled = True
265 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(True) 270 self.buttonBox.button(
266 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False) 271 QDialogButtonBox.StandardButton.Close).setEnabled(True)
267 self.buttonBox.button(QDialogButtonBox.Close).setDefault(True) 272 self.buttonBox.button(
273 QDialogButtonBox.StandardButton.Cancel).setEnabled(False)
274 self.buttonBox.button(
275 QDialogButtonBox.StandardButton.Close).setDefault(True)
268 QApplication.processEvents() 276 QApplication.processEvents()
269 self.resultList.header().resizeSections(QHeaderView.ResizeToContents) 277 self.resultList.header().resizeSections(
278 QHeaderView.ResizeMode.ResizeToContents)
270 self.resultList.header().setStretchLastSection(True) 279 self.resultList.header().setStretchLastSection(True)
271 self.summaryList.header().resizeSections(QHeaderView.ResizeToContents) 280 self.summaryList.header().resizeSections(
281 QHeaderView.ResizeMode.ResizeToContents)
272 self.summaryList.header().setStretchLastSection(True) 282 self.summaryList.header().setStretchLastSection(True)
273 283
274 def __unfinish(self): 284 def __unfinish(self):
275 """ 285 """
276 Private slot called to revert the effects of the __finish slot. 286 Private slot called to revert the effects of the __finish slot.
277 """ 287 """
278 self.cancelled = False 288 self.cancelled = False
279 self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False) 289 self.buttonBox.button(
280 self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True) 290 QDialogButtonBox.StandardButton.Close).setEnabled(False)
281 self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True) 291 self.buttonBox.button(
292 QDialogButtonBox.StandardButton.Cancel).setEnabled(True)
293 self.buttonBox.button(
294 QDialogButtonBox.StandardButton.Cancel).setDefault(True)
282 295
283 def on_buttonBox_clicked(self, button): 296 def on_buttonBox_clicked(self, button):
284 """ 297 """
285 Private slot called by a button of the button box clicked. 298 Private slot called by a button of the button box clicked.
286 299
287 @param button button that was clicked (QAbstractButton) 300 @param button button that was clicked (QAbstractButton)
288 """ 301 """
289 if button == self.buttonBox.button(QDialogButtonBox.Close): 302 if button == self.buttonBox.button(
303 QDialogButtonBox.StandardButton.Close
304 ):
290 self.close() 305 self.close()
291 elif button == self.buttonBox.button(QDialogButtonBox.Cancel): 306 elif button == self.buttonBox.button(
307 QDialogButtonBox.StandardButton.Cancel
308 ):
292 self.__finish() 309 self.__finish()
293 310
294 def __showContextMenu(self, coord): 311 def __showContextMenu(self, coord):
295 """ 312 """
296 Private slot to show the context menu of the listview. 313 Private slot to show the context menu of the listview.

eric ide

mercurial