From f90128c1f1286e99d6deb8d8f78a50c95b7e67ec Mon Sep 17 00:00:00 2001
From: Orgad Shaneh <orgads@gmail.com>
Date: Thu, 26 Jan 2012 20:57:00 +0200
Subject: [PATCH] Debugger: Use toolchain for remote debugging

Just like the other dialogs

Change-Id: If2a87a688f5d3653bca02912dc9052399f72de87
Reviewed-by: hjk <qthjk@ovi.com>
---
 src/plugins/debugger/debuggerdialogs.cpp  | 23 ++++++++++++++++-------
 src/plugins/debugger/debuggerdialogs.h    |  6 ++++--
 src/plugins/debugger/debuggerplugin.cpp   | 13 ++++++-------
 src/plugins/debugger/startremotedialog.ui | 17 +++++++++++------
 4 files changed, 37 insertions(+), 22 deletions(-)

diff --git a/src/plugins/debugger/debuggerdialogs.cpp b/src/plugins/debugger/debuggerdialogs.cpp
index 70e88a6e4c2..70401043f08 100644
--- a/src/plugins/debugger/debuggerdialogs.cpp
+++ b/src/plugins/debugger/debuggerdialogs.cpp
@@ -561,10 +561,8 @@ StartRemoteDialog::StartRemoteDialog(QWidget *parent, bool enableStartScript)
 {
     setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
     m_ui->setupUi(this);
+    m_ui->toolchainComboBox->init(false);
     m_ui->buttonBox->button(QDialogButtonBox::Ok)->setDefault(true);
-    m_ui->debuggerPathChooser->setExpectedKind(PathChooser::File);
-    m_ui->debuggerPathChooser->setPromptDialogTitle(tr("Select Debugger"));
-    m_ui->debuginfoPathChooser->setExpectedKind(PathChooser::File);
     m_ui->debuginfoPathChooser->setPromptDialogTitle(tr("Select Location of Debugging Information"));
     m_ui->executablePathChooser->setExpectedKind(PathChooser::File);
     m_ui->executablePathChooser->setPromptDialogTitle(tr("Select Executable"));
@@ -611,14 +609,25 @@ QString StartRemoteDialog::localExecutable() const
     return m_ui->executablePathChooser->path();
 }
 
-void StartRemoteDialog::setDebugger(const QString &debugger)
+ProjectExplorer::Abi StartRemoteDialog::abi() const
+{
+    return m_ui->toolchainComboBox->abi();
+}
+
+void StartRemoteDialog::setAbiIndex(int i)
+{
+    if (i >= 0 && i < m_ui->toolchainComboBox->count())
+        m_ui->toolchainComboBox->setCurrentIndex(i);
+}
+
+int StartRemoteDialog::abiIndex() const
 {
-    m_ui->debuggerPathChooser->setPath(debugger);
+    return m_ui->toolchainComboBox->currentIndex();
 }
 
-QString StartRemoteDialog::debugger() const
+QString StartRemoteDialog::debuggerCommand() const
 {
-    return m_ui->debuggerPathChooser->path();
+    return m_ui->toolchainComboBox->debuggerCommand();
 }
 
 void StartRemoteDialog::setDebugInfoLocation(const QString &location)
diff --git a/src/plugins/debugger/debuggerdialogs.h b/src/plugins/debugger/debuggerdialogs.h
index e9a689bef51..d9d30961521 100644
--- a/src/plugins/debugger/debuggerdialogs.h
+++ b/src/plugins/debugger/debuggerdialogs.h
@@ -195,8 +195,10 @@ public:
     QString sysroot() const;
     void setSysroot(const QString &sysroot);
 
-    QString debugger() const;
-    void setDebugger(const QString &debugger);
+    int abiIndex() const;
+    void setAbiIndex(int);
+    ProjectExplorer::Abi abi() const;
+    QString debuggerCommand() const;
 
     void setDebugInfoLocation(const QString &location);
     QString debugInfoLocation() const;
diff --git a/src/plugins/debugger/debuggerplugin.cpp b/src/plugins/debugger/debuggerplugin.cpp
index 1d332b7f187..3078dce397f 100644
--- a/src/plugins/debugger/debuggerplugin.cpp
+++ b/src/plugins/debugger/debuggerplugin.cpp
@@ -1614,7 +1614,7 @@ void DebuggerPluginPrivate::attachCore()
     AttachCoreDialog dlg(mainWindow());
     dlg.setExecutableFile(configValue(_("LastExternalExecutableFile")).toString());
     dlg.setCoreFile(configValue(_("LastExternalCoreFile")).toString());
-    dlg.setAbiIndex(configValue(_("LastExternalCoreAbiIndex")).toInt());
+    dlg.setAbiIndex(configValue(_("LastExternalAbiIndex")).toInt());
     dlg.setSysroot(configValue(_("LastSysroot")).toString());
     dlg.setOverrideStartScript(configValue(_("LastExternalStartScript")).toString());
 
