ProjectItem vs. ProjectFolderItem
Matt Rogers
mattr at kde.org
Sun Sep 30 14:03:28 UTC 2007
On Sunday 30 September 2007 04:51:02 am Andreas Pakulat wrote:
> Hi,
>
> as Aleix pointed out its currently quite ugly to create custom
> ProjectItem's for your buildmanager. The reason is that you'd have to
> subclass KDevelop::ProjectItem+<custom folder item> resulting in this:
>
> class QMakeProjectItem : public ProjectItem, QMakeFolderItem
> {
> };
>
> The reason why this is ugly because the inheritance graph for this is
> now:
>
> ProjectFolderItem
>
> ----------+-------------
>
> QMakeFolderItem ProjectItem
>
> ----------+-------------
>
> QMakeProjectItem
>
> (not 100% correct, I left out the ProjectBuildFolderItem)
>
> So we have that dreaded diamond-shape inheritance :(
>
Why do we have ProjectItem to begin with? Is there some reason we can't just
add an isProjectRoot() function to ProjectFolderItem?
> Unfortunately I don't see a way of removing this inheritance graph
> without having to duplicate the code between ProjectFolderItem and
> ProjectItem (and thus all subclasses as well).
>
Remove ProjectItem
> All those Item classes are ProjectBaseItem subclasses which is a
> QStandardItem subclass.
>
> The only way I currently see is making the project item a separate thing
> from the source folder of the project. Of course you'd see that in the
> project manager, so we'd have "Project->project-source-folder" instead of
> only "Project" in the hierarchy.
>
> My question is: Did I overlook a way to solve that inheritance dilemma
> without having to duplicate code? (I thought about changing to
> has-a-relationship between projectitem and projectfolderitem, but then
> you'd still get the new hierarchy in the project manager)
>
> Andreas
You did. Remove the inheritance. It's not needed. Add some nice functions to
ProjectFolderItem to find the root of the project.
--
Matt
More information about the KDevelop-devel
mailing list