1
votes

I am trying to modify the stock QFileDialog to better support the SNFS file-system. Currently it doesn't update after deleting files. So if a user deletes a file, the file is still shown in the Dialog.

So what I need is some way to get notified once the user has deleted a file from the dialog, or a way to remove the default shortcut so I can implement my own.

What I've tried so far:

Installing an eventFilter for the DEL key

The event seems to get stopped by QFileDialog before it gets to my filter.

Adding my own Shortcut

This results in :

QAction::eventFilter: Ambiguous shortcut overload: Del

Removing set Shortcuts

I call the following function on the dialog to recursively remove all set shortcuts and actions:

def to_children(self, parent):
    for child in parent.children():
        if hasattr(child, 'removeAction'):
            for a in child.actions():
                child.removeAction(a)
        if hasattr(child, 'releaseShortcut'):
            for i in range(100):
                self.releaseShortcut(i)
        self.to_children(child)

However the shortcut still works.

1
Perhaps you want to amend your question to indicate that you are only interested in overriding the delete functionality of the Qt's version of the file dialog, and deletions elsewhere are not important.Kuba hasn't forgotten Monica
Most likely, the stock file dialog uses shortcut actions of its own and they may not be the children of the dialog.Kuba hasn't forgotten Monica
I removed those as well, but it didn't help.BoshWash

1 Answers

1
votes

There are many ways of deleting files - hooking shortcuts won't help you.

There are two kinds of file dialogs: native and Qt dialogs. Native dialogs track filesystem state on both Windows and OS X, perhaps with a slight delay that is platform specific and present in all applications in to the same degree. On these platforms, you shouldn't need to do anything further. Qt dialogs, always used on Windows, and optionally on other platforms, use a filesystem model that will, when it can, get notified of filesystem state changes.

Questions that have to be answered:

  1. Which dialog are you using (native or Qt)? The DontUseNativeDialog option can be set to force a Qt dialog.

  2. Does SNFS on your platform implement filesystem change notifications?

  3. Did you verify that the filesystem change notifications work and are picked up by Qt's QFileSystemModel - if so, Qt file dialogs will be notified whether the platform dialogs are or not.