OSDN Git Service

Added toolchain selection option to Publish to Ovi wizard
authorPawel Polanski <pawel.3.polanski@nokia.com>
Tue, 10 May 2011 15:05:35 +0000 (17:05 +0200)
committerPawel Polanski <pawel.3.polanski@nokia.com>
Fri, 13 May 2011 10:35:53 +0000 (12:35 +0200)
User is now able to choose another than the default
toolchain

Reviewed-by: dt
src/plugins/qt4projectmanager/qt-s60/s60publishingbuildsettingspageovi.cpp
src/plugins/qt4projectmanager/qt-s60/s60publishingbuildsettingspageovi.h
src/plugins/qt4projectmanager/qt-s60/s60publishingbuildsettingspageovi.ui

index d9490ce..e45daf1 100644 (file)
@@ -38,6 +38,7 @@
 
 #include <projectexplorer/project.h>
 #include <projectexplorer/target.h>
+#include <projectexplorer/toolchain.h>
 
 #include <QtGui/QAbstractButton>
 
@@ -46,6 +47,8 @@ namespace Internal {
 
 S60PublishingBuildSettingsPageOvi::S60PublishingBuildSettingsPageOvi(S60PublisherOvi *publisher, const ProjectExplorer::Project *project, QWidget *parent) :
     QWizardPage(parent),
+    m_bc(0),
+    m_toolchain(0),
     m_ui(new Ui::S60PublishingBuildSettingsPageOvi),
     m_publisher(publisher)
 {
@@ -69,9 +72,6 @@ S60PublishingBuildSettingsPageOvi::S60PublishingBuildSettingsPageOvi(S60Publishe
     foreach (Qt4BuildConfiguration *qt4bc, list)
         m_ui->chooseBuildConfigDropDown->addItem(qt4bc->displayName(), QVariant::fromValue(static_cast<ProjectExplorer::BuildConfiguration *>(qt4bc)));
 
-
-    m_bc = 0;
-
     // todo more intelligent selection? prefer newer versions?
     foreach (Qt4BuildConfiguration *qt4bc, list)
         if (!m_bc && !(qt4bc->qmakeBuildConfiguration() & BaseQtVersion::DebugBuild))
@@ -84,14 +84,46 @@ S60PublishingBuildSettingsPageOvi::S60PublishingBuildSettingsPageOvi(S60Publishe
     int focusedIndex = m_ui->chooseBuildConfigDropDown->findData(QVariant::fromValue(m_bc));
     m_ui->chooseBuildConfigDropDown->setCurrentIndex(focusedIndex);
     m_publisher->setBuildConfiguration(static_cast<Qt4BuildConfiguration *>(m_bc));
+
+    populateToolchainList(m_bc);
+
     //change the build configuration if the user changes it
     connect(m_ui->chooseBuildConfigDropDown, SIGNAL(currentIndexChanged(int)), this, SLOT(buildConfigChosen()));
-    connect(this, SIGNAL(buildChosen()), SIGNAL(completeChanged()));
+    connect(this, SIGNAL(configurationChosen()), SIGNAL(completeChanged()));
+    connect(this, SIGNAL(toolchainConfigurationChosen()), SIGNAL(completeChanged()));
 }
 
 bool S60PublishingBuildSettingsPageOvi::isComplete() const
 {
-    return (m_bc != 0);
+    return m_bc && m_toolchain;
+}
+
+void S60PublishingBuildSettingsPageOvi::populateToolchainList(ProjectExplorer::BuildConfiguration *bc)
+{
+    if (!bc)
+        return;
+
+    disconnect(m_ui->chooseToolchainDropDown, SIGNAL(currentIndexChanged(int)), this, SLOT(toolchainChosen()));
+    m_ui->chooseToolchainDropDown->clear();
+    QList<ProjectExplorer::ToolChain *> toolchains = bc->target()->possibleToolChains(bc);
+
+    int index = 0;
+    bool toolchainChanged = true; // if the new build conf. doesn't contain previous toolchain
+    foreach (ProjectExplorer::ToolChain *toolchain, toolchains) {
+        m_ui->chooseToolchainDropDown->addItem(toolchain->displayName(),
+                                               qVariantFromValue(static_cast<void *>(toolchain)));
+        if (toolchainChanged && m_toolchain == toolchain) {
+            toolchainChanged = false;
+            m_ui->chooseToolchainDropDown->setCurrentIndex(index);
+        }
+        ++index;
+    }
+    connect(m_ui->chooseToolchainDropDown, SIGNAL(currentIndexChanged(int)), this, SLOT(toolchainChosen()));
+    m_ui->chooseToolchainDropDown->setEnabled(toolchains.size() > 1);
+    if (toolchainChanged)
+        toolchainChosen();
+    else
+        bc->setToolChain(m_toolchain);
 }
 
 void S60PublishingBuildSettingsPageOvi::buildConfigChosen()
@@ -100,8 +132,25 @@ void S60PublishingBuildSettingsPageOvi::buildConfigChosen()
     if (currentIndex == -1)
         return;
     m_bc = m_ui->chooseBuildConfigDropDown->itemData(currentIndex).value<ProjectExplorer::BuildConfiguration *>();
+    populateToolchainList(m_bc);
     m_publisher->setBuildConfiguration(static_cast<Qt4BuildConfiguration *>(m_bc));
-    emit buildChosen();
+    emit configurationChosen();
+}
+
+void S60PublishingBuildSettingsPageOvi::toolchainChosen()
+{
+    const int currentIndex = m_ui->chooseToolchainDropDown->currentIndex();
+    if (currentIndex == -1) {
+        m_toolchain = 0;
+        emit toolchainConfigurationChosen();
+        return;
+    }
+
+    m_toolchain = static_cast<ProjectExplorer::ToolChain *>(m_ui->chooseToolchainDropDown->itemData(currentIndex, Qt::UserRole).value<void *>());
+
+    if (m_bc)
+        m_bc->setToolChain(m_toolchain);
+    emit toolchainConfigurationChosen();
 }
 
 S60PublishingBuildSettingsPageOvi::~S60PublishingBuildSettingsPageOvi()
index d09615b..c570d26 100644 (file)
@@ -44,6 +44,7 @@ QT_END_NAMESPACE
 namespace ProjectExplorer {
 class Project;
 class BuildConfiguration;
+class ToolChain;
 }
 
 namespace Qt4ProjectManager {
@@ -60,13 +61,19 @@ public:
     virtual bool isComplete() const;
 
 signals:
-    void buildChosen();
+    void configurationChosen();
+    void toolchainConfigurationChosen();
 
 private slots:
     void buildConfigChosen();
+    void toolchainChosen();
+
+private:
+    void populateToolchainList(ProjectExplorer::BuildConfiguration *bc);
 
 private:
     ProjectExplorer::BuildConfiguration *m_bc;
+    ProjectExplorer::ToolChain *m_toolchain;
     Ui::S60PublishingBuildSettingsPageOvi * m_ui;
     S60PublisherOvi * const m_publisher;
 };
index 17af23e..57adf12 100644 (file)
@@ -37,7 +37,7 @@
      </property>
     </spacer>
    </item>
-   <item row="2" column="0" colspan="3">
+   <item row="3" column="0" colspan="3">
     <widget class="QLabel" name="label">
      <property name="text">
       <string>Only Qt versions above 4.6.3 are made available in this wizard.
@@ -45,7 +45,7 @@ Previous Qt versions have limitations in building suitable SIS files.</string>
      </property>
     </widget>
    </item>
-   <item row="1" column="1">
+   <item row="2" column="1">
     <spacer name="verticalSpacer_2">
      <property name="orientation">
       <enum>Qt::Vertical</enum>
@@ -58,6 +58,29 @@ Previous Qt versions have limitations in building suitable SIS files.</string>
      </property>
     </spacer>
    </item>
+   <item row="1" column="0">
+    <widget class="QLabel" name="chooseToolchainLabel">
+     <property name="text">
+      <string>Choose a tool chain:</string>
+     </property>
+    </widget>
+   </item>
+   <item row="1" column="1">
+    <widget class="QComboBox" name="chooseToolchainDropDown"/>
+   </item>
+   <item row="1" column="2">
+    <spacer name="horizontalSpacer_2">
+     <property name="orientation">
+      <enum>Qt::Horizontal</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>40</width>
+       <height>20</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
   </layout>
  </widget>
  <resources/>