diff --git a/src/libs/utils/treemodel.cpp b/src/libs/utils/treemodel.cpp index 131a56768a0..fa16a80e3fc 100644 --- a/src/libs/utils/treemodel.cpp +++ b/src/libs/utils/treemodel.cpp @@ -611,14 +611,12 @@ namespace Utils { // TreeItem // TreeItem::TreeItem() - : m_parent(0), m_model(0), m_displays(0), m_lazy(false), m_populated(false), - m_flags(Qt::ItemIsEnabled|Qt::ItemIsSelectable) + : m_parent(0), m_model(0), m_displays(0), m_flags(Qt::ItemIsEnabled|Qt::ItemIsSelectable) { } TreeItem::TreeItem(const QStringList &displays, int flags) - : m_parent(0), m_model(0), m_displays(new QStringList(displays)), m_lazy(false), m_populated(false), - m_flags(flags) + : m_parent(0), m_model(0), m_displays(new QStringList(displays)), m_flags(flags) { } @@ -630,26 +628,15 @@ TreeItem::~TreeItem() TreeItem *TreeItem::child(int pos) const { - ensurePopulated(); QTC_ASSERT(pos >= 0, return 0); return pos < m_children.size() ? m_children.at(pos) : 0; } -bool TreeItem::isLazy() const -{ - return m_lazy; -} - int TreeItem::rowCount() const { - ensurePopulated(); return m_children.size(); } -void TreeItem::populate() -{ -} - QVariant TreeItem::data(int column, int role) const { if (role == Qt::DisplayRole && m_displays && column >= 0 && column < m_displays->size()) @@ -696,7 +683,7 @@ void TreeItem::insertChild(int pos, TreeItem *item) QTC_CHECK(!item->parent()); QTC_ASSERT(0 <= pos && pos <= m_children.size(), return); // '<= size' is intentional. - if (m_model && !m_lazy) { + if (m_model) { QModelIndex idx = index(); m_model->beginInsertRows(idx, pos, pos); item->m_parent = this; @@ -770,11 +757,6 @@ int TreeItem::level() const return l; } -void TreeItem::setLazy(bool on) -{ - m_lazy = on; -} - void TreeItem::setFlags(Qt::ItemFlags flags) { m_flags = flags; @@ -830,15 +812,6 @@ void TreeItem::expand() m_model->requestExpansion(index()); } -void TreeItem::ensurePopulated() const -{ - if (!m_populated) { - if (isLazy()) - const_cast(this)->populate(); - m_populated = true; - } -} - void TreeItem::propagateModel(TreeModel *m) { QTC_ASSERT(m, return); diff --git a/src/libs/utils/treemodel.h b/src/libs/utils/treemodel.h index fef813dfe73..9be4dc805a3 100644 --- a/src/libs/utils/treemodel.h +++ b/src/libs/utils/treemodel.h @@ -72,9 +72,7 @@ public: virtual TreeItem *parent() const { return m_parent; } virtual TreeItem *child(int pos) const; - virtual bool isLazy() const; virtual int rowCount() const; - virtual void populate(); virtual QVariant data(int column, int role) const; virtual bool setData(int column, const QVariant &data, int role); @@ -96,8 +94,6 @@ public: TreeItem *lastChild() const; int level() const; - void setLazy(bool on); - void setPopulated(bool on); void setFlags(Qt::ItemFlags flags); int childCount() const { return m_children.size(); } TreeItem *childAt(int index) const { return m_children.at(index); } @@ -115,14 +111,12 @@ private: void operator=(const TreeItem &) Q_DECL_EQ_DELETE; void clear(); - void ensurePopulated() const; void propagateModel(TreeModel *m); TreeItem *m_parent; // Not owned. TreeModel *m_model; // Not owned. QVector m_children; // Owned. QStringList *m_displays; - bool m_lazy; mutable bool m_populated; Qt::ItemFlags m_flags; diff --git a/src/plugins/coreplugin/variablechooser.cpp b/src/plugins/coreplugin/variablechooser.cpp index 8044c049d54..c7337de83f0 100644 --- a/src/plugins/coreplugin/variablechooser.cpp +++ b/src/plugins/coreplugin/variablechooser.cpp @@ -127,9 +127,8 @@ class VariableGroupItem : public TreeItem { public: VariableGroupItem() - : m_chooser(0) + : m_chooser(0), m_populated(false) { - setLazy(true); } QVariant data(int column, int role) const @@ -143,16 +142,23 @@ public: return QVariant(); } - void populate() + bool canFetchMore() const + { + return !m_populated; + } + + void fetchMore() { if (MacroExpander *expander = m_provider()) populateGroup(expander); + m_populated = true; } void populateGroup(MacroExpander *expander); public: VariableChooserPrivate *m_chooser; // Not owned. + bool m_populated; MacroExpanderProvider m_provider; };