Commit fb482846 authored by hjk's avatar hjk

TreeModel: Add a StaticTreeItem(QString) convenience constructor

Covers the common case and hopefully avoids the recurring MSVC
problem with initializer lists in this location.

Change-Id: I1b2bbb083f9fc86af3b51b8f52615fb70c832b95
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
Reviewed-by: default avatarTim Jenssen <tim.jenssen@theqtcompany.com>
parent 9a8043d9
......@@ -1054,6 +1054,11 @@ StaticTreeItem::StaticTreeItem(const QStringList &displays)
{
}
StaticTreeItem::StaticTreeItem(const QString &display)
: m_displays(display)
{
}
QVariant StaticTreeItem::data(int column, int role) const
{
if (role == Qt::DisplayRole && column >= 0 && column < m_displays.size())
......
......@@ -174,6 +174,7 @@ class QTCREATOR_UTILS_EXPORT StaticTreeItem : public TreeItem
{
public:
StaticTreeItem(const QStringList &displays);
StaticTreeItem(const QString &display);
QVariant data(int column, int role) const override;
Qt::ItemFlags flags(int column) const override;
......
......@@ -142,8 +142,8 @@ public:
CMakeToolItemModel::CMakeToolItemModel()
{
setHeader({tr("Name"), tr("Location")});
rootItem()->appendChild(new StaticTreeItem(QStringList(tr("Auto-detected"))));
rootItem()->appendChild(new StaticTreeItem(QStringList(tr("Manual"))));
rootItem()->appendChild(new StaticTreeItem(tr("Auto-detected")));
rootItem()->appendChild(new StaticTreeItem(tr("Manual")));
foreach (const CMakeTool *item, CMakeToolManager::cmakeTools())
addCMakeTool(item, false);
......
......@@ -107,8 +107,8 @@ KitModel::KitModel(QBoxLayout *parentLayout, QObject *parent)
m_parentLayout(parentLayout)
{
setHeader(QStringList(tr("Name")));
m_autoRoot = new StaticTreeItem(QStringList(tr("Auto-detected")));
m_manualRoot = new StaticTreeItem(QStringList(tr("Manual")));
m_autoRoot = new StaticTreeItem(tr("Auto-detected"));
m_manualRoot = new StaticTreeItem(tr("Manual"));
rootItem()->appendChild(m_autoRoot);
rootItem()->appendChild(m_manualRoot);
......
......@@ -114,8 +114,8 @@ public:
[](ToolChainFactory *factory) { return factory->canCreate();});
m_model.setHeader({ ToolChainOptionsPage::tr("Name"), ToolChainOptionsPage::tr("Type") });
m_autoRoot = new StaticTreeItem(QStringList(ToolChainOptionsPage::tr("Auto-detected")));
m_manualRoot = new StaticTreeItem(QStringList(ToolChainOptionsPage::tr("Manual")));
m_autoRoot = new StaticTreeItem(ToolChainOptionsPage::tr("Auto-detected"));
m_manualRoot = new StaticTreeItem(ToolChainOptionsPage::tr("Manual"));
m_model.rootItem()->appendChild(m_autoRoot);
m_model.rootItem()->appendChild(m_manualRoot);
foreach (ToolChain *tc, ToolChainManager::toolChains()) {
......
......@@ -220,8 +220,8 @@ QtOptionsPageWidget::QtOptionsPageWidget(QWidget *parent)
m_ui->versionInfoWidget->setWidget(versionInfoWidget);
m_ui->versionInfoWidget->setState(DetailsWidget::NoSummary);
m_autoItem = new StaticTreeItem(QStringList(tr("Auto-detected")));
m_manualItem = new StaticTreeItem(QStringList(tr("Manual" )));
m_autoItem = new StaticTreeItem(tr("Auto-detected"));
m_manualItem = new StaticTreeItem(tr("Manual"));
m_model = new LeveledTreeModel<Utils::TreeItem, QtVersionItem>();
m_model->setHeader({tr("Name"), tr("qmake Location"), tr("Type")});
......
......@@ -53,7 +53,7 @@ static int countLevelItems(TreeItem *base, int level)
static TreeItem *createItem(const QString &name)
{
return new StaticTreeItem(QStringList(name));
return new StaticTreeItem(name);
}
void tst_TreeModel::testIteration()
......
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