Commits

Kimmo Varis committed 45f041d

Add a dialog showing plain results got from Cppcheck.

Seeing what Cppcheck actually returned is a nice problem solving aid.

Comments (0)

Files changed (6)

src/cppcheckresultsdialog.py

+import sys
+from PyQt4 import QtCore, QtGui
+from ui.cppcheckresultsdialog import Ui_dlgCppcheckResults
+ 
+class CppcheckResultsDialog(QtGui.QDialog):
+    '''The Results-dialog showing the results Cppcheck returned.'''
+
+    def __init__(self, parent=None):
+        QtGui.QDialog.__init__(self, parent)
+        self.ui = Ui_dlgCppcheckResults()
+        self.ui.setupUi(self)
+        self.results = ''
+        
+    def updateresults(self, results):
+        '''Update the Cppcheck results into the dialog edit control.'''
+
+        self.results = results
+        self.ui.editCppcheckResults.setPlainText(self.results)
+        
+
+if __name__ == "__main__":
+      app = QtGui.QApplication(sys.argv)
+      myapp = CppcheckResultsDialog()
+      myapp.show()
+      sys.exit(app.exec_())

src/mainwindow.py

 from PyQt4 import QtCore, QtGui
 from ui.mainwindow import Ui_MainWindow
 from aboutdialog import AboutDialog
+from cppcheckresultsdialog import CppcheckResultsDialog
 import runcppcheck
 import error
  
         QtGui.QMainWindow.__init__(self, parent)
         self.ui = Ui_MainWindow()
         self.ui.setupUi(self)
+        self.results = []
+        self.cppcheckout = ''
         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)
         QtCore.QObject.connect(self.ui.actionCheck_file, QtCore.SIGNAL("triggered()"), self.checkfile)
+        QtCore.QObject.connect(self.ui.actionCppcheck_results, QtCore.SIGNAL("triggered()"), self.showcppcheckresults)
         
     def showabout(self):
         '''Show the About-dialog.'''
         runner.setcppcheckpath(runcppcheck.cppcheck_path)
         runner.runcppcheck(path)
         runner.parseresults()
-        results = runner.getresults()
+        self.results = runner.getresults()
+        self.cppcheckout = runner.getcppcheckout()
+        
+    def showcppcheckresults(self):
+        '''Show Cppcheck output in the dialog.'''
+
+        self.cppcheckresultsdlg = CppcheckResultsDialog(self)
+        self.cppcheckresultsdlg.updateresults(self.cppcheckout)
+        self.cppcheckresultsdlg.show()
 
 
 if __name__ == "__main__":

src/runcppcheck.py

             
     def getresults(self):
         '''Return a list of errors.'''
+        return self.results
         
-        return self.results
+    def getcppcheckout(self):
+        '''Return output of Cppcheck.'''
+        return self.errout
 
     def dumperrors(self):
         '''Write the errors to the console.'''

src/ui/cppcheckresultsdialog.ui

+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>dlgCppcheckResults</class>
+ <widget class="QDialog" name="dlgCppcheckResults">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>400</width>
+    <height>300</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Cppcheck Results</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <widget class="QPlainTextEdit" name="editCppcheckResults">
+     <property name="undoRedoEnabled">
+      <bool>false</bool>
+     </property>
+     <property name="readOnly">
+      <bool>true</bool>
+     </property>
+    </widget>
+   </item>
+   <item>
+    <widget class="QDialogButtonBox" name="buttonBox">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="standardButtons">
+      <set>QDialogButtonBox::Close</set>
+     </property>
+    </widget>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>accepted()</signal>
+   <receiver>dlgCppcheckResults</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>248</x>
+     <y>254</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>157</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>buttonBox</sender>
+   <signal>rejected()</signal>
+   <receiver>dlgCppcheckResults</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>316</x>
+     <y>260</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>286</x>
+     <y>274</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>

src/ui/mainwindow.ui

     </property>
     <addaction name="action_About_Cppcheck_GUI"/>
    </widget>
+   <widget class="QMenu" name="menu_View">
+    <property name="title">
+     <string>&amp;View</string>
+    </property>
+    <addaction name="actionCppcheck_results"/>
+   </widget>
    <addaction name="menu_File"/>
+   <addaction name="menu_View"/>
    <addaction name="menu_About"/>
   </widget>
   <widget class="QStatusBar" name="statusbar"/>
     <string>Ch&amp;eck file...</string>
    </property>
   </action>
+  <action name="actionCppcheck_results">
+   <property name="text">
+    <string>&amp;Cppcheck results</string>
+   </property>
+  </action>
  </widget>
  <resources/>
  <connections/>

src/ui/update.bat

 
 call %PYUIC4BIN% mainwindow.ui -o mainwindow.py
 call %PYUIC4BIN% aboutdialog.ui -o aboutdialog.py
+call %PYUIC4BIN% cppcheckresultsdialog.ui -o cppcheckresultsdialog.py