45 #populate the list widgets and set the default selection |
45 #populate the list widgets and set the default selection |
46 for widget in self.localsList, self.globalsList: |
46 for widget in self.localsList, self.globalsList: |
47 for varType, varTypeStr in ConfigVarTypeDispStrings.items(): |
47 for varType, varTypeStr in ConfigVarTypeDispStrings.items(): |
48 itm = QListWidgetItem(self.tr(varTypeStr), widget) |
48 itm = QListWidgetItem(self.tr(varTypeStr), widget) |
49 itm.setData(Qt.UserRole, ConfigVarTypeFilters[varType]) |
49 itm.setData(Qt.UserRole, ConfigVarTypeFilters[varType]) |
|
50 itm.setFlags(Qt.ItemIsEnabled | Qt.ItemIsUserCheckable | |
|
51 Qt.ItemNeverHasChildren) |
|
52 itm.setCheckState(Qt.Unchecked) |
50 widget.addItem(itm) |
53 widget.addItem(itm) |
51 |
54 |
52 lDefaultFilter, gDefaultFilter = Preferences.getVarFilters() |
55 lDefaultFilter, gDefaultFilter = Preferences.getVarFilters() |
53 self.setSelection(lDefaultFilter, gDefaultFilter) |
56 self.setSelection(lDefaultFilter, gDefaultFilter) |
54 |
57 |
60 locals variables filter, the second the globals variables filter. |
63 locals variables filter, the second the globals variables filter. |
61 """ |
64 """ |
62 lList = [] |
65 lList = [] |
63 for row in range(self.localsList.count()): |
66 for row in range(self.localsList.count()): |
64 itm = self.localsList.item(row) |
67 itm = self.localsList.item(row) |
65 if itm.isSelected(): |
68 if itm.checkState() == Qt.Unchecked: |
66 lList.append(itm.data(Qt.UserRole)) |
69 lList.append(itm.data(Qt.UserRole)) |
67 |
70 |
68 gList = [] |
71 gList = [] |
69 for row in range(self.globalsList.count()): |
72 for row in range(self.globalsList.count()): |
70 itm = self.globalsList.item(row) |
73 itm = self.globalsList.item(row) |
71 if itm.isSelected(): |
74 if itm.checkState() == Qt.Unchecked: |
72 gList.append(itm.data(Qt.UserRole)) |
75 gList.append(itm.data(Qt.UserRole)) |
73 return (lList, gList) |
76 return (lList, gList) |
74 |
77 |
75 def setSelection(self, lList, gList): |
78 def setSelection(self, lList, gList): |
76 """ |
79 """ |
79 @param lList local variables filter (list of int) |
82 @param lList local variables filter (list of int) |
80 @param gList global variables filter (list of int) |
83 @param gList global variables filter (list of int) |
81 """ |
84 """ |
82 for row in range(self.localsList.count()): |
85 for row in range(self.localsList.count()): |
83 itm = self.localsList.item(row) |
86 itm = self.localsList.item(row) |
84 itm.setSelected(itm.data(Qt.UserRole) in lList) |
87 if itm.data(Qt.UserRole) in lList: |
|
88 itm.setCheckState(Qt.Unchecked) |
|
89 else: |
|
90 itm.setCheckState(Qt.Checked) |
85 |
91 |
86 for row in range(self.globalsList.count()): |
92 for row in range(self.globalsList.count()): |
87 itm = self.globalsList.item(row) |
93 itm = self.globalsList.item(row) |
88 itm.setSelected(itm.data(Qt.UserRole) in gList) |
94 if itm.data(Qt.UserRole) in gList: |
|
95 itm.setCheckState(Qt.Unchecked) |
|
96 else: |
|
97 itm.setCheckState(Qt.Checked) |
89 |
98 |
90 def on_buttonBox_clicked(self, button): |
99 def on_buttonBox_clicked(self, button): |
91 """ |
100 """ |
92 Private slot called by a button of the button box clicked. |
101 Private slot called by a button of the button box clicked. |
93 |
102 |