UI/BrowserModel.py

changeset 5656
9c21b2746218
parent 5624
cdd346d8858b
child 5708
9b01b4004314
--- a/UI/BrowserModel.py	Thu Mar 23 18:58:56 2017 +0100
+++ b/UI/BrowserModel.py	Thu Mar 23 19:06:13 2017 +0100
@@ -68,13 +68,16 @@
             
             self.__populateModel()
     
-    def columnCount(self, parent=QModelIndex()):
+    def columnCount(self, parent=None):
         """
         Public method to get the number of columns.
         
         @param parent index of parent item (QModelIndex)
         @return number of columns (integer)
         """
+        if parent is None:
+            parent = QModelIndex()
+        
         if parent.isValid():
             item = parent.internalPointer()
         else:
@@ -143,7 +146,7 @@
         
         return None
     
-    def index(self, row, column, parent=QModelIndex()):
+    def index(self, row, column, parent=None):
         """
         Public method to create an index.
         
@@ -152,6 +155,9 @@
         @param parent index of parent item (QModelIndex)
         @return index object (QModelIndex)
         """
+        if parent is None:
+            parent = QModelIndex()
+        
         # The model/view framework considers negative values out-of-bounds,
         # however in python they work when indexing into lists. So make sure
         # we return an invalid index for out-of-bounds row/col
@@ -193,13 +199,16 @@
         
         return self.createIndex(parentItem.row(), 0, parentItem)
     
-    def rowCount(self, parent=QModelIndex()):
+    def rowCount(self, parent=None):
         """
         Public method to get the number of rows.
         
         @param parent index of parent item (QModelIndex)
         @return number of rows (integer)
         """
+        if parent is None:
+            parent = QModelIndex()
+        
         # Only the first column should have children
         if parent.column() > 0:
             return 0
@@ -213,7 +222,7 @@
         
         return parentItem.childCount()
 
-    def hasChildren(self, parent=QModelIndex()):
+    def hasChildren(self, parent=None):
         """
         Public method to check for the presence of child items.
         
@@ -223,6 +232,9 @@
         @param parent index of parent item (QModelIndex)
         @return flag indicating the presence of child items (boolean)
         """
+        if parent is None:
+            parent = QModelIndex()
+        
         # Only the first column should have children
         if parent.column() > 0:
             return 0
@@ -483,13 +495,16 @@
         """
         parentItem.appendChild(itm)
     
-    def addItem(self, itm, parent=QModelIndex()):
+    def addItem(self, itm, parent=None):
         """
         Public slot to add an item.
         
         @param itm item to add (BrowserItem)
         @param parent index of parent item (QModelIndex)
         """
+        if parent is None:
+            parent = QModelIndex()
+        
         if not parent.isValid():
             parentItem = self.rootItem
         else:

eric ide

mercurial