#pragma once
#include <QtGui/QTreeWidgetItem>

class UnitsToSelect
{
public:
  typedef std::set<size_t>::const_iterator ProcessIDIterator;
  std::pair<ProcessIDIterator, ProcessIDIterator> getProcessesID() const
  {
    return std::make_pair(m_processesID.begin(), m_processesID.end());
  }
  typedef std::set<size_t>::const_iterator UnitRecordIDIterator;
  std::pair<UnitRecordIDIterator, UnitRecordIDIterator> getUnitRecordsID() const
  {
    return std::make_pair(m_unitRecordsID.begin(), m_unitRecordsID.end());
  }

  void clear()
  {
    m_processesID.clear();
    m_unitRecordsID.clear();
  }

  void insertProcess(size_t processID)
  {
    m_processesID.insert(processID);
  }

  void insertUnitRecord(size_t unitRecordID)
  {
    m_unitRecordsID.insert(unitRecordID);
  }

private:
  std::set<size_t> m_processesID;
  std::set<size_t> m_unitRecordsID;
};

class QTreeWidgetItemKey : public QTreeWidgetItem
{
public:
  QTreeWidgetItemKey(QTreeWidget *view, const void* key)
    : QTreeWidgetItem(view)
    , m_key(key)
  {
  }
  QTreeWidgetItemKey(QTreeWidgetItem *item, const void* key)
    : QTreeWidgetItem(item)
    , m_key(key)
  {
  }
  ~QTreeWidgetItemKey() {}
  const void* getKey() const { return m_key; }

  virtual void addUnits(UnitsToSelect&) const {}
protected:
  const void* const m_key;
};


template <class CustomData>
class QTreeWidgetItemCustom : public QTreeWidgetItemKey
{
public:
  QTreeWidgetItemCustom(QTreeWidget *view, const void* key)
    : QTreeWidgetItemKey(view, key)
    , m_data()
  {
  }
  QTreeWidgetItemCustom(QTreeWidgetItem *item, const void* key)
    : QTreeWidgetItemKey(item, key)
    , m_data()
  {
  }
  CustomData getCustomData() { return m_data; }
  void setCustomData(CustomData data) { m_data = data; }
protected:
  CustomData m_data;
};
