Commit 58aa9324 authored by Tobias Hunger's avatar Tobias Hunger

QtVersion: Warn on duplicate names

This breaks the nice property of changes to one Qt version only
effecting that version:-/

Task-number: QTCREATORBUG-14677
Change-Id: Ibec062663b6cc5cabedcd910a8c642b870527d72
Reviewed-by: default avatarDaniel Teske <daniel.teske@theqtcompany.com>
parent 06a60b9f
......@@ -296,8 +296,7 @@ void QtOptionsPageWidget::toolChainsUpdated()
updateDescriptionLabel();
updateDebuggingHelperUi();
} else {
const ValidityInfo info = validInformation(m_versions.at(i));
item->setIcon(0, info.icon);
updateVersionItem(m_versions.at(i));
}
}
}
......@@ -369,6 +368,9 @@ QtOptionsPageWidget::ValidityInfo QtOptionsPageWidget::validInformation(const Ba
bool useable = true;
QStringList warnings;
if (!isNameUnique(version))
warnings << tr("Display Name is not unique.");
if (!missingToolChains.isEmpty()) {
if (missingToolChains.count() == abiCount) {
// Yes, this Qt version can't be used at all!
......@@ -422,6 +424,27 @@ QString QtOptionsPageWidget::defaultToolChainId(const BaseQtVersion *version)
return QString();
}
bool QtOptionsPageWidget::isNameUnique(const BaseQtVersion *version)
{
const QString name = version->displayName().trimmed();
foreach (const BaseQtVersion *i, m_versions) {
if (i == version)
continue;
if (i->displayName().trimmed() == name)
return false;
}
return true;
}
void QtOptionsPageWidget::updateVersionItem(BaseQtVersion *version)
{
const ValidityInfo info = validInformation(version);
QTreeWidgetItem *item = treeItemForIndex(m_versions.indexOf(version));
item->setText(0, version->displayName());
item->setText(1, version->qmakeCommand().toUserOutput());
item->setIcon(0, info.icon);
}
void QtOptionsPageWidget::buildDebuggingHelper(DebuggingHelperBuildTask::Tools tools)
{
const int index = currentIndex();
......@@ -551,12 +574,8 @@ void QtOptionsPageWidget::updateQtVersions(const QList<int> &additions, const QL
m_versions.append(version);
QTreeWidgetItem *item = new QTreeWidgetItem;
item->setText(0, version->displayName());
item->setText(1, version->qmakeCommand().toUserOutput());
item->setData(0, VersionIdRole, version->uniqueId());
item->setData(0, ToolChainIdRole, defaultToolChainId(version));
const ValidityInfo info = validInformation(version);
item->setIcon(0, info.icon);
// Insert in the right place:
QTreeWidgetItem *parent = version->isAutodetected()? m_autoItem : m_manualItem;
......@@ -572,6 +591,10 @@ void QtOptionsPageWidget::updateQtVersions(const QList<int> &additions, const QL
if (parent)
parent->addChild(item);
}
// Only set the icon after all versions are there to make sure all names are known:
foreach (BaseQtVersion *i, m_versions)
updateVersionItem(i);
}
QtOptionsPageWidget::~QtOptionsPageWidget()
......@@ -902,9 +925,13 @@ void QtOptionsPageWidget::updateCurrentQtName()
int currentItemIndex = indexForTreeItem(currentItem);
if (currentItemIndex < 0)
return;
m_versions[currentItemIndex]->setUnexpandedDisplayName(m_versionUi->nameEdit->text());
currentItem->setText(0, m_versions[currentItemIndex]->displayName());
BaseQtVersion *version = m_versions[currentItemIndex];
version->setUnexpandedDisplayName(m_versionUi->nameEdit->text());
updateDescriptionLabel();
foreach (BaseQtVersion *i, m_versions)
updateVersionItem(i);
}
void QtOptionsPageWidget::apply()
......
......@@ -126,6 +126,9 @@ private:
QList<ProjectExplorer::ToolChain*> toolChains(const BaseQtVersion *version);
QString defaultToolChainId(const BaseQtVersion *verison);
bool isNameUnique(const BaseQtVersion *version);
void updateVersionItem(BaseQtVersion *version);
QTreeWidgetItem *m_autoItem;
QTreeWidgetItem *m_manualItem;
};
......
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