Commits

Kimmo Varis committed 840cb2f

Adding real results to the treeview.

Adding real results from the checked file to the tree. However I'm
still missing something as the treeview doesn't refresh itself.

  • Participants
  • Parent commits a0dc800

Comments (0)

Files changed (3)

src/mainwindow.py

         self.results = []
         self.cppcheckout = ''
         self.cppcheckresultsdlg = None
-        centralWidget = ResultsWidget()
-        self.setCentralWidget(centralWidget)
+        self.centralWidget = ResultsWidget()
+        self.setCentralWidget(self.centralWidget)
         
         QtCore.QObject.connect(self.ui.actionE_xit, QtCore.SIGNAL("triggered()"), self.close)
         QtCore.QObject.connect(self.ui.action_About_Cppcheck_GUI, QtCore.SIGNAL("triggered()"), self.showabout)
         self.results = runner.getresults()
         self.cppcheckout = runner.getcppcheckout()
         
+        for result in self.results:
+            self.centralWidget.adderror(result)
+        
     def showcppcheckresults(self):
         '''Show Cppcheck output in the dialog.'''
 

src/resultstreemodel.py

         self.rootItem = resultstreeitem.TreeItem(None, "ALL", None)
         self.parents = {0 : self.rootItem}
         
-        for eid, emsg, etype in (('id1','My error1', 0), 
-                ('id2', 'My error2', 1), ('Id3', 'My error3', 0)):
-            err = error.Error(id=eid, msg=emsg, etype=etype)
-            self.errors.append(err)
+        #for eid, emsg, etype in (('id1','My error1', 0), 
+        #        ('id2', 'My error2', 1), ('Id3', 'My error3', 0)):
+        #    err = error.Error(id=eid, msg=emsg, etype=etype)
+        #    self.errors.append(err)
             
-        self.setupModelData()
+        #self.setupModelData()
 
     def columnCount(self, parent=None):
         if parent and parent.isValid():
 
     def setupModelData(self):
         for err in self.errors:
-            if err.etype == 0:
-                etype = "Errors"
-            else:
-                etype = "Information"
-            
-            if not etype in self.parents.keys():                
-                newparent = resultstreeitem.TreeItem(None, etype, self.rootItem)
-                self.rootItem.appendChild(newparent)
+            self.addError(err)
 
-                self.parents[etype] = newparent
+    def internalAddError(self, error):
+        if error.etype == 0:
+            etype = "Errors"
+        else:
+            etype = "Information"
+        
+        if not etype in self.parents.keys():                
+            newparent = resultstreeitem.TreeItem(None, etype, self.rootItem)
+            self.rootItem.appendChild(newparent)
 
-            parentItem = self.parents[etype]
-            newItem = resultstreeitem.TreeItem(err, "", parentItem)
-            parentItem.appendChild(newItem)
+            self.parents[etype] = newparent
+
+        parentItem = self.parents[etype]
+        newItem = resultstreeitem.TreeItem(error, "", parentItem)
+        parentItem.appendChild(newItem)
+        
+    def addError(self, error):
+        self.errors.append(error)
+        self.internalAddError(error)

src/resultswidget.py

         self.model = resultstreemodel.TreeModel()
         self.ui.resultsTree.setModel(self.model)
         self.ui.resultsTree.setAlternatingRowColors(True)
+
+    def adderror(self, error):
+        self.model.addError(error)