From 1c0896286a12cb7cada8e34b0dceca8bd3eb37a2 Mon Sep 17 00:00:00 2001
From: Tobias Hunger <tobias.hunger@nokia.com>
Date: Tue, 29 Mar 2011 17:51:40 +0200
Subject: [PATCH] Toolchain: Add option to make toolchain readonly

Do not just disable the toolchain when it is read-only. Add a method to
make it read-only instead.

Task-number: QTCREATORBUG-4211
---
 src/plugins/projectexplorer/gcctoolchain.cpp           | 7 +++++++
 src/plugins/projectexplorer/gcctoolchainfactories.h    | 1 +
 src/plugins/projectexplorer/toolchainconfigwidget.cpp  | 6 ++++++
 src/plugins/projectexplorer/toolchainconfigwidget.h    | 2 ++
 src/plugins/projectexplorer/toolchainoptionspage.cpp   | 3 ++-
 src/plugins/qt4projectmanager/qt-s60/rvcttoolchain.cpp | 8 ++++++++
 src/plugins/qt4projectmanager/qt-s60/rvcttoolchain.h   | 1 +
 7 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/src/plugins/projectexplorer/gcctoolchain.cpp b/src/plugins/projectexplorer/gcctoolchain.cpp
index 91072330489..b804b9aced7 100644
--- a/src/plugins/projectexplorer/gcctoolchain.cpp
+++ b/src/plugins/projectexplorer/gcctoolchain.cpp
@@ -626,6 +626,13 @@ bool Internal::GccToolChainConfigWidget::isDirty() const
             || m_abiList.at(m_abiComboBox->currentIndex()) != tc->targetAbi();
 }
 
+void Internal::GccToolChainConfigWidget::makeReadOnly()
+{
+    m_compilerPath->setEnabled(false);
+    m_abiComboBox->setEnabled(false);
+    ToolChainConfigWidget::makeReadOnly();
+}
+
 void Internal::GccToolChainConfigWidget::handlePathChange()
 {
     QString path = m_compilerPath->path();
diff --git a/src/plugins/projectexplorer/gcctoolchainfactories.h b/src/plugins/projectexplorer/gcctoolchainfactories.h
index 5ee603d2dd3..bed6fefeedb 100644
--- a/src/plugins/projectexplorer/gcctoolchainfactories.h
+++ b/src/plugins/projectexplorer/gcctoolchainfactories.h
@@ -91,6 +91,7 @@ public:
     void apply();
     void discard() { setFromToolchain(); }
     bool isDirty() const;
+    void makeReadOnly();
 
 private slots:
     void handlePathChange();
diff --git a/src/plugins/projectexplorer/toolchainconfigwidget.cpp b/src/plugins/projectexplorer/toolchainconfigwidget.cpp
index 7efa4bb69ab..1285e7fdec1 100644
--- a/src/plugins/projectexplorer/toolchainconfigwidget.cpp
+++ b/src/plugins/projectexplorer/toolchainconfigwidget.cpp
@@ -83,6 +83,12 @@ ToolChain *ToolChainConfigWidget::toolChain() const
     return m_d->m_toolChain;
 }
 
+void ToolChainConfigWidget::makeReadOnly()
+{
+    if (m_d->m_debuggerPathChooser)
+        m_d->m_debuggerPathChooser->setEnabled(false);
+}
+
 void ToolChainConfigWidget::emitDirty()
 {
     emit dirty(toolChain());
diff --git a/src/plugins/projectexplorer/toolchainconfigwidget.h b/src/plugins/projectexplorer/toolchainconfigwidget.h
index c4dd1ba2d83..4945fd24584 100644
--- a/src/plugins/projectexplorer/toolchainconfigwidget.h
+++ b/src/plugins/projectexplorer/toolchainconfigwidget.h
@@ -68,6 +68,8 @@ public:
 
     virtual bool isDirty() const = 0;
 
+    virtual void makeReadOnly();
+
 signals:
     void dirty(ProjectExplorer::ToolChain *);
 
diff --git a/src/plugins/projectexplorer/toolchainoptionspage.cpp b/src/plugins/projectexplorer/toolchainoptionspage.cpp
index 5b755283b07..65a5a26376b 100644
--- a/src/plugins/projectexplorer/toolchainoptionspage.cpp
+++ b/src/plugins/projectexplorer/toolchainoptionspage.cpp
@@ -63,7 +63,8 @@ public:
             p->childNodes.append(this);
         widget = tc ? tc->configurationWidget() : 0;
         if (widget) {
-            widget->setEnabled(tc ? !tc->isAutoDetected() : false);
+            if (tc && tc->isAutoDetected())
+                widget->makeReadOnly();
             widget->setVisible(false);
         }
     }
diff --git a/src/plugins/qt4projectmanager/qt-s60/rvcttoolchain.cpp b/src/plugins/qt4projectmanager/qt-s60/rvcttoolchain.cpp
index a29485bbcb4..aa9c4e86c2a 100644
--- a/src/plugins/qt4projectmanager/qt-s60/rvcttoolchain.cpp
+++ b/src/plugins/qt4projectmanager/qt-s60/rvcttoolchain.cpp
@@ -421,6 +421,14 @@ bool RvctToolChainConfigWidget::isDirty() const
             || tc->debuggerCommand() != debuggerCommand();
 }
 
+void RvctToolChainConfigWidget::makeReadOnly()
+{
+    m_ui->versionComboBox->setEnabled(false);
+    m_ui->compilerPath->setEnabled(false);
+    m_ui->environmentView->setEditTriggers(QAbstractItemView::NoEditTriggers);
+    ProjectExplorer::ToolChainConfigWidget::makeReadOnly();
+}
+
 QList<Utils::EnvironmentItem> RvctToolChainConfigWidget::environmentChanges() const
 {
     Utils::Environment baseEnv;
diff --git a/src/plugins/qt4projectmanager/qt-s60/rvcttoolchain.h b/src/plugins/qt4projectmanager/qt-s60/rvcttoolchain.h
index 40efbac9a40..d8c3acb2ccc 100644
--- a/src/plugins/qt4projectmanager/qt-s60/rvcttoolchain.h
+++ b/src/plugins/qt4projectmanager/qt-s60/rvcttoolchain.h
@@ -147,6 +147,7 @@ public:
     void apply();
     void discard() { setFromToolChain(); }
     bool isDirty() const;
+    void makeReadOnly();
 
 private:
     void setFromToolChain();
-- 
GitLab