QFileSystemModel - Customise Features of Setting ReadOnly(false)
-
Hey Again,
Another small query,
When we set the qfilesystemmodel to not be readonly ( to get drag-drop, rename..) is there anyway to turn a particular feature off?
My main reason for asking this is that the double click tries to edit the filename, I do not want that action since I have a slot to open the file on double click. So with both together its like a nasty flicker on item(entering edit and exiting) on double click and file opens.
I'd like the rename function that the default double click gives itself but say from a customcontextmenu or something.
Looking at the data() function for qfilesystemmodel I'm not sure if we can have one without the other
@
flags |= Qt::ItemIsDragEnabled;
if (d->readOnly)
return flags;
if ((index.column() == 0) && indexNode->permissions() & QFile::WriteUser) {
flags |= Qt::ItemIsEditable;
if (indexNode->isDir())
flags |= Qt::ItemIsDropEnabled;
}
return flags;
@Would be nice if i could just disable the annoying edit on double click.
Also how does the default model set the item in a editing state btw(provided it has a flag set for Qt::ItemIsEditable)?
-
Forgot to post a reply, but I solved this eventually myself.
The flicker is due to QTreeView and its edit function being tied to a double click. Hence I just Subclassed QTreeView with
@
bool DerivedTreeView::edit(const QModelIndex& index,
EditTrigger trigger,
QEvent* event) {
if (trigger == QAbstractItemView::DoubleClicked)
return false;
return QTreeView::edit(index, trigger, event);
}
@^^ That just ignores the edit call when the trigger is a double click and hence the flicker is gone. Also by using the same edit function from the context menu I could get the rename functionality as well when needed.