It's obvious we want to do this (it's been done in tk plugin as well).

Here's a concrete proposal how we should (IMHO) do this:

- We add CommandChainDispatcher g.visit_tree_item. This allows plugins
to register their own functions to manipulate QTreeWidgetItem after
leo has constructed it. This would happen during tree redraw cycle.
- The function signature would just be:

visit_tree_item(c,p, myQTreeWidgetItem)

- I don't see much point in abstacting this more (in a tk compatible
fashion). We want to offer full control of widget items, incl. stuff
like alignment, font, adding tooltips, statustips,  "whats this?"
support, ...

- This could also change the icon, overriding leo's icon creation code
(if needed).

- CommandChainDispatcher is better than just offering the tree widget
item to a list of handlers, since commandchaindispatcher can
optionally suppress following handlers and provides priority ordering.

- Here's an example that makes @url nodes bold and gives it a tool tip
(yeah, tooltip is contorted use case):

def url_itemvisitor(c,p, wi):
  if not p.h.startswith('@url '): raise TryNext
  wi.setFont(0, myBoldFont)
  wi.setToolTip(0, u"doubleclick on this to open url " + unicode(p.h))
  raise TryNext


g.visit_tree_item.add(url_itemvisitor, priority = '60')

Note that we rause TryNext in the end - we don't want to be too
"eclusive" with the @url colorizer, it's ok for other plugins to
change it as well. It would typically be the case for most widget item
manipulators. Other plugins may want to change the color, layout, ...

Also note that, again, this leaves the door open to e.g. storing the
color info to uAs. It's just not the only way.

Some "reverse logic" is at play here - ofter, the handlers with the
lowest priority are what make the final call, because by definition
they get the "last word". If you don't like that, don't call TryNext
in yoru high priority handler ;-).

-- 
Ville M. Vainio
http://tinyurl.com/vainio

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To post to this group, send email to leo-editor@googlegroups.com
To unsubscribe from this group, send email to 
leo-editor+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/leo-editor?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to