#include "virtualmodeladapter.h"

#include "../virtualmodelinterface/virtualmodelinterface.h"

int VirtualModelAdapter::indexOfItem(void *parent, void *item, int start) {
  int count = getItemsCount(parent);
  for (int i = start; i < count; ++i)
    if (getItem(parent, i) == item)
      return i;
  return -1;
}

bool VirtualModelAdapter::hasItems(void *parent) {
  return getItemsCount(parent) > 0;
}

void *VirtualModelAdapter::getItemParent(void *item) { return item; }

void VirtualModelAdapter::beginUpdate() {
  if (m_virtualModelInterface)
    m_virtualModelInterface->beginUpdate();
}

void VirtualModelAdapter::endUpdate() {
  if (m_virtualModelInterface)
    m_virtualModelInterface->endUpdate();
}

void VirtualModelAdapter::queuedUpdate() {
  if (m_virtualModelInterface)
    m_virtualModelInterface->queuedUpdate();
}

void VirtualModelAdapter::setModel(VirtualModelInterface *virtualModel) {
  m_virtualModelInterface = virtualModel;
}

VirtualModelInterface *VirtualModelAdapter::getModel() { return m_virtualModelInterface; }
