Hiding some properties of TreeItem

This commit is contained in:
Dan Paulat 2022-10-10 15:45:51 -05:00
parent 1ab0d62b1f
commit f24aa78b50
2 changed files with 14 additions and 3 deletions

View file

@ -12,6 +12,8 @@ namespace qt
namespace model
{
class TreeModel;
class TreeItem
{
public:
@ -36,14 +38,18 @@ public:
int row() const;
const TreeItem* parent_item() const;
void AppendChild(TreeItem* child);
TreeItem* FindChild(int column, const QVariant& data);
bool InsertChildren(int position, int count, int columns);
bool SetData(int column, const QVariant& value);
protected:
void AppendChild(TreeItem* child);
bool InsertChildren(int position, int count, int columns);
bool SetData(int column, const QVariant& value);
private:
class Impl;
std::unique_ptr<Impl> p;
friend class TreeModel;
};
} // namespace model

View file

@ -50,6 +50,11 @@ TreeItem* TreeModel::root_item()
int TreeModel::rowCount(const QModelIndex& parent) const
{
if (parent.isValid() && parent.column() > 0)
{
return 0;
}
const TreeItem* parentItem = p->item(parent);
return parentItem ? parentItem->child_count() : 0;
}