#ifndef INTERNALNODE_H
#define INTERNALNODE_H

#include "virtualtreemodel.h"

#include <vector>

#include <memory>

class VirtualModelAdapter;

// internal tree structure
struct VirtualTreeModel::InternalNode {
public:
  using InternalChildren = std::vector<std::unique_ptr<InternalNode>>;

public:
  InternalNode *parent;
  void *item;
  size_t parentIndex;
  InternalChildren children;

  bool hasChildrenQueryed = false;
  bool hasChildren = false;
  bool childInitialized = false;

public:
  explicit InternalNode(InternalNode *parent, void *obj, size_t index);

public:
  bool isInitialized(VirtualModelAdapter *adapter);
  void loadChildren(VirtualModelAdapter *adapter);
  int childCount(VirtualModelAdapter *adapter);
  void eraseChildren(const InternalChildren::iterator &begin,
                     const InternalChildren::iterator &end);
  void insertedChildren(size_t lastIndex);
};

#endif // INTERNALNODE_H
