Commit d4569079 authored by Thomas Zander's avatar Thomas Zander

Split KoShapeContainerModel out into its own file.

Noted that the KoShapeLayer had a copy paste of a SimpleShapeContainerModel
from KoShapeGroup, so splitted that out into its own file and remove the
duplicate.

svn path=/trunk/koffice/; revision=650915
parent 34c0698d
......@@ -19,6 +19,7 @@
#include <kdebug.h>
#include "KoShapeContainer.h"
#include "KoShapeContainerModel.h"
#include <QPointF>
#include <QPainter>
......
......@@ -29,71 +29,7 @@
class QPainter;
class QPointF;
/**
* The interface for the container model.
* This class has no implementation, but only pure virtual methods. Extending this
* class and implementing all methods allows you to implement a custom data-backend
* for the KoShapeContainer.
* @see KoShapeContainer
*/
class FLAKE_EXPORT KoShapeContainerModel {
public:
/// default constructor
KoShapeContainerModel() {}
/// destructor
virtual ~KoShapeContainerModel() {}
/**
* Add a child to this models store.
* @param child the child to be managed in the container.
*/
virtual void add(KoShape *child) = 0;
/**
* Remove a child to be completely separated from the model.
* @param child the child to be removed.
*/
virtual void remove(KoShape *child) = 0;
/**
* Set the argument child to have its 'clipping' property set.
* @param child the child for which the property will be changed.
* @param clipping the property; see KoShapeContainerModel for an explenation of what
* this bool is for.
*/
virtual void setClipping(const KoShape *child, bool clipping) = 0;
/**
* Returns if the argument child has its 'clipping' property set.
* See KoShapeContainerModel for an explenation of what this bool is for.
* @return if the argument child has its 'clipping' property set.
* @param child the child for which the property will be returned.
*/
virtual bool childClipped(const KoShape *child) const = 0;
/**
* Return the current number of children registered.
* @return the current number of children registered.
*/
virtual int count() const = 0;
/**
* Create and return an iterator over all child objects.
* @return an interator over all child objects.
*/
virtual QList<KoShape*> iterator() const = 0;
/**
* This method is called as a notification that one of the properties of the
* container changed. This can be one of size, position, rotation and skew.
* Note that clipped children will automatically get all these changes, the model
* does not have to do anything for that.
* @param container the actual container that changed.
*/
virtual void containerChanged(KoShapeContainer *container) = 0;
};
class KoShapeContainerModel;
/**
* This is the base class that all Flake group-objects are based on.
......
/* This file is part of the KDE project
* Copyright (C) 2006-2007 Thomas Zander <zander@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef KOSHAPECONTAINERMODEL_H
#define KOSHAPECONTAINERMODEL_H
#include <QList>
#include <flake_export.h>
class KoShape;
/**
* The interface for the container model.
* This class has no implementation, but only pure virtual methods. Extending this
* class and implementing all methods allows you to implement a custom data-backend
* for the KoShapeContainer.
* @see KoShapeContainer
*/
class FLAKE_EXPORT KoShapeContainerModel {
public:
/// default constructor
KoShapeContainerModel() {}
/// destructor
virtual ~KoShapeContainerModel() {}
/**
* Add a child to this models store.
* @param child the child to be managed in the container.
*/
virtual void add(KoShape *child) = 0;
/**
* Remove a child to be completely separated from the model.
* @param child the child to be removed.
*/
virtual void remove(KoShape *child) = 0;
/**
* Set the argument child to have its 'clipping' property set.
* @param child the child for which the property will be changed.
* @param clipping the property; see KoShapeContainerModel for an explenation of what
* this bool is for.
*/
virtual void setClipping(const KoShape *child, bool clipping) = 0;
/**
* Returns if the argument child has its 'clipping' property set.
* See KoShapeContainerModel for an explenation of what this bool is for.
* @return if the argument child has its 'clipping' property set.
* @param child the child for which the property will be returned.
*/
virtual bool childClipped(const KoShape *child) const = 0;
/**
* Return the current number of children registered.
* @return the current number of children registered.
*/
virtual int count() const = 0;
/**
* Create and return an iterator over all child objects.
* @return an interator over all child objects.
*/
virtual QList<KoShape*> iterator() const = 0;
/**
* This method is called as a notification that one of the properties of the
* container changed. This can be one of size, position, rotation and skew.
* Note that clipped children will automatically get all these changes, the model
* does not have to do anything for that.
* @param container the actual container that changed.
*/
virtual void containerChanged(KoShapeContainer *container) = 0;
};
#endif
......@@ -18,9 +18,11 @@
*/
#include "KoShapeGroup.h"
#include "KoShapeContainerModel.h"
#include "SimpleShapeContainerModel.h"
KoShapeGroup::KoShapeGroup()
: KoShapeContainer(new GroupMembers())
: KoShapeContainer(new SimpleShapeContainerModel())
{
}
......@@ -34,39 +36,6 @@ bool KoShapeGroup::hitTest( const QPointF &position ) const {
return false;
}
// ############# GroupMembers #############
void KoShapeGroup::GroupMembers::add(KoShape *child) {
if(m_groupMembers.contains(child))
return;
m_groupMembers.append(child);
}
void KoShapeGroup::GroupMembers::remove(KoShape *child) {
m_groupMembers.removeAll(child);
}
int KoShapeGroup::GroupMembers::count() const {
return m_groupMembers.count();
}
QList<KoShape*> KoShapeGroup::GroupMembers::iterator() const {
return QList<KoShape*>(m_groupMembers);
}
void KoShapeGroup::GroupMembers::containerChanged(KoShapeContainer *container) {
Q_UNUSED(container);
}
void KoShapeGroup::GroupMembers::setClipping(const KoShape *child, bool clipping) {
Q_UNUSED(child);
Q_UNUSED(clipping);
}
bool KoShapeGroup::GroupMembers::childClipped(const KoShape *child) const {
Q_UNUSED(child);
return false;
}
void KoShapeGroup::childCountChanged() {
QRectF br = boundingRect();
setPosition( br.topLeft() );
......
......@@ -49,21 +49,6 @@ public:
bool hitTest( const QPointF &position ) const;
private:
class GroupMembers: public KoShapeContainerModel {
public:
GroupMembers() {};
~GroupMembers() {}
void add(KoShape *child);
void setClipping(const KoShape *child, bool clipping);
bool childClipped(const KoShape *child) const;
void remove(KoShape *child);
int count() const;
QList<KoShape*> iterator() const;
void containerChanged(KoShapeContainer *container);
private: // members
QList <KoShape *> m_groupMembers;
};
void childCountChanged();
};
......
......@@ -18,9 +18,10 @@
*/
#include "KoShapeLayer.h"
#include "SimpleShapeContainerModel.h"
KoShapeLayer::KoShapeLayer()
: KoShapeContainer(new LayerMembers())
: KoShapeContainer(new SimpleShapeContainerModel())
{
setSelectable(false);
}
......@@ -45,52 +46,3 @@ QRectF KoShapeLayer::boundingRect() const
return bb;
}
// ############# LayerMembers #############
KoShapeLayer::LayerMembers::LayerMembers()
{
}
KoShapeLayer::LayerMembers::~LayerMembers()
{
}
void KoShapeLayer::LayerMembers::add(KoShape *child)
{
if(m_layerMembers.contains(child))
return;
m_layerMembers.append(child);
}
void KoShapeLayer::LayerMembers::remove(KoShape *child)
{
m_layerMembers.removeAll(child);
}
int KoShapeLayer::LayerMembers::count() const
{
return m_layerMembers.count();
}
QList<KoShape*> KoShapeLayer::LayerMembers::iterator() const
{
return QList<KoShape*>(m_layerMembers);
}
void KoShapeLayer::LayerMembers::containerChanged(KoShapeContainer *container)
{
Q_UNUSED(container);
}
void KoShapeLayer::LayerMembers::setClipping(const KoShape *child, bool clipping)
{
Q_UNUSED(child);
Q_UNUSED(clipping);
}
bool KoShapeLayer::LayerMembers::childClipped(const KoShape *child) const
{
Q_UNUSED(child);
return false;
}
......@@ -40,22 +40,6 @@ public:
virtual void paintComponent(QPainter &, const KoViewConverter &) {}
bool hitTest( const QPointF &position ) const;
virtual QRectF boundingRect() const;
private:
class LayerMembers: public KoShapeContainerModel {
public:
LayerMembers();
~LayerMembers();
void add(KoShape *child);
void setClipping(const KoShape *child, bool clipping);
bool childClipped(const KoShape *child) const;
void remove(KoShape *child);
int count() const;
QList<KoShape*> iterator() const;
void containerChanged(KoShapeContainer *container);
private: // members
QList <KoShape *> m_layerMembers;
};
};
#endif // __KOSHAPELAYER_H__
......
/* This file is part of the KDE project
* Copyright (C) 2006-2007 Thomas Zander <zander@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef SIMPLESHAPECONTAINERMODEL_H
#define SIMPLESHAPECONTAINERMODEL_H
#include "KoShapeContainerModel.h"
/// \internal
class SimpleShapeContainerModel: public KoShapeContainerModel {
public:
SimpleShapeContainerModel() {}
~SimpleShapeContainerModel() {}
void add(KoShape *child) {
if(m_members.contains(child))
return;
m_members.append(child);
}
void setClipping(const KoShape *, bool ) { }
bool childClipped(const KoShape *) const { return false; }
void remove(KoShape *child) {
m_members.removeAll(child);
}
int count() const {
return m_members.count();
}
QList<KoShape*> iterator() const {
return QList<KoShape*>(m_members);
}
void containerChanged(KoShapeContainer *) { }
private: // members
QList <KoShape *> m_members;
};
#endif
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