forked from qt-creator/qt-creator
TreeModel: Clean up TreeItem API
isLazy/populate was the first incarnation of the canFetchMore/ fetchMore mechanism which now can take over completely. So: - remove isLazy/populate - the use in VariableChooser Change-Id: I885d492c134fb6899759e19a73156b52df7a880a Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
This commit is contained in:
@@ -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<TreeItem *>(this)->populate();
|
||||
m_populated = true;
|
||||
}
|
||||
}
|
||||
|
||||
void TreeItem::propagateModel(TreeModel *m)
|
||||
{
|
||||
QTC_ASSERT(m, return);
|
||||
|
||||
Reference in New Issue
Block a user