forked from qt-creator/qt-creator
Utils: Introduce TreeItem::{begin,end}
... and use this to reduce the number of explicit uses of m_children. Despite of being shorter code by itself it is a step towards having an explicit LeafItem object that doesn't explicitly store a(n empty) vector of child nodes. Change-Id: If8db85e2f1134dd1578a78d31235bf57a28f863a Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -620,7 +620,13 @@ TreeItem::~TreeItem()
|
||||
TreeItem *TreeItem::childAt(int pos) const
|
||||
{
|
||||
QTC_ASSERT(pos >= 0, return 0);
|
||||
return pos < m_children.size() ? m_children.at(pos) : 0;
|
||||
return pos < childCount() ? *(begin() + pos) : nullptr;
|
||||
}
|
||||
|
||||
int TreeItem::indexOf(const TreeItem *item) const
|
||||
{
|
||||
auto it = std::find(begin(), end(), item);
|
||||
return it == end() ? -1 : it - begin();
|
||||
}
|
||||
|
||||
QVariant TreeItem::data(int column, int role) const
|
||||
@@ -661,14 +667,14 @@ void TreeItem::prependChild(TreeItem *item)
|
||||
|
||||
void TreeItem::appendChild(TreeItem *item)
|
||||
{
|
||||
insertChild(m_children.size(), item);
|
||||
insertChild(childCount(), item);
|
||||
}
|
||||
|
||||
void TreeItem::insertChild(int pos, TreeItem *item)
|
||||
{
|
||||
QTC_CHECK(!item->model());
|
||||
QTC_CHECK(!item->parent());
|
||||
QTC_ASSERT(0 <= pos && pos <= m_children.size(), return); // '<= size' is intentional.
|
||||
QTC_ASSERT(0 <= pos && pos <= childCount(), return); // '<=' is intentional.
|
||||
|
||||
if (m_model) {
|
||||
QModelIndex idx = index();
|
||||
@@ -733,7 +739,7 @@ void TreeItem::updateAll()
|
||||
if (m_model) {
|
||||
QModelIndex idx = index();
|
||||
m_model->dataChanged(idx, idx.sibling(idx.row(), m_model->m_columnCount - 1));
|
||||
foreach (TreeItem *item, m_children)
|
||||
for (TreeItem *item : *this)
|
||||
item->updateAll();
|
||||
}
|
||||
}
|
||||
@@ -748,12 +754,12 @@ void TreeItem::updateColumn(int column)
|
||||
|
||||
TreeItem *TreeItem::firstChild() const
|
||||
{
|
||||
return m_children.isEmpty() ? 0 : m_children.first();
|
||||
return childCount() == 0 ? nullptr : *begin();
|
||||
}
|
||||
|
||||
TreeItem *TreeItem::lastChild() const
|
||||
{
|
||||
return m_children.isEmpty() ? 0 : m_children.last();
|
||||
return childCount() == 0 ? nullptr : *(end() - 1);
|
||||
}
|
||||
|
||||
int TreeItem::level() const
|
||||
@@ -766,7 +772,7 @@ int TreeItem::level() const
|
||||
|
||||
int TreeItem::indexInParent() const
|
||||
{
|
||||
return m_parent ? m_parent->m_children.indexOf(const_cast<TreeItem *>(this)) : -1;
|
||||
return m_parent ? m_parent->indexOf(this) : -1;
|
||||
}
|
||||
|
||||
QModelIndex TreeItem::index() const
|
||||
@@ -782,7 +788,7 @@ QAbstractItemModel *TreeItem::model() const
|
||||
|
||||
void TreeItem::forAllChildren(const std::function<void (TreeItem *)> &pred) const
|
||||
{
|
||||
foreach (TreeItem *item, m_children) {
|
||||
for (TreeItem *item : *this) {
|
||||
pred(item);
|
||||
item->forAllChildren(pred);
|
||||
}
|
||||
@@ -790,7 +796,7 @@ void TreeItem::forAllChildren(const std::function<void (TreeItem *)> &pred) cons
|
||||
|
||||
void TreeItem::forSelectedChildren(const std::function<bool (TreeItem *)> &pred) const
|
||||
{
|
||||
foreach (TreeItem *item, m_children) {
|
||||
for (TreeItem *item : *this) {
|
||||
if (pred(item))
|
||||
item->forSelectedChildren(pred);
|
||||
}
|
||||
@@ -800,10 +806,10 @@ void TreeItem::forChildrenAtLevel(int level, const std::function<void(TreeItem *
|
||||
{
|
||||
QTC_ASSERT(level > 0, return);
|
||||
if (level == 1) {
|
||||
foreach (TreeItem *item, m_children)
|
||||
for (TreeItem *item : *this)
|
||||
pred(item);
|
||||
} else {
|
||||
foreach (TreeItem *item, m_children)
|
||||
for (TreeItem *item : *this)
|
||||
item->forChildrenAtLevel(level - 1, pred);
|
||||
}
|
||||
}
|
||||
@@ -812,11 +818,11 @@ TreeItem *TreeItem::findChildAtLevel(int level, const std::function<bool(TreeIte
|
||||
{
|
||||
QTC_ASSERT(level > 0, return 0);
|
||||
if (level == 1) {
|
||||
foreach (TreeItem *item, m_children)
|
||||
for (TreeItem *item : *this)
|
||||
if (pred(item))
|
||||
return item;
|
||||
} else {
|
||||
foreach (TreeItem *item, m_children) {
|
||||
for (TreeItem *item : *this) {
|
||||
if (auto found = item->findChildAtLevel(level - 1, pred))
|
||||
return found;
|
||||
}
|
||||
@@ -826,7 +832,7 @@ TreeItem *TreeItem::findChildAtLevel(int level, const std::function<bool(TreeIte
|
||||
|
||||
TreeItem *TreeItem::findAnyChild(const std::function<bool(TreeItem *)> &pred) const
|
||||
{
|
||||
foreach (TreeItem *item, m_children) {
|
||||
for (TreeItem *item : *this) {
|
||||
if (pred(item))
|
||||
return item;
|
||||
if (TreeItem *found = item->findAnyChild(pred))
|
||||
@@ -837,7 +843,7 @@ TreeItem *TreeItem::findAnyChild(const std::function<bool(TreeItem *)> &pred) co
|
||||
|
||||
void TreeItem::clear()
|
||||
{
|
||||
while (m_children.size()) {
|
||||
while (childCount() != 0) {
|
||||
TreeItem *item = m_children.takeLast();
|
||||
item->m_model = 0;
|
||||
item->m_parent = 0;
|
||||
@@ -857,7 +863,7 @@ void TreeItem::propagateModel(BaseTreeModel *m)
|
||||
QTC_ASSERT(m_model == 0 || m_model == m, return);
|
||||
if (m && !m_model) {
|
||||
m_model = m;
|
||||
foreach (TreeItem *item, m_children)
|
||||
for (TreeItem *item : *this)
|
||||
item->propagateModel(m);
|
||||
}
|
||||
}
|
||||
@@ -1067,7 +1073,7 @@ QModelIndex BaseTreeModel::indexForItem(const TreeItem *item) const
|
||||
QTC_ASSERT(p, return QModelIndex());
|
||||
|
||||
TreeItem *mitem = const_cast<TreeItem *>(item);
|
||||
int row = p->m_children.indexOf(mitem);
|
||||
int row = p->indexOf(mitem);
|
||||
return createIndex(row, 0, mitem);
|
||||
}
|
||||
|
||||
@@ -1095,7 +1101,7 @@ TreeItem *BaseTreeModel::takeItem(TreeItem *item)
|
||||
QTC_ASSERT(item, return item);
|
||||
TreeItem *parent = item->parent();
|
||||
QTC_ASSERT(parent, return item);
|
||||
int pos = parent->m_children.indexOf(item);
|
||||
int pos = parent->indexOf(item);
|
||||
QTC_ASSERT(pos != -1, return item);
|
||||
|
||||
QModelIndex idx = indexForItem(parent);
|
||||
|
||||
@@ -64,10 +64,14 @@ public:
|
||||
TreeItem *lastChild() const;
|
||||
int level() const;
|
||||
|
||||
int childCount() const { return m_children.size(); }
|
||||
using const_iterator = QVector<TreeItem *>::const_iterator;
|
||||
using value_type = TreeItem *;
|
||||
int childCount() const { return end() - begin(); }
|
||||
int indexInParent() const;
|
||||
TreeItem *childAt(int index) const;
|
||||
QVector<TreeItem *> children() const { return m_children; }
|
||||
int indexOf(const TreeItem *item) const;
|
||||
const_iterator begin() const { return m_children.begin(); }
|
||||
const_iterator end() const { return m_children.end(); }
|
||||
QModelIndex index() const;
|
||||
QAbstractItemModel *model() const;
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ void TestResultItem::updateResult()
|
||||
return;
|
||||
|
||||
Result::Type newResult = Result::MessageTestCaseSuccess;
|
||||
foreach (Utils::TreeItem *child, children()) {
|
||||
for (Utils::TreeItem *child : *this) {
|
||||
const TestResult *current = static_cast<TestResultItem *>(child)->testResult();
|
||||
if (current) {
|
||||
switch (current->result()) {
|
||||
@@ -131,7 +131,7 @@ void TestResultItem::updateResult()
|
||||
|
||||
void TestResultItem::updateIntermediateChildren()
|
||||
{
|
||||
for (Utils::TreeItem *child : children()) {
|
||||
for (Utils::TreeItem *child : *this) {
|
||||
TestResultItem *childItem = static_cast<TestResultItem *>(child);
|
||||
if (childItem->testResult()->result() == Result::MessageIntermediate)
|
||||
childItem->updateResult();
|
||||
@@ -225,9 +225,9 @@ void TestResultModel::addTestResult(const TestResultPtr &testResult, bool autoEx
|
||||
|
||||
void TestResultModel::removeCurrentTestMessage()
|
||||
{
|
||||
QVector<Utils::TreeItem *> topLevelItems = rootItem()->children();
|
||||
std::vector<Utils::TreeItem *> topLevelItems(rootItem()->begin(), rootItem()->end());
|
||||
for (int row = topLevelItems.size() - 1; row >= 0; --row) {
|
||||
TestResultItem *current = static_cast<TestResultItem *>(topLevelItems.at(row));
|
||||
TestResultItem *current = static_cast<TestResultItem *>(topLevelItems[row]);
|
||||
if (current->testResult()->result() == Result::MessageCurrentTest) {
|
||||
destroyItem(current);
|
||||
break;
|
||||
|
||||
@@ -67,7 +67,7 @@ TestTreeModel *TestTreeModel::instance()
|
||||
|
||||
TestTreeModel::~TestTreeModel()
|
||||
{
|
||||
foreach (Utils::TreeItem *item, rootItem()->children()) {
|
||||
for (Utils::TreeItem *item : *rootItem()) {
|
||||
item->removeChildren();
|
||||
takeItem(item); // do NOT delete the item as it's still a ptr hold by TestFrameworkManager
|
||||
}
|
||||
@@ -141,7 +141,7 @@ Qt::ItemFlags TestTreeModel::flags(const QModelIndex &index) const
|
||||
|
||||
bool TestTreeModel::hasTests() const
|
||||
{
|
||||
foreach (Utils::TreeItem *frameworkRoot, rootItem()->children()) {
|
||||
for (Utils::TreeItem *frameworkRoot : *rootItem()) {
|
||||
if (frameworkRoot->hasChildren())
|
||||
return true;
|
||||
}
|
||||
@@ -151,7 +151,7 @@ bool TestTreeModel::hasTests() const
|
||||
QList<TestConfiguration *> TestTreeModel::getAllTestCases() const
|
||||
{
|
||||
QList<TestConfiguration *> result;
|
||||
foreach (Utils::TreeItem *frameworkRoot, rootItem()->children())
|
||||
for (Utils::TreeItem *frameworkRoot : *rootItem())
|
||||
result.append(static_cast<TestTreeItem *>(frameworkRoot)->getAllTestConfigurations());
|
||||
return result;
|
||||
}
|
||||
@@ -159,7 +159,7 @@ QList<TestConfiguration *> TestTreeModel::getAllTestCases() const
|
||||
QList<TestConfiguration *> TestTreeModel::getSelectedTests() const
|
||||
{
|
||||
QList<TestConfiguration *> result;
|
||||
foreach (Utils::TreeItem *frameworkRoot, rootItem()->children())
|
||||
for (Utils::TreeItem *frameworkRoot : *rootItem())
|
||||
result.append(static_cast<TestTreeItem *>(frameworkRoot)->getSelectedTestConfigurations());
|
||||
return result;
|
||||
}
|
||||
@@ -167,7 +167,7 @@ QList<TestConfiguration *> TestTreeModel::getSelectedTests() const
|
||||
void TestTreeModel::syncTestFrameworks()
|
||||
{
|
||||
// remove all currently registered
|
||||
foreach (Utils::TreeItem *item, rootItem()->children()) {
|
||||
for (Utils::TreeItem *item : *rootItem()) {
|
||||
item->removeChildren();
|
||||
takeItem(item); // do NOT delete the item as it's still a ptr hold by TestFrameworkManager
|
||||
}
|
||||
@@ -190,8 +190,8 @@ void TestTreeModel::removeFiles(const QStringList &files)
|
||||
|
||||
void TestTreeModel::markAllForRemoval()
|
||||
{
|
||||
foreach (Utils::TreeItem *frameworkRoot, rootItem()->children()) {
|
||||
foreach (Utils::TreeItem *item, frameworkRoot->children())
|
||||
for (Utils::TreeItem *frameworkRoot : *rootItem()) {
|
||||
for (Utils::TreeItem *item : *frameworkRoot)
|
||||
static_cast<TestTreeItem *>(item)->markForRemovalRecursively(true);
|
||||
}
|
||||
}
|
||||
@@ -201,7 +201,7 @@ void TestTreeModel::markForRemoval(const QString &filePath)
|
||||
if (filePath.isEmpty())
|
||||
return;
|
||||
|
||||
for (Utils::TreeItem *frameworkRoot : rootItem()->children()) {
|
||||
for (Utils::TreeItem *frameworkRoot : *rootItem()) {
|
||||
TestTreeItem *root = static_cast<TestTreeItem *>(frameworkRoot);
|
||||
for (int childRow = root->childCount() - 1; childRow >= 0; --childRow) {
|
||||
TestTreeItem *child = root->childItem(childRow);
|
||||
@@ -212,7 +212,7 @@ void TestTreeModel::markForRemoval(const QString &filePath)
|
||||
|
||||
void TestTreeModel::sweep()
|
||||
{
|
||||
for (Utils::TreeItem *frameworkRoot : rootItem()->children()) {
|
||||
for (Utils::TreeItem *frameworkRoot : *rootItem()) {
|
||||
TestTreeItem *root = static_cast<TestTreeItem *>(frameworkRoot);
|
||||
sweepChildren(root);
|
||||
}
|
||||
@@ -277,7 +277,7 @@ void TestTreeModel::handleParseResult(const TestParseResult *result, TestTreeIte
|
||||
|
||||
void TestTreeModel::removeAllTestItems()
|
||||
{
|
||||
foreach (Utils::TreeItem *item, rootItem()->children())
|
||||
for (Utils::TreeItem *item : *rootItem())
|
||||
item->removeChildren();
|
||||
emit testTreeModelChanged();
|
||||
}
|
||||
@@ -353,9 +353,9 @@ int TestTreeModel::dataTagsCount() const
|
||||
return 0;
|
||||
|
||||
int dataTagCount = 0;
|
||||
foreach (Utils::TreeItem *item, rootNode->children()) {
|
||||
for (Utils::TreeItem *item : *rootNode) {
|
||||
TestTreeItem *classItem = static_cast<TestTreeItem *>(item);
|
||||
foreach (Utils::TreeItem *functionItem, classItem->children())
|
||||
for (Utils::TreeItem *functionItem : *classItem)
|
||||
dataTagCount += functionItem->childCount();
|
||||
}
|
||||
return dataTagCount;
|
||||
|
||||
@@ -135,7 +135,7 @@ void GdbServerProviderModel::apply()
|
||||
QTC_ASSERT(m_providersToRemove.isEmpty(), m_providersToRemove.clear());
|
||||
|
||||
// Update providers
|
||||
foreach (TreeItem *item, rootItem()->children()) {
|
||||
for (TreeItem *item : *rootItem()) {
|
||||
auto n = static_cast<GdbServerProviderNode *>(item);
|
||||
if (!n->changed)
|
||||
continue;
|
||||
@@ -173,7 +173,7 @@ GdbServerProviderNode *GdbServerProviderModel::findNode(const GdbServerProvider
|
||||
return static_cast<GdbServerProviderNode *>(item)->provider == provider;
|
||||
};
|
||||
|
||||
return static_cast<GdbServerProviderNode *>(Utils::findOrDefault(rootItem()->children(), test));
|
||||
return static_cast<GdbServerProviderNode *>(Utils::findOrDefault(*rootItem(), test));
|
||||
}
|
||||
|
||||
QModelIndex GdbServerProviderModel::indexForProvider(GdbServerProvider *provider) const
|
||||
@@ -209,7 +209,7 @@ GdbServerProviderNode *GdbServerProviderModel::createNode(
|
||||
auto n = new GdbServerProviderNode(provider, changed);
|
||||
if (n->widget) {
|
||||
connect(n->widget, &GdbServerProviderConfigWidget::dirty, this, [this, n] {
|
||||
foreach (TreeItem *item, rootItem()->children()) {
|
||||
for (TreeItem *item : *rootItem()) {
|
||||
auto nn = static_cast<GdbServerProviderNode *>(item);
|
||||
if (nn->widget == n->widget) {
|
||||
nn->changed = true;
|
||||
|
||||
@@ -80,7 +80,7 @@ void ClangStaticAnalyzerDiagnosticModel::addDiagnostics(const QList<Diagnostic>
|
||||
QList<Diagnostic> ClangStaticAnalyzerDiagnosticModel::diagnostics() const
|
||||
{
|
||||
QList<Diagnostic> diags;
|
||||
foreach (const Utils::TreeItem * const item, rootItem()->children())
|
||||
for (const Utils::TreeItem * const item : *rootItem())
|
||||
diags << static_cast<const DiagnosticItem *>(item)->diagnostic();
|
||||
return diags;
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ QVariant CppIncludeHierarchyItem::data(int column, int role) const
|
||||
|
||||
bool CppIncludeHierarchyItem::canFetchMore() const
|
||||
{
|
||||
if (m_isCyclic || m_checkedForChildren || !children().isEmpty())
|
||||
if (m_isCyclic || m_checkedForChildren || childCount() > 0)
|
||||
return false;
|
||||
|
||||
return !model()->m_searching || !model()->m_seen.contains(m_filePath);
|
||||
|
||||
@@ -128,7 +128,7 @@ bool ConsoleItem::setData(int column, const QVariant &data, int role)
|
||||
bool ConsoleItem::canFetchMore() const
|
||||
{
|
||||
// Always fetch all children, too, as the labels depend on them.
|
||||
foreach (TreeItem *child, children()) {
|
||||
for (TreeItem *child : *this) {
|
||||
if (static_cast<ConsoleItem *>(child)->m_doFetch)
|
||||
return true;
|
||||
}
|
||||
@@ -143,7 +143,7 @@ void ConsoleItem::fetchMore()
|
||||
m_doFetch = std::function<void(ConsoleItem *)>();
|
||||
}
|
||||
|
||||
foreach (TreeItem *child, children()) {
|
||||
for (TreeItem *child : *this) {
|
||||
ConsoleItem *item = static_cast<ConsoleItem *>(child);
|
||||
if (item->m_doFetch) {
|
||||
item->m_doFetch(item);
|
||||
|
||||
@@ -221,7 +221,7 @@ ToolTipWatchItem::ToolTipWatchItem(TreeItem *item)
|
||||
valueColor = model->data(idx.sibling(idx.row(), 1), Qt::ForegroundRole).value<QColor>();
|
||||
expandable = model->hasChildren(idx);
|
||||
expression = model->data(idx.sibling(idx.row(), 0), Qt::EditRole).toString();
|
||||
foreach (TreeItem *child, item->children())
|
||||
for (TreeItem *child : *item)
|
||||
appendChild(new ToolTipWatchItem(child));
|
||||
}
|
||||
|
||||
|
||||
@@ -273,7 +273,7 @@ static ThreadItem *itemForThreadId(const ThreadsHandler *handler, ThreadId threa
|
||||
static int indexForThreadId(const ThreadsHandler *handler, ThreadId threadId)
|
||||
{
|
||||
ThreadItem *item = itemForThreadId(handler, threadId);
|
||||
return item ? handler->rootItem()->children().indexOf(item) : -1;
|
||||
return item ? handler->rootItem()->indexOf(item) : -1;
|
||||
}
|
||||
|
||||
int ThreadsHandler::currentThreadIndex() const
|
||||
|
||||
@@ -970,9 +970,9 @@ QVariant WatchModel::data(const QModelIndex &idx, int role) const
|
||||
|
||||
if (role == BaseTreeView::ExtraIndicesForColumnWidth) {
|
||||
QModelIndexList l;
|
||||
foreach (TreeItem *item, m_watchRoot->children())
|
||||
for (const TreeItem *item : *m_watchRoot)
|
||||
l.append(indexForItem(item));
|
||||
foreach (TreeItem *item, m_returnRoot->children())
|
||||
for (const TreeItem *item : *m_returnRoot)
|
||||
l.append(indexForItem(item));
|
||||
return QVariant::fromValue(l);
|
||||
}
|
||||
@@ -1237,7 +1237,7 @@ void WatchModel::fetchMore(const QModelIndex &idx)
|
||||
WatchItem *item = nonRootItemForIndex(idx);
|
||||
if (item) {
|
||||
m_expandedINames.insert(item->iname);
|
||||
if (item->children().isEmpty())
|
||||
if (item->childCount() == 0)
|
||||
m_engine->expandItem(item->iname);
|
||||
}
|
||||
}
|
||||
@@ -1988,10 +1988,10 @@ bool WatchHandler::insertItem(WatchItem *item)
|
||||
QTC_ASSERT(parent, return false);
|
||||
|
||||
bool found = false;
|
||||
const QVector<TreeItem *> siblings = parent->children();
|
||||
const std::vector<TreeItem *> siblings(parent->begin(), parent->end());
|
||||
for (int row = 0, n = siblings.size(); row < n; ++row) {
|
||||
if (static_cast<WatchItem *>(siblings.at(row))->iname == item->iname) {
|
||||
m_model->destroyItem(parent->children().at(row));
|
||||
if (static_cast<WatchItem *>(siblings[row])->iname == item->iname) {
|
||||
m_model->destroyItem(parent->childAt(row));
|
||||
parent->insertChild(row, item);
|
||||
found = true;
|
||||
break;
|
||||
@@ -2381,7 +2381,7 @@ void WatchHandler::fetchMore(const QString &iname) const
|
||||
{
|
||||
if (WatchItem *item = m_model->findItem(iname)) {
|
||||
m_model->m_expandedINames.insert(iname);
|
||||
if (item->children().isEmpty())
|
||||
if (item->childCount() == 0)
|
||||
m_model->m_engine->expandItem(iname);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ void KitModel::isAutoDetectedChanged()
|
||||
{
|
||||
auto w = qobject_cast<KitManagerConfigWidget *>(sender());
|
||||
int idx = -1;
|
||||
idx = Utils::indexOf(m_manualRoot->children(), [w](TreeItem *node) {
|
||||
idx = Utils::indexOf(*m_manualRoot, [w](TreeItem *node) {
|
||||
return static_cast<KitNode *>(node)->widget == w;
|
||||
});
|
||||
TreeItem *oldParent = nullptr;
|
||||
@@ -176,7 +176,7 @@ void KitModel::isAutoDetectedChanged()
|
||||
if (idx != -1) {
|
||||
oldParent = m_manualRoot;
|
||||
} else {
|
||||
idx = Utils::indexOf(m_autoRoot->children(), [w](TreeItem *node) {
|
||||
idx = Utils::indexOf(*m_autoRoot, [w](TreeItem *node) {
|
||||
return static_cast<KitNode *>(node)->widget == w;
|
||||
});
|
||||
if (idx != -1) {
|
||||
@@ -185,7 +185,7 @@ void KitModel::isAutoDetectedChanged()
|
||||
}
|
||||
|
||||
if (oldParent && oldParent != newParent) {
|
||||
beginMoveRows(indexForItem(oldParent), idx, idx, indexForItem(newParent), newParent->children().size());
|
||||
beginMoveRows(indexForItem(oldParent), idx, idx, indexForItem(newParent), newParent->childCount());
|
||||
TreeItem *n = oldParent->childAt(idx);
|
||||
takeItem(n);
|
||||
newParent->appendChild(n);
|
||||
@@ -281,8 +281,7 @@ KitNode *KitModel::createNode(Kit *k)
|
||||
auto node = new KitNode(k);
|
||||
m_parentLayout->addWidget(node->widget);
|
||||
connect(node->widget, &KitManagerConfigWidget::dirty, [this, node] {
|
||||
if (m_autoRoot->children().contains(node)
|
||||
|| m_manualRoot->children().contains(node))
|
||||
if (m_autoRoot->indexOf(node) != -1 || m_manualRoot->indexOf(node) != -1)
|
||||
node->update();
|
||||
});
|
||||
connect(node->widget, &KitManagerConfigWidget::isAutoDetectedChanged,
|
||||
@@ -306,7 +305,7 @@ void KitModel::setDefaultNode(KitNode *node)
|
||||
|
||||
void KitModel::addKit(Kit *k)
|
||||
{
|
||||
foreach (TreeItem *n, m_manualRoot->children()) {
|
||||
for (TreeItem *n : *m_manualRoot) {
|
||||
// Was added by us
|
||||
if (static_cast<KitNode *>(n)->widget->configures(k))
|
||||
return;
|
||||
|
||||
@@ -178,7 +178,7 @@ public:
|
||||
if (role == ItemActivatedFromBelowRole) {
|
||||
TreeItem *item = data.value<TreeItem *>();
|
||||
QTC_ASSERT(item, return false);
|
||||
m_currentPanelIndex = children().indexOf(item);
|
||||
m_currentPanelIndex = indexOf(item);
|
||||
QTC_ASSERT(m_currentPanelIndex != -1, return false);
|
||||
parent()->setData(0, QVariant::fromValue(static_cast<TreeItem *>(this)),
|
||||
ItemActivatedFromBelowRole);
|
||||
@@ -251,9 +251,9 @@ public:
|
||||
}
|
||||
|
||||
if (role == ItemActivatedFromBelowRole) {
|
||||
TreeItem *item = dat.value<TreeItem *>();
|
||||
const TreeItem *item = dat.value<TreeItem *>();
|
||||
QTC_ASSERT(item, return false);
|
||||
int res = children().indexOf(item);
|
||||
int res = indexOf(item);
|
||||
QTC_ASSERT(res >= 0, return false);
|
||||
m_currentChildIndex = res;
|
||||
announceChange();
|
||||
|
||||
@@ -386,7 +386,7 @@ public:
|
||||
|
||||
if (role == ItemActivatedFromBelowRole) {
|
||||
// I.e. 'Build' and 'Run' items were present and user clicked on them.
|
||||
int child = children().indexOf(data.value<TreeItem *>());
|
||||
int child = indexOf(data.value<TreeItem *>());
|
||||
QTC_ASSERT(child != -1, return false);
|
||||
m_currentChild = child; // Triggered from sub-item.
|
||||
SessionManager::setActiveTarget(m_project, target(), SetActive::Cascade);
|
||||
@@ -788,7 +788,7 @@ void TargetGroupItemPrivate::handleAddedKit(Kit *kit)
|
||||
|
||||
void TargetItem::updateSubItems()
|
||||
{
|
||||
if (children().isEmpty() && isEnabled())
|
||||
if (childCount() == 0 && isEnabled())
|
||||
m_currentChild = DefaultPage; // We will add children below.
|
||||
removeChildren();
|
||||
if (isEnabled()) {
|
||||
|
||||
@@ -330,7 +330,7 @@ void ToolChainOptionsWidget::apply()
|
||||
// Update tool chains:
|
||||
foreach (const Core::Id &l, m_languageMap.keys()) {
|
||||
StaticTreeItem *parent = m_languageMap.value(l).second;
|
||||
foreach (TreeItem *item, parent->children()) {
|
||||
for (TreeItem *item : *parent) {
|
||||
auto tcItem = static_cast<ToolChainTreeItem *>(item);
|
||||
Q_ASSERT(tcItem->toolChain);
|
||||
if (tcItem->widget)
|
||||
|
||||
@@ -298,7 +298,7 @@ void QtOptionsPageWidget::cleanUpQtVersions()
|
||||
QVector<QtVersionItem *> toRemove;
|
||||
QString text;
|
||||
|
||||
foreach (Utils::TreeItem *child, m_manualItem->children()) {
|
||||
for (TreeItem *child : *m_manualItem) {
|
||||
auto item = static_cast<QtVersionItem *>(child);
|
||||
if (item->version() && !item->version()->isValid()) {
|
||||
toRemove.append(item);
|
||||
@@ -672,7 +672,7 @@ void QtOptionsPageWidget::editPath()
|
||||
void QtOptionsPageWidget::updateCleanUpButton()
|
||||
{
|
||||
bool hasInvalidVersion = false;
|
||||
foreach (Utils::TreeItem *child, m_manualItem->children()) {
|
||||
for (TreeItem *child : *m_manualItem) {
|
||||
auto item = static_cast<QtVersionItem *>(child);
|
||||
if (item->version() && !item->version()->isValid()) {
|
||||
hasInvalidVersion = true;
|
||||
|
||||
Reference in New Issue
Block a user