#include <QFileSystemModel>

TreeModel_left::TreeModel_left(QObject* parent) : TreeModel(parent) {}
//TreeModel inherits from QFileSystemModel

QVariant TreeModel_left::data(const QModelIndex& index, int role) const
    {
         if (index.column() == 0 && role == Qt::CheckStateRole) {
             return checkstatus; //checkstatus is Qt::CheckState
        }

      return QFileSystemModel::data(index, role);
    }

Qt::ItemFlags TreeModel_left::flags(const QModelIndex& index) const {
    if (!index.isValid())
            return Qt::NoItemFlags;

        Qt::ItemFlags flags = QFileSystemModel::flags(index);
        if (index.column() == 0) {
            flags |= Qt::ItemIsUserCheckable;
        }

        return flags;
}

bool TreeModel_left::setData(const QModelIndex& index, const QVariant& value, int role) {

        if (index.column() == 0 && role == Qt::CheckStateRole) {
            Qt::CheckState state = static_cast<Qt::CheckState>(value.toInt());
            checkstatus = state; //checkstatus is Qt::CheckState
        }

        return QFileSystemModel::setData(index, value, role);
}