@@ -1623,7 +1623,7 @@ void DebuggerPluginPrivate::attachCore()
 
     setConfigValue(_("LastExternalExecutableFile"), dlg.executableFile());
     setConfigValue(_("LastExternalCoreFile"), dlg.coreFile());
-    setConfigValue(_("LastExternalCoreAbiIndex"), QVariant(dlg.abiIndex()));
+    setConfigValue(_("LastExternalAbiIndex"), QVariant(dlg.abiIndex()));
     setConfigValue(_("LastSysroot"), dlg.sysroot());
     setConfigValue(_("LastExternalStartScript"), dlg.overrideStartScript());
 
@@ -1690,7 +1690,7 @@ bool DebuggerPluginPrivate::queryRemoteParameters(DebuggerStartParameters &sp, b
             configValue(_("LastRemoteChannel")).toString());
     dlg.setLocalExecutable(
             configValue(_("LastLocalExecutable")).toString());
-    dlg.setDebugger(configValue(_("LastDebugger")).toString());
+    dlg.setAbiIndex(configValue(_("LastExternalAbiIndex")).toInt());
     dlg.setRemoteArchitecture(lastUsed);
     dlg.setOverrideStartScript(configValue(_("LastRemoteStartScript")).toString());
     dlg.setServerStartScript(
@@ -1703,7 +1703,7 @@ bool DebuggerPluginPrivate::queryRemoteParameters(DebuggerStartParameters &sp, b
         return false;
     setConfigValue(_("LastRemoteChannel"), dlg.remoteChannel());
     setConfigValue(_("LastLocalExecutable"), dlg.localExecutable());
-    setConfigValue(_("LastDebugger"), dlg.debugger());
+    setConfigValue(_("LastExternalAbiIndex"), QVariant(dlg.abiIndex()));
     setConfigValue(_("LastRemoteArchitecture"), dlg.remoteArchitecture());
     setConfigValue(_("LastRemoteStartScript"), dlg.overrideStartScript());
     setConfigValue(_("LastServerStartScript"), dlg.serverStartScript());
@@ -1714,9 +1714,8 @@ bool DebuggerPluginPrivate::queryRemoteParameters(DebuggerStartParameters &sp, b
     sp.remoteArchitecture = dlg.remoteArchitecture();
     sp.executable = dlg.localExecutable();
     sp.displayName = tr("Remote: \"%1\"").arg(sp.remoteChannel);
-    sp.debuggerCommand = dlg.debugger(); // Override toolchain-detection.
-    if (!sp.debuggerCommand.isEmpty())
-        sp.toolChainAbi = Abi();
+    sp.debuggerCommand = dlg.debuggerCommand();
+    sp.toolChainAbi = dlg.abi();
     sp.overrideStartScript = dlg.overrideStartScript();
     sp.useServerStartScript = dlg.useServerStartScript();
     sp.serverStartScript = dlg.serverStartScript();
diff --git a/src/plugins/debugger/startremotedialog.ui b/src/plugins/debugger/startremotedialog.ui
index 1ad0b07b182..7df03e954df 100644
--- a/src/plugins/debugger/startremotedialog.ui
+++ b/src/plugins/debugger/startremotedialog.ui
@@ -22,16 +22,13 @@
      <item row="0" column="0">
       <widget class="QLabel" name="debuggerLabel">
        <property name="text">
-        <string>&amp;Debugger:</string>
+        <string>Tool &amp;chain:</string>
        </property>
        <property name="buddy">
-        <cstring>debuggerPathChooser</cstring>
+        <cstring>toolchainComboBox</cstring>
        </property>
       </widget>
      </item>
-     <item row="0" column="1">
-      <widget class="Utils::PathChooser" name="debuggerPathChooser" native="true"/>
-     </item>
      <item row="1" column="0">
       <widget class="QLabel" name="executableLabel">
        <property name="text">
@@ -95,7 +92,7 @@
      <item row="5" column="0">
       <widget class="QLabel" name="debuginfoLabel">
        <property name="text">
-        <string>Location of debugging information:</string>
+        <string>Location of debugging &amp;information:</string>
        </property>
        <property name="buddy">
         <cstring>debuginfoPathChooser</cstring>
@@ -144,6 +141,9 @@
      <item row="8" column="1">
       <widget class="Utils::PathChooser" name="serverStartScriptPathChooser" native="true"/>
      </item>
+     <item row="0" column="1">
+      <widget class="Debugger::Internal::DebuggerToolChainComboBox" name="toolchainComboBox"/>
+     </item>
     </layout>
    </item>
    <item>
@@ -169,6 +169,11 @@
     <signal>browsingFinished()</signal>
    </slots>
   </customwidget>
+  <customwidget>
+   <class>Debugger::Internal::DebuggerToolChainComboBox</class>
+   <extends>QComboBox</extends>
+   <header>debuggertoolchaincombobox.h</header>
+  </customwidget>
  </customwidgets>
  <resources/>
  <connections/>
-- 
GitLab