OSDN Git Service

RemoteLinux: Add support for alternate remote command.
authorChristian Kandeler <christian.kandeler@nokia.com>
Tue, 27 Sep 2011 15:17:23 +0000 (17:17 +0200)
committerChristian Kandeler <christian.kandeler@nokia.com>
Tue, 27 Sep 2011 15:20:25 +0000 (17:20 +0200)
Sometimes, it is not the deployed binary that we want to call, but e.g.
some wrapper.

Change-Id: Ic8fe8f865cc29bf01e64b3781a92362b4521d8e4
Reviewed-on: http://codereview.qt-project.org/5642
Reviewed-by: Christian Kandeler <christian.kandeler@nokia.com>
src/plugins/remotelinux/remotelinuxrunconfiguration.cpp
src/plugins/remotelinux/remotelinuxrunconfiguration.h
src/plugins/remotelinux/remotelinuxrunconfigurationwidget.cpp
src/plugins/remotelinux/remotelinuxrunconfigurationwidget.h

index 5b3b5e1..e8a697e 100644 (file)
@@ -60,6 +60,9 @@ const char ProFileKey[] = "Qt4ProjectManager.MaemoRunConfiguration.ProFile";
 const char BaseEnvironmentBaseKey[] = "Qt4ProjectManager.MaemoRunConfiguration.BaseEnvironmentBase";
 const char UserEnvironmentChangesKey[]
     = "Qt4ProjectManager.MaemoRunConfiguration.UserEnvironmentChanges";
+const char UseAlternateExeKey[] = "RemoteLinux.RunConfig.UseAlternateRemoteExecutable";
+const char AlternateExeKey[] = "RemoteLinux.RunConfig.AlternateRemoteExecutable";
+
 } // anonymous namespace
 
 class RemoteLinuxRunConfigurationPrivate {
@@ -68,7 +71,8 @@ public:
         : proFilePath(proFilePath),
           baseEnvironmentType(RemoteLinuxRunConfiguration::SystemBaseEnvironment),
           validParse(target->qt4Project()->validParse(proFilePath)),
-          parseInProgress(target->qt4Project()->parseInProgress(proFilePath))
+          parseInProgress(target->qt4Project()->parseInProgress(proFilePath)),
+          useAlternateRemoteExecutable(false)
     {
     }
 
@@ -78,7 +82,9 @@ public:
           systemEnvironment(other->systemEnvironment),
           userEnvironmentChanges(other->userEnvironmentChanges),
           validParse(other->validParse),
-          parseInProgress(other->parseInProgress)
+          parseInProgress(other->parseInProgress),
+          useAlternateRemoteExecutable(other->useAlternateRemoteExecutable),
+          alternateRemoteExecutable(other->alternateRemoteExecutable)
     {
     }
 
@@ -91,7 +97,10 @@ public:
     bool validParse;
     bool parseInProgress;
     QString disabledReason;
+    bool useAlternateRemoteExecutable;
+    QString alternateRemoteExecutable;
 };
+
 } // namespace Internal
 
 using namespace Internal;
@@ -205,6 +214,8 @@ QVariantMap RemoteLinuxRunConfiguration::toMap() const
     map.insert(QLatin1String(BaseEnvironmentBaseKey), d->baseEnvironmentType);
     map.insert(QLatin1String(UserEnvironmentChangesKey),
         Utils::EnvironmentItem::toStringList(d->userEnvironmentChanges));
+    map.insert(QLatin1String(UseAlternateExeKey), d->useAlternateRemoteExecutable);
+    map.insert(QLatin1String(AlternateExeKey), d->alternateRemoteExecutable);
     return map;
 }
 
@@ -221,6 +232,8 @@ bool RemoteLinuxRunConfiguration::fromMap(const QVariantMap &map)
         .toStringList());
     d->baseEnvironmentType = static_cast<BaseEnvironmentType>(map.value(QLatin1String(BaseEnvironmentBaseKey),
         SystemBaseEnvironment).toInt());
+    d->useAlternateRemoteExecutable = map.value(QLatin1String(UseAlternateExeKey), false).toBool();
+    d->alternateRemoteExecutable = map.value(QLatin1String(AlternateExeKey)).toString();
 
     d->validParse = qt4Target()->qt4Project()->validParse(d->proFilePath);
     d->parseInProgress = qt4Target()->qt4Project()->parseInProgress(d->proFilePath);
@@ -286,13 +299,19 @@ QString RemoteLinuxRunConfiguration::localExecutableFilePath() const
     return QDir::cleanPath(ti.workingDir + QLatin1Char('/') + ti.target);
 }
 
-QString RemoteLinuxRunConfiguration::remoteExecutableFilePath() const
+QString RemoteLinuxRunConfiguration::defaultRemoteExecutableFilePath() const
 {
     return deployConfig()
         ? deployConfig()->deploymentInfo()->remoteExecutableFilePath(localExecutableFilePath())
         : QString();
 }
 
+QString RemoteLinuxRunConfiguration::remoteExecutableFilePath() const
+{
+    return d->useAlternateRemoteExecutable
+        ? alternateRemoteExecutable() : defaultRemoteExecutableFilePath();
+}
+
 PortList RemoteLinuxRunConfiguration::freePorts() const
 {
     const LinuxDeviceConfiguration::ConstPtr &devConf = deviceConfig();
@@ -306,6 +325,26 @@ void RemoteLinuxRunConfiguration::setArguments(const QString &args)
     d->arguments = args;
 }
 
