4.4 API: AbstractToolBox::ToolType

Aaron J. Seigo aseigo at kde.org
Mon Jan 4 10:39:28 CET 2010


On January 4, 2010, Marco Martin wrote:
> On Monday 04 January 2010, Aaron J. Seigo wrote:
> >  AbstractToolBox:
> >     enum ToolType {
> >     
> >         AddTool = 0,
> >         ConfigureTool = 100,
> >         ControlTool = 200,
> >         MiscTool = 300,
> >         DestructiveTool = 400,
> >         LastToolType = DestructiveTool + 1
> >     
> >     };
> 
> hmm, why increments of 100 each one? also LastToolType -> UserTool?

so we can add other items in between later if we want and still rely on the 
numeric order for sorting. we can always resort if needed to an internal 
mapping of types to order, but it would be nice to avoid that if possible.

> > then one sets the data on a QAction with one of these values and the
> > 
> >  toolbox can use it to figure out what to do. this prevents any changes
> >  in the Plasma API, does not require a QAction subclass and seems to
> >  work pretty well.
> > 
> > i now have an orderly toolbox on my desktop.
> > 
> > i am not overly satisfied with using QAction::data() as such a metadata
> > dumping ground but i couldn't think of another more elegant solution.
> > 
> >  anyone else have ideas?
> 
> well, the abstracttoolbox is new in 4.4, so its api can still be changed,
> we could have addAction(action, type);

that was one of the things i tried, but it doesn't work. actions that come 
from Corona are added by things like plasma-desktop's PlasmaApp. at that point 
we don't know what the type is, so the type has to travel with the action as 
far as i can see.

> or what about a simple addAction(action, int weight)?

you need to know what other weights there are and we want to be able to sort 
them internally to our liking. e.g. destructive items at the end.

-- 
Aaron J. Seigo
humru othro a kohnu se
GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA  EE75 D6B7 2EB1 A7F1 DB43

KDE core developer sponsored by Qt Development Frameworks


More information about the Plasma-devel mailing list