KFlowRects proposal (planned for next Monday)

Matthew Woehlke mw_triad at users.sourceforge.net
Mon Aug 6 22:28:15 BST 2007


Matt Newell wrote:
> On Monday 06 August 2007 09:22, Matthew Woehlke wrote:
>> I would like to add (next Monday) this class to kdelibs (probably kdeui?
>> where is a good place?). This class takes some information about items
>> and "flows" them in a container. The container is a rectangle, with
>> fixed-size items and fixed spacing between the items. The purpose it to
>> determine the coordinates of the n'th item by "flowing" items in the
>> container with the requested size and spacing.
>>
> 
> Why such a longwinded api for something so simple.
> 
> QRect getFlowedRect( int index, const QSize & itemSize, int layoutWidth, int 
> h_spacing, int v_spacing )
> {
> 	int itemsPerRow = layoutWidth / (itemSize.width() + h_spacing);
> 	return QRect( QPoint( (index % itemsPerRow) * (itemSize.width() + h_spacing), 
> (index / itemsPerRow) * (itemSize.height() + v_spacing) ), itemSize );
> }
> 
> Seems to me that it's so simple it'd be better off put in a wiki and copy and 
> pasted for people to use inline who need it. 

For one, this isn't stateful. Otherwise, this was actually my original 
plan, but after looking at the current KPixmapSplitter users I changed 
my mind. Maybe I will look again and change my mind back? (Any chance 
you would feel like writing a patch against the existing KPixmapSplitter 
users?)

-- 
Matthew
"Braaaaaaaaiins!" -- Zombies





More information about the kde-core-devel mailing list