OSDN Git Service

Gcc: Improve config widget
authorTobias Hunger <tobias.hunger@nokia.com>
Wed, 8 Jun 2011 15:39:14 +0000 (15:39 +0000)
committerTobias Hunger <tobias.hunger@nokia.com>
Tue, 21 Jun 2011 11:31:12 +0000 (13:31 +0200)
Change-Id: Id26ed4c1712ae93c70efb7f23ef00684ead9ca0a
Reviewed-on: http://codereview.qt.nokia.com/405
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com>
src/plugins/projectexplorer/abiwidget.cpp
src/plugins/projectexplorer/gcctoolchain.cpp
src/plugins/projectexplorer/gcctoolchainfactories.h

index edd17f9..2be1b98 100644 (file)
@@ -159,21 +159,24 @@ void AbiWidget::setAbis(const QList<Abi> &abiList, const Abi &current)
     }
 
     if (d->m_abi->currentIndex() == 0) {
-        d->m_abi->setCurrentIndex(0);
-        d->m_architectureComboBox->setCurrentIndex(static_cast<int>(current.architecture()));
-        d->m_osComboBox->setCurrentIndex(static_cast<int>(current.os()));
-        osChanged();
-        for (int i = 0; i < d->m_osFlavorComboBox->count(); ++i) {
-            if (d->m_osFlavorComboBox->itemData(i).toInt() == current.osFlavor()) {
-                d->m_osFlavorComboBox->setCurrentIndex(i);
-                break;
+        if (!current.isValid() && !abiList.isEmpty()) {
+            d->m_abi->setCurrentIndex(1); // default to the first Abi if none is selected.
+        } else {
+            d->m_architectureComboBox->setCurrentIndex(static_cast<int>(current.architecture()));
+            d->m_osComboBox->setCurrentIndex(static_cast<int>(current.os()));
+            osChanged();
+            for (int i = 0; i < d->m_osFlavorComboBox->count(); ++i) {
+                if (d->m_osFlavorComboBox->itemData(i).toInt() == current.osFlavor()) {
+                    d->m_osFlavorComboBox->setCurrentIndex(i);
+                    break;
+                }
             }
-        }
-        d->m_binaryFormatComboBox->setCurrentIndex(static_cast<int>(current.binaryFormat()));
-        for (int i = 0; i < d->m_wordWidthComboBox->count(); ++i) {
-            if (d->m_wordWidthComboBox->itemData(i).toInt() == current.wordWidth()) {
-                d->m_wordWidthComboBox->setCurrentIndex(i);
-                break;
+            d->m_binaryFormatComboBox->setCurrentIndex(static_cast<int>(current.binaryFormat()));
+            for (int i = 0; i < d->m_wordWidthComboBox->count(); ++i) {
+                if (d->m_wordWidthComboBox->itemData(i).toInt() == current.wordWidth()) {
+                    d->m_wordWidthComboBox->setCurrentIndex(i);
+                    break;
+                }
             }
         }
     }
index 7241f30..aec1abb 100644 (file)
@@ -606,12 +606,11 @@ Internal::GccToolChainConfigWidget::GccToolChainConfigWidget(GccToolChain *tc) :
     connect(m_compilerPath, SIGNAL(changed(QString)), this, SLOT(handlePathChange()));
     layout->addRow(tr("&Compiler path:"), m_compilerPath);
     layout->addRow(tr("&ABI:"), m_abiWidget);
+    m_abiWidget->setEnabled(false);
 
     addDebuggerCommandControls(layout, gnuVersionArgs);
     addErrorLabel(layout);
 
-    populateAbiList(tc->supportedAbis(), tc->targetAbi());
-
     connect(m_abiWidget, SIGNAL(abiChanged()), this, SLOT(handleAbiChange()));
 
     setFromToolchain();
@@ -635,19 +634,14 @@ void Internal::GccToolChainConfigWidget::apply()
     m_autoDebuggerCommand = QLatin1String("<manually set>");
 }
 
-void Internal::GccToolChainConfigWidget::populateAbiList(const QList<Abi> &list, const Abi &current)
-{
-    m_abiWidget->setAbis(list, current);
-    handleAbiChange();
-}
-
 void Internal::GccToolChainConfigWidget::setFromToolchain()
 {
+    blockSignals(true);
     GccToolChain *tc = static_cast<GccToolChain *>(toolChain());
-    Q_ASSERT(tc);
     m_compilerPath->setPath(tc->compilerPath());
+    m_abiWidget->setAbis(tc->supportedAbis(), tc->targetAbi());
     setDebuggerCommand(tc->debuggerCommand());
-    populateAbiList(tc->supportedAbis(), tc->targetAbi());
+    blockSignals(false);
 }
 
 bool Internal::GccToolChainConfigWidget::isDirty() const
@@ -669,10 +663,17 @@ void Internal::GccToolChainConfigWidget::handlePathChange()
 {
     QString path = m_compilerPath->path();
     QList<Abi> abiList;
-    if (QFileInfo(path).isExecutable())
+    bool haveCompiler = false;
+    if (!path.isEmpty()) {
+        QFileInfo fi(path);
+        haveCompiler = fi.isExecutable() && fi.isFile();
+    }
+    if (haveCompiler)
         abiList = guessGccAbi(path, Utils::Environment::systemEnvironment().toStringList());
-    populateAbiList(abiList, m_abiWidget->currentAbi());
-    emit dirty(toolChain());
+    m_abiWidget->setEnabled(haveCompiler);
+    Abi currentAbi = m_abiWidget->currentAbi();
+    m_abiWidget->setAbis(abiList, abiList.contains(currentAbi) ? currentAbi : Abi());
+    handleAbiChange();
 }
 
 void Internal::GccToolChainConfigWidget::handleAbiChange()
index 6bef83d..ff3feb2 100644 (file)
@@ -98,7 +98,6 @@ private slots:
     void handleAbiChange();
 
 private:
-    void populateAbiList(const QList<Abi> &supported, const Abi &current);
     void setFromToolchain();
 
     Utils::PathChooser *m_compilerPath;