From 6b3ef9f8185f12c00f7f67a0c9e3001b14f4e355 Mon Sep 17 00:00:00 2001
From: con <qtc-committer@nokia.com>
Date: Thu, 4 Jun 2009 10:50:44 +0200
Subject: [PATCH] Parametrize metroworks tools path.

---
 .../qt4projectmanager/qt-s60/qt-s60-todo.txt  |  3 +-
 .../qt4projectmanager/qt-s60/s60manager.cpp   |  2 +-
 .../qt-s60/winscwtoolchain.cpp                |  4 +-
 .../qt-s60/winscwtoolchain.h                  |  2 +-
 .../qt4projectmanager/qtoptionspage.cpp       | 37 +++++++++++++++++++
 src/plugins/qt4projectmanager/qtoptionspage.h |  4 ++
 .../qt4projectmanager/qtversionmanager.cpp    | 19 ++++++++++
 .../qt4projectmanager/qtversionmanager.h      |  7 ++++
 .../qt4projectmanager/qtversionmanager.ui     | 24 ++++++++++++
 9 files changed, 97 insertions(+), 5 deletions(-)

diff --git a/src/plugins/qt4projectmanager/qt-s60/qt-s60-todo.txt b/src/plugins/qt4projectmanager/qt-s60/qt-s60-todo.txt
index ee6481c0664..b7f0d13b75d 100644
--- a/src/plugins/qt4projectmanager/qt-s60/qt-s60-todo.txt
+++ b/src/plugins/qt4projectmanager/qt-s60/qt-s60-todo.txt
@@ -8,4 +8,5 @@
 * WINSCW tool chain:
     * predefined macros
     * system includes
-    * get rid of hardcoded carbide path
+
+* Run WINSCW executables
diff --git a/src/plugins/qt4projectmanager/qt-s60/s60manager.cpp b/src/plugins/qt4projectmanager/qt-s60/s60manager.cpp
index 283bb76a519..caa78d2eeb1 100644
--- a/src/plugins/qt4projectmanager/qt-s60/s60manager.cpp
+++ b/src/plugins/qt4projectmanager/qt-s60/s60manager.cpp
@@ -114,5 +114,5 @@ void S60Manager::updateQtVersions()
 ProjectExplorer::ToolChain *S60Manager::createWINSCWToolChain(const Qt4ProjectManager::QtVersion *version) const
 {
     QString id = version->autodetectionSource().mid(QString(S60_AUTODETECTION_SOURCE).length()+1);
-    return new WINSCWToolChain(m_devices->deviceForId(id));
+    return new WINSCWToolChain(m_devices->deviceForId(id), version->mwcDirectory());
 }
diff --git a/src/plugins/qt4projectmanager/qt-s60/winscwtoolchain.cpp b/src/plugins/qt4projectmanager/qt-s60/winscwtoolchain.cpp
index b0bad58ac5f..6a924b95a67 100644
--- a/src/plugins/qt4projectmanager/qt-s60/winscwtoolchain.cpp
+++ b/src/plugins/qt4projectmanager/qt-s60/winscwtoolchain.cpp
@@ -3,9 +3,9 @@
 using namespace ProjectExplorer;
 using namespace Qt4ProjectManager::Internal;
 
-WINSCWToolChain::WINSCWToolChain(S60Devices::Device device)
+WINSCWToolChain::WINSCWToolChain(S60Devices::Device device, const QString &mwcDirectory)
         // TODO get rid of hardcoded carbide path
-    : m_carbidePath(QLatin1String("C:\\Apps\\Nokia\\Carbide.c++ v2.0")),
+    : m_carbidePath(mwcDirectory),
     m_deviceId(device.id),
     m_deviceName(device.name),
     m_deviceRoot(device.epocRoot)
