[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-04 17:07:02
Message-ID: 20110904170702.B0CDEAC87C () svn ! kde ! org
[Download RAW message or body]
SVN commit 1251410 by danxuliu:
Change start button behavior: instead of disabling it until the lcov job finishes, \
now it can be used to stop the running lcov job (as well as the general KDevelop \
"Stop Jobs" button, which was already supported).
M +34 -12 reportwidget.cpp
M +19 -1 reportwidget.h
M +2 -10 reportwidget.ui
--- trunk/playground/devtools/kdevelop4-extra-plugins/coverage/reportwidget.cpp \
#1251409:1251410 @@ -1,6 +1,7 @@
/* KDevelop coverage plugin
* Copyright 2008 Manuel Breugelmans <mbr.nxi@gmail.com>
* Copyright 2010 Daniel Calviño Sánchez <danxuliu@gmail.com>
+ * Copyright 2011 Daniel Calviño Sánchez <danxuliu@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -99,7 +100,7 @@
//KUrlNavigator can't be set using a placeholder in Qt Designer as there is
//no KUrlNavigator(QWidget*) constructor
- int startButtonIndex = \
m_ui->buildPathSelectionLayout->indexOf(m_ui->startButton); + int startButtonIndex \
= m_ui->buildPathSelectionLayout->indexOf(m_ui->lcovJobButton);
m_targetDirectory = new KUrlNavigator(0, KUrl(QDir::homePath()), this);
m_ui->buildPathSelectionLayout->insertWidget(startButtonIndex, \
m_targetDirectory);
@@ -115,8 +116,8 @@
static_cast<KComboBox*>(projectSelectionWidget)->setSizeAdjustPolicy(QComboBox::AdjustToContents);
}
- m_ui->startButton->setIcon(KIcon("arrow-right"));
- connect(m_ui->startButton, SIGNAL(clicked(bool)), SLOT(startLcovJob()));
+ setStartLcovJobButton();
+ connect(m_ui->lcovJobButton, SIGNAL(clicked(bool)), SLOT(startOrStopLcovJob()));
connect(table(), SIGNAL(doubleClicked(QModelIndex)),
SLOT(dispatchDoubleClickedSignal(QModelIndex)));
@@ -329,10 +330,18 @@
}
}
+void ReportWidget::startOrStopLcovJob()
+{
+ if (!m_lcovJob) {
+ startLcovJob();
+ } else {
+ m_lcovJob->kill(KJob::EmitResult);
+ }
+}
+
void ReportWidget::startLcovJob()
{
- Q_ASSERT(m_delegate); Q_ASSERT(m_targetDirectory); \
Q_ASSERT(m_ui->startButton->isEnabled());
- m_ui->startButton->setEnabled(false);
+ Q_ASSERT(m_delegate); Q_ASSERT(m_targetDirectory);
if (m_state == FileView) {
filterBox()->setReadOnly(false);
@@ -379,9 +388,28 @@
job->setParser(parser);
ICore::self()->runController()->registerJob(job);
- connect(job, SIGNAL(finished(KJob*)), SLOT(jobFinished()));
+ connect(job, SIGNAL(finished(KJob*)), SLOT(setStartLcovJobButton()));
+
+ m_lcovJob = job;
+
+ setStopLcovJobButton();
}
+void ReportWidget::setStartLcovJobButton()
+{
+ m_ui->lcovJobButton->setToolTip(i18nc("@info:tooltip", "Start coverage \
analysis")); + m_ui->lcovJobButton->setWhatsThis(i18nc("@info:whatsthis", \
"<para>Start coverage analysis in the specified path.</para>\n" +"<para>The directory \
and, recursively, its subdirectories are scanned for .gcda files.</para>")); + \
m_ui->lcovJobButton->setIcon(KIcon("arrow-right")); +}
+
+void ReportWidget::setStopLcovJobButton()
+{
+ m_ui->lcovJobButton->setToolTip(i18nc("@info:tooltip", "Stop coverage \
analysis")); + m_ui->lcovJobButton->setWhatsThis(i18nc("@info:whatsthis", \
"<para>Stop coverage analysis killing <command>geninfo</command> process.</para>")); \
+ m_ui->lcovJobButton->setIcon(KIcon("process-stop")); +}
+
void ReportWidget::updateColumns()
{
switch(m_state) {
@@ -391,10 +419,4 @@
}
}
-void ReportWidget::jobFinished()
-{
- Q_ASSERT(!m_ui->startButton->isEnabled());
- m_ui->startButton->setEnabled(true);
-}
-
#include "reportwidget.moc"
--- trunk/playground/devtools/kdevelop4-extra-plugins/coverage/reportwidget.h \
#1251409:1251410 @@ -1,5 +1,6 @@
/* KDevelop coverage plugin
* Copyright 2008 Manuel Breugelmans <mbr.nxi@gmail.com>
+ * Copyright 2011 Daniel Calviño Sánchez <danxuliu@gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -20,6 +21,7 @@
#ifndef VERITAS_COVERAGE_REPORTWIDGET_H
#define VERITAS_COVERAGE_REPORTWIDGET_H
+#include <QPointer>
#include <QtGui/QWidget>
#include <KUrl>
#include <interfaces/iuicontroller.h>
@@ -31,6 +33,7 @@
class QModelIndex;
class QStandardItem;
class QTableView;
+class KJob;
class KUrlNavigator;
namespace Ui
@@ -73,9 +76,23 @@
void updateTableView();
void updateColumns();
+ /*!
+ * Starts or stops the lcov job depending on whether there is a job already
+ * running or not.
+ */
+ void startOrStopLcovJob();
void startLcovJob();
- void jobFinished();
+ /*!
+ * Sets the icon and texts of lcov job button to start the job.
+ */
+ void setStartLcovJobButton();
+
+ /*!
+ * Sets the icon and texts of lcov job button to stop the job.
+ */
+ void setStopLcovJobButton();
+
private:
/*!
@@ -147,6 +164,7 @@
KUrlNavigator* m_targetDirectory; // lets the user select a directory to run \
coverage on CovOutputDelegate* m_delegate;
Ui::ReportWidget* m_ui;
+ QPointer<KJob> m_lcovJob;
};
}
--- trunk/playground/devtools/kdevelop4-extra-plugins/coverage/reportwidget.ui \
#1251409:1251410 @@ -43,15 +43,7 @@
</widget>
</item>
<item>
- <widget class="QPushButton" name="startButton" >
- <property name="toolTip" >
- <string>Start coverage analysis</string>
- </property>
- <property name="whatsThis" >
- <string>Start coverage analysis in the specified path.
-
-The directory and, recursively, its subdirectories are scanned for .gcda \
files.</string>
- </property>
+ <widget class="QPushButton" name="lcovJobButton" >
<property name="text" >
<string/>
</property>
@@ -280,7 +272,7 @@
</customwidget>
</customwidgets>
<tabstops>
- <tabstop>startButton</tabstop>
+ <tabstop>lcovJobButton</tabstop>
<tabstop>filterBox</tabstop>
<tabstop>table</tabstop>
</tabstops>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic