#include "floorplanlistmodel.h"

#include <QPixmap>
#include <QImageReader>
#include <QDebug>
#include <QUrl>

floorplanlistmodel::floorplanlistmodel(const QStringList &nameString, const QPixmap p[], QObject *parent) :
        QAbstractListModel(parent), nameString(nameString)
{

    for(int i=0;i<151;i++){_p[i]=p[i];}
    arrow = QPixmap::fromImage(QImage(":/new/prefix1/Image/arrow_right.png"));
    qDebug()<<"size : "<<nameString.size();


}

int floorplanlistmodel::rowCount(const QModelIndex &parent) const
{
    qDebug()<<"count : "<<nameString.count();
    return nameString.count();
}

QVariant floorplanlistmodel::data(const QModelIndex &index, int role) const
{
    qDebug()<<"row : "<<index.row();
    qDebug()<<"valid : "<<index.isValid();
    if ( (!index.isValid()) || (index.row() >= nameString.size()))
        return QVariant();


    if(role == Qt::UserRole)
    {
        qDebug()<<nameString.at(index.row());
        return nameString.at(index.row());
    }
    else if( role == Qt::UserRole+1)
    {

        return _p[index.row()];
    }
    else if( role == Qt::UserRole+2)
    {

        return arrow;
    }




    return QVariant();
}



void floorplanlistmodel::setStrings(const QStringList & strings)
{
    qDebug()<<"check!";
    nameString = strings;
    reset();
}
