2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2010-03-05 11:25:49 +01:00
|
|
|
** Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-06-17 00:01:27 +10:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
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
|
2009-08-14 09:30:56 +02:00
|
|
|
** contact the sales department at http://qt.nokia.com/contact.
|
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
|
|
|
#ifndef RUNCONFIGURATION_H
|
|
|
|
|
#define RUNCONFIGURATION_H
|
|
|
|
|
|
2010-01-19 13:41:02 +01:00
|
|
|
#include "projectconfiguration.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "projectexplorer_export.h"
|
|
|
|
|
|
|
|
|
|
#include <QtCore/QMetaType>
|
2009-10-08 18:37:18 +02:00
|
|
|
#include <QtCore/QWeakPointer>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
class QString;
|
|
|
|
|
class QWidget;
|
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
|
|
|
|
namespace ProjectExplorer {
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
class Target;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
class RunControl;
|
2009-10-28 17:21:27 +01:00
|
|
|
class BuildConfiguration;
|
2010-04-19 10:48:50 +02:00
|
|
|
class OutputFormatter;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-04-16 11:46:47 +02:00
|
|
|
/**
|
|
|
|
|
* Base class for a run configuration. A run configuration specifies how a
|
2010-02-08 15:50:06 +01:00
|
|
|
* target should be run, while the runner (see below) does the actual running.
|
2008-12-02 12:01:29 +01:00
|
|
|
*
|
2010-02-08 15:50:06 +01:00
|
|
|
* Note that all RunControls and the target hold a shared pointer to the RunConfiguration.
|
|
|
|
|
* That is the lifetime of the RunConfiguration might exceed the life of the target.
|
2008-12-02 12:01:29 +01:00
|
|
|
* The user might still have a RunControl running (or output tab of that RunControl open)
|
2010-02-08 15:50:06 +01:00
|
|
|
* and yet unloaded the target.
|
|
|
|
|
* Also a RunConfiguration might be already removed from the list of RunConfigurations
|
|
|
|
|
* for a target, but stil be runnable via the output tab.
|
|
|
|
|
*/
|
2010-01-19 13:41:02 +01:00
|
|
|
class PROJECTEXPLORER_EXPORT RunConfiguration : public ProjectConfiguration
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
2010-01-19 13:41:02 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
public:
|
|
|
|
|
virtual ~RunConfiguration();
|
|
|
|
|
|
2010-04-16 11:46:47 +02:00
|
|
|
/**
|
|
|
|
|
* Used to find out whether a runconfiguration works with the given
|
|
|
|
|
* buildconfiguration.
|
|
|
|
|
* \note bc may be 0!
|
|
|
|
|
*/
|
2010-01-19 13:41:02 +01:00
|
|
|
virtual bool isEnabled(BuildConfiguration *bc) const;
|
2010-04-16 11:46:47 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Used to find out whether a runconfiguration works with the active
|
|
|
|
|
* buildconfiguration.
|
|
|
|
|
*/
|
2009-10-28 17:21:27 +01:00
|
|
|
bool isEnabled() const;
|
2009-06-12 12:58:02 +02:00
|
|
|
|
2010-04-16 11:46:47 +02:00
|
|
|
/// Returns the widget used to configure this run configuration. Ownership is transferred to the caller
|
|
|
|
|
virtual QWidget *createConfigurationWidget() = 0;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
Target *target() const;
|
2010-01-19 13:41:02 +01:00
|
|
|
|
2010-07-13 15:02:37 +02:00
|
|
|
virtual ProjectExplorer::OutputFormatter *createOutputFormatter() const;
|
|
|
|
|
|
2010-03-05 11:11:05 +01:00
|
|
|
signals:
|
|
|
|
|
void isEnabledChanged(bool value);
|
|
|
|
|
|
2010-01-19 13:41:02 +01:00
|
|
|
protected:
|
2010-02-08 15:50:06 +01:00
|
|
|
RunConfiguration(Target *parent, const QString &id);
|
|
|
|
|
RunConfiguration(Target *parent, RunConfiguration *source);
|
2010-01-19 13:41:02 +01:00
|
|
|
|
2010-04-16 11:46:47 +02:00
|
|
|
/// convenience method to get current build configuration.
|
2010-01-19 13:41:02 +01:00
|
|
|
BuildConfiguration *activeBuildConfiguration() const;
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
2010-04-16 11:46:47 +02:00
|
|
|
/**
|
|
|
|
|
* The run configuration factory is used for restoring run configurations from
|
2008-12-02 12:01:29 +01:00
|
|
|
* settings. And used to create new runconfigurations in the "Run Settings" Dialog.
|
2010-02-08 15:50:06 +01:00
|
|
|
* For the first case bool canRestore(Target *parent, const QString &id) and
|
|
|
|
|
* RunConfiguration* create(Target *parent, const QString &id) are used.
|
|
|
|
|
* For the second type the functions QStringList availableCreationIds(Target *parent) and
|
2009-06-12 17:57:03 +02:00
|
|
|
* QString displayNameForType(const QString&) are used to generate a list of creatable
|
2008-12-02 12:01:29 +01:00
|
|
|
* RunConfigurations, and create(..) is used to create it.
|
|
|
|
|
*/
|
2010-04-16 11:46:47 +02:00
|
|
|
class PROJECTEXPLORER_EXPORT IRunConfigurationFactory : public QObject
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
2010-01-19 13:41:02 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
public:
|
2009-09-25 11:35:44 +02:00
|
|
|
explicit IRunConfigurationFactory(QObject *parent = 0);
|
2008-12-02 12:01:29 +01:00
|
|
|
virtual ~IRunConfigurationFactory();
|
2010-01-19 13:41:02 +01:00
|
|
|
|
2010-04-16 11:46:47 +02:00
|
|
|
/// used to show the list of possible additons to a target, returns a list of types
|
2010-02-08 15:50:06 +01:00
|
|
|
virtual QStringList availableCreationIds(Target *parent) const = 0;
|
2010-04-16 11:46:47 +02:00
|
|
|
|
|
|
|
|
/// used to translate the types to names to display to the user
|
2010-01-07 18:17:24 +01:00
|
|
|
virtual QString displayNameForId(const QString &id) const = 0;
|
2010-01-19 13:41:02 +01:00
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
virtual bool canCreate(Target *parent, const QString &id) const = 0;
|
|
|
|
|
virtual RunConfiguration *create(Target *parent, const QString &id) = 0;
|
|
|
|
|
virtual bool canRestore(Target *parent, const QVariantMap &map) const = 0;
|
|
|
|
|
virtual RunConfiguration *restore(Target *parent, const QVariantMap &map) = 0;
|
|
|
|
|
virtual bool canClone(Target *parent, RunConfiguration *product) const = 0;
|
|
|
|
|
virtual RunConfiguration *clone(Target *parent, RunConfiguration *product) = 0;
|
|
|
|
|
|
|
|
|
|
static IRunConfigurationFactory *createFactory(Target *parent, const QString &id);
|
|
|
|
|
static IRunConfigurationFactory *cloneFactory(Target *parent, RunConfiguration *source);
|
|
|
|
|
static IRunConfigurationFactory *restoreFactory(Target *parent, const QVariantMap &map);
|
2010-01-19 13:41:02 +01:00
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
void availableCreationIdsChanged();
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
2009-09-25 11:35:44 +02:00
|
|
|
class PROJECTEXPLORER_EXPORT IRunControlFactory : public QObject
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
2009-09-25 11:35:44 +02:00
|
|
|
explicit IRunControlFactory(QObject *parent = 0);
|
|
|
|
|
virtual ~IRunControlFactory();
|
|
|
|
|
|
2009-10-08 18:37:18 +02:00
|
|
|
virtual bool canRun(RunConfiguration *runConfiguration, const QString &mode) const = 0;
|
|
|
|
|
virtual RunControl* create(RunConfiguration *runConfiguration, const QString &mode) = 0;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
virtual QString displayName() const = 0;
|
|
|
|
|
|
2010-04-16 11:46:47 +02:00
|
|
|
/// Returns the widget used to configure this runner. Ownership is transferred to the caller
|
|
|
|
|
virtual QWidget *createConfigurationWidget(RunConfiguration *runConfiguration) = 0;
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
|
|
|
|
|
2010-04-16 11:46:47 +02:00
|
|
|
/**
|
|
|
|
|
* Each instance of this class represents one item that is run.
|
2008-12-02 12:01:29 +01:00
|
|
|
*/
|
2010-04-16 11:46:47 +02:00
|
|
|
class PROJECTEXPLORER_EXPORT RunControl : public QObject
|
|
|
|
|
{
|
2008-12-02 12:01:29 +01:00
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
2010-04-30 13:19:31 +02:00
|
|
|
explicit RunControl(RunConfiguration *runConfiguration, QString mode);
|
2008-12-02 12:01:29 +01:00
|
|
|
virtual ~RunControl();
|
|
|
|
|
virtual void start() = 0;
|
2010-04-16 16:45:50 +02:00
|
|
|
virtual void stop() = 0; // Warning: assumed to be synchroneous!
|
2008-12-02 12:01:29 +01:00
|
|
|
virtual bool isRunning() const = 0;
|
2009-10-08 18:37:18 +02:00
|
|
|
virtual QString displayName() const;
|
|
|
|
|
|
|
|
|
|
bool sameRunConfiguration(RunControl *other);
|
|
|
|
|
|
2010-07-13 15:02:37 +02:00
|
|
|
OutputFormatter *outputFormatter();
|
2010-04-30 13:19:31 +02:00
|
|
|
QString runMode() const;
|
2010-04-19 10:48:50 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
signals:
|
2010-07-02 15:30:25 +02:00
|
|
|
void addToOutputWindow(ProjectExplorer::RunControl *, const QString &line, bool onStdErr);
|
|
|
|
|
void addToOutputWindowInline(ProjectExplorer::RunControl *, const QString &line, bool onStdErr);
|
|
|
|
|
void appendMessage(ProjectExplorer::RunControl *, const QString &error, bool isError);
|
2008-12-02 12:01:29 +01:00
|
|
|
void started();
|
|
|
|
|
void finished();
|
2010-04-16 12:51:15 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
public slots:
|
|
|
|
|
void bringApplicationToForeground(qint64 pid);
|
2010-04-16 12:51:15 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
private slots:
|
|
|
|
|
void bringApplicationToForegroundInternal();
|
|
|
|
|
|
|
|
|
|
private:
|
2009-10-08 18:37:18 +02:00
|
|
|
QString m_displayName;
|
2010-04-30 13:19:31 +02:00
|
|
|
QString m_runMode;
|
2009-10-08 18:37:18 +02:00
|
|
|
const QWeakPointer<RunConfiguration> m_runConfiguration;
|
2010-07-13 15:02:37 +02:00
|
|
|
OutputFormatter *m_outputFormatter;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
#ifdef Q_OS_MAC
|
|
|
|
|
//these two are used to bring apps in the foreground on Mac
|
|
|
|
|
qint64 m_internalPid;
|
|
|
|
|
int m_foregroundCount;
|
|
|
|
|
#endif
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace ProjectExplorer
|
|
|
|
|
|
|
|
|
|
// Allow a RunConfiguration to be stored in a QVariant
|
|
|
|
|
Q_DECLARE_METATYPE(ProjectExplorer::RunConfiguration*)
|
|
|
|
|
|
|
|
|
|
#endif // RUNCONFIGURATION_H
|