UI-less kdevplatform

Aleix aleixpol at gmail.com
Wed Aug 6 02:15:19 UTC 2008


On 8/5/08, Andreas Pakulat <apaku at gmx.de> wrote:
> 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.
Fixed in the attatched patch.

>
>
>  > - 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.
Fixed in the patch

>
>
>  > - 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/
I think it is useful to be able to do it without having installed the
whole plugin and, anyway, it is not in IProjectController but
ProjectController so it can be only used in few places, no bad use is
guaranteed.
>
>  > 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.
It is used because the UiLessController inherits UiController (so that
it works in the Core::initialize())

I find 2 other solutions (1 already discussed here).
 - Create a new base class for them both (instead of using
UIController as the base for UILessController) > That could be done,
but I don't really see the advantage
 - Abstract the d-pointer. > This makes the implementation a bit ugly I think.

>
>  > 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.
I don't think we would ever have an if(d) here, since the ui-less
intention is not to be called at all...

>
>  > +            /* 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.
>
Fixed in the patch too

Thanks for reviewing,
Aleix
>  Andreas
>
>
>  --
>  You will be successful in love.
PS: ^ Thank god! XD
>
>  _______________________________________________
>  KDevelop-devel mailing list
>  KDevelop-devel at kdevelop.org
>  https://barney.cs.uni-potsdam.de/mailman/listinfo/kdevelop-devel
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: uiless2_kdevplatform.patch
Type: text/x-diff
Size: 9270 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20080806/4c46977b/attachment.bin>


More information about the KDevelop-devel mailing list