#include "ModeleListe.h"
#include <QList>

ModeleListe::ModeleListe(QObject *parent)
	: QAbstractListModel(parent)
{
	for (int i = 0; i < 6; i++)
	{
		liste.append(QString("Chaine %1").arg(i) );
	}
}

int ModeleListe::rowCount(const QModelIndex &parent) const
{
	return liste.count();
}

QVariant ModeleListe::data(const QModelIndex &index, int role) const
{
	if (false == index.isValid() )
	{
		return QVariant();
	}
	
	if (Qt::DisplayRole != role)
	{
		return QVariant();
	}
	
	if (index.row() >= liste.count() )
	{
		return QVariant();
	}
	
	return liste.at(index.row() );
}

Qt::ItemFlags ModeleListe::flags(const QModelIndex &index) const
{
	if (true == index.isValid() )
	{
		return Qt::ItemIsDragEnabled | QAbstractItemModel::flags(index);
	}
	else
	{
		return QAbstractItemModel::flags(index);
	}
}
