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: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
Thomas Hartmann
2013-07-12 11:12:08 +02:00
parent 62994a367a
commit ab15d38726

View File

@@ -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);