2009-02-25 09:15:00 +01:00
/**************************************************************************
2008-12-02 12:01:29 +01:00
* *
* * This file is part of Qt Creator
* *
2009-02-25 09:15:00 +01:00
* * Copyright ( c ) 2009 Nokia Corporation and / or its subsidiary ( - ies ) .
2008-12-02 12:01:29 +01:00
* *
* * Contact : Qt Software Information ( qt - info @ nokia . com )
* *
2009-02-25 09:15:00 +01:00
* * Commercial Usage
2008-12-02 14:17:16 +01:00
* *
2009-02-25 09:15:00 +01:00
* * Licensees holding valid Qt Commercial licenses may use this file in
* * accordance with the Qt Commercial License Agreement provided with the
* * Software or , alternatively , in accordance with the terms contained in
* * a written agreement between you and Nokia .
2008-12-02 14:17:16 +01:00
* *
2009-02-25 09:15:00 +01:00
* * GNU Lesser General Public License Usage
2008-12-02 14:17:16 +01:00
* *
2009-02-25 09:15:00 +01:00
* * Alternatively , this file may be used under the terms of the GNU Lesser
* * General Public License version 2.1 as published by the Free Software
* * Foundation and appearing in the file LICENSE . LGPL included in the
* * packaging of this file . Please review the following information to
* * ensure the GNU Lesser General Public License version 2.1 requirements
* * will be met : http : //www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
2008-12-02 14:17:16 +01:00
* *
2009-02-25 09:15:00 +01:00
* * If you are unsure which license is appropriate for your use , please
* * contact the sales department at qt - sales @ nokia . com .
2008-12-02 12:01:29 +01:00
* *
2009-02-25 09:15:00 +01:00
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2008-12-02 16:19:05 +01:00
2008-12-02 12:01:29 +01:00
# include "qt4runconfiguration.h"
2008-12-02 16:19:05 +01:00
2008-12-09 15:25:01 +01:00
# include "makestep.h"
2008-12-02 12:01:29 +01:00
# include "profilereader.h"
# include "qt4nodes.h"
2008-12-09 15:25:01 +01:00
# include "qt4project.h"
2008-12-02 12:01:29 +01:00
# include <coreplugin/icore.h>
# include <coreplugin/messagemanager.h>
# include <coreplugin/variablemanager.h>
# include <projectexplorer/buildstep.h>
2008-12-09 15:25:01 +01:00
# include <utils/qtcassert.h>
2008-12-02 12:01:29 +01:00
# include <QtGui/QFormLayout>
# include <QtGui/QInputDialog>
2009-01-27 18:23:02 +01:00
# include <QtGui/QLabel>
2009-02-18 17:04:04 +01:00
# include <QtGui/QCheckBox>
2008-12-02 12:01:29 +01:00
using namespace Qt4ProjectManager : : Internal ;
using namespace Qt4ProjectManager ;
using ProjectExplorer : : ApplicationRunConfiguration ;
using ProjectExplorer : : PersistentSettingsReader ;
using ProjectExplorer : : PersistentSettingsWriter ;
2009-03-20 16:13:46 +01:00
Qt4RunConfiguration : : Qt4RunConfiguration ( Qt4Project * pro , const QString & proFilePath )
2009-01-27 18:23:02 +01:00
: ApplicationRunConfiguration ( pro ) ,
m_proFilePath ( proFilePath ) ,
2009-03-18 17:43:55 +01:00
m_runMode ( Gui ) ,
2009-01-27 18:23:02 +01:00
m_userSetName ( false ) ,
m_configWidget ( 0 ) ,
m_executableLabel ( 0 ) ,
2009-03-19 15:04:43 +01:00
m_workingDirectoryLabel ( 0 ) ,
m_cachedTargetInformationValid ( false )
2008-12-02 12:01:29 +01:00
{
2009-03-20 16:13:46 +01:00
if ( ! m_proFilePath . isEmpty ( ) )
setName ( QFileInfo ( m_proFilePath ) . completeBaseName ( ) ) ;
else
setName ( tr ( " Qt4RunConfiguration " ) ) ;
2009-03-19 15:04:43 +01:00
2009-01-27 18:23:02 +01:00
connect ( pro , SIGNAL ( activeBuildConfigurationChanged ( ) ) ,
2009-03-19 15:04:43 +01:00
this , SLOT ( invalidateCachedTargetInformation ( ) ) ) ;
2008-12-02 12:01:29 +01:00
}
Qt4RunConfiguration : : ~ Qt4RunConfiguration ( )
{
}
QString Qt4RunConfiguration : : type ( ) const
{
return " Qt4ProjectManager.Qt4RunConfiguration " ;
}
2009-01-27 18:23:02 +01:00
//////
/// Qt4RunConfigurationWidget
/////
Qt4RunConfigurationWidget : : Qt4RunConfigurationWidget ( Qt4RunConfiguration * qt4RunConfiguration , QWidget * parent )
2009-03-19 15:04:43 +01:00
: QWidget ( parent ) , m_qt4RunConfiguration ( qt4RunConfiguration ) , m_ignoreChange ( false ) , m_isShown ( false )
2008-12-02 12:01:29 +01:00
{
2009-01-27 18:23:02 +01:00
QFormLayout * toplayout = new QFormLayout ( this ) ;
2008-12-02 12:01:29 +01:00
toplayout - > setMargin ( 0 ) ;
QLabel * nameLabel = new QLabel ( tr ( " Name: " ) ) ;
2009-01-27 18:23:02 +01:00
m_nameLineEdit = new QLineEdit ( m_qt4RunConfiguration - > name ( ) ) ;
nameLabel - > setBuddy ( m_nameLineEdit ) ;
toplayout - > addRow ( nameLabel , m_nameLineEdit ) ;
2008-12-02 12:01:29 +01:00
2009-01-27 18:23:02 +01:00
m_executableLabel = new QLabel ( m_qt4RunConfiguration - > executable ( ) ) ;
toplayout - > addRow ( tr ( " Executable: " ) , m_executableLabel ) ;
2008-12-02 12:01:29 +01:00
2009-01-27 18:23:02 +01:00
m_workingDirectoryLabel = new QLabel ( m_qt4RunConfiguration - > workingDirectory ( ) ) ;
toplayout - > addRow ( tr ( " Working Directory: " ) , m_workingDirectoryLabel ) ;
2008-12-02 12:01:29 +01:00
QLabel * argumentsLabel = new QLabel ( tr ( " &Arguments: " ) ) ;
2009-01-27 18:23:02 +01:00
m_argumentsLineEdit = new QLineEdit ( ProjectExplorer : : Environment : : joinArgumentList ( qt4RunConfiguration - > commandLineArguments ( ) ) ) ;
argumentsLabel - > setBuddy ( m_argumentsLineEdit ) ;
toplayout - > addRow ( argumentsLabel , m_argumentsLineEdit ) ;
2008-12-02 12:01:29 +01:00
2009-02-18 17:04:04 +01:00
m_useTerminalCheck = new QCheckBox ( tr ( " Run in &Terminal " ) ) ;
m_useTerminalCheck - > setChecked ( m_qt4RunConfiguration - > runMode ( ) = = ProjectExplorer : : ApplicationRunConfiguration : : Console ) ;
toplayout - > addRow ( QString ( ) , m_useTerminalCheck ) ;
2009-03-18 17:43:55 +01:00
connect ( m_argumentsLineEdit , SIGNAL ( textEdited ( QString ) ) ,
this , SLOT ( setCommandLineArguments ( QString ) ) ) ;
2008-12-02 12:01:29 +01:00
2009-03-18 17:43:55 +01:00
connect ( m_nameLineEdit , SIGNAL ( textEdited ( QString ) ) ,
this , SLOT ( nameEdited ( QString ) ) ) ;
2008-12-02 12:01:29 +01:00
2009-02-18 17:04:04 +01:00
connect ( m_useTerminalCheck , SIGNAL ( toggled ( bool ) ) ,
this , SLOT ( termToggled ( bool ) ) ) ;
2009-01-27 18:23:02 +01:00
connect ( qt4RunConfiguration , SIGNAL ( commandLineArgumentsChanged ( QString ) ) ,
this , SLOT ( commandLineArgumentsChanged ( QString ) ) ) ;
connect ( qt4RunConfiguration , SIGNAL ( nameChanged ( QString ) ) ,
this , SLOT ( nameChanged ( QString ) ) ) ;
2009-02-18 17:04:04 +01:00
connect ( qt4RunConfiguration , SIGNAL ( runModeChanged ( ProjectExplorer : : ApplicationRunConfiguration : : RunMode ) ) ,
this , SLOT ( runModeChanged ( ProjectExplorer : : ApplicationRunConfiguration : : RunMode ) ) ) ;
2009-01-27 18:23:02 +01:00
2009-03-19 15:04:43 +01:00
connect ( qt4RunConfiguration , SIGNAL ( effectiveTargetInformationChanged ( ) ) ,
this , SLOT ( effectiveTargetInformationChanged ( ) ) , Qt : : QueuedConnection ) ;
2009-01-27 18:23:02 +01:00
}
void Qt4RunConfigurationWidget : : setCommandLineArguments ( const QString & args )
{
m_ignoreChange = true ;
m_qt4RunConfiguration - > setCommandLineArguments ( args ) ;
m_ignoreChange = false ;
}
void Qt4RunConfigurationWidget : : nameEdited ( const QString & name )
{
m_ignoreChange = true ;
m_qt4RunConfiguration - > nameEdited ( name ) ;
m_ignoreChange = false ;
}
2009-02-18 17:04:04 +01:00
void Qt4RunConfigurationWidget : : termToggled ( bool on )
{
m_ignoreChange = true ;
m_qt4RunConfiguration - > setRunMode ( on ? ApplicationRunConfiguration : : Console
: ApplicationRunConfiguration : : Gui ) ;
m_ignoreChange = false ;
}
2009-01-27 18:23:02 +01:00
void Qt4RunConfigurationWidget : : commandLineArgumentsChanged ( const QString & args )
{
if ( ! m_ignoreChange )
m_argumentsLineEdit - > setText ( args ) ;
}
void Qt4RunConfigurationWidget : : nameChanged ( const QString & name )
{
if ( ! m_ignoreChange )
m_nameLineEdit - > setText ( name ) ;
}
2009-02-18 17:04:04 +01:00
void Qt4RunConfigurationWidget : : runModeChanged ( ApplicationRunConfiguration : : RunMode runMode )
{
if ( ! m_ignoreChange )
m_useTerminalCheck - > setChecked ( runMode = = ApplicationRunConfiguration : : Console ) ;
}
2009-03-19 15:04:43 +01:00
void Qt4RunConfigurationWidget : : effectiveTargetInformationChanged ( )
2009-01-27 18:23:02 +01:00
{
2009-03-19 15:04:43 +01:00
if ( m_isShown ) {
m_executableLabel - > setText ( m_qt4RunConfiguration - > executable ( ) ) ;
m_workingDirectoryLabel - > setText ( m_qt4RunConfiguration - > workingDirectory ( ) ) ;
}
2009-01-27 18:23:02 +01:00
}
2009-03-19 15:04:43 +01:00
void Qt4RunConfigurationWidget : : showEvent ( QShowEvent * event )
2009-01-27 18:23:02 +01:00
{
2009-03-19 15:04:43 +01:00
m_isShown = true ;
effectiveTargetInformationChanged ( ) ;
QWidget : : showEvent ( event ) ;
2009-01-27 18:23:02 +01:00
}
2009-03-19 15:04:43 +01:00
void Qt4RunConfigurationWidget : : hideEvent ( QHideEvent * event )
{
m_isShown = false ;
QWidget : : hideEvent ( event ) ;
}
2009-01-27 18:23:02 +01:00
2009-03-19 15:04:43 +01:00
////// TODO c&p above
2009-01-27 18:23:02 +01:00
QWidget * Qt4RunConfiguration : : configurationWidget ( )
{
return new Qt4RunConfigurationWidget ( this , 0 ) ;
2008-12-02 12:01:29 +01:00
}
void Qt4RunConfiguration : : save ( PersistentSettingsWriter & writer ) const
{
writer . saveValue ( " CommandLineArguments " , m_commandLineArguments ) ;
writer . saveValue ( " ProFile " , m_proFilePath ) ;
writer . saveValue ( " UserSetName " , m_userSetName ) ;
2009-02-18 17:04:04 +01:00
writer . saveValue ( " UseTerminal " , m_runMode = = Console ) ;
2008-12-02 12:01:29 +01:00
ApplicationRunConfiguration : : save ( writer ) ;
}
void Qt4RunConfiguration : : restore ( const PersistentSettingsReader & reader )
{
ApplicationRunConfiguration : : restore ( reader ) ;
m_commandLineArguments = reader . restoreValue ( " CommandLineArguments " ) . toStringList ( ) ;
m_proFilePath = reader . restoreValue ( " ProFile " ) . toString ( ) ;
m_userSetName = reader . restoreValue ( " UserSetName " ) . toBool ( ) ;
2009-02-18 17:04:04 +01:00
m_runMode = reader . restoreValue ( " UseTerminal " ) . toBool ( ) ? Console : Gui ;
2008-12-02 12:01:29 +01:00
if ( ! m_proFilePath . isEmpty ( ) ) {
2009-03-19 15:04:43 +01:00
m_cachedTargetInformationValid = false ;
2008-12-02 12:01:29 +01:00
if ( ! m_userSetName )
2009-03-20 16:13:46 +01:00
setName ( QFileInfo ( m_proFilePath ) . completeBaseName ( ) ) ;
2008-12-02 12:01:29 +01:00
}
}
QString Qt4RunConfiguration : : executable ( ) const
{
2009-03-19 15:04:43 +01:00
const_cast < Qt4RunConfiguration * > ( this ) - > updateTarget ( ) ;
return m_executable ;
2008-12-02 12:01:29 +01:00
}
ApplicationRunConfiguration : : RunMode Qt4RunConfiguration : : runMode ( ) const
{
return m_runMode ;
}
QString Qt4RunConfiguration : : workingDirectory ( ) const
{
2009-03-19 15:04:43 +01:00
const_cast < Qt4RunConfiguration * > ( this ) - > updateTarget ( ) ;
return m_workingDir ;
2008-12-02 12:01:29 +01:00
}
QStringList Qt4RunConfiguration : : commandLineArguments ( ) const
{
return m_commandLineArguments ;
}
ProjectExplorer : : Environment Qt4RunConfiguration : : environment ( ) const
{
Qt4Project * pro = qobject_cast < Qt4Project * > ( project ( ) ) ;
2008-12-17 15:51:48 +01:00
Q_ASSERT ( pro ) ;
2008-12-02 12:01:29 +01:00
return pro - > environment ( pro - > activeBuildConfiguration ( ) ) ;
}
void Qt4RunConfiguration : : setCommandLineArguments ( const QString & argumentsString )
{
m_commandLineArguments = ProjectExplorer : : Environment : : parseCombinedArgString ( argumentsString ) ;
2009-01-27 18:23:02 +01:00
emit commandLineArgumentsChanged ( argumentsString ) ;
2008-12-02 12:01:29 +01:00
}
2009-02-18 17:04:04 +01:00
void Qt4RunConfiguration : : setRunMode ( RunMode runMode )
{
m_runMode = runMode ;
emit runModeChanged ( runMode ) ;
}
2008-12-02 12:01:29 +01:00
void Qt4RunConfiguration : : nameEdited ( const QString & name )
{
if ( name = = " " ) {
setName ( tr ( " Qt4RunConfiguration " ) ) ;
m_userSetName = false ;
} else {
setName ( name ) ;
m_userSetName = true ;
}
2009-01-27 18:23:02 +01:00
emit nameChanged ( name ) ;
2008-12-02 12:01:29 +01:00
}
QString Qt4RunConfiguration : : proFilePath ( ) const
{
return m_proFilePath ;
}
2009-03-19 15:04:43 +01:00
void Qt4RunConfiguration : : updateTarget ( )
2008-12-02 12:01:29 +01:00
{
2009-03-19 15:04:43 +01:00
if ( m_cachedTargetInformationValid )
return ;
//qDebug()<<"updateTarget";
Qt4Project * pro = static_cast < Qt4Project * > ( project ( ) ) ;
ProFileReader * reader = pro - > createProFileReader ( ) ;
2009-01-29 18:42:06 +01:00
reader - > setCumulative ( false ) ;
2009-03-19 15:04:43 +01:00
reader - > setQtVersion ( pro - > qtVersion ( pro - > activeBuildConfiguration ( ) ) ) ;
// Find out what flags we pass on to qmake, this code is duplicated in the qmake step
QtVersion : : QmakeBuildConfig defaultBuildConfiguration = pro - > qtVersion ( pro - > activeBuildConfiguration ( ) ) - > defaultBuildConfig ( ) ;
QtVersion : : QmakeBuildConfig projectBuildConfiguration = QtVersion : : QmakeBuildConfig ( pro - > qmakeStep ( ) - > value ( pro - > activeBuildConfiguration ( ) , " buildConfiguration " ) . toInt ( ) ) ;
QStringList addedUserConfigArguments ;
QStringList removedUserConfigArguments ;
if ( ( defaultBuildConfiguration & QtVersion : : BuildAll ) & & ! ( projectBuildConfiguration & QtVersion : : BuildAll ) )
removedUserConfigArguments < < " debug_and_release " ;
if ( ! ( defaultBuildConfiguration & QtVersion : : BuildAll ) & & ( projectBuildConfiguration & QtVersion : : BuildAll ) )
addedUserConfigArguments < < " debug_and_release " ;
if ( ( defaultBuildConfiguration & QtVersion : : DebugBuild ) & & ! ( projectBuildConfiguration & QtVersion : : DebugBuild ) )
addedUserConfigArguments < < " release " ;
if ( ! ( defaultBuildConfiguration & QtVersion : : DebugBuild ) & & ( projectBuildConfiguration & QtVersion : : DebugBuild ) )
addedUserConfigArguments < < " debug " ;
reader - > setUserConfigCmdArgs ( addedUserConfigArguments , removedUserConfigArguments ) ;
QHash < QString , QStringList > : : const_iterator it ;
2008-12-02 12:01:29 +01:00
if ( ! reader - > readProFile ( m_proFilePath ) ) {
delete reader ;
2009-01-20 11:52:04 +01:00
Core : : ICore : : instance ( ) - > messageManager ( ) - > printToOutputPane ( QString ( " Could not parse %1. The Qt4 run configuration %2 can not be started. " ) . arg ( m_proFilePath ) . arg ( name ( ) ) ) ;
2008-12-02 12:01:29 +01:00
return ;
}
2009-03-19 15:04:43 +01:00
// Extract data
2009-03-19 16:11:20 +01:00
QDir baseProjectDirectory = QFileInfo ( project ( ) - > file ( ) - > fileName ( ) ) . absoluteDir ( ) ;
QString relSubDir = baseProjectDirectory . relativeFilePath ( QFileInfo ( m_proFilePath ) . path ( ) ) ;
QDir baseBuildDirectory = project ( ) - > buildDirectory ( project ( ) - > activeBuildConfiguration ( ) ) ;
QString baseDir = baseBuildDirectory . absoluteFilePath ( relSubDir ) ;
2008-12-02 12:01:29 +01:00
2009-03-19 15:04:43 +01:00
//qDebug()<<relSubDir<<baseDir;
// Working Directory
2008-12-02 12:01:29 +01:00
if ( reader - > contains ( " DESTDIR " ) ) {
2009-03-19 15:04:43 +01:00
//qDebug()<<"reader contains destdir:"<<reader->value("DESTDIR");
m_workingDir = reader - > value ( " DESTDIR " ) ;
if ( QDir : : isRelativePath ( m_workingDir ) ) {
m_workingDir = baseDir + QLatin1Char ( ' / ' ) + m_workingDir ;
//qDebug()<<"was relative and expanded to"<<m_workingDir;
2008-12-02 12:01:29 +01:00
}
} else {
2009-03-19 15:04:43 +01:00
//qDebug()<<"reader didn't contain DESTDIR, setting to "<<baseDir;
m_workingDir = baseDir ;
2008-12-02 12:01:29 +01:00
# if defined(Q_OS_WIN)
2009-03-19 15:04:43 +01:00
QString qmakeBuildConfig = " release " ;
if ( projectBuildConfiguration & QtVersion : : DebugBuild )
qmakeBuildConfig = " debug " ;
2008-12-02 12:01:29 +01:00
if ( ! reader - > contains ( " DESTDIR " ) )
2009-03-19 15:31:54 +01:00
m_workingDir + = QLatin1Char ( ' / ' ) + qmakeBuildConfig ;
2008-12-02 12:01:29 +01:00
# endif
}
# if defined (Q_OS_MAC)
2009-03-11 16:06:36 +01:00
if ( reader - > values ( " CONFIG " ) . contains ( " app_bundle " ) ) {
2009-03-19 15:31:54 +01:00
m_workingDir + = QLatin1Char ( ' / ' )
2009-03-19 15:54:21 +01:00
+ reader - > value ( " TARGET " )
2008-12-02 12:01:29 +01:00
+ QLatin1String ( " .app/Contents/MacOS " ) ;
}
# endif
2009-03-19 15:04:43 +01:00
m_workingDir = QDir : : cleanPath ( m_workingDir ) ;
m_executable = QDir : : cleanPath ( m_workingDir + QLatin1Char ( ' / ' ) + reader - > value ( " TARGET " ) ) ;
//qDebug()<<"##### updateTarget sets:"<<m_workingDir<<m_executable;
2008-12-02 12:01:29 +01:00
# if defined (Q_OS_WIN)
m_executable + = QLatin1String ( " .exe " ) ;
# endif
delete reader ;
2009-01-27 18:23:02 +01:00
2009-03-19 15:04:43 +01:00
m_cachedTargetInformationValid = true ;
2008-12-02 12:01:29 +01:00
2009-03-19 15:04:43 +01:00
emit effectiveTargetInformationChanged ( ) ;
2008-12-02 12:01:29 +01:00
}
2009-03-19 15:04:43 +01:00
void Qt4RunConfiguration : : invalidateCachedTargetInformation ( )
2008-12-02 12:01:29 +01:00
{
2009-03-19 15:04:43 +01:00
m_cachedTargetInformationValid = false ;
emit effectiveTargetInformationChanged ( ) ;
2008-12-02 12:01:29 +01:00
}
2009-03-25 15:18:37 +01:00
QString Qt4RunConfiguration : : dumperLibrary ( ) const
{
Qt4Project * pro = qobject_cast < Qt4Project * > ( project ( ) ) ;
QtVersion * version = pro - > qtVersion ( pro - > activeBuildConfiguration ( ) ) ;
return version - > dumperLibrary ( ) ;
}
2008-12-02 12:01:29 +01:00
///
/// Qt4RunConfigurationFactory
/// This class is used to restore run settings (saved in .user files)
///
Qt4RunConfigurationFactory : : Qt4RunConfigurationFactory ( )
{
}
Qt4RunConfigurationFactory : : ~ Qt4RunConfigurationFactory ( )
{
}
// used to recreate the runConfigurations when restoring settings
bool Qt4RunConfigurationFactory : : canCreate ( const QString & type ) const
{
return type = = " Qt4ProjectManager.Qt4RunConfiguration " ;
}
2008-12-09 15:25:01 +01:00
QSharedPointer < ProjectExplorer : : RunConfiguration > Qt4RunConfigurationFactory : : create
( ProjectExplorer : : Project * project , const QString & type )
2008-12-02 12:01:29 +01:00
{
Qt4Project * p = qobject_cast < Qt4Project * > ( project ) ;
2008-12-17 15:51:48 +01:00
Q_ASSERT ( p ) ;
Q_ASSERT ( type = = " Qt4ProjectManager.Qt4RunConfiguration " ) ;
2008-12-02 12:01:29 +01:00
// The right path is set in restoreSettings
QSharedPointer < ProjectExplorer : : RunConfiguration > rc ( new Qt4RunConfiguration ( p , QString : : null ) ) ;
return rc ;
}
QStringList Qt4RunConfigurationFactory : : canCreate ( ProjectExplorer : : Project * pro ) const
{
Qt4Project * qt4project = qobject_cast < Qt4Project * > ( pro ) ;
if ( qt4project )
return QStringList ( ) ;
else
return QStringList ( ) ;
}
QString Qt4RunConfigurationFactory : : nameForType ( const QString & type ) const
{
Q_UNUSED ( type ) ;
return " Run Qt4 application " ;
}
///
/// Qt4RunConfigurationFactoryUser
/// This class is used to create new RunConfiguration from the runsettings page
///
Qt4RunConfigurationFactoryUser : : Qt4RunConfigurationFactoryUser ( )
{
}
Qt4RunConfigurationFactoryUser : : ~ Qt4RunConfigurationFactoryUser ( )
{
}
bool Qt4RunConfigurationFactoryUser : : canCreate ( const QString & type ) const
{
Q_UNUSED ( type ) ;
return false ;
}
QSharedPointer < ProjectExplorer : : RunConfiguration > Qt4RunConfigurationFactoryUser : : create ( ProjectExplorer : : Project * project , const QString & type )
{
Qt4Project * p = qobject_cast < Qt4Project * > ( project ) ;
2008-12-17 15:51:48 +01:00
Q_ASSERT ( p ) ;
2008-12-02 12:01:29 +01:00
QString fileName = type . mid ( QString ( " Qt4RunConfiguration. " ) . size ( ) ) ;
return QSharedPointer < ProjectExplorer : : RunConfiguration > ( new Qt4RunConfiguration ( p , fileName ) ) ;
}
QStringList Qt4RunConfigurationFactoryUser : : canCreate ( ProjectExplorer : : Project * pro ) const
{
Qt4Project * qt4project = qobject_cast < Qt4Project * > ( pro ) ;
if ( qt4project ) {
QStringList applicationProFiles ;
QList < Qt4ProFileNode * > list = qt4project - > applicationProFiles ( ) ;
2008-12-09 11:07:24 +01:00
foreach ( Qt4ProFileNode * node , list ) {
2008-12-02 12:01:29 +01:00
applicationProFiles . append ( " Qt4RunConfiguration. " + node - > path ( ) ) ;
}
return applicationProFiles ;
} else {
return QStringList ( ) ;
}
}
QString Qt4RunConfigurationFactoryUser : : nameForType ( const QString & type ) const
{
QString fileName = type . mid ( QString ( " Qt4RunConfiguration. " ) . size ( ) ) ;
2009-03-20 16:13:46 +01:00
return QFileInfo ( fileName ) . completeBaseName ( ) ;
2008-12-02 12:01:29 +01:00
}