Debugger/VariablesFilterDialog.py

changeset 0
de9c2efb9d02
child 12
1d8dd9706f46
equal deleted inserted replaced
-1:000000000000 0:de9c2efb9d02
1 # -*- coding: utf-8 -*-
2
3 # Copyright (c) 2002 - 2009 Detlev Offenbach <detlev@die-offenbachs.de>
4 #
5
6 """
7 Module implementing the variables filter dialog.
8 """
9
10 from PyQt4.QtCore import *
11 from PyQt4.QtGui import *
12
13 from Debugger.Config import ConfigVarTypeDispStrings
14 import Preferences
15
16 from Ui_VariablesFilterDialog import Ui_VariablesFilterDialog
17
18
19 class VariablesFilterDialog(QDialog, Ui_VariablesFilterDialog):
20 """
21 Class implementing the variables filter dialog.
22
23 It opens a dialog window for the configuration of the variables type
24 filter to be applied during a debugging session.
25 """
26 def __init__(self, parent = None, name = None, modal = False):
27 """
28 Constructor
29
30 @param parent parent widget of this dialog (QWidget)
31 @param name name of this dialog (string)
32 @param modal flag to indicate a modal dialog (boolean)
33 """
34 QDialog.__init__(self,parent)
35 if name:
36 self.setObjectName(name)
37 self.setModal(modal)
38 self.setupUi(self)
39
40 self.defaultButton = self.buttonBox.addButton(\
41 self.trUtf8("Save Default"), QDialogButtonBox.ActionRole)
42
43 lDefaultFilter, gDefaultFilter = Preferences.getVarFilters()
44
45 #populate the listboxes and set the default selection
46 for lb in self.localsList, self.globalsList:
47 for ts in ConfigVarTypeDispStrings:
48 lb.addItem(self.trUtf8(ts))
49
50 for filterIndex in lDefaultFilter:
51 itm = self.localsList.item(filterIndex)
52 self.localsList.setItemSelected(itm, True)
53 for filterIndex in gDefaultFilter:
54 itm = self.globalsList.item(filterIndex)
55 self.globalsList.setItemSelected(itm, True)
56
57 def getSelection(self):
58 """
59 Public slot to retrieve the current selections.
60
61 @return A tuple of lists of integer values. The first list is the locals variables
62 filter, the second the globals variables filter.
63 """
64 lList = []
65 gList = []
66 for i in range(self.localsList.count()):
67 itm = self.localsList.item(i)
68 if self.localsList.isItemSelected(itm):
69 lList.append(i)
70 for i in range(self.globalsList.count()):
71 itm = self.globalsList.item(i)
72 if self.globalsList.isItemSelected(itm):
73 gList.append(i)
74 return (lList, gList)
75
76 def setSelection(self, lList, gList):
77 """
78 Public slot to set the current selection.
79
80 @param lList local variables filter (list of int)
81 @param gList global variables filter (list of int)
82 """
83 for filterIndex in lList:
84 itm = self.localsList.item(filterIndex)
85 self.localsList.setItemSelected(itm, True)
86 for filterIndex in gList:
87 itm = self.globalsList.item(filterIndex)
88 self.globalsList.setItemSelected(itm, True)
89
90 def on_buttonBox_clicked(self, button):
91 """
92 Private slot called by a button of the button box clicked.
93
94 @param button button that was clicked (QAbstractButton)
95 """
96 if button == self.defaultButton:
97 Preferences.setVarFilters(self.getSelection())

eric ide

mercurial