Commit 1fb31db2 authored by Thomas Zander's avatar Thomas Zander
Browse files

Refactor;

Follow standard that enum values are CamelCase
Move public API enum to KoFlake
Add include protection to KoFlake.h

svn path=/trunk/koffice/; revision=603096
parent 84a2e4a0
......@@ -16,6 +16,8 @@
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef KOFLAKE_H
#define KOFLAKE_H
/**
* Flake reference
......@@ -42,6 +44,19 @@ public:
NoHandle ///< Value to indicate no handle
};
/**
* Used to change the behavior of KoShapeManager::shapeAt()
*/
enum ShapeSelection {
Selected, ///< return the first selected with the highest z-ordering (i.e. on top).
Unselected, ///< return the first unselected on top.
NextUnselected, ///< return the first unselected directly under a selected shape, or the top most one if nothing is selected.
ShapeOnTop ///< return the shape highest z-ordering, regardless of selection.
};
private:
KoFlake();
};
#endif
......@@ -151,12 +151,12 @@ void KoShapeManager::paint( QPainter &painter, const KoViewConverter &converter,
m_selection->paint( painter, converter );
}
KoShape * KoShapeManager::shapeAt( const QPointF &position, SelectionType selection, bool omitHiddenShapes )
KoShape * KoShapeManager::shapeAt( const QPointF &position, KoFlake::ShapeSelection selection, bool omitHiddenShapes )
{
updateTree();
QList<KoShape*> sorterdShapes( m_tree.contains( position ) );
qSort(sorterdShapes.begin(), sorterdShapes.end(), KoShape::compareShapeZIndex);
KoShape *firstUnselectedShape = 0L;
KoShape *firstUnselectedShape = 0;
for(int count = sorterdShapes.count()-1; count >= 0; count--) {
KoShape *shape = sorterdShapes.at(count);
if ( omitHiddenShapes && ! shape->isVisible() )
......@@ -166,22 +166,22 @@ KoShape * KoShapeManager::shapeAt( const QPointF &position, SelectionType select
switch ( selection )
{
case shapeOnTop:
case KoFlake::ShapeOnTop:
return shape;
case selected:
case KoFlake::Selected:
if ( m_selection->isSelected( shape ) )
return shape;
break;
case unselected:
case KoFlake::Unselected:
if ( ! m_selection->isSelected( shape ) )
return shape;
break;
case nextUnselected:
case KoFlake::NextUnselected:
// we want an unselected shape
if ( m_selection->isSelected( shape ) )
continue;
// memorize the first unselected shape
if( ! firstUnselectedShape )
if( ! firstUnselectedShape )
firstUnselectedShape = shape;
// check if the shape above is selected
if( count < sorterdShapes.count() && m_selection->isSelected( sorterdShapes.at(count+1) ) )
......@@ -191,7 +191,7 @@ KoShape * KoShapeManager::shapeAt( const QPointF &position, SelectionType select
}
// if we want the next unselected below a selected but there was none selected,
// return the first found unselected shape
if( selection == nextUnselected && firstUnselectedShape )
if( selection == KoFlake::NextUnselected && firstUnselectedShape )
return firstUnselectedShape;
if ( m_selection->hitTest( position ) )
......
......@@ -25,6 +25,7 @@
#include <QObject>
#include <QSet>
#include "KoFlake.h"
#include <koffice_export.h>
#include <KoRTree.h>
......@@ -93,16 +94,6 @@ public:
*/
virtual void paint( QPainter &painter, const KoViewConverter &converter, bool forPrint );
/**
* Used to change the behavior of shapeAt()
*/
enum SelectionType {
selected, ///< return the first selected with the highest z-ordering (i.e. on top).
unselected, ///< return the first unselected on top.
nextUnselected, ///< return the first unselected directly under a selected shape, or the top most one if nothing is selected.
shapeOnTop ///< return the shape highest z-ordering, regardless of selection.
};
/**
* Returns the shape located at a specific point in the document.
* If more than one shape is located at the specific point, the given selection type
......@@ -111,7 +102,7 @@ public:
* @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, SelectionType selection = shapeOnTop, bool omitHiddenShapes = false );
KoShape * shapeAt( const QPointF &position, KoFlake::ShapeSelection selection = KoFlake::ShapeOnTop, bool omitHiddenShapes = false );
/**
* Returns the shapes which intersects the specific rect in the document.
......
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