[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    playground/devtools/kdevelop4-extra-plugins/coverage
From:       Daniel Calviño Sánchez <danxuliu () gmail ! com>
Date:       2011-09-06 18:12:01
Message-ID: 20110906181201.C9EA9AC87D () svn ! kde ! org
[Download RAW message or body]

SVN commit 1251782 by danxuliu:

Add a button to remove coverage data. The button starts a job that removes the gcda \
files from the specified directory and, recursively, its subdirectories.

 M  +1 -0      CMakeLists.txt  
 AM            removegcdafilesjob.cpp   [License: GPL (v2+)]
 AM            removegcdafilesjob.h   [License: GPL (v2+)]
 M  +62 -1     reportwidget.cpp  
 M  +37 -1     reportwidget.h  
 M  +7 -0      reportwidget.ui  
 M  +2 -0      tests/CMakeLists.txt  
 AM            tests/removegcdafilesjobtest.cpp   [License: GPL (v2+)]
 AM            tests/removegcdafilesjobtest.h   [License: GPL (v2+)]


--- trunk/playground/devtools/kdevelop4-extra-plugins/coverage/CMakeLists.txt \
#1251781:1251782 @@ -39,6 +39,7 @@
     discretecolorrange.cpp
     gradientcolorrange.cpp
     buildpathselection.cpp
+    removegcdafilesjob.cpp
     tests/viewstub.cpp
     tests/pluginstub.cpp)
 
--- trunk/playground/devtools/kdevelop4-extra-plugins/coverage/reportwidget.cpp \
#1251781:1251782 @@ -29,12 +29,14 @@
 #include "lcovinfoparser.h"
 #include "lcovjob.h"
 #include "covoutputdelegate.h"
+#include "removegcdafilesjob.h"
 #include "ui_reportwidget.h"
 
 #include <QTimer>
 #include <KLocale>
 #include <KComboBox>
 #include <KIcon>
+#include <KMessageBox>
 #include <KProcess>
 #include <KUrlNavigator>
 
@@ -61,6 +63,7 @@
 using Veritas::DrillDownView;
 using Veritas::LcovInfoParser;
 using Veritas::LcovJob;
+using Veritas::RemoveGcdaFilesJob;
 using Veritas::ReportWidget;
 using Veritas::ReportDirData;
 using Veritas::ReportModel;
@@ -119,6 +122,9 @@
     setStartLcovJobButton();
     connect(m_ui->lcovJobButton, SIGNAL(clicked(bool)), SLOT(startOrStopLcovJob()));
     
+    setStartRemoveGcdaFilesJobButton();
+    connect(m_ui->removeGcdaFilesJobButton, SIGNAL(clicked(bool)), \
SLOT(startOrStopRemoveGcdaFilesJob())); +
     connect(table(), SIGNAL(doubleClicked(QModelIndex)),
             SLOT(dispatchDoubleClickedSignal(QModelIndex)));
 
@@ -388,13 +394,20 @@
     job->setParser(parser);
 
     ICore::self()->runController()->registerJob(job);
-    connect(job, SIGNAL(finished(KJob*)), SLOT(setStartLcovJobButton()));
+    connect(job, SIGNAL(finished(KJob*)), SLOT(updateStateWhenLcovJobFinishes()));
 
     m_lcovJob = job;
 
     setStopLcovJobButton();
+    m_ui->removeGcdaFilesJobButton->setEnabled(false);
 }
 
+void ReportWidget::updateStateWhenLcovJobFinishes()
+{
+    setStartLcovJobButton();
+    m_ui->removeGcdaFilesJobButton->setEnabled(true);
+}
+
 void ReportWidget::setStartLcovJobButton()
 {
     m_ui->lcovJobButton->setToolTip(i18nc("@info:tooltip", "Start coverage \
analysis")); @@ -410,6 +423,54 @@
     m_ui->lcovJobButton->setIcon(KIcon("process-stop"));
 }
 