+void RemoteLinuxRunConfiguration::setUseAlternateExecutable(bool useAlternate)
+{
+    d->useAlternateRemoteExecutable = useAlternate;
+}
+
+bool RemoteLinuxRunConfiguration::useAlternateExecutable() const
+{
+    return d->useAlternateRemoteExecutable;
+}
+
+void RemoteLinuxRunConfiguration::setAlternateRemoteExecutable(const QString &exe)
+{
+    d->alternateRemoteExecutable = exe;
+}
+
+QString RemoteLinuxRunConfiguration::alternateRemoteExecutable() const
+{
+    return d->alternateRemoteExecutable;
+}
+
 RemoteLinuxRunConfiguration::DebuggingType RemoteLinuxRunConfiguration::debuggingType() const
 {
     if (useCppDebugger()) {
index e1ad021..406850e 100644 (file)
@@ -89,9 +89,14 @@ public:
     virtual DebuggingType debuggingType() const;
 
     QString localExecutableFilePath() const;
+    QString defaultRemoteExecutableFilePath() const;
     QString remoteExecutableFilePath() const;
     QString arguments() const;
     void setArguments(const QString &args);
+    void setAlternateRemoteExecutable(const QString &exe);
+    QString alternateRemoteExecutable() const;
+    void setUseAlternateExecutable(bool useAlternate);
+    bool useAlternateExecutable() const;
     QSharedPointer<const LinuxDeviceConfiguration> deviceConfig() const;
     QString gdbCmd() const;
 
index db8d832..b12ee17 100644 (file)
@@ -47,6 +47,7 @@
 #include <QtGui/QButtonGroup>
 #include <QtCore/QCoreApplication>
 #include <QtCore/QDir>
+#include <QtGui/QCheckBox>
 #include <QtGui/QComboBox>
 #include <QtGui/QFormLayout>
 #include <QtGui/QGroupBox>
@@ -85,6 +86,8 @@ public:
     QLineEdit argsLineEdit;
     QLabel localExecutableLabel;
     QLabel remoteExecutableLabel;
+    QCheckBox useAlternateCommandBox;
+    QLineEdit alternateCommand;
     QLabel devConfLabel;
     QLabel debuggingLanguagesLabel;
     QRadioButton debugCppOnlyButton;
@@ -177,6 +180,16 @@ void RemoteLinuxRunConfigurationWidget::addGenericWidgets(QVBoxLayout *mainLayou
     d->localExecutableLabel.setText(d->runConfiguration->localExecutableFilePath());
     formLayout->addRow(tr("Executable on host:"), &d->localExecutableLabel);
     formLayout->addRow(tr("Executable on device:"), &d->remoteExecutableLabel);
+    QWidget * const altRemoteExeWidget = new QWidget;
+    QHBoxLayout * const altRemoteExeLayout = new QHBoxLayout(altRemoteExeWidget);
+    altRemoteExeLayout->setContentsMargins(0, 0, 0, 0);
+    d->alternateCommand.setText(d->runConfiguration->alternateRemoteExecutable());
+    altRemoteExeLayout->addWidget(&d->alternateCommand);
+    d->useAlternateCommandBox.setText(tr("Use this command instead"));
+    d->useAlternateCommandBox.setChecked(d->runConfiguration->useAlternateExecutable());
+    altRemoteExeLayout->addWidget(&d->useAlternateCommandBox);
+    formLayout->addRow(tr("Alternate executable on device:"), altRemoteExeWidget);
+
     d->argsLineEdit.setText(d->runConfiguration->arguments());
     formLayout->addRow(tr("Arguments:"), &d->argsLineEdit);
 
@@ -214,7 +227,12 @@ void RemoteLinuxRunConfigurationWidget::addGenericWidgets(QVBoxLayout *mainLayou
     connect(d->runConfiguration, SIGNAL(targetInformationChanged()), this,
         SLOT(updateTargetInformation()));
     connect(d->runConfiguration, SIGNAL(deploySpecsChanged()), SLOT(handleDeploySpecsChanged()));
+    connect(&d->useAlternateCommandBox, SIGNAL(toggled(bool)),
+        SLOT(handleUseAlternateCommandChanged()));
+    connect(&d->alternateCommand, SIGNAL(textEdited(QString)),
+        SLOT(handleAlternateCommandChanged()));
     handleDeploySpecsChanged();
+    handleUseAlternateCommandChanged();
 }
 
 void RemoteLinuxRunConfigurationWidget::addEnvironmentWidgets(QVBoxLayout *mainLayout)
@@ -267,7 +285,20 @@ void RemoteLinuxRunConfigurationWidget::updateTargetInformation()
 
 void RemoteLinuxRunConfigurationWidget::handleDeploySpecsChanged()
 {
-    d->remoteExecutableLabel.setText(d->runConfiguration->remoteExecutableFilePath());
+    d->remoteExecutableLabel.setText(d->runConfiguration->defaultRemoteExecutableFilePath());
+}
+
+void RemoteLinuxRunConfigurationWidget::handleUseAlternateCommandChanged()
+{
+    const bool useAltExe = d->useAlternateCommandBox.isChecked();
+    d->remoteExecutableLabel.setEnabled(!useAltExe);
+    d->alternateCommand.setEnabled(useAltExe);
+    d->runConfiguration->setUseAlternateExecutable(useAltExe);
+}
+
+void RemoteLinuxRunConfigurationWidget::handleAlternateCommandChanged()
+{
+    d->runConfiguration->setAlternateRemoteExecutable(d->alternateCommand.text().trimmed());
 }
 
 void RemoteLinuxRunConfigurationWidget::showDeviceConfigurationsDialog(const QString &link)
index 41f7e54..06393c8 100644 (file)
@@ -77,6 +77,8 @@ private slots:
     void userEnvironmentChangesChanged(const QList<Utils::EnvironmentItem> &userChanges);
     void handleDebuggingTypeChanged();
     void handleDeploySpecsChanged();
+    void handleUseAlternateCommandChanged();
+    void handleAlternateCommandChanged();
 
 private:
     void addGenericWidgets(QVBoxLayout *mainLayout);