00001
#include <qlayout.h>
00002
#include <qcheckbox.h>
00003
#include <qregexp.h>
00004
00005
#include <klocale.h>
00006
#include <kurlrequester.h>
00007
#include <klineedit.h>
00008
#include <kstandarddirs.h>
00009
#include <kmessagebox.h>
00010
00011
#include "dialog_widget.h"
00012
#include "valgrind_dialog.h"
00013
00014
#include "valgrind_dialog.moc"
00015
00016
00017 ValgrindDialog::ValgrindDialog(
QWidget* parent )
00018 :
KDialogBase( parent, "valgrind dialog", true, i18n("Valgrind Memory Check"), Ok|Cancel )
00019 {
00020
w =
new DialogWidget(
this );
00021
w->
valExecutableEdit->
setURL(
"valgrind" );
00022
w->
executableEdit->setFocus();
00023 setMainWidget(
w );
00024 connect(
w->
executableEdit->
lineEdit(), SIGNAL( textChanged(
const QString &)),
this, SLOT(
valgrindTextChanged()));
00025 connect(
w->
valExecutableEdit->
lineEdit(), SIGNAL( textChanged(
const QString &)),
this, SLOT(
valgrindTextChanged()));
00026 enableButtonOK(
false );
00027 }
00028
00029
00030 ValgrindDialog::~ValgrindDialog()
00031 {
00032 }
00033
00034 void ValgrindDialog::valgrindTextChanged()
00035 {
00036 enableButtonOK( !
w->
valExecutableEdit->
lineEdit()->text().isEmpty() && !
w->
executableEdit->
lineEdit()->text().isEmpty() );
00037 }
00038
00039 QString ValgrindDialog::executableName()
const
00040
{
00041
return w->
executableEdit->
url();
00042 }
00043
00044 void ValgrindDialog::setExecutable(
const QString& url )
00045 {
00046
w->
executableEdit->
setURL( url );
00047 }
00048
00049 QString ValgrindDialog::valExecutable()
const
00050
{
00051
return w->
valExecutableEdit->
url();
00052 }
00053
00054 QString ValgrindDialog::parameters()
const
00055
{
00056
return w->
paramEdit->text();
00057 }
00058
00059 void ValgrindDialog::setParameters(
const QString& params )
00060 {
00061
w->
paramEdit->
setText( params );
00062 }
00063
00064 void ValgrindDialog::setValExecutable(
const QString& ve )
00065 {
00066
QString vUrl = ve;
00067
if ( vUrl.isEmpty() ) {
00068 vUrl = KStandardDirs::findExe(
"valgrind" );
00069 }
00070
if ( vUrl.isEmpty() ) {
00071 KMessageBox::sorry(
this, i18n(
"Could not find valgrind in your $PATH. Please make "
00072
"sure it is installed properly." ),
00073 i18n(
"Valgrind Not Found" ) );
00074
w->
valExecutableEdit->
setURL(
"valgrind" );
00075 }
else {
00076
w->
valExecutableEdit->
setURL( vUrl );
00077 }
00078 }
00079
00080
static const QString leakCheckParam(
"--leak-check=yes" );
00081
static const QString reachableParam(
"--show-reachable=yes" );
00082
static const QString childrenParam(
"--trace-children=yes" );
00083
00084 QString ValgrindDialog::valParams()
const
00085
{
00086
QString params =
w->
valParamEdit->text();
00087
if (
w->
memleakBox->isChecked() )
00088 params +=
" " +
leakCheckParam;
00089
if (
w->
reachableBox->isChecked() )
00090 params +=
" " +
reachableParam;
00091
if (
w->
childrenBox->isChecked() )
00092 params +=
" " +
childrenParam;
00093
00094
return params;
00095 }
00096
00097 void ValgrindDialog::setValParams(
const QString& params )
00098 {
00099
QString myParams = params;
00100
if ( myParams.contains(
leakCheckParam ) )
00101
w->
memleakBox->setChecked(
true );
00102
if ( myParams.contains(
reachableParam ) )
00103
w->
reachableBox->setChecked(
true );
00104
if ( myParams.contains(
childrenParam ) )
00105
w->
childrenBox->setChecked(
true );
00106
w->
init();
00107
00108 myParams = myParams.replace(
QRegExp(
leakCheckParam ),
"" );
00109 myParams = myParams.replace(
QRegExp(
reachableParam ),
"" );
00110 myParams = myParams.replace(
QRegExp(
childrenParam ),
"" );
00111 myParams = myParams.stripWhiteSpace();
00112
w->
valParamEdit->
setText( myParams );
00113 }
00114