[bt-devel] new helper class BTModuleTreeItem

Eeli Kaikkonen eekaikko at mail.student.oulu.fi
Mon Nov 5 06:53:09 MST 2007


I wrote a new backend helper class BTModuleTreeItem. Its purpose is to
replace and encapsulate the functionality from at least mainindex,
search module chooser, bookshelf manager and wherever module list/tree
views are used.

It was painful to see for example the search module chooser code, how it
builds the module tree. All views have to build the tree so there is
much duplication and ad hoc code in different places which does not
actually belong to the frontend at all. One change to backend means
checking and possibly changing all views (take e.g. adding a new
category). The new class handles categories, languages, modules,
sorting, i18n etc. It also makes some new behaviour possible and even
very easy, like hiding some modules or changing the grouping
(Category/Language/Module -> Category/Module, Language/Module,
Language/Category/Module, Module).

Language and module sorting order is now locale dependend (I'm not sure
if it was previously in different places in the code). Categories are
always sorted in the same order, not depending on i18n'ed text. I think
that they are so fixed in meaning and usage that it's better to have
them always in the same order, not in arbitrary language dependend
order. This can be changed if wanted.

The documentation in the header file should be sufficient.
The search module chooser is now a good example. It has the same
grouping than the mainindex which is now hardcoded but can be easily
changed to be customizable (you can change one argument and compile
the code to see how it happens). I also added tristate checkboxes to
tree groups which in my opinion enhances usability.

My further idea is to give users possibility to change the view from the
mainindex RMB menu: hide some modules, change the grouping etc. Those
changes could be saved to configuration and applied to different views
where possible so that the views would be more coherent with each other.

We are not using a model/view architecture, I have thought about that
but it seemed too complex for me. This new class helps dividing backend
from frontend without being too complex and still gives much
flexibility.

  Yours,
	Eeli Kaikkonen (Mr.), Oulu, Finland
	e-mail: eekaikko at mailx.studentx.oulux.fix (with no x)



More information about the bt-devel mailing list