KDevelop API Documentation

valgrind_dialog.cpp

Go to the documentation of this file.
00001 #include <qlayout.h>
00002 #include <qcheckbox.h>
00003 #include <qregexp.h>
00004 #include <qwidgetstack.h>
00005 
00006 #include <klocale.h>
00007 #include <kurlrequester.h>
00008 #include <klineedit.h>
00009 #include <kstandarddirs.h>
00010 #include <kmessagebox.h>
00011 
00012 #include "dialog_widget.h"
00013 #include "valgrind_dialog.h"
00014 
00015 #include "valgrind_dialog.moc"
00016 
00017 
00018 ValgrindDialog::ValgrindDialog( Type type, QWidget* parent )
00019   : KDialogBase( parent, "valgrind dialog", true, i18n("Valgrind Memory Check"), Ok|Cancel ),
00020   m_type(type)
00021 {
00022   w = new DialogWidget( this );
00023   w->valExecutableEdit->setURL( "valgrind" );
00024   w->executableEdit->setFocus();
00025   w->stack->raiseWidget(m_type);
00026   setMainWidget( w );
00027   connect( w->executableEdit->lineEdit(),  SIGNAL( textChanged( const QString &)), this, SLOT( valgrindTextChanged()));
00028   connect( w->valExecutableEdit->lineEdit(), SIGNAL( textChanged( const QString &)), this, SLOT( valgrindTextChanged()));
00029   connect( w->ctExecutableEdit->lineEdit(),  SIGNAL( textChanged( const QString &)), this, SLOT( valgrindTextChanged()));
00030   connect( w->kcExecutableEdit->lineEdit(), SIGNAL( textChanged( const QString &)), this, SLOT( valgrindTextChanged()));
00031   enableButtonOK( false );
00032 }
00033 
00034 
00035 ValgrindDialog::~ValgrindDialog()
00036 {
00037 }
00038 
00039 void ValgrindDialog::valgrindTextChanged()
00040 {
00041     if (m_type == Memcheck)
00042         enableButtonOK( !w->valExecutableEdit->lineEdit()->text().isEmpty() &&  !w->executableEdit->lineEdit()->text().isEmpty() );
00043     else if (m_type == Calltree)
00044         enableButtonOK( !w->executableEdit->lineEdit()->text().isEmpty() &&  !w->ctExecutableEdit->lineEdit()->text().isEmpty() && !w->kcExecutableEdit->lineEdit()->text().isEmpty() );
00045 }
00046 
00047 QString ValgrindDialog::executableName() const
00048 {
00049   return w->executableEdit->url();
00050 }
00051 
00052 void ValgrindDialog::setExecutable( const QString& url )
00053 {
00054   w->executableEdit->setURL( url );
00055 }
00056 
00057 QString ValgrindDialog::valExecutable() const
00058 {
00059   return w->valExecutableEdit->url();
00060 }
00061 
00062 QString ValgrindDialog::parameters() const
00063 {
00064   return w->paramEdit->text();
00065 }
00066 
00067 void ValgrindDialog::setParameters( const QString& params )
00068 {
00069   w->paramEdit->setText( params );
00070 }
00071 
00072 void ValgrindDialog::setValExecutable( const QString& ve )
00073 {
00074   QString vUrl = ve;
00075   if ( vUrl.isEmpty() ) {
00076     vUrl = KStandardDirs::findExe( "valgrind" );
00077   }
00078   if ( vUrl.isEmpty() ) {
00079     KMessageBox::sorry( this, i18n( "Could not find valgrind in your $PATH. Please make "
00080                                     "sure it is installed properly." ),
00081                         i18n( "Valgrind Not Found" ) );
00082     w->valExecutableEdit->setURL( "valgrind" );
00083   } else {
00084     w->valExecutableEdit->setURL( vUrl );
00085   }
00086 }
00087 
00088 static const QString leakCheckParam( "--leak-check=yes" );
00089 static const QString reachableParam( "--show-reachable=yes" );
00090 static const QString childrenParam( "--trace-children=yes" );
00091 
00092 QString ValgrindDialog::valParams() const
00093 {
00094   QString params = w->valParamEdit->text();
00095   if ( w->memleakBox->isChecked() )
00096     params += " " + leakCheckParam;
00097   if ( w->reachableBox->isChecked() )
00098     params += " " + reachableParam;
00099   if ( w->childrenBox->isChecked() )
00100     params += " " + childrenParam;
00101 
00102   return params;
00103 }
00104 
00105 void ValgrindDialog::setValParams( const QString& params )
00106 {
00107   QString myParams = params;
00108   if ( myParams.contains( leakCheckParam ) )
00109     w->memleakBox->setChecked( true );
00110   if ( myParams.contains( reachableParam ) )
00111     w->reachableBox->setChecked( true );
00112   if ( myParams.contains( childrenParam ) )
00113     w->childrenBox->setChecked( true );
00114   w->init();
00115 
00116   myParams = myParams.replace( QRegExp( leakCheckParam ), "" );
00117   myParams = myParams.replace( QRegExp( reachableParam ), "" );
00118   myParams = myParams.replace( QRegExp( childrenParam ), "" );
00119   myParams = myParams.stripWhiteSpace();
00120   w->valParamEdit->setText( myParams );
00121 }
00122 
00123 QString ValgrindDialog::ctExecutable() const
00124 {
00125   return w->ctExecutableEdit->url();
00126 }
00127 
00128 void ValgrindDialog::setCtExecutable( const QString& ce )
00129 {
00130   QString vUrl = ce;
00131   if ( vUrl.isEmpty() ) {
00132     vUrl = KStandardDirs::findExe( "calltree" );
00133   }
00134   if ( vUrl.isEmpty() ) {
00135     KMessageBox::sorry( this, i18n( "Could not find calltree in your $PATH. Please make "
00136                                     "sure it is installed properly." ),
00137                         i18n( "Calltree Not Found" ) );
00138     w->ctExecutableEdit->setURL( "calltree" );
00139   } else {
00140     w->ctExecutableEdit->setURL( vUrl );
00141   }
00142 }
00143 
00144 QString ValgrindDialog::ctParams() const
00145 {
00146   QString params = w->ctParamEdit->text();
00147   if ( w->ctChildrenBox->isChecked() )
00148     params += " " + childrenParam;
00149 
00150   return params;
00151 }
00152 
00153 void ValgrindDialog::setCtParams( const QString& params )
00154 {
00155   QString myParams = params;
00156   if ( myParams.contains( childrenParam ) )
00157     w->ctChildrenBox->setChecked( true );
00158   w->init();
00159 
00160   myParams = myParams.replace( QRegExp( childrenParam ), "" );
00161   myParams = myParams.stripWhiteSpace();
00162   w->ctParamEdit->setText( myParams );
00163 }
00164 
00165 QString ValgrindDialog::kcExecutable( ) const
00166 {
00167   return w->kcExecutableEdit->url();
00168 }
00169 
00170 void ValgrindDialog::setKcExecutable( const QString& ke )
00171 {
00172   QString vUrl = ke;
00173   if ( vUrl.isEmpty() ) {
00174     vUrl = KStandardDirs::findExe( "kcachegrind" );
00175   }
00176   if ( vUrl.isEmpty() ) {
00177     KMessageBox::sorry( this, i18n( "Could not find kcachegrind in your $PATH. Please make "
00178                                     "sure it is installed properly." ),
00179                         i18n( "KCachegrind Not Found" ) );
00180     w->kcExecutableEdit->setURL( "kcachegrind" );
00181   } else {
00182     w->kcExecutableEdit->setURL( vUrl );
00183   }
00184 }
00185 
KDE Logo
This file is part of the documentation for KDevelop Version 3.1.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 23 00:03:58 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003