Commit ab15d387 authored by Thomas Hartmann's avatar Thomas Hartmann

Wizards.Dialog: fix the All Templates case

The "All Templates" case in the comobox did not work as expected
from users.
It still did only show wizards we have a kit installed for
and it was not available for the case of one platform.

The semantics for "All Templates" were actually "All available Platforms".
This was confusing especially in the case of no platform.
Now "All Templates" does show all templates, but the wizard give an error
message, if no corresponding kit is available.

Task-number: QTCREATORBUG-9792
Change-Id: Ia83a0577bde7e726b2638868bcaffbe13499f2f7
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent 62994a36
......@@ -83,7 +83,7 @@ public:
QModelIndex sourceIndex = sourceModel()->index(sourceRow, 0, sourceParent);
Core::IWizard *wizard = wizardOfItem(qobject_cast<QStandardItemModel*>(sourceModel())->itemFromIndex(sourceIndex));
if (wizard)
return wizard->isAvailable(m_platform);
return m_platform.isEmpty() || wizard->isAvailable(m_platform);
return true;
}
......@@ -259,39 +259,31 @@ void NewDialog::setWizards(QList<IWizard*> wizards)
m_dummyIcon = QIcon(QLatin1String(Core::Constants::ICON_NEWFILE));
QStringList availablePlatforms = IWizard::allAvailablePlatforms();
m_ui->comboBox->addItem(tr("All Templates"), QString());
if (availablePlatforms.count() > 1) {
m_ui->comboBox->addItem(tr("All Templates"), QString());
foreach (const QString &platform, availablePlatforms) {
const QString displayNameForPlatform = IWizard::displayNameForPlatform(platform);
m_ui->comboBox->addItem(tr("%1 Templates").arg(displayNameForPlatform), platform);
}
} else {
if (availablePlatforms.isEmpty()) {
m_ui->comboBox->addItem(tr("All Templates"), QString());
} else {
const QString platform = availablePlatforms.first();
const QString displayNameForPlatform = IWizard::displayNameForPlatform(platform);
m_ui->comboBox->addItem(tr("%1 Templates").arg(displayNameForPlatform), platform);
}
m_ui->comboBox->setDisabled(true);
foreach (const QString &platform, availablePlatforms) {
const QString displayNameForPlatform = IWizard::displayNameForPlatform(platform);
m_ui->comboBox->addItem(tr("%1 Templates").arg(displayNameForPlatform), platform);
}
if (!availablePlatforms.isEmpty())
m_ui->comboBox->setCurrentIndex(1); //First Platform
else
m_ui->comboBox->setDisabled(true);
foreach (IWizard *wizard, wizards) {
if (wizard->isAvailable(selectedPlatform())) {
QStandardItem *kindItem;
switch (wizard->kind()) {
case IWizard::ProjectWizard:
kindItem = projectKindItem;
break;
case IWizard::ClassWizard:
case IWizard::FileWizard:
default:
kindItem = filesClassesKindItem;
break;
}
addItem(kindItem, wizard);
QStandardItem *kindItem;
switch (wizard->kind()) {
case IWizard::ProjectWizard:
kindItem = projectKindItem;
break;
case IWizard::ClassWizard:
case IWizard::FileWizard:
default:
kindItem = filesClassesKindItem;
break;
}
addItem(kindItem, wizard);
}
if (projectKindItem->columnCount() == 0)
parentItem->removeRow(0);
......
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