bool UpdateDevModel::pushItem(DeviceItem *item)
{

    int pos = items.size();
    if (!this->insertRow(pos, QModelIndex()))
        return false;

    DeviceItem * newItem = items.value(pos);
    bool result = newItem->setData(item);
    if (result){
        QModelIndex left = this->createIndex(pos,0);
        QModelIndex right = this->createIndex(pos,headerTexts.size()-1);
        topLeftList.append(left);
        bottomRightList.append(right);
        //emit dataChanged(left, right);
    }
    return result;
}
bool UpdateDevModel::setData(const QModelIndex &index, const QVariant &value, int role)
{

//    if(role == Qt::CheckStateRole && index.column() == 0){
//        DeviceItem *item = static_cast<DeviceItem*>(index.internalPointer());
//        if (value==Qt::Unchecked)
//        {
//            item->setCheckState(false);
//            emit dataChanged(index, index);
//            //m_checkedList.removeOne(item);
//            //emit selectedRows(m_checkedList.size());
//        }
//        else if(value==Qt::Checked)
//        {
//            item->setCheckState(true);
//            emit dataChanged(index, index);
//            if(!m_checkedList.contains(item)){
//                m_checkedList.append(item);
//                emit selectedRows(m_checkedList.size());
//            }
//        }
//        return true;
//    }

    if(role == Qt::UserRole){
        return false;
    }
    if (role != Qt::EditRole)
        return false;

    DeviceItem *item = items.value(index.row());
    bool result = item->setData(index.column(), value);

    if (result){
        topLeftList.append(index);
        bottomRightList.append(index);
    //    emit dataChanged(index, index);
    }
    return result;
}