42 Qt.Alignment(Qt.AlignHCenter), |
42 Qt.Alignment(Qt.AlignHCenter), |
43 Qt.Alignment(Qt.AlignRight), |
43 Qt.Alignment(Qt.AlignRight), |
44 Qt.Alignment(Qt.AlignHCenter), |
44 Qt.Alignment(Qt.AlignHCenter), |
45 ] |
45 ] |
46 |
46 |
47 def columnCount(self, parent=QModelIndex()): |
47 def columnCount(self, parent=None): |
48 """ |
48 """ |
49 Public method to get the current column count. |
49 Public method to get the current column count. |
50 |
50 |
51 @param parent reference to parent index (QModelIndex) |
51 @param parent reference to parent index (QModelIndex) (Unused) |
52 @return column count (integer) |
52 @return column count (integer) |
53 """ |
53 """ |
54 return len(self.header) |
54 return len(self.header) |
55 |
55 |
56 def rowCount(self, parent=QModelIndex()): |
56 def rowCount(self, parent=None): |
57 """ |
57 """ |
58 Public method to get the current row count. |
58 Public method to get the current row count. |
59 |
59 |
60 @param parent reference to parent index (QModelIndex) |
60 @param parent reference to parent index (QModelIndex) |
61 @return row count (integer) |
61 @return row count (integer) |
62 """ |
62 """ |
63 # we do not have a tree, parent should always be invalid |
63 # we do not have a tree, parent should always be invalid |
64 if not parent.isValid(): |
64 if parent is None or not parent.isValid(): |
65 return len(self.breakpoints) |
65 return len(self.breakpoints) |
66 else: |
66 else: |
67 return 0 |
67 return 0 |
68 |
68 |
69 def data(self, index, role=Qt.DisplayRole): |
69 def data(self, index, role=Qt.DisplayRole): |
141 else: |
141 else: |
142 return self.header[section] |
142 return self.header[section] |
143 |
143 |
144 return None |
144 return None |
145 |
145 |
146 def index(self, row, column, parent=QModelIndex()): |
146 def index(self, row, column, parent=None): |
147 """ |
147 """ |
148 Public method to create an index. |
148 Public method to create an index. |
149 |
149 |
150 @param row row number for the index (integer) |
150 @param row row number for the index (integer) |
151 @param column column number for the index (integer) |
151 @param column column number for the index (integer) |
152 @param parent index of the parent item (QModelIndex) |
152 @param parent index of the parent item (QModelIndex) |
153 @return requested index (QModelIndex) |
153 @return requested index (QModelIndex) |
154 """ |
154 """ |
155 if parent.isValid() or \ |
155 if (parent and parent.isValid()) or \ |
156 row < 0 or row >= len(self.breakpoints) or \ |
156 row < 0 or row >= len(self.breakpoints) or \ |
157 column < 0 or column >= len(self.header): |
157 column < 0 or column >= len(self.header): |
158 return QModelIndex() |
158 return QModelIndex() |
159 |
159 |
160 return self.createIndex(row, column, self.breakpoints[row]) |
160 return self.createIndex(row, column, self.breakpoints[row]) |
166 @param index index of item to get parent (QModelIndex) |
166 @param index index of item to get parent (QModelIndex) |
167 @return index of parent (QModelIndex) |
167 @return index of parent (QModelIndex) |
168 """ |
168 """ |
169 return QModelIndex() |
169 return QModelIndex() |
170 |
170 |
171 def hasChildren(self, parent=QModelIndex()): |
171 def hasChildren(self, parent=None): |
172 """ |
172 """ |
173 Public method to check for the presence of child items. |
173 Public method to check for the presence of child items. |
174 |
174 |
175 @param parent index of parent item (QModelIndex) |
175 @param parent index of parent item (QModelIndex) |
176 @return flag indicating the presence of child items (boolean) |
176 @return flag indicating the presence of child items (boolean) |
177 """ |
177 """ |
178 if not parent.isValid(): |
178 if parent is None or not parent.isValid(): |
179 return len(self.breakpoints) > 0 |
179 return len(self.breakpoints) > 0 |
180 else: |
180 else: |
181 return False |
181 return False |
182 |
182 |
183 ########################################################################### |
183 ########################################################################### |