Is there a way to update a file's permissions in QFileSystemModel (c++)? Prior to allowing a user to rename a file listed in the model using a qtreeview, I make sure the file gets checked out of source control. At this point the file is no longer read only, but the model still believes it's read only. How can I force the model to update a file's permissions without losing the expand / collapse state of the tree?
Thanks!
Update: The file is already flagged as writeable after checking out the file. The Model remains unaware of the change though.
QFile file(path.c_str());
QFileDevice::Permissions perms = file.permissions();
if (perms & QFile::WriteUser)
{
// Is already true
}
Just to be sure, I went ahead and used
file.setPermissions(file.permissions() | QFile::WriteUser);
with no luck changing the permissions reported for that file in the model.
Update:
int perms = fsModel->data(index, QFileSystemModel::Roles::FilePermissions).value<int>();
if (perms & QFile::WriteUser)
{
int i = 0;
}
Note: the above permissions never has the QFile::WriteUser flag set unless the file was writeable before the model was created.