107 @param node reference to the bookmark node to change (BookmarkNode) |
107 @param node reference to the bookmark node to change (BookmarkNode) |
108 """ |
108 """ |
109 idx = self.nodeIndex(node) |
109 idx = self.nodeIndex(node) |
110 self.dataChanged.emit(idx, idx) |
110 self.dataChanged.emit(idx, idx) |
111 |
111 |
112 def removeRows(self, row, count, parent=QModelIndex()): |
112 def removeRows(self, row, count, parent=None): |
113 """ |
113 """ |
114 Public method to remove bookmarks from the model. |
114 Public method to remove bookmarks from the model. |
115 |
115 |
116 @param row row of the first bookmark to remove (integer) |
116 @param row row of the first bookmark to remove (integer) |
117 @param count number of bookmarks to remove (integer) |
117 @param count number of bookmarks to remove (integer) |
118 @param parent index of the parent bookmark node (QModelIndex) |
118 @param parent index of the parent bookmark node (QModelIndex) |
119 @return flag indicating successful removal (boolean) |
119 @return flag indicating successful removal (boolean) |
120 """ |
120 """ |
|
121 if parent is None: |
|
122 parent = QModelIndex() |
|
123 |
121 if row < 0 or count <= 0 or row + count > self.rowCount(parent): |
124 if row < 0 or count <= 0 or row + count > self.rowCount(parent): |
122 return False |
125 return False |
123 |
126 |
124 bookmarkNode = self.node(parent) |
127 bookmarkNode = self.node(parent) |
125 children = bookmarkNode.children()[row:(row + count)] |
128 children = bookmarkNode.children()[row:(row + count)] |
200 return WebBrowser.WebBrowserWindow.WebBrowserWindow.icon( |
203 return WebBrowser.WebBrowserWindow.WebBrowserWindow.icon( |
201 QUrl(bookmarkNode.url)) |
204 QUrl(bookmarkNode.url)) |
202 |
205 |
203 return None |
206 return None |
204 |
207 |
205 def columnCount(self, parent=QModelIndex()): |
208 def columnCount(self, parent=None): |
206 """ |
209 """ |
207 Public method to get the number of columns. |
210 Public method to get the number of columns. |
208 |
211 |
209 @param parent index of parent (QModelIndex) |
212 @param parent index of parent (QModelIndex) |
210 @return number of columns (integer) |
213 @return number of columns (integer) |
211 """ |
214 """ |
|
215 if parent is None: |
|
216 parent = QModelIndex() |
|
217 |
212 if parent.column() > 0: |
218 if parent.column() > 0: |
213 return 0 |
219 return 0 |
214 else: |
220 else: |
215 return len(self.__headers) |
221 return len(self.__headers) |
216 |
222 |
217 def rowCount(self, parent=QModelIndex()): |
223 def rowCount(self, parent=None): |
218 """ |
224 """ |
219 Public method to determine the number of rows. |
225 Public method to determine the number of rows. |
220 |
226 |
221 @param parent index of parent (QModelIndex) |
227 @param parent index of parent (QModelIndex) |
222 @return number of rows (integer) |
228 @return number of rows (integer) |
223 """ |
229 """ |
|
230 if parent is None: |
|
231 parent = QModelIndex() |
|
232 |
224 if parent.column() > 0: |
233 if parent.column() > 0: |
225 return 0 |
234 return 0 |
226 |
235 |
227 if not parent.isValid(): |
236 if not parent.isValid(): |
228 return len(self.__bookmarksManager.bookmarks().children()) |
237 return len(self.__bookmarksManager.bookmarks().children()) |
229 |
238 |
230 itm = parent.internalPointer() |
239 itm = parent.internalPointer() |
231 return len(itm.children()) |
240 return len(itm.children()) |
232 |
241 |
233 def index(self, row, column, parent=QModelIndex()): |
242 def index(self, row, column, parent=None): |
234 """ |
243 """ |
235 Public method to get a model index for a node cell. |
244 Public method to get a model index for a node cell. |
236 |
245 |
237 @param row row number (integer) |
246 @param row row number (integer) |
238 @param column column number (integer) |
247 @param column column number (integer) |
239 @param parent index of the parent (QModelIndex) |
248 @param parent index of the parent (QModelIndex) |
240 @return index (QModelIndex) |
249 @return index (QModelIndex) |
241 """ |
250 """ |
|
251 if parent is None: |
|
252 parent = QModelIndex() |
|
253 |
242 if row < 0 or column < 0 or \ |
254 if row < 0 or column < 0 or \ |
243 row >= self.rowCount(parent) or column >= self.columnCount(parent): |
255 row >= self.rowCount(parent) or column >= self.columnCount(parent): |
244 return QModelIndex() |
256 return QModelIndex() |
245 |
257 |
246 parentNode = self.node(parent) |
258 parentNode = self.node(parent) |
247 return self.createIndex(row, column, parentNode.children()[row]) |
259 return self.createIndex(row, column, parentNode.children()[row]) |
248 |
260 |
249 def parent(self, index=QModelIndex()): |
261 def parent(self, index=None): |
250 """ |
262 """ |
251 Public method to get the index of the parent node. |
263 Public method to get the index of the parent node. |
252 |
264 |
253 @param index index of the child node (QModelIndex) |
265 @param index index of the child node (QModelIndex) |
254 @return index of the parent node (QModelIndex) |
266 @return index of the parent node (QModelIndex) |
255 """ |
267 """ |
|
268 if index is None: |
|
269 index = QModelIndex() |
|
270 |
256 if not index.isValid(): |
271 if not index.isValid(): |
257 return QModelIndex() |
272 return QModelIndex() |
258 |
273 |
259 itemNode = self.node(index) |
274 itemNode = self.node(index) |
260 if itemNode is None: |
275 if itemNode is None: |
269 # get the parent's row |
284 # get the parent's row |
270 grandParentNode = parentNode.parent() |
285 grandParentNode = parentNode.parent() |
271 parentRow = grandParentNode.children().index(parentNode) |
286 parentRow = grandParentNode.children().index(parentNode) |
272 return self.createIndex(parentRow, 0, parentNode) |
287 return self.createIndex(parentRow, 0, parentNode) |
273 |
288 |
274 def hasChildren(self, parent=QModelIndex()): |
289 def hasChildren(self, parent=None): |
275 """ |
290 """ |
276 Public method to check, if a parent node has some children. |
291 Public method to check, if a parent node has some children. |
277 |
292 |
278 @param parent index of the parent node (QModelIndex) |
293 @param parent index of the parent node (QModelIndex) |
279 @return flag indicating the presence of children (boolean) |
294 @return flag indicating the presence of children (boolean) |
280 """ |
295 """ |
|
296 if parent is None: |
|
297 parent = QModelIndex() |
|
298 |
281 if not parent.isValid(): |
299 if not parent.isValid(): |
282 return True |
300 return True |
283 |
301 |
284 from .BookmarkNode import BookmarkNode |
302 from .BookmarkNode import BookmarkNode |
285 parentNode = self.node(parent) |
303 parentNode = self.node(parent) |