UI-less kdevplatform
Andreas Pakulat
apaku at gmx.de
Tue Aug 5 20:42:21 UTC 2008
On 05.08.08 04:18:56, Aleix wrote:
> Hi list!
> As some of you know, these days I've been working on an application
> using kdevplatform (more precisely the duchain).
>
> As you might imagine, I don't need a UI application for that, so I've
> been playing with the shell to be able to instanciate it without
> relying on the graphics.
>
> Here I send a patch that makes it possible. These are the major changes:
> - Core::initialize takes an (optional) parameter that tells the core
> if it is initializing an application with/without UI. I could have
> added another ::initializeNoUi method, but I didn't want to copy much
> code.
Please use enum's instead of bool's for flags.
> - There is a Core::hasUI() method that queries if he has the Ui
> capability and depending on if he has, the IUIController will be
> either a fullfeatured UIController or a UiLessController which just
> returns false or 0 in all his methods.
I guess that should then be uiFlags(), setupFlags() or just flags() and
return the enum value.
> - This is not very related but needed too, a method to the
> ProjectController to add a custom project in the IDE. I used it to
> instantiate a Project with a custom projectmanager without the need of
> a Plugin and so (even if it is an IPlugin).
I don't quite understand why this is needed. Why can't you just load the
project the normal way? IProject isn't really supposed to be subclassed
outside shell/
> Index: shell/uicontroller.h
> ===================================================================
> --- shell/uicontroller.h (revision 842215)
> +++ shell/uicontroller.h (working copy)
> @@ -40,7 +40,7 @@
> Q_OBJECT
>
> public:
> - UiController(Core *core);
> + UiController(Core *core, bool ui=true);
> virtual ~UiController();
Again the flag-thing. Apart from that I don't see the need for this
actually. If you create UiLessController instead of UiController when
doing non-ui Core then there's no need that UiController works without
Ui.
> Index: shell/uicontroller.cpp
> ===================================================================
> --- shell/uicontroller.cpp (revision 842215)
> +++ shell/uicontroller.cpp (working copy)
> @@ -138,8 +138,8 @@
> IToolViewFactory *factory;
> };
>
> -UiController::UiController(Core *core)
> - :Sublime::Controller(0), IUiController(), d(new UiControllerPrivate(this))
> +UiController::UiController(Core *core, bool ui)
> + :Sublime::Controller(0), IUiController(), d(ui ? new UiControllerPrivate(this) : 0)
Why does UiController not have a private class? I think you should
rather look into d-pointer-inheritance and provide a UiControllerPrivate
subclass for UiLessController which overrides the parent methods that
deal with ui-code and let them do nothing.
Having tons of if(d) cluttered about the code is really really bad and
will bite back as soon as someone forgets this little thing here.
> + /* Need to do this after everything else is loaded. It's too
> + hard to restore position of views, and toolbars, and whatever
> + that are not created yet. */
Broken indentation here, please fix that before comitting anything.
Andreas
--
You will be successful in love.
More information about the KDevelop-devel
mailing list