39 self.setupUi(self) |
40 self.setupUi(self) |
40 |
41 |
41 self.defaultButton = self.buttonBox.addButton( |
42 self.defaultButton = self.buttonBox.addButton( |
42 self.tr("Save Default"), QDialogButtonBox.ActionRole) |
43 self.tr("Save Default"), QDialogButtonBox.ActionRole) |
43 |
44 |
|
45 #populate the list widgets and set the default selection |
|
46 for widget in self.localsList, self.globalsList: |
|
47 for varType, varTypeStr in ConfigVarTypeDispStrings.items(): |
|
48 itm = QListWidgetItem(self.tr(varTypeStr), widget) |
|
49 itm.setData(Qt.UserRole, ConfigVarTypeFilters[varType]) |
|
50 widget.addItem(itm) |
|
51 |
44 lDefaultFilter, gDefaultFilter = Preferences.getVarFilters() |
52 lDefaultFilter, gDefaultFilter = Preferences.getVarFilters() |
45 |
53 self.setSelection(lDefaultFilter, gDefaultFilter) |
46 #populate the listboxes and set the default selection |
|
47 for lb in self.localsList, self.globalsList: |
|
48 for ts in ConfigVarTypeDispStrings: |
|
49 lb.addItem(self.tr(ts)) |
|
50 |
|
51 for filterIndex in lDefaultFilter: |
|
52 itm = self.localsList.item(filterIndex) |
|
53 itm.setSelected(True) |
|
54 for filterIndex in gDefaultFilter: |
|
55 itm = self.globalsList.item(filterIndex) |
|
56 itm.setSelected(True) |
|
57 |
54 |
58 def getSelection(self): |
55 def getSelection(self): |
59 """ |
56 """ |
60 Public slot to retrieve the current selections. |
57 Public slot to retrieve the current selections. |
61 |
58 |
62 @return A tuple of lists of integer values. The first list is the |
59 @return A tuple of lists of integer values. The first list is the |
63 locals variables filter, the second the globals variables filter. |
60 locals variables filter, the second the globals variables filter. |
64 """ |
61 """ |
65 lList = [] |
62 lList = [] |
66 gList = [] |
|
67 for row in range(self.localsList.count()): |
63 for row in range(self.localsList.count()): |
68 itm = self.localsList.item(row) |
64 itm = self.localsList.item(row) |
69 if itm.isSelected(): |
65 if itm.isSelected(): |
70 lList.append(row) |
66 lList.append(itm.data(Qt.UserRole)) |
|
67 |
|
68 gList = [] |
71 for row in range(self.globalsList.count()): |
69 for row in range(self.globalsList.count()): |
72 itm = self.globalsList.item(row) |
70 itm = self.globalsList.item(row) |
73 if itm.isSelected(): |
71 if itm.isSelected(): |
74 gList.append(row) |
72 gList.append(itm.data(Qt.UserRole)) |
75 return (lList, gList) |
73 return (lList, gList) |
76 |
74 |
77 def setSelection(self, lList, gList): |
75 def setSelection(self, lList, gList): |
78 """ |
76 """ |
79 Public slot to set the current selection. |
77 Public slot to set the current selection. |
80 |
78 |
81 @param lList local variables filter (list of int) |
79 @param lList local variables filter (list of int) |
82 @param gList global variables filter (list of int) |
80 @param gList global variables filter (list of int) |
83 """ |
81 """ |
84 for row in range(self.localsList.count()): |
82 for row in range(self.localsList.count()): |
85 itm = self.localsList.item(row) |
83 itm = self.localsList.item(row) |
86 itm.setSelected(row in lList) |
84 itm.setSelected(itm.data(Qt.UserRole) in lList) |
|
85 |
87 for row in range(self.globalsList.count()): |
86 for row in range(self.globalsList.count()): |
88 itm = self.globalsList.item(row) |
87 itm = self.globalsList.item(row) |
89 itm.setSelected(row in gList) |
88 itm.setSelected(itm.data(Qt.UserRole) in gList) |
90 |
89 |
91 def on_buttonBox_clicked(self, button): |
90 def on_buttonBox_clicked(self, button): |
92 """ |
91 """ |
93 Private slot called by a button of the button box clicked. |
92 Private slot called by a button of the button box clicked. |
94 |
93 |