Commit 3fd47d51 authored by Thomas Zander's avatar Thomas Zander
Browse files

Refactor:

    KoShapeManager::setObjects() => KoShapeManager::setShapes()
    KoShapeManager::objects() => KoShapeManager::shapes()
    KoShapeManager::getObjectAt() => KoShapeManager::getShapeAt()

svn path=/trunk/koffice/; revision=552145
parent 9d61d357
......@@ -75,7 +75,7 @@ KoInteractionStrategy* KoInteractionStrategy::createStrategy(KoPointerEvent *eve
return new KoShapeMoveStrategy(parent, canvas, event->point);
}
KoShape * object( shapeManager->getObjectAt( event->point ) );
KoShape * object( shapeManager->getShapeAt( event->point ) );
if( !object && handle == KoFlake::NoHandle) {
parent->repaintDecorations();
select->deselectAll();
......
......@@ -31,17 +31,17 @@
#include <QDebug>
#include <QPainter>
KoShapeManager::KoShapeManager( KoCanvasBase *canvas, const QList<KoShape *> &objects )
KoShapeManager::KoShapeManager( KoCanvasBase *canvas, const QList<KoShape *> &shapes )
: m_selection( new KoSelection() )
{
connect( m_selection, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged()) );
m_repaintManager = new KoRepaintManager(canvas, m_selection);
setObjects(objects);
setShapes(shapes);
m_selection->setRepaintManager(m_repaintManager);
}
KoShapeManager::KoShapeManager(KoCanvasBase *canvas)
: m_objects()
: m_shapes()
, m_selection( new KoSelection() )
{
connect( m_selection, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged()) );
......@@ -57,40 +57,40 @@ KoShapeManager::~KoShapeManager()
}
void KoShapeManager::setObjects( const QList<KoShape *> &objects )
void KoShapeManager::setShapes( const QList<KoShape *> &shapes )
{
m_objects = objects;
foreach(KoShape *shape, m_objects)
m_shapes = shapes;
foreach(KoShape *shape, m_shapes)
shape->setRepaintManager(m_repaintManager);
}
void KoShapeManager::add(KoShape *shape) {
shape->setRepaintManager(m_repaintManager);
m_objects.append(shape);
m_shapes.append(shape);
}
void KoShapeManager::remove(KoShape *shape) {
m_objects.removeAll(shape);
m_shapes.removeAll(shape);
}
void KoShapeManager::paint( QPainter &painter, KoViewConverter &converter, bool forPrint)
{
QPen pen(Qt::NoPen); // painters by default have a black stroke, lets turn that off.
painter.setPen(pen);
QList<KoShape*> sorterdObjects(m_objects);
qSort(sorterdObjects.begin(), sorterdObjects.end(), KoShape::compareShapeZIndex);
QList<KoShape*> sorterdShapes(m_shapes);
qSort(sorterdShapes.begin(), sorterdShapes.end(), KoShape::compareShapeZIndex);
const QRegion clipRegion = painter.clipRegion();
foreach ( KoShape * shape, sorterdObjects ) {
foreach ( KoShape * shape, sorterdShapes ) {
if(! shape->isVisible())
continue;
if(shape->parent() != 0 && shape->parent()->childClipped(shape))
continue;
if(painter.hasClipping()) {
QRectF objectBox = shape->boundingRect();
objectBox = converter.normalToView(objectBox);
QRegion objectRegion = QRegion(objectBox.toRect());
QRectF shapeBox = shape->boundingRect();
shapeBox = converter.normalToView(shapeBox);
QRegion shapeRegion = QRegion(shapeBox.toRect());
if(clipRegion.intersect(objectRegion).isEmpty())
if(clipRegion.intersect(shapeRegion).isEmpty())
continue;
}
painter.save();
......@@ -117,15 +117,15 @@ void KoShapeManager::paint( QPainter &painter, KoViewConverter &converter, bool
m_selection->paint( painter, converter );
}
KoShape * KoShapeManager::getObjectAt( const QPointF &position )
KoShape * KoShapeManager::getShapeAt( const QPointF &position )
{
QList<KoShape*> sorterdObjects(m_objects);
qSort(sorterdObjects.begin(), sorterdObjects.end(), KoShape::compareShapeZIndex);
for(int count = sorterdObjects.count()-1; count >= 0; count--) {
if ( sorterdObjects.at(count)->hitTest( position ) )
QList<KoShape*> sorterdShapes(m_shapes);
qSort(sorterdShapes.begin(), sorterdShapes.end(), KoShape::compareShapeZIndex);
for(int count = sorterdShapes.count()-1; count >= 0; count--) {
if ( sorterdShapes.at(count)->hitTest( position ) )
{
//qDebug() << "Hittest succeeded";
return sorterdObjects.at(count);
return sorterdShapes.at(count);
}
}
if ( m_selection->hitTest( position ) )
......
......@@ -18,8 +18,8 @@
* Boston, MA 02110-1301, USA.
*/
#ifndef KOOBJECTMANAGER_H
#define KOOBJECTMANAGER_H
#ifndef KOSHAPEMANAGER_H
#define KOSHAPEMANAGER_H
#include <QList>
#include <QObject>
......@@ -36,8 +36,8 @@ class QPainter;
class QPointF;
/**
* The object manager hold a list of all object which are in scope.
* There is one object manager per view.
* The shape manager hold a list of all shape which are in scope.
* There is one shape manager per view.
*
* The selection in the different views can be different.
*/
......@@ -51,21 +51,21 @@ public:
*/
KoShapeManager(KoCanvasBase *canvas);
/**
* Constructor that takes a list of objects, convenience version.
* @param objects the objects to start out with, see also setObjects()
* Constructor that takes a list of shapes, convenience version.
* @param shapes the shapes to start out with, see also setShapes()
* @param canvas the canvas this shape manager is working on.
*/
KoShapeManager(KoCanvasBase *canvas, const QList<KoShape *> &objects);
KoShapeManager(KoCanvasBase *canvas, const QList<KoShape *> &shapes);
virtual ~KoShapeManager();
/**
* Remove all previously owned objects and make the argument list the new objects
* Remove all previously owned shapes and make the argument list the new shapes
* to be managed by this manager.
* @param objects the new objects to manage.
* @param shapes the new shapes to manage.
*/
void setObjects( const QList<KoShape *> &objects );
/// returns the list of maintained objects
const QList<KoShape *> & objects() const { return m_objects; }
void setShapes( const QList<KoShape *> &shapes );
/// returns the list of maintained shapes
const QList<KoShape *> & shapes() const { return m_shapes; }
/**
* Add a KoShape to be displayed and managed by this manager.
......@@ -78,11 +78,11 @@ public:
*/
void remove(KoShape *shape);
/// return the selection object for this shapeManager
/// return the selection shapes for this shapeManager
KoSelection * selection() const { return m_selection; }
/**
* Paint all objects and their selection handles etc.
* Paint all shapes and their selection handles etc.
* @param painter the painter to paint to.
* @param forPrint if true, make sure only actual content is drawn and no decorations.
* @param converter to convert between internal and view coordinates.
......@@ -90,20 +90,20 @@ public:
virtual void paint( QPainter &painter, KoViewConverter &converter, bool forPrint );
/**
* Returns the object located at a specific point in the document.
* Returns the shape located at a specific point in the document.
* @param position the position in the normal coordinate system.
*/
KoShape * getObjectAt( const QPointF &position );
KoShape * getShapeAt( const QPointF &position );
signals:
/// emitted when the selection is changed
void selectionChanged();
private:
QList<KoShape *> m_objects;
QList<KoShape *> m_shapes;
KoSelection * m_selection;
KoRepaintManager *m_repaintManager;
};
#endif /* KOOBJECTMANAGER_H */
#endif
......@@ -88,8 +88,8 @@ void KoShapeRubberSelectStrategy::handleMouseMove(const QPointF &point, Qt::Keyb
void KoShapeRubberSelectStrategy::finishInteraction()
{
KoSelection * selection = m_canvas->shapeManager()->selection();
const QList<KoShape *> &objects = m_canvas->shapeManager()->objects();
foreach ( KoShape * object, objects )
const QList<KoShape *> &shapes = m_canvas->shapeManager()->shapes();
foreach ( KoShape * object, shapes )
{
//qDebug() << "o bb:" << object->boundingRect() << ", m_selectRect:" << m_selectRect;
if ( object->boundingRect().intersects( m_selectRect ) )
......
......@@ -112,7 +112,7 @@ class MoveTool : public KoInteractionTool {
public:
MoveTool(KoCanvasBase *canvas) : KoInteractionTool(canvas) {};
void mousePressEvent( KoPointerEvent *event ) {
KoShape *clickedShape = m_canvas->shapeManager()->getObjectAt(event->point);
KoShape *clickedShape = m_canvas->shapeManager()->getShapeAt(event->point);
repaintDecorations();
m_canvas->shapeManager()->selection()->deselectAll();
if(clickedShape) {
......@@ -174,7 +174,7 @@ void KoShapeSelector::add(KoShape *shape) {
do {
int rowHeight=0;
ok=true;
foreach(const KoShape *shape, m_shapeManager->objects()) {
foreach(const KoShape *shape, m_shapeManager->shapes()) {
rowHeight = qMax(rowHeight, qRound(shape->size().height()));
x = qMax(x, qRound(shape->position().x() + shape->size().width()) + 5); // 5=gap
if(x + w > width()) {
......@@ -227,7 +227,7 @@ bool KoShapeSelector::event(QEvent *e) {
QHelpEvent *helpEvent = static_cast<QHelpEvent *>(e);
const QPointF pos(helpEvent->x(), helpEvent->y());
KoShape *shape = m_shapeManager->getObjectAt(pos);
KoShape *shape = m_shapeManager->getShapeAt(pos);
if(shape) {
IconShape *is = static_cast<IconShape*> (shape);
QToolTip::showText(helpEvent->globalPos(), is->toolTip());
......@@ -268,6 +268,8 @@ KoShapeSelector::Canvas::Canvas(KoShapeSelector *parent)
}
void KoShapeSelector::Canvas::gridSize (double *horizontal, double *vertical) const {
Q_UNUSED(horizontal);
Q_UNUSED(vertical);
}
void KoShapeSelector::Canvas::updateCanvas (const QRectF &rc) {
......
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