+void ReportWidget::startOrStopRemoveGcdaFilesJob()
+{
+    if (!m_removeGcdaFilesJob) {
+        if (KMessageBox::warningContinueCancel(this, i18nc("@info", "Remove all the \
.gcda files in <filename>%1</filename> directory and, recursively, in its \
subdirectories?", m_targetDirectory->url().toLocalFile()), +                          \
i18nc("@title:window", "Remove .gcda files")) == KMessageBox::Continue) { +           \
startRemoveGcdaFilesJob(); +        }
+    } else {
+        m_removeGcdaFilesJob->kill(KJob::EmitResult);
+    }
+}
+
+void ReportWidget::startRemoveGcdaFilesJob()
+{
+    Q_ASSERT(m_targetDirectory);
+
+    setStopRemoveGcdaFilesJobButton();
+    m_ui->lcovJobButton->setEnabled(false);
+
+    RemoveGcdaFilesJob* job = new RemoveGcdaFilesJob(m_targetDirectory->url(), \
this); +    connect(job, SIGNAL(finished(KJob*)), \
SLOT(updateStateWhenRemoveGcdaFilesJobFinishes())); +
+    m_removeGcdaFilesJob = job;
+
+    ICore::self()->runController()->registerJob(job);
+}
+
+void ReportWidget::updateStateWhenRemoveGcdaFilesJobFinishes()
+{
+    setStartRemoveGcdaFilesJobButton();
+    m_ui->lcovJobButton->setEnabled(true);
+}
+
+void ReportWidget::setStartRemoveGcdaFilesJobButton()
+{
+    m_ui->removeGcdaFilesJobButton->setToolTip(i18nc("@info:tooltip", "Remove \
coverage data")); +    \
m_ui->removeGcdaFilesJobButton->setWhatsThis(i18nc("@info:whatsthis", "<para>Remove \
coverage data from the specified path.</para>\n" +"<para>The .gcda files are removed \
in the given directory and, recursively, its subdirectories.</para>")); +    \
m_ui->removeGcdaFilesJobButton->setIcon(KIcon("edit-delete")); +}
+
+void ReportWidget::setStopRemoveGcdaFilesJobButton()
+{
+    m_ui->removeGcdaFilesJobButton->setToolTip(i18nc("@info:tooltip", "Stop removing \
coverage data")); +    \
m_ui->removeGcdaFilesJobButton->setWhatsThis(i18nc("@info:whatsthis", "<para>Stop \
removing coverage data from the specified path.</para>")); +    \
m_ui->removeGcdaFilesJobButton->setIcon(KIcon("process-stop")); +}
+
 void ReportWidget::updateColumns()
 {
     switch(m_state) {
--- trunk/playground/devtools/kdevelop4-extra-plugins/coverage/reportwidget.h \
#1251781:1251782 @@ -81,9 +81,36 @@
      * running or not.
      */
     void startOrStopLcovJob();
+
+    /*!
+     * Restores the widgets changed when the lcov job was started.
+     */
+    void updateStateWhenLcovJobFinishes();
+
+    /*!
+     * Starts or stops the remove gcda files job depending on whether there is a
+     * job already running or not.
+     */
+    void startOrStopRemoveGcdaFilesJob();
+    
+    /*!
+     * Restores the widgets changed when the remove gcda files job was started.
+     */
+    void updateStateWhenRemoveGcdaFilesJobFinishes();
+
+private:
+
+    /*!
+     * Starts the lcov job.
+     */
     void startLcovJob();
     
     /*!
+     * Starts the remove gcda files job.
+     */
+    void startRemoveGcdaFilesJob();
+
+    /*!
      * Sets the icon and texts of lcov job button to start the job.
      */
     void setStartLcovJobButton();
@@ -93,9 +120,17 @@
      */
     void setStopLcovJobButton();
 
-private:
+    /*!
+     * Sets the icon and texts of remove gcda files job button to start the job.
+     */
+    void setStartRemoveGcdaFilesJobButton();
 
     /*!
+     * Sets the icon and texts of remove gcda files job button to stop the job.
+     */
+    void setStopRemoveGcdaFilesJobButton();
+
+    /*!
      * Returns the ReportDirData used in the item identified by the index.
      * If no ReportDirData exists for that index (that is, if the index does
      * not identify a ReportDirItem), a null pointer is returned.
@@ -165,6 +200,7 @@
     CovOutputDelegate* m_delegate;
     Ui::ReportWidget* m_ui;
     QPointer<KJob> m_lcovJob;
+    QPointer<KJob> m_removeGcdaFilesJob;
 };
 
 }
--- trunk/playground/devtools/kdevelop4-extra-plugins/coverage/reportwidget.ui \
#1251781:1251782 @@ -49,6 +49,13 @@
           </property>
          </widget>
         </item>
+        <item>
+         <widget class="QPushButton" name="removeGcdaFilesJobButton">
+          <property name="text">
+           <string/>
+          </property>
+         </widget>
+        </item>
        </layout>
       </item>
       <item>
--- trunk/playground/devtools/kdevelop4-extra-plugins/coverage/tests/CMakeLists.txt \
#1251781:1251782 @@ -30,6 +30,7 @@
 kdev_add_test(unit-colorrange colorrangetest.cpp)
 kdev_add_test(unit-discretecolorrange discretecolorrangetest.cpp)
 kdev_add_test(unit-gradientcolorrange gradientcolorrangetest.cpp)
+kdev_add_test(unit-removegcdafilesjob removegcdafilesjobtest.cpp)
 kdev_add_test(unit-reportmodel reportmodeltest.cpp)
 kdev_add_test(unit-reportitems reportitemstest.cpp)
 kdev_add_test(unit-reportfileitem reportfileitemtest.cpp)
@@ -51,6 +52,7 @@
 coverage_add_mem_test(colorrange unit)
 coverage_add_mem_test(discretecolorrange unit)
 coverage_add_mem_test(gradientcolorrange unit)
+coverage_add_mem_test(removegcdafilesjob unit)
 coverage_add_mem_test(reportmodel unit)
 coverage_add_mem_test(reportitems unit)
 coverage_add_mem_test(reportfileitem unit)


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic