Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 399273c7 authored by Boudewijn Rempt's avatar Boudewijn Rempt

Remove unused KoAnnotationLayoutManager class

It was referenced only in KoTextDocumentLayout, but not actually
instantiated or used.
parent 3b7b0ba8
......@@ -119,7 +119,6 @@ set(kritaflake_SRCS
KoTosContainerModel.cpp
KoClipPath.cpp
KoCurveFit.cpp
KoAnnotationLayoutManager.cpp
commands/KoShapeGroupCommand.cpp
commands/KoShapeAlignCommand.cpp
commands/KoShapeBackgroundCommand.cpp
......
/* This file is part of the KDE project
* Copyright (C) 2013 Mojtaba Shahi Senobari <mojtaba.shahi3000@gmail.com>
*
* 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.
*/
#include "KoAnnotationLayoutManager.h"
#include <KoViewConverter.h>
#include <KoShapeManager.h>
#include <KoCanvasBase.h>
#include <KoShape.h>
#include <QWidget>
#include <QList>
#include <QHash>
#include <QMap>
#include <QtAlgorithms>
#include <QPainter>
#include <QPen>
#include <QLine>
#include <QLineF>
#include <FlakeDebug.h>
int compare(const QPair < QPointF, KoShape * > &a, const QPair < QPointF, KoShape * > &b)
{
if (a.first.y() == b.first.y()) {
return a.first.x() < b.first.x();
}
return a.first.y() < b.first.y();
}
class Q_DECL_HIDDEN KoAnnotationLayoutManager::Private
{
public:
Private()
: shapeManager(0),
canvas(0)
{}
qreal x; // The x point of annotation shapes position.
QList< QPair < QPointF, KoShape * > > annotationShapePositions;
KoShapeManager *shapeManager;
KoCanvasBase *canvas;
};
KoAnnotationLayoutManager::KoAnnotationLayoutManager(QObject *parent)
:d(new Private())
{
Q_UNUSED(parent);
}
KoAnnotationLayoutManager::~KoAnnotationLayoutManager()
{
}
void KoAnnotationLayoutManager::setShapeManager(KoShapeManager *shapeManager)
{
if (d->shapeManager) {
disconnect(d->shapeManager, SIGNAL(shapeChanged(KoShape*)), this, SLOT(updateLayout(KoShape*)));
}
d->shapeManager = shapeManager;
connect(d->shapeManager, SIGNAL(shapeChanged(KoShape*)), this, SLOT(updateLayout(KoShape*)));
}
void KoAnnotationLayoutManager::setCanvasBase(KoCanvasBase *canvas)
{
d->canvas = canvas;
}
void KoAnnotationLayoutManager::setViewContentWidth(qreal width)
{
d->x = width;
}
void KoAnnotationLayoutManager::paintConnections(QPainter &painter)
{
painter.save();
QPen pen(QColor(230, 216, 87)); // Color of lines.
pen.setStyle(Qt::DashLine);
pen.setWidth(2);
pen.setJoinStyle(Qt::RoundJoin);
pen.setCapStyle(Qt::RoundCap);
painter.setPen(pen);
QList< QPair < QPointF, KoShape * > >::const_iterator it = d->annotationShapePositions.constBegin();
while (it != d->annotationShapePositions.constEnd() && !d->annotationShapePositions.isEmpty()) {
KoShape *shape = it->second;
// To make it more beautiful start line from shape a little downer of top-left of annotation shape (shape->position().y() + 20.0).
QPointF shapePosition(d->canvas->viewConverter()->documentToView(QPointF(shape->position().x(), (shape->position().y() + 20.0))));
QPointF refTextPosition(d->canvas->viewConverter()->documentToView(QPointF(it->first.x(), (it->first.y()))));
QPointF connectionPoint(d->canvas->viewConverter()->documentToView(QPointF((shape->position().x() - connectionPointLines), (it->first.y()))));
QPointF pointLine(d->canvas->viewConverter()->documentToView(QPointF(it->first.x(), (it->first.y() + 5))));
//Draw first line, from shape to connection Point.
painter.drawLine(shapePosition, connectionPoint);
// Draw second line, from connection point to reftext position.
painter.drawLine(connectionPoint, refTextPosition);
// Draw pointer.
painter.drawLine(refTextPosition, pointLine);
it++;
}
painter.restore();
}
bool KoAnnotationLayoutManager::isAnnotationShape(KoShape *shape)
{
QList< QPair < QPointF, KoShape * > >::iterator it = d->annotationShapePositions.begin();
while (it != d->annotationShapePositions.end()) {
if (shape == it->second) {
return true;
}
++it;
}
return false;
}
void KoAnnotationLayoutManager::registerAnnotationRefPosition(KoShape *annotationShape, const QPointF &pos)
{
QList< QPair < QPointF, KoShape * > >::iterator it = d->annotationShapePositions.begin();
bool yPositionChanged = false;
while (it != d->annotationShapePositions.end()) {
KoShape *shape = it->second;
if (shape == annotationShape) {
if (it->first.y() != pos.y()) {
yPositionChanged = true;
}
d->annotationShapePositions.erase(it);
break;
}
++it;
}
if (d->annotationShapePositions.isEmpty()) {
emit hasAnnotationsChanged(true);
}
d->annotationShapePositions.append(QPair< QPointF, KoShape * >(pos, annotationShape));
layoutAnnotationShapes();
if (d->canvas && yPositionChanged) {
d->canvas->canvasWidget()->update();
}
}
void KoAnnotationLayoutManager::removeAnnotationShape(KoShape *annotationShape)
{
QList< QPair < QPointF, KoShape * > >::iterator it = d->annotationShapePositions.begin();
while (it != d->annotationShapePositions.end()) {
if (it->second == annotationShape) {
d->annotationShapePositions.erase(it);
break;
}
++it;
}
layoutAnnotationShapes();
if (d->annotationShapePositions.isEmpty()) {
emit hasAnnotationsChanged(false);
}
//Should update canvas.
d->canvas->canvasWidget()->update();
}
void KoAnnotationLayoutManager::updateLayout(KoShape *shape)
{
QList< QPair < QPointF, KoShape * > >::const_iterator it = d->annotationShapePositions.constBegin();
while (it != d->annotationShapePositions.constEnd() && !d->annotationShapePositions.isEmpty()) {
if (it->second == shape) {
layoutAnnotationShapes();
break;
}
++it;
}
}
void KoAnnotationLayoutManager::layoutAnnotationShapes()
{
qreal currentY = 0.0;
qStableSort(d->annotationShapePositions.begin(), d->annotationShapePositions.end(), compare);
QList< QPair < QPointF, KoShape * > >::const_iterator it = d->annotationShapePositions.constBegin();
while (it != d->annotationShapePositions.constEnd()) {
KoShape *shape = it->second;
qreal refPosition = it->first.y();
if (refPosition > currentY) {
currentY = refPosition;
}
shape->update();
shape->setSize(QSize(shapeWidth, shape->size().height()));
shape->setPosition(QPointF(d->x, currentY));
// This makes the shape visible. It was set to invisible when it was created.
shape->setVisible(true);
shape->update();
currentY += shape->size().height() + shapeSpace;
++it;
}
}
// only static const integral data members can be initialized within a class
const qreal KoAnnotationLayoutManager::shapeSpace = 10.0; // Distance between annotation shapes.
const qreal KoAnnotationLayoutManager::shapeWidth = 200.0; // Annotation shapes width.
const qreal KoAnnotationLayoutManager::connectionPointLines = 50.0; //Connection point of lines from shape to this point and from this point to refText psoition.
/* This file is part of the KDE project
* Copyright (C) 2013 Mojtaba Shahi Senobari <mojtaba.shahi3000@gmail.com>
*
* 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 KOANNOTATIONLAYOUTMANAGER_H
#define KOANNOTATIONLAYOUTMANAGER_H
#include "kritaflake_export.h"
#include <QObject>
class KoShapeManager;
class KoCanvasBase;
class QPainter;
class QPointF;
class KoShape;
class KRITAFLAKE_EXPORT KoAnnotationLayoutManager: public QObject
{
Q_OBJECT
public:
static const qreal shapeSpace; // Distance between annotation shapes.
static const qreal shapeWidth; // Annotation shapes width.
//Connection point of lines from shape to this point and from this point to refText psoition.
static const qreal connectionPointLines;
explicit KoAnnotationLayoutManager(QObject *parent = 0);
virtual ~KoAnnotationLayoutManager();
void setShapeManager(KoShapeManager *shapeManager);
void setCanvasBase(KoCanvasBase *canvas);
void setViewContentWidth(qreal width);
void paintConnections(QPainter &painter);
// Return true if shape is in annotaion shapes list.
bool isAnnotationShape(KoShape *shape);
public Q_SLOTS:
/// register the position of an annotation shape.
void registerAnnotationRefPosition(KoShape *annotationShape, const QPointF& refPosition);
/// Remove annotation shape.
void removeAnnotationShape(KoShape *annotationShape);
/// Update layout annotation shapes. Called when shape size changed.
void updateLayout(KoShape *shape);
Q_SIGNALS:
void hasAnnotationsChanged(bool hasAnnotations);
private:
/// layout annotation shapes
void layoutAnnotationShapes();
private:
class Private;
Private * const d;
};
#endif // KOANNOTATIONLAYOUTMANAGER_H
......@@ -42,7 +42,6 @@
#include <KoPostscriptPaintDevice.h>
#include <KoShape.h>
#include <KoShapeContainer.h>
#include <KoAnnotationLayoutManager.h>
#include <KoAnnotation.h>
#include <KoTextDocument.h>
#include <KoUnit.h>
......@@ -81,7 +80,6 @@ public:
, allowPositionInlineObject(true)
, continuationObstruction(0)
, referencedLayout(0)
, annotationLayoutManager(0)
, defaultTabSizing(0)
, y(0)
, isLayouting(false)
......@@ -124,8 +122,6 @@ public:
KoTextDocumentLayout *referencedLayout;
KoAnnotationLayoutManager *annotationLayoutManager;
QHash<KoInlineObject *, KoTextLayoutRootArea *> rootAreaForInlineObject;
qreal defaultTabSizing;
......
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