Move KDirModel to KioGui
Open, Needs TriagePublic

Description

Koko uses KDirModel in QML, but it has some issues like QWidgets dialogs with error messages popping up. The model itself isn't depending on Widgets, but it uses other stuff from KioWidgets.

joburlcache_p.h should be straightforward to move to core
fileundomanager has some widgets depencencies that need to be untangled first

dfaure added a subscriber: dfaure.Oct 4 2019, 2:33 PM

Do you mean QtGui? We need icons...

nicolasfella renamed this task from Move KDirModel to KioCore to Move KDirModel to KioGui.Nov 21 2019, 5:44 PM

Since JobUrlCache is entirely internal to KDirModel, I would move it to KioGui together with KDirModel, to avoid having to export it from KioCore.

FileUndoManager already has an interface for the GUI stuff (FileUndoManager::UiInterface).
We "just" need to make that pure abstract, move the implementation to a subclass, and possibly hook in that subclass automatically from KioWidgets like we do for delegates. Or we let the few apps using FileUndoManager choose which impl to use (the widgets one or their own, like dolphin already does by calling setUiInterface).

ognarb added a subscriber: ognarb.Jul 12 2020, 6:23 PM
dfaure moved this task from Backlog to In Progress on the KF6 board.Jan 1 2021, 9:44 PM
dfaure claimed this task.Mar 27 2021, 1:30 PM

Next issue: KDirModel uses KDirLister (which extends KCoreDirLister with QWidget* and KMessageBox for errors).
Idea: take a JobUiDelegate in KCoreDirLister, remove KDirLister, rename KCoreDirLister to KDirLister.
And set the ui delegate from the factory automatically like in KIO jobs.

Better plan, let KCoreDirLister emit error(KJob*) and handle that in apps and in KDirModel.

dfaure added a comment.EditedApr 3 2021, 11:58 AM

I locally attempted the move to kiogui, to see what would create problems.

I had to move all of clipboardupdater.cpp fileundomanager.cpp joburlcache.cpp kdirmodel.cpp org.kde.kuiserver.xml org.kde.kio.FileUndoManager.xml,
adjust export macros, qCDebug
add linking to KIconThemes
export ClipboardUpdater for usage by kiowidgets
make use of ../gui/org.kde.kuiserver.xml in kiowidgets/CMakeLists.txt

Apart from the known issues (KDirLister=>KCoreDirLister, FileUndoManager::UiInterface which clearly needs to stay in KIOWidgets) I found another issue: the signal KIO::WidgetsAskUserActionHandler::askUserDeleteResult provides a QWidget* which is used by e.g. KDirOperator to find out if it is the target for that signal. This is a case where we don't want to change to QWindow*, there could be multiple widgets in the same window. Ah, but QObject* would do. I'll add TODOs.