diff --git a/src/plugins/qt4projectmanager/qt-s60/winscwtoolchain.h b/src/plugins/qt4projectmanager/qt-s60/winscwtoolchain.h
index 84f4ab9d722..835ac84bece 100644
--- a/src/plugins/qt4projectmanager/qt-s60/winscwtoolchain.h
+++ b/src/plugins/qt4projectmanager/qt-s60/winscwtoolchain.h
@@ -11,7 +11,7 @@ namespace Internal {
 class WINSCWToolChain : public ProjectExplorer::ToolChain
 {
 public:
-    WINSCWToolChain(S60Devices::Device device);
+    WINSCWToolChain(S60Devices::Device device, const QString &mwcDirectory);
     QByteArray predefinedMacros();
     QList<ProjectExplorer::HeaderPath> systemHeaderPaths();
     void addToEnvironment(ProjectExplorer::Environment &env);
diff --git a/src/plugins/qt4projectmanager/qtoptionspage.cpp b/src/plugins/qt4projectmanager/qtoptionspage.cpp
index 839223ef5be..06c2eb585d3 100644
--- a/src/plugins/qt4projectmanager/qtoptionspage.cpp
+++ b/src/plugins/qt4projectmanager/qtoptionspage.cpp
@@ -81,6 +81,8 @@ QtOptionsPageWidget::QtOptionsPageWidget(QWidget *parent, QList<QtVersion *> ver
     m_ui->qtPath->setPromptDialogTitle(tr("Select QTDIR"));
     m_ui->mingwPath->setExpectedKind(Core::Utils::PathChooser::Directory);
     m_ui->qtPath->setPromptDialogTitle(tr("Select the Qt Directory"));
+    m_ui->mwcPath->setExpectedKind(Core::Utils::PathChooser::Directory);
+    m_ui->mwcPath->setPromptDialogTitle(tr("Select \"x86build\" Directory from Carbide Install"));
 
     m_ui->addButton->setIcon(QIcon(Core::Constants::ICON_PLUS));
     m_ui->delButton->setIcon(QIcon(Core::Constants::ICON_MINUS));
@@ -126,6 +128,10 @@ QtOptionsPageWidget::QtOptionsPageWidget(QWidget *parent, QList<QtVersion *> ver
             this, SLOT(updateCurrentQtPath()));
     connect(m_ui->mingwPath, SIGNAL(changed()),
             this, SLOT(updateCurrentMingwDirectory()));
+#ifdef QTCREATOR_WITH_S60
+    connect(m_ui->mwcPath, SIGNAL(changed()),
+            this, SLOT(updateCurrentMwcDirectory()));
+#endif
 
     connect(m_ui->addButton, SIGNAL(clicked()),
             this, SLOT(addQtDir()));
@@ -278,6 +284,12 @@ void QtOptionsPageWidget::makeMSVCVisible(bool visible)
     m_ui->msvcNotFoundLabel->setVisible(false);
 }
 
+void QtOptionsPageWidget::makeMWCVisible(bool visible)
+{
+    m_ui->mwcLabel->setVisible(visible);
+    m_ui->mwcPath->setVisible(visible);
+}
+
 void QtOptionsPageWidget::showEnvironmentPage(QTreeWidgetItem *item)
 {
     if (item) {
@@ -285,6 +297,7 @@ void QtOptionsPageWidget::showEnvironmentPage(QTreeWidgetItem *item)
         if (index < 0) {
             makeMSVCVisible(false);
             makeMingwVisible(false);
+            makeMWCVisible(false);
             return;
         }
         m_ui->errorLabel->setText("");
@@ -292,10 +305,12 @@ void QtOptionsPageWidget::showEnvironmentPage(QTreeWidgetItem *item)
         if (t == ProjectExplorer::ToolChain::MinGW) {
             makeMSVCVisible(false);
             makeMingwVisible(true);
+            makeMWCVisible(false);
             m_ui->mingwPath->setPath(m_versions.at(index)->mingwDirectory());
         } else if (t == ProjectExplorer::ToolChain::MSVC || t == ProjectExplorer::ToolChain::WINCE){
             makeMSVCVisible(false);
             makeMingwVisible(false);
+            makeMWCVisible(false);
             QStringList msvcEnvironments = ProjectExplorer::ToolChain::availableMSVCVersions();
             if (msvcEnvironments.count() == 0) {
                 m_ui->msvcLabel->setVisible(true);
@@ -312,9 +327,17 @@ void QtOptionsPageWidget::showEnvironmentPage(QTreeWidgetItem *item)
                  }
                  m_ui->msvcComboBox->blockSignals(block);
             }
+#ifdef QTCREATOR_WITH_S60
+        } else if (t == ProjectExplorer::ToolChain::WINSCW) {
+            makeMSVCVisible(false);
+            makeMingwVisible(false);
+            makeMWCVisible(true);
+            m_ui->mwcPath->setPath(m_versions.at(index)->mwcDirectory());
+#endif
         } else if (t == ProjectExplorer::ToolChain::INVALID) {
             makeMSVCVisible(false);
             makeMingwVisible(false);
+            makeMWCVisible(false);
             if (!m_versions.at(index)->isInstalled())
                 m_ui->errorLabel->setText(tr("The Qt Version %1 is not installed. Run make install")
                                            .arg(QDir::toNativeSeparators(m_versions.at(index)->path())));
@@ -323,6 +346,7 @@ void QtOptionsPageWidget::showEnvironmentPage(QTreeWidgetItem *item)
         } else { //ProjectExplorer::ToolChain::GCC
             makeMSVCVisible(false);
             makeMingwVisible(false);
+            makeMWCVisible(false);
             m_ui->errorLabel->setText(tr("Found Qt version %1, using mkspec %2")
                                      .arg(m_versions.at(index)->qtVersionString(),
                                           m_versions.at(index)->mkspec()));
@@ -330,6 +354,7 @@ void QtOptionsPageWidget::showEnvironmentPage(QTreeWidgetItem *item)
     } else {
         makeMSVCVisible(false);
         makeMingwVisible(false);
+        makeMWCVisible(false);
     }
 }
 
@@ -507,6 +532,18 @@ void QtOptionsPageWidget::msvcVersionChanged()
     m_versions[currentItemIndex]->setMsvcVersion(msvcVersion);
 }
 
+#ifdef QTCREATOR_WITH_S60
+void QtOptionsPageWidget::updateCurrentMwcDirectory()
+{
+    QTreeWidgetItem *currentItem = m_ui->qtdirList->currentItem();
+    Q_ASSERT(currentItem);
+    int currentItemIndex = indexForTreeItem(currentItem);
+    if (currentItemIndex < 0)
+        return;
+    m_versions[currentItemIndex]->setMwcDirectory(m_ui->mwcPath->path());
+}
+#endif
+
 QList<QtVersion *> QtOptionsPageWidget::versions() const
 {
     return m_versions;
diff --git a/src/plugins/qt4projectmanager/qtoptionspage.h b/src/plugins/qt4projectmanager/qtoptionspage.h
index 81e99d40ea8..a78b80460e0 100644
--- a/src/plugins/qt4projectmanager/qtoptionspage.h
+++ b/src/plugins/qt4projectmanager/qtoptionspage.h
@@ -75,12 +75,16 @@ private slots:
     void updateState();
     void makeMingwVisible(bool visible);
     void makeMSVCVisible(bool visible);
+    void makeMWCVisible(bool visible);
     void onQtBrowsed();
     void onMingwBrowsed();
     void defaultChanged(int index);
     void updateCurrentQtName();
     void updateCurrentQtPath();
     void updateCurrentMingwDirectory();
+#ifdef QTCREATOR_WITH_S60
+    void updateCurrentMwcDirectory();
+#endif
     void msvcVersionChanged();
     void buildDebuggingHelper();
     void showDebuggingBuildLog();
diff --git a/src/plugins/qt4projectmanager/qtversionmanager.cpp b/src/plugins/qt4projectmanager/qtversionmanager.cpp
index 9f2ec031ab7..6309a7ebb5d 100644
--- a/src/plugins/qt4projectmanager/qtversionmanager.cpp
+++ b/src/plugins/qt4projectmanager/qtversionmanager.cpp
@@ -107,6 +107,9 @@ QtVersionManager::QtVersionManager()
                                            autodetectionSource);
         version->setMingwDirectory(s->value("MingwDirectory").toString());
         version->setMsvcVersion(s->value("msvcVersion").toString());
+#ifdef QTCREATOR_WITH_S60
+        version->setMwcDirectory(s->value("MwcDirectory").toString());
+#endif
         m_versions.append(version);
     }
     s->endArray();
@@ -221,6 +224,9 @@ void QtVersionManager::writeVersionsIntoSettings()
         s->setValue("isAutodetected", version->isAutodetected());
         if (version->isAutodetected())
             s->setValue("autodetectionSource", version->autodetectionSource());
+#ifdef QTCREATOR_WITH_S60
+        s->setValue("MwcDirectory", version->mwcDirectory());
+#endif
     }
     s->endArray();
 }
@@ -1021,6 +1027,19 @@ ProjectExplorer::ToolChain::ToolChainType QtVersion::toolchainType() const
         return ProjectExplorer::ToolChain::GCC;
 }
 
+#ifdef QTCREATOR_WITH_S60
+QString QtVersion::mwcDirectory() const
+{
+    return m_mwcDirectory;
+}
+
+void QtVersion::setMwcDirectory(const QString &directory)
+{
+    m_mwcDirectory = directory;
+    m_toolChainUpToDate = false;
+}
+#endif
+
 QString QtVersion::mingwDirectory() const
 {
     return m_mingwDirectory;
diff --git a/src/plugins/qt4projectmanager/qtversionmanager.h b/src/plugins/qt4projectmanager/qtversionmanager.h
index b9a1b051eb8..217a763e4a9 100644
--- a/src/plugins/qt4projectmanager/qtversionmanager.h
+++ b/src/plugins/qt4projectmanager/qtversionmanager.h
@@ -83,6 +83,10 @@ public:
 
     ProjectExplorer::ToolChain::ToolChainType toolchainType() const;
 
+#ifdef QTCREATOR_WITH_S60
+    QString mwcDirectory() const;
+    void setMwcDirectory(const QString &directory);
+#endif
     QString mingwDirectory() const;
     void setMingwDirectory(const QString &directory);
     QString msvcVersion() const;
@@ -135,6 +139,9 @@ private:
     bool m_isAutodetected;
     QString m_autodetectionSource;
     bool m_hasDebuggingHelper;
+#ifdef QTCREATOR_WITH_S60
+    QString m_mwcDirectory;
+#endif
 
     mutable bool m_mkspecUpToDate;
     mutable QString m_mkspec; // updated lazily
diff --git a/src/plugins/qt4projectmanager/qtversionmanager.ui b/src/plugins/qt4projectmanager/qtversionmanager.ui
index d870d16df98..b92932ece62 100644
--- a/src/plugins/qt4projectmanager/qtversionmanager.ui
+++ b/src/plugins/qt4projectmanager/qtversionmanager.ui
@@ -162,6 +162,16 @@ p, li { white-space: pre-wrap; }
         </item>
        </layout>
       </item>
+      <item row="5" column="0">
+       <widget class="QLabel" name="mwcLabel">
+        <property name="text">
+         <string>MWC Directory:</string>
+        </property>
+       </widget>
+      </item>
+      <item row="5" column="1">
+       <widget class="Core::Utils::PathChooser" name="mwcPath" native="true"/>
+      </item>
       <item row="6" column="0">
        <widget class="QLabel" name="label">
         <property name="text">
@@ -208,6 +218,20 @@ p, li { white-space: pre-wrap; }
        </widget>
       </item>
      </layout>
+     <zorder>qtdirList</zorder>
+     <zorder>versionNameLabel</zorder>
+     <zorder>nameEdit</zorder>
+     <zorder>pathLabel</zorder>
+     <zorder>qtPath</zorder>
+     <zorder>mingwLabel</zorder>
+     <zorder>mingwPath</zorder>
+     <zorder>msvcLabel</zorder>
+     <zorder>label</zorder>
+     <zorder>errorLabel</zorder>
+     <zorder>mwcLabel</zorder>
+     <zorder>mwcPath</zorder>
+     <zorder>msvcComboBox</zorder>
+     <zorder>msvcNotFoundLabel</zorder>
     </widget>
    </item>
    <item>
-- 
GitLab