Commit e4f6dede authored by Kai Koehne's avatar Kai Koehne

QtOptionsPage: Store selected toolchain for debugging helpers

Keep selected toolchain when switching between Qt versions.

Change-Id: I801e507d11b36b01888f016c35196fb098473bbf
Reviewed-on: http://codereview.qt.nokia.com/2183Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: default avatarDaniel Teske <daniel.teske@nokia.com>
parent 68b027ea
......@@ -58,7 +58,7 @@
#include <QtGui/QFileDialog>
#include <QtGui/QMainWindow>
enum ModelRoles { VersionIdRole = Qt::UserRole, BuildLogRole, BuildRunningRole};
enum ModelRoles { VersionIdRole = Qt::UserRole, ToolChainIdRole, BuildLogRole, BuildRunningRole};
using namespace QtSupport;
using namespace QtSupport::Internal;
......@@ -172,6 +172,7 @@ QtOptionsPageWidget::QtOptionsPageWidget(QWidget *parent, QList<BaseQtVersion *>
item->setText(0, version->displayName());
item->setText(1, QDir::toNativeSeparators(version->qmakeCommand()));
item->setData(0, VersionIdRole, version->uniqueId());
item->setData(0, ToolChainIdRole, defaultToolChainId(version));
const ValidityInfo info = validInformation(version);
item->setIcon(0, info.icon);
}
......@@ -204,6 +205,8 @@ QtOptionsPageWidget::QtOptionsPageWidget(QWidget *parent, QList<BaseQtVersion *>
connect(m_debuggingHelperUi->showLogButton, SIGNAL(clicked()),
this, SLOT(slotShowDebuggingBuildLog()));
connect(m_debuggingHelperUi->toolChainComboBox, SIGNAL(activated(int)),
this, SLOT(selectedToolChainChanged(int)));
connect(m_ui->cleanUpButton, SIGNAL(clicked()), this, SLOT(cleanUpQtVersions()));
userChangedCurrentVersion();
......@@ -326,15 +329,30 @@ void QtOptionsPageWidget::toolChainsUpdated()
{
for (int i = 0; i < m_versions.count(); ++i) {
QTreeWidgetItem *item = treeItemForIndex(i);
if (item == m_ui->qtdirList->currentItem())
if (item == m_ui->qtdirList->currentItem()) {
updateDescriptionLabel();
else {
updateDebuggingHelperUi();
} else {
const ValidityInfo info = validInformation(m_versions.at(i));
item->setIcon(0, info.icon);
}
}
}
void QtOptionsPageWidget::selectedToolChainChanged(int comboIndex)
{
const int index = currentIndex();
if (index < 0)
return;
QTreeWidgetItem *item = treeItemForIndex(index);
QTC_ASSERT(item, return);
QString toolChainId = m_debuggingHelperUi->toolChainComboBox->itemData(comboIndex).toString();
item->setData(0, ToolChainIdRole, toolChainId);
}
void QtOptionsPageWidget::qtVersionsDumpUpdated(const QString &qmakeCommand)
{
foreach (BaseQtVersion *version, m_versions) {
......@@ -424,6 +442,14 @@ QList<ProjectExplorer::ToolChain*> QtOptionsPageWidget::toolChains(const BaseQtV
return toolChains.values();
}
QString QtOptionsPageWidget::defaultToolChainId(const BaseQtVersion *version)
{
QList<ProjectExplorer::ToolChain*> possibleToolChains = toolChains(version);
if (!possibleToolChains.isEmpty())
return possibleToolChains.first()->id();
return QString();
}
void QtOptionsPageWidget::buildDebuggingHelper(DebuggingHelperBuildTask::Tools tools)
{
const int index = currentIndex();
......@@ -569,6 +595,7 @@ void QtOptionsPageWidget::addQtDir()
item->setText(0, version->displayName());
item->setText(1, QDir::toNativeSeparators(version->qmakeCommand()));
item->setData(0, VersionIdRole, version->uniqueId());
item->setData(0, ToolChainIdRole, defaultToolChainId(version));
item->setIcon(0, version->isValid()? m_validVersionIcon : m_invalidVersionIcon);
m_ui->qtdirList->setCurrentItem(item); // should update the rest of the ui
m_versionUi->nameEdit->setFocus();
......@@ -624,6 +651,7 @@ void QtOptionsPageWidget::editPath()
item->setText(0, version->displayName());
item->setText(1, QDir::toNativeSeparators(version->qmakeCommand()));
item->setData(0, VersionIdRole, version->uniqueId());
item->setData(0, ToolChainIdRole, defaultToolChainId(version));
item->setIcon(0, version->isValid()? m_validVersionIcon : m_invalidVersionIcon);
}
......@@ -780,8 +808,7 @@ void QtOptionsPageWidget::updateDebuggingHelperUi()
& !isBuildingQmlObserver);
QList<ProjectExplorer::ToolChain*> toolchains = toolChains(currentVersion());
QString selectedToolChainId = m_debuggingHelperUi->toolChainComboBox->itemData(
m_debuggingHelperUi->toolChainComboBox->currentIndex()).toString();
QString selectedToolChainId = currentItem->data(0, ToolChainIdRole).toString();
m_debuggingHelperUi->toolChainComboBox->clear();
for (int i = 0; i < toolchains.size(); ++i) {
if (!toolchains.at(i)->isValid())
......
......@@ -111,9 +111,11 @@ private slots:
void buildQmlDebuggingLibrary();
void buildQmlObserver();
void slotShowDebuggingBuildLog();
void debuggingHelperBuildFinished(int qtVersionId, const QString &output, DebuggingHelperBuildTask::Tools tools);
void debuggingHelperBuildFinished(int qtVersionId, const QString &output,
DebuggingHelperBuildTask::Tools tools);
void cleanUpQtVersions();
void toolChainsUpdated();
void selectedToolChainChanged(int index);
void qtVersionsDumpUpdated(const QString &qmakeCommand);
......@@ -125,6 +127,7 @@ private:
};
ValidityInfo validInformation(const BaseQtVersion *version);
QList<ProjectExplorer::ToolChain*> toolChains(const BaseQtVersion *version);
QString defaultToolChainId(const BaseQtVersion *verison);
};
class QtOptionsPage : public Core::IOptionsPage
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment