[fondue-commits] [SCM] Fondue Font Editor branch, master, updated. c190fbb61058a8c2f7e7a2c650bf0528d75324be
Eugeniy Meshcheryakov
eugen at debian.org
Mon Feb 11 10:41:41 UTC 2008
The following commit has been merged in the master branch:
commit fdfff6cf5605917b23dab4567b28e910198ab60c
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date: Sun Feb 10 23:30:27 2008 +0100
make GlyphItemBase a QObject and handle glyph outline change in it
diff --git a/gui/glyphgraphics.cxx b/gui/glyphgraphics.cxx
index 10e3f66..07c321e 100644
--- a/gui/glyphgraphics.cxx
+++ b/gui/glyphgraphics.cxx
@@ -33,7 +33,7 @@ GlyphGraphics::GlyphGraphics(GlyphCell *parent, Glyph *glyph) :
Q_ASSERT(glyph);
Q_ASSERT(glyph->document());
- item = new GlyphItemOutline(this);
+ item = new GlyphItemOutline(m_glyph);
for (int i = 0; i < m_glyph->content().size(); i++) {
GlyphContentBase *v = m_glyph->content().at(i);
@@ -64,7 +64,6 @@ GlyphGraphics::GlyphGraphics(GlyphCell *parent, Glyph *glyph) :
}
}
p->scene()->addItem(item);
- connect(m_glyph, SIGNAL(outlineChanged()), this, SLOT(glyphOutlineChanged()));
}
GlyphGraphics::GlyphGraphics(GlyphGraphics *parent, Glyph *glyph, const QPointF &pos) :
@@ -74,7 +73,7 @@ GlyphGraphics::GlyphGraphics(GlyphGraphics *parent, Glyph *glyph, const QPointF
Q_ASSERT(m_glyph);
Q_ASSERT(m_glyph->parent());
- item = new GlyphItemOutline(this, parent->item);
+ item = new GlyphItemOutline(m_glyph, parent->item);
for (int i = 0; i < m_glyph->content().size(); i++) {
const GlyphContentBase *v = m_glyph->content().at(i);
if (v->type() == GlyphContentBase::Reference) {
@@ -93,7 +92,6 @@ GlyphGraphics::GlyphGraphics(GlyphGraphics *parent, Glyph *glyph, const QPointF
}
item->setPos(pos.x(), -pos.y());
- connect(m_glyph, SIGNAL(outlineChanged()), this, SLOT(glyphOutlineChanged()));
}
QPainterPath GlyphGraphics::contourToPath(const GlyphContour *contour)
@@ -139,11 +137,6 @@ QPainterPath GlyphGraphics::contourToPath(const GlyphContour *contour)
return path;
}
-void GlyphGraphics::glyphOutlineChanged()
-{
- item->update();
-}
-
void GlyphGraphics::contourPointsAdded(int start, int end)
{
GlyphContour *contour = qobject_cast<GlyphContour *>(sender());
diff --git a/gui/glyphgraphics.h b/gui/glyphgraphics.h
index 4f5d5ec..42d5df9 100644
--- a/gui/glyphgraphics.h
+++ b/gui/glyphgraphics.h
@@ -36,7 +36,6 @@ public:
// FIXME destructor may be needed
//~GlyphGraphics();
public slots:
- void glyphOutlineChanged();
void contourPointsAdded(int start, int end);
void contourPointsAboutToBeRemoved(int start, int end);
private:
diff --git a/gui/glyphitem.cxx b/gui/glyphitem.cxx
index 4094c1e..f42baad 100644
--- a/gui/glyphitem.cxx
+++ b/gui/glyphitem.cxx
@@ -19,11 +19,12 @@
#include "glyph.h"
#include <QPainter>
-GlyphItemBase::GlyphItemBase(GlyphGraphics *gfx, QGraphicsItem *parent) :
- QGraphicsItem(parent), m_gfx(gfx)
+GlyphItemBase::GlyphItemBase(Glyph *glyph, QGraphicsItem *parent) :
+ QObject(), QGraphicsItem(parent), m_glyph(glyph)
{
- Q_ASSERT(m_gfx);
+ Q_ASSERT(m_glyph);
calculateBoundingRect();
+ connect(m_glyph, SIGNAL(outlineChanged()), this, SLOT(update()));
}
void GlyphItemBase::update()
@@ -37,7 +38,7 @@ void GlyphItemBase::calculateBoundingRect()
QPainterPath path;
bool hadContours = false;
- foreach (const GlyphContentBase *i, m_gfx->m_glyph->content()) {
+ foreach (const GlyphContentBase *i, m_glyph->content()) {
if (i->type() == GlyphContentBase::Contour) {
const GlyphContour *c = qobject_cast<const GlyphContour *>(i);
Q_ASSERT(c);
@@ -64,7 +65,7 @@ void GlyphItemBase::paintOutline(QPainter *painter, bool paintOpen)
{
QPainterPath path;
- foreach (const GlyphContentBase *i, m_gfx->m_glyph->content()) {
+ foreach (const GlyphContentBase *i, m_glyph->content()) {
if (i->type() == GlyphContentBase::Contour) {
const GlyphContour *c = qobject_cast<const GlyphContour *>(i);
Q_ASSERT(c);
@@ -80,7 +81,7 @@ void GlyphItemBase::paintOutline(QPainter *painter, bool paintOpen)
if (paintOpen) {
// draw open contours
- foreach (const GlyphContentBase *i, m_gfx->m_glyph->content()) {
+ foreach (const GlyphContentBase *i, m_glyph->content()) {
if (i->type() == GlyphContentBase::Contour) {
const GlyphContour *c = qobject_cast<const GlyphContour *>(i);
Q_ASSERT(c);
@@ -95,7 +96,7 @@ void GlyphItemBase::paintFill(QPainter *painter)
{
QPainterPath path;
- foreach (const GlyphContentBase *i, m_gfx->m_glyph->content()) {
+ foreach (const GlyphContentBase *i, m_glyph->content()) {
if (i->type() == GlyphContentBase::Contour) {
const GlyphContour *c = qobject_cast<const GlyphContour *>(i);
Q_ASSERT(c);
diff --git a/gui/glyphitem.h b/gui/glyphitem.h
index 3ecddbf..0791af7 100644
--- a/gui/glyphitem.h
+++ b/gui/glyphitem.h
@@ -20,25 +20,28 @@
#include <QList>
#include "glyphcontentbase.h"
-class GlyphGraphics;
+class Glyph;
-class GlyphItemBase : public QGraphicsItem {
+class GlyphItemBase : public QObject, public QGraphicsItem {
+ Q_OBJECT
public:
- GlyphItemBase(GlyphGraphics *gfx, QGraphicsItem *parent = 0);
- void update();
+ GlyphItemBase(Glyph *glyph, QGraphicsItem *parent = 0);
QRectF boundingRect() const;
+public slots:
+ void update();
protected:
void paintOutline(QPainter *painter, bool paintOpen = true);
void paintFill(QPainter *painter);
void calculateBoundingRect();
- GlyphGraphics *m_gfx;
+ Glyph *m_glyph;
QRectF m_boundingRect;
};
class GlyphItemOutline : public GlyphItemBase {
+ Q_OBJECT
public:
- GlyphItemOutline(GlyphGraphics *gfx, QGraphicsItem *parent = 0) : GlyphItemBase(gfx, parent) {}
+ GlyphItemOutline(Glyph *glyph, QGraphicsItem *parent = 0) : GlyphItemBase(glyph, parent) {}
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
};
diff --git a/gui/gui.rules b/gui/gui.rules
index f0b54f2..525ed60 100644
--- a/gui/gui.rules
+++ b/gui/gui.rules
@@ -39,7 +39,8 @@ nodist_libfonduegui_a_SOURCES = \
gui/maxpeditor.moc.cxx \
gui/glyphgraphics.moc.cxx \
gui/documentinfoeditor.moc.cxx \
- gui/controlpoint.moc.cxx
+ gui/controlpoint.moc.cxx \
+ gui/glyphitem.moc.cxx
gui/instnames.tbl.cxx: data/instructions.xml
gui/instnames.tbl.cxx: DATAFILE=$(srcdir)/data/instructions.xml
--
Fondue Font Editor
More information about the fondue-commits
mailing list