Commit daed22ab authored by Jan Hambrecht's avatar Jan Hambrecht
Browse files

* extended KoShapeManager::shapeAt to return a shape out of the shapes at...

* extended KoShapeManager::shapeAt to return a shape out of the shapes at point based on its selection.
* extended KoShapeManager::shapesAt to optionally not return hidden shapes (KoShape::visible())

all the above is untested, but i have confidence that it works correct ;-)


svn path=/trunk/koffice/; revision=568349
parent 3bad66a8
......@@ -151,33 +151,71 @@ void KoShapeManager::paint( QPainter &painter, const KoViewConverter &converter,
m_selection->paint( painter, converter );
}
KoShape * KoShapeManager::shapeAt( const QPointF &position, bool omitHiddenShapes )
KoShape * KoShapeManager::shapeAt( const QPointF &position, SelectionType selection, bool omitHiddenShapes )
{
updateTree();
QList<KoShape*> sorterdShapes( m_tree.contains( position ) );
qSort(sorterdShapes.begin(), sorterdShapes.end(), KoShape::compareShapeZIndex);
KoShape *firstUnselectedShape = 0L;
for(int count = sorterdShapes.count()-1; count >= 0; count--) {
KoShape *shape = sorterdShapes.at(count);
if( omitHiddenShapes && ! shape->isVisible() )
if ( omitHiddenShapes && ! shape->isVisible() )
continue;
if ( shape->hitTest( position ) )
if ( ! shape->hitTest( position ) )
continue;
switch ( selection )
{
//kDebug() << "Hittest succeeded" << endl;
return shape;
case shapeOnTop:
return shape;
case selected:
if ( m_selection->isSelected( shape ) )
return shape;
break;
case unselected:
if ( ! m_selection->isSelected( shape ) )
return shape;
break;
case nextUnselected:
// we want an unselected shape
if ( m_selection->isSelected( shape ) )
continue;
// memorize the first unselected shape
if( ! firstUnselectedShape )
firstUnselectedShape = shape;
// check if the shape above is selected
if( count < sorterdShapes.count() && m_selection->isSelected( sorterdShapes.at(count+1) ) )
return shape;
break;
}
}
// if we want the next unselected below a selected but there was none selected,
// return the first found unselected shape
if( selection == nextUnselected && firstUnselectedShape )
return firstUnselectedShape;
if ( m_selection->hitTest( position ) )
return m_selection;
return 0; // missed everything
}
QList<KoShape *> KoShapeManager::shapesAt( const QRectF &rect )
QList<KoShape *> KoShapeManager::shapesAt( const QRectF &rect, bool omitHiddenShapes )
{
updateTree();
//TODO check if object is really in the rect and not
// only the bounding rect of the object.
return m_tree.intersects( rect );
if( omitHiddenShapes ) {
QList<KoShape*> intersectedShapes( m_tree.intersects( rect ) );
for(int count = intersectedShapes.count()-1; count >= 0; count--) {
KoShape *shape = intersectedShapes.at( count );
if( ! shape->isVisible() )
intersectedShapes.removeAt( count );
}
return intersectedShapes;
}
else
return m_tree.intersects( rect );
}
void KoShapeManager::repaint( QRectF &rect, const KoShape *shape, bool selectionHandles )
......
......@@ -91,20 +91,37 @@ public:
*/
virtual void paint( QPainter &painter, const KoViewConverter &converter, bool forPrint );
/**
* Used to change the behavior of shapeAt()<dl>
* <dt>selected</dt>
* <dd>return the first selected with the highest z-ordering (i.e. on top).</dd>
* <dt>unselected</dt>
* <dd>return the first unselected on top.</dd>
* <dt>nextUnselected</dt>
* <dd>return the first unselected directly under a selected shape, or
* the top most one if nothing is selected.</dd>
* <dt>shapeOnTop</dt>
* <dd>return the shape highest z-ordering, regardless of selection.</dd>
* </dl>
*/
enum SelectionType { selected, unselected, nextUnselected, shapeOnTop };
/**
* Returns the shape located at a specific point in the document.
* If more than one shape is located at the specific point, the one with
* the highest z-index is returned.
* If more than one shape is located at the specific point, the given selection type
* controls which of them is returned.
* @param position the position in the document coordinate system.
* @param omitHiddenShape if true, only visible shapes are considered
* @param selection controls which shape is returned when more than one shape is at the specific point
* @param omitHiddenShapes if true, only visible shapes are considered
*/
KoShape * shapeAt( const QPointF &position, bool omitHiddenShapes = false );
KoShape * shapeAt( const QPointF &position, SelectionType selection = shapeOnTop, bool omitHiddenShapes = false );
/**
* Returns the shapes which intersects the specific rect in the document.
* @param rect the rectangle in the document coordinate system.
* @param omitHiddenShapes if true, only visible shapes are considered
*/
QList<KoShape *> shapesAt( const QRectF &rect );
QList<KoShape *> shapesAt( const QRectF &rect, bool omitHiddenShapes = false );
/**
* Request a repaint to be queued.
......
* add a ShearingStrategy (boemann)
* Add 'ensureVisible(KoShape)' to KoCanvasController (see QScrollArea for what it should do)
* extend KoShapeManager shapeAt to
- optionally not return hidden shapes (KoShape::visible())
- return a shape out of the shapes at point based on its selection.
The parameter passed to specify which shape to select should be something like:
enum SelectionType { selected, unselected, nextUnselected, frameOnTop };
see kword/KWFrameViewManager for an explenation of the options.
* update KoShapeContainer positon/boundingRect when a child is added or updated
Use xcursorgen to create real xcursors ? (boemann)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment