[fondue-commits] [SCM] Fondue Font Editor branch, master, updated. 215f1949ba6c3b57dc8e9b43325fb312846b55dc

Eugeniy Meshcheryakov eugen at debian.org
Thu Jan 3 17:00:10 UTC 2008


The branch, master has been updated
       via  215f1949ba6c3b57dc8e9b43325fb312846b55dc (commit)
       via  3168e712e58e153ffee474546220b77b775fc7d4 (commit)
       via  8ba6dc2cd8800e31704c382a3394528f2296b358 (commit)
       via  65990fb877055ab28e605706d341552d3388b7ca (commit)
       via  9423ada184eb18f84683ad717dbaad0b724fedbe (commit)
       via  7117c5811f2bc8e87a017dd984b86e09a9243d52 (commit)
       via  61ba80d2e0f4f4c49eb25e3a9345f30d6a28ad34 (commit)
       via  be3d536e97f30efa1fb666008b9da404e7b606d2 (commit)
       via  51338b46c0e64a7cf7dc6d856be6c0c1da29aa68 (commit)
       via  2ce87079a32be88c7cdd9339ac024efe5d49bd97 (commit)
       via  09e26d0b66a8675c2997e24ef2e2720dd3e90dc5 (commit)
       via  f7e1e0bee38e0fca3440b98c4b725035f42ba971 (commit)
       via  a713b791727b37df8a0d1aaef0113619b9144c00 (commit)
       via  87194a825e154dd5c930e444003ca0994724ebf6 (commit)
       via  04f03d6a31c2f243b6c24ff56cd0a95d19ac5909 (commit)
       via  7a313ea210de62e0c490ec17ee002a771c10d955 (commit)
       via  91447e7df93c430c7d336657a8af53bf6b430a67 (commit)
       via  5538b408adfbf53e0df435e3573bfc5b2e2050f3 (commit)
       via  b187d6a2f38bbf97a9cd9cc33eb372b29fb120db (commit)
       via  6080d7b19b89e94f49cb6366b592cd7f5aa38861 (commit)
       via  ac7c4f15d9e10fff4a13348e7fd895ecc095b2c3 (commit)
       via  849ffa9198367d35809c9843050945cd1410987c (commit)
       via  e62dc1dd6a4910b24bbf7d5749cf3119bd5649ab (commit)
       via  eada3b6d7cf472251ffcea55a8d75e57b8a128a3 (commit)
      from  fa7010f30f1b10e5e400fca09c676f75d93fa55b (commit)


- Shortlog ------------------------------------------------------------
215f194 make contours editable: doubleclick adds point to the first contour of a glyph
3168e71 use different colors to display first point of a contour
8ba6dc2 emit signals when points are added to a contour
65990fb emit signals when properties of a glyph change
9423ada emit signal when contour becomes open/closed
7117c58 split Glyph::appendContent() in two functions (Glyph::append{Reference,Contour}())
61ba80d add NOTIFY declarations for properties
be3d536 handle changes of CVT in FontDocument class
51338b4 do not use GlyphModel in GlyphCell class
2ce8707 do not store model and model index in GlyphEditWidget
09e26d0 add FontDocument::glyphIndex()
f7e1e0b add a TODO item
a713b79 handle glyphs{AboutToBe,}Added signals from FontDocument in GlyphsModel
87194a8 emit FontDocument::glyphs{AboutToBe,}Added signals in FontDocument::addGlyph()
04f03d6 do not segfault on glyphs removal when edit widget is open
7a313ea move glyphs removal to FontDocument class
91447e7 remove some useless debug code
5538b40 use QObject::deleteLater() for destroying glyphs, it should be safer
b187d6a make ControlPoint a QObject and let it manage points movement in GlyphContour
6080d7b add GlyphPoint::pos()
ac7c4f1 simplify meta types registration
849ffa9 cleanup glyph gui classes
e62dc1d handle points movement in class GlyphContour, not in Glyph
eada3b6 add operator == for GlyphPoints

Summary of changes:
 gui/controlpoint.cxx          |   43 +++++++++++++++++++------
 gui/controlpoint.h            |   19 +++++++----
 gui/glyphcell.cxx             |   47 +++++++++++++++++++++-------
 gui/glyphcell.h               |   11 ++----
 gui/glypheditwidget.cxx       |   62 ++++++++++++++-----------------------
 gui/glypheditwidget.h         |   13 ++-----
 gui/glyphgraphics.cxx         |   37 ++++++++--------------
 gui/glyphgraphics.h           |   10 +-----
 gui/glyphsmodel.cxx           |   45 ++++++++++++++++++---------
 gui/glyphsmodel.h             |    7 +++-
 gui/gui.rules                 |    3 +-
 gui/mainwindow.cxx            |    7 +---
 gui/unicodeproxymodel.h       |    1 +
 nongui/cvtmodel.cxx           |   68 +++++++++++++++++++++++++---------------
 nongui/cvtmodel.h             |    6 +++
 nongui/fontdocument.cxx       |   60 ++++++++++++++++++++++++++---------
 nongui/fontdocument.h         |   54 ++++++++++++++++++++------------
 nongui/fontdocumentreader.cxx |    4 +-
 nongui/glyph.cxx              |   59 +++++++++++++++++++++--------------
 nongui/glyph.h                |   23 ++++++++-----
 nongui/glyphcontour.cxx       |   20 +++++++++--
 nongui/glyphcontour.h         |    8 ++++-
 nongui/glyphpoint.h           |    7 ++++
 nongui/glyphreference.h       |    4 +-
 qscript/constructors.cxx      |   25 +++++----------
 25 files changed, 383 insertions(+), 260 deletions(-)
-----------------------------------------------------------------------
Details of changes:

commit 215f1949ba6c3b57dc8e9b43325fb312846b55dc
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Thu Jan 3 17:59:52 2008 +0100

    make contours editable: doubleclick adds point to the first contour of a glyph
    graphics update is buggy, document change status is not updated

diff --git a/gui/glyphcell.cxx b/gui/glyphcell.cxx
index 571eb17..4679e18 100644
--- a/gui/glyphcell.cxx
+++ b/gui/glyphcell.cxx
@@ -94,3 +94,31 @@ void GlyphCell::drawForeground(QPainter *painter, const QRectF &rect)
 		painter->drawLine(QLineF(m_glyph->horizAdvX(), rect.bottom(), m_glyph->horizAdvX(), rect.top()));
 	}
 }
+
+void GlyphCell::mouseDoubleClickEvent(QMouseEvent *e)
+{
+	qDebug() << "Double click";
+
+	QGraphicsItem *item = itemAt(e->pos());
+	if (!item || item->type() != ControlPoint::Type) {
+		GlyphContour *contour = 0;
+		foreach (GlyphContentBase *i, m_glyph->content()) {
+			// Try to find a contour
+			if (i->type() == GlyphContentBase::Contour) {
+				contour = qobject_cast<GlyphContour *>(i);
+				Q_ASSERT(contour);
+				break;
+			}
+		}
+		if (contour) {
+			// add a point to the first contour
+			QPointF pointPos = mapToScene(e->pos());
+			pointPos.setY(-pointPos.y());
+			contour->appendPoint(pointPos);
+			qDebug() << "Appended point at pos" << pointPos;
+		}
+	}
+	else
+		qDebug() << "Item at double click pos!";
+	QGraphicsView::mouseDoubleClickEvent(e);
+}
diff --git a/gui/glyphcell.h b/gui/glyphcell.h
index 32ce107..ca02db3 100644
--- a/gui/glyphcell.h
+++ b/gui/glyphcell.h
@@ -31,6 +31,7 @@ public slots:
 	void fitGlyph();
 protected:
 	void drawForeground(QPainter *painter, const QRectF &rect);
+	void mouseDoubleClickEvent(QMouseEvent *e);
 private:
 	GlyphGraphics *gg;
 	Glyph *m_glyph;
diff --git a/gui/glyphgraphics.cxx b/gui/glyphgraphics.cxx
index f928e8e..bb16c35 100644
--- a/gui/glyphgraphics.cxx
+++ b/gui/glyphgraphics.cxx
@@ -47,6 +47,7 @@ GlyphGraphics::GlyphGraphics(GlyphCell *parent, Glyph *glyph) :
 				points.append(cp);
 				cp->setPos(pt.x(), -pt.y());
 			}
+			connect(c, SIGNAL(pointsAdded(int, int)), this, SLOT(contourPointsAdded(int, int)));
 		}
 		else {
 			// TODO make it useable
@@ -143,3 +144,18 @@ void GlyphGraphics::glyphOutlineChanged()
 {
 	item->update();
 }
+
+void GlyphGraphics::contourPointsAdded(int start, int end)
+{
+	GlyphContour *contour = qobject_cast<GlyphContour *>(sender());
+	if (!contour)
+		return;
+
+	for (int i = start; i <= end; i++) {
+		qDebug() << "Adding a point";
+		const GlyphPoint pt = contour->points().at(i);
+		ControlPoint *cp = new ControlPoint(contour, i, item);
+		points.append(cp);
+		cp->setPos(pt.x(), -pt.y()); // TODO ControlPoint should be able to do this by itself
+	}
+}
diff --git a/gui/glyphgraphics.h b/gui/glyphgraphics.h
index 89767e6..027eacb 100644
--- a/gui/glyphgraphics.h
+++ b/gui/glyphgraphics.h
@@ -37,6 +37,7 @@ public:
 	//~GlyphGraphics();
 public slots:
 	void glyphOutlineChanged();
+	void contourPointsAdded(int start, int end);
 private:
 	GlyphGraphics(GlyphGraphics *parent, Glyph *glyph, const QPointF &pos);
 	GlyphCell *p;

commit 3168e712e58e153ffee474546220b77b775fc7d4
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Thu Jan 3 16:51:54 2008 +0100

    use different colors to display first point of a contour

diff --git a/gui/controlpoint.cxx b/gui/controlpoint.cxx
index 294ace2..3316df2 100644
--- a/gui/controlpoint.cxx
+++ b/gui/controlpoint.cxx
@@ -48,10 +48,18 @@ void ControlPoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
 	Q_UNUSED(widget);
 
 	painter->setPen(Qt::NoPen);
-	if (isSelected())
-		painter->setBrush(Qt::darkYellow);
-	else
-		painter->setBrush(Qt::red);
+	if (isSelected()) {
+		if (!m_pointNumber)
+			painter->setBrush(Qt::darkGreen);
+		else
+			painter->setBrush(Qt::darkYellow);
+	}
+	else {
+		if (!m_pointNumber)
+			painter->setBrush(Qt::green); // TODO make this adjustable
+		else
+			painter->setBrush(Qt::red);
+	}
 	painter->drawEllipse(QRectF(-3, -3, 6, 6));
 }
 

commit 8ba6dc2cd8800e31704c382a3394528f2296b358
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Thu Jan 3 16:46:34 2008 +0100

    emit signals when points are added to a contour

diff --git a/nongui/glyphcontour.cxx b/nongui/glyphcontour.cxx
index 15c4341..0b7b91a 100644
--- a/nongui/glyphcontour.cxx
+++ b/nongui/glyphcontour.cxx
@@ -36,7 +36,11 @@ void GlyphContour::setOpen(bool open)
 
 void GlyphContour::appendPoint(const GlyphPoint &point)
 {
+	int pointNo = m_points.size();
+
+	emit pointsAboutToBeAdded(pointNo, pointNo);
 	m_points << point;
+	emit pointsAdded(pointNo, pointNo);
 }
 
 void GlyphContour::changePoint(int number, const GlyphPoint &newPoint)
diff --git a/nongui/glyphcontour.h b/nongui/glyphcontour.h
index 1e48b27..29c156c 100644
--- a/nongui/glyphcontour.h
+++ b/nongui/glyphcontour.h
@@ -37,6 +37,9 @@ public:
 signals:
 	void pointChanged(int number);
 	void opennessChanged(); // FIXME any better name?
+
+	void pointsAboutToBeAdded(int start, int end);
+	void pointsAdded(int start, int end);
 private:
 	bool m_open;
 	GlyphPointList m_points;

commit 65990fb877055ab28e605706d341552d3388b7ca
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Thu Jan 3 16:43:38 2008 +0100

    emit signals when properties of a glyph change

diff --git a/nongui/glyph.cxx b/nongui/glyph.cxx
index 3d19f6f..d5708d5 100644
--- a/nongui/glyph.cxx
+++ b/nongui/glyph.cxx
@@ -46,6 +46,8 @@ void Glyph::appendReference(GlyphReference *ref)
 	ref->setParent(this);
 	m_content << ref;
 	// TODO
+	emit outlineChanged();
+	setChanged();
 }
 
 void Glyph::appendContour(GlyphContour *contour)
@@ -57,6 +59,8 @@ void Glyph::appendContour(GlyphContour *contour)
 	m_content << contour;
 
 	connect(contour, SIGNAL(pointChanged(int)), this, SLOT(contourPointChanged()));
+	emit outlineChanged();
+	setChanged();
 }
 
 template <typename T>
@@ -115,7 +119,7 @@ void Glyph::setHorizAdvX(qreal adv)
 	bool changed = false;
 
 	if (setIfChanged(horiz_adv_x, adv))
-		changed = true;	
+		changed = true;
 
 	if (setIfChanged(horiz_adv_x_set, true))
 		changed = true;
@@ -163,8 +167,10 @@ void Glyph::setInstructions(const QString &instructions, bool valid)
 		changed = true;
 	if (setIfChanged(instructions_valid, valid))
 		changed = true;
-	if (changed)
+	if (changed) {
+		emit instructionsChanged();
 		setChanged();
+	}
 }
 
 /** return TrueType instructions for the glyph.
@@ -208,8 +214,10 @@ bool Glyph::instructionsAreValid() const
  */
 void Glyph::setColorString(const QString &s)
 {
-	if (setIfChanged(m_colorString, s))
+	if (setIfChanged(m_colorString, s)) {
+		emit colorStringChanged();
 		setChanged();
+	}
 }
 
 /** returns color string.
@@ -223,10 +231,12 @@ QString Glyph::colorString() const
 /** Set comment string.
  * @sa comment()
  */
-void Glyph::setComment(const QString &s) 
+void Glyph::setComment(const QString &s)
 {
-	if (setIfChanged(m_comment, s))
+	if (setIfChanged(m_comment, s)) {
+		emit commentChanged();
 		setChanged();
+	}
 }
 
 /** returns comment string
diff --git a/nongui/glyph.h b/nongui/glyph.h
index 784b677..8948821 100644
--- a/nongui/glyph.h
+++ b/nongui/glyph.h
@@ -30,10 +30,10 @@ class Glyph : public QObject {
 	Q_OBJECT
 	Q_PROPERTY(QString glyphName READ glyphName WRITE setGlyphName NOTIFY glyphNameChanged)
 	Q_PROPERTY(qreal horizAdvX READ horizAdvX WRITE setHorizAdvX RESET unsetHorizAdvX)
-	Q_PROPERTY(QString instructions READ instructions WRITE setInstructions)
+	Q_PROPERTY(QString instructions READ instructions WRITE setInstructions NOTIFY instructionsChanged)
 	Q_PROPERTY(bool instructionsAreValid READ instructionsAreValid WRITE setInstructionsValidity)
-	Q_PROPERTY(QString colorString READ colorString WRITE setColorString)
-	Q_PROPERTY(QString comment READ comment WRITE setComment)
+	Q_PROPERTY(QString colorString READ colorString WRITE setColorString NOTIFY colorStringChanged)
+	Q_PROPERTY(QString comment READ comment WRITE setComment NOTIFY commentChanged)
 	Q_PROPERTY(int unicode READ unicode WRITE setUnicode NOTIFY unicodeChanged)
 	Q_PROPERTY(bool changed READ changed WRITE setChanged)
 	Q_PROPERTY(GlyphContentList content READ content)
@@ -77,6 +77,9 @@ public:
 signals:
 	void glyphChanged();
 	void glyphNameChanged(const QString &oldName, const QString &newName);
+	void instructionsChanged();
+	void colorStringChanged();
+	void commentChanged();
 	void unicodeChanged(int oldUnicode, int newUnicode);
 
 	void outlineChanged();

commit 9423ada184eb18f84683ad717dbaad0b724fedbe
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Thu Jan 3 16:43:02 2008 +0100

    emit signal when contour becomes open/closed

diff --git a/nongui/glyphcontour.cxx b/nongui/glyphcontour.cxx
index 18bb55c..15c4341 100644
--- a/nongui/glyphcontour.cxx
+++ b/nongui/glyphcontour.cxx
@@ -28,7 +28,10 @@ bool GlyphContour::isOpen() const
 
 void GlyphContour::setOpen(bool open)
 {
-	m_open = open;
+	if (m_open != open) {
+		m_open = open;
+		emit opennessChanged();
+	}
 }
 
 void GlyphContour::appendPoint(const GlyphPoint &point)
diff --git a/nongui/glyphcontour.h b/nongui/glyphcontour.h
index c6fea1f..1e48b27 100644
--- a/nongui/glyphcontour.h
+++ b/nongui/glyphcontour.h
@@ -36,6 +36,7 @@ public:
 	Q_INVOKABLE void changePoint(int number, const GlyphPoint &newPoint);
 signals:
 	void pointChanged(int number);
+	void opennessChanged(); // FIXME any better name?
 private:
 	bool m_open;
 	GlyphPointList m_points;

commit 7117c5811f2bc8e87a017dd984b86e09a9243d52
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Thu Dec 27 01:04:08 2007 +0100

    split Glyph::appendContent() in two functions (Glyph::append{Reference,Contour}())

diff --git a/nongui/fontdocumentreader.cxx b/nongui/fontdocumentreader.cxx
index 69dea13..1306c6e 100644
--- a/nongui/fontdocumentreader.cxx
+++ b/nongui/fontdocumentreader.cxx
@@ -276,7 +276,7 @@ void FontDocumentReader::readContent(Glyph *glyph)
 				if (!ok) return;
 
 				GlyphReference *ref = new GlyphReference(g.toString(), QPointF(xVal, yVal));
-				glyph->appendContent(ref);
+				glyph->appendReference(ref);
 				readUnknownElement();
 			}
 			else
@@ -321,7 +321,7 @@ void FontDocumentReader::readContour(Glyph *glyph)
 				readUnknownElement();
 		}
 	}
-	glyph->appendContent(contour);
+	glyph->appendContour(contour);
 }
 
 void FontDocumentReader::readCvt()
diff --git a/nongui/glyph.cxx b/nongui/glyph.cxx
index 26ca11e..3d19f6f 100644
--- a/nongui/glyph.cxx
+++ b/nongui/glyph.cxx
@@ -38,20 +38,25 @@ GlyphContentList Glyph::content() const
 	return m_content;
 }
 
-void Glyph::appendContent(GlyphContentBase *item)
+void Glyph::appendReference(GlyphReference *ref)
 {
-	Q_ASSERT(item);
-	Q_ASSERT(!item->parent());
+	Q_ASSERT(ref);
+	Q_ASSERT(!ref->parent());
 
-	item->setParent(this);
-	m_content << item;
+	ref->setParent(this);
+	m_content << ref;
+	// TODO
+}
+
+void Glyph::appendContour(GlyphContour *contour)
+{
+	Q_ASSERT(contour);
+	Q_ASSERT(!contour->parent());
 
-	if (item->type() == GlyphContentBase::Contour) {
-		GlyphContour *contour = qobject_cast<GlyphContour *>(item);
-		Q_ASSERT(contour);
+	contour->setParent(this);
+	m_content << contour;
 
-		connect(contour, SIGNAL(pointChanged(int)), this, SLOT(contourPointChanged()));
-	}
+	connect(contour, SIGNAL(pointChanged(int)), this, SLOT(contourPointChanged()));
 }
 
 template <typename T>
diff --git a/nongui/glyph.h b/nongui/glyph.h
index 476db6a..784b677 100644
--- a/nongui/glyph.h
+++ b/nongui/glyph.h
@@ -20,6 +20,8 @@
 #include "glyphcontentbase.h"
 
 class FontDocument;
+class GlyphReference;
+class GlyphContour;
 
 /** %Glyph description.
  * This class contains information about a glyph.
@@ -41,7 +43,8 @@ public:
 	FontDocument *document() const;
 
 	GlyphContentList content() const;
-	Q_INVOKABLE void appendContent(GlyphContentBase *item);
+	Q_INVOKABLE void appendReference(GlyphReference *ref);
+	Q_INVOKABLE void appendContour(GlyphContour *contour);
 
 	bool setGlyphName(const QString &name);
 	QString glyphName() const;

commit 61ba80d2e0f4f4c49eb25e3a9345f30d6a28ad34
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Wed Dec 26 23:36:50 2007 +0100

    add NOTIFY declarations for properties

diff --git a/nongui/fontdocument.h b/nongui/fontdocument.h
index 09124cb..affb079 100644
--- a/nongui/fontdocument.h
+++ b/nongui/fontdocument.h
@@ -33,24 +33,24 @@ Q_DECLARE_METATYPE(QVector<CVTEntry>)
  */
 class FontDocument : public QObject {
 	Q_OBJECT
-	Q_PROPERTY(QString copyright READ copyright WRITE setCopyright)
-	Q_PROPERTY(QString prep READ prep WRITE setPrep)
-	Q_PROPERTY(QString fpgm READ fpgm WRITE setFpgm)
-	Q_PROPERTY(QString fontName READ fontName WRITE setFontName)
-	Q_PROPERTY(QString fontFamily READ fontFamily WRITE setFontFamily)
-	Q_PROPERTY(QString fontWeight READ fontWeight WRITE setFontWeight)
-	Q_PROPERTY(qreal ascent READ ascent WRITE setAscent)
-	Q_PROPERTY(qreal descent READ descent WRITE setDescent)
-	Q_PROPERTY(qreal italicAngle READ italicAngle WRITE setItalicAngle)
-	Q_PROPERTY(qreal underlinePosition READ underlinePosition WRITE setUnderlinePosition)
-	Q_PROPERTY(qreal underlineThickness READ underlineThickness WRITE setUnderlineThickness)
-	Q_PROPERTY(bool changed READ changed WRITE setChanged)
-	Q_PROPERTY(unsigned zonesCount READ zonesCount WRITE setZonesCount)
-	Q_PROPERTY(unsigned maxTwilightPoints READ maxTwilightPoints WRITE setMaxTwilightPoints)
-	Q_PROPERTY(unsigned maxStorage READ maxStorage WRITE setMaxStorage)
-	Q_PROPERTY(unsigned maxFDEFs READ maxFDEFs WRITE setMaxFDEFs)
-	Q_PROPERTY(unsigned maxIDEFs READ maxIDEFs WRITE setMaxIDEFs)
-	Q_PROPERTY(unsigned maxStackDepth READ maxStackDepth WRITE setMaxStackDepth)
+	Q_PROPERTY(QString copyright READ copyright WRITE setCopyright NOTIFY copyrightChanged)
+	Q_PROPERTY(QString prep READ prep WRITE setPrep NOTIFY prepChanged)
+	Q_PROPERTY(QString fpgm READ fpgm WRITE setFpgm NOTIFY fpgmChanged)
+	Q_PROPERTY(QString fontName READ fontName WRITE setFontName NOTIFY fontNameChanged)
+	Q_PROPERTY(QString fontFamily READ fontFamily WRITE setFontFamily NOTIFY fontFamilyChanged)
+	Q_PROPERTY(QString fontWeight READ fontWeight WRITE setFontWeight NOTIFY fontWeightChanged)
+	Q_PROPERTY(qreal ascent READ ascent WRITE setAscent NOTIFY ascentChanged)
+	Q_PROPERTY(qreal descent READ descent WRITE setDescent NOTIFY descentChanged)
+	Q_PROPERTY(qreal italicAngle READ italicAngle WRITE setItalicAngle NOTIFY italicAngleChanged)
+	Q_PROPERTY(qreal underlinePosition READ underlinePosition WRITE setUnderlinePosition NOTIFY underlinePositionChanged)
+	Q_PROPERTY(qreal underlineThickness READ underlineThickness WRITE setUnderlineThickness NOTIFY underlineThicknessChanged)
+	Q_PROPERTY(bool changed READ changed WRITE setChanged NOTIFY documentChanged)
+	Q_PROPERTY(unsigned zonesCount READ zonesCount WRITE setZonesCount NOTIFY zonesCountChanged)
+	Q_PROPERTY(unsigned maxTwilightPoints READ maxTwilightPoints WRITE setMaxTwilightPoints NOTIFY maxTwilightPointsChanged)
+	Q_PROPERTY(unsigned maxStorage READ maxStorage WRITE setMaxStorage NOTIFY maxStorageChanged)
+	Q_PROPERTY(unsigned maxFDEFs READ maxFDEFs WRITE setMaxFDEFs NOTIFY maxFDEFsChanged)
+	Q_PROPERTY(unsigned maxIDEFs READ maxIDEFs WRITE setMaxIDEFs NOTIFY maxIDEFsChanged)
+	Q_PROPERTY(unsigned maxStackDepth READ maxStackDepth WRITE setMaxStackDepth NOTIFY maxStackDepthChanged)
 	Q_PROPERTY(QList<Glyph *> glyphs READ glyphs)
 	Q_PROPERTY(QVector<CVTEntry> cvt READ cvt)
 public:
diff --git a/nongui/glyph.h b/nongui/glyph.h
index 860e3a6..476db6a 100644
--- a/nongui/glyph.h
+++ b/nongui/glyph.h
@@ -26,13 +26,13 @@ class FontDocument;
  */
 class Glyph : public QObject {
 	Q_OBJECT
-	Q_PROPERTY(QString glyphName READ glyphName WRITE setGlyphName)
+	Q_PROPERTY(QString glyphName READ glyphName WRITE setGlyphName NOTIFY glyphNameChanged)
 	Q_PROPERTY(qreal horizAdvX READ horizAdvX WRITE setHorizAdvX RESET unsetHorizAdvX)
 	Q_PROPERTY(QString instructions READ instructions WRITE setInstructions)
 	Q_PROPERTY(bool instructionsAreValid READ instructionsAreValid WRITE setInstructionsValidity)
 	Q_PROPERTY(QString colorString READ colorString WRITE setColorString)
 	Q_PROPERTY(QString comment READ comment WRITE setComment)
-	Q_PROPERTY(int unicode READ unicode WRITE setUnicode)
+	Q_PROPERTY(int unicode READ unicode WRITE setUnicode NOTIFY unicodeChanged)
 	Q_PROPERTY(bool changed READ changed WRITE setChanged)
 	Q_PROPERTY(GlyphContentList content READ content)
 public:
diff --git a/nongui/glyphreference.h b/nongui/glyphreference.h
index 0e4e1b1..44d045d 100644
--- a/nongui/glyphreference.h
+++ b/nongui/glyphreference.h
@@ -22,8 +22,8 @@
 
 class GlyphReference : public GlyphContentBase {
 	Q_OBJECT
-	Q_PROPERTY(QPointF offset READ offset WRITE setOffset)
-	Q_PROPERTY(QString glyphName READ glyphName WRITE setGlyphName)
+	Q_PROPERTY(QPointF offset READ offset WRITE setOffset NOTIFY offsetChanged)
+	Q_PROPERTY(QString glyphName READ glyphName WRITE setGlyphName NOTIFY glyphNameChanged)
 public:
 	GlyphReference(const QString &name = 0, const QPointF &off = QPointF());
 	GlyphReference(const GlyphReference &other);

commit be3d536e97f30efa1fb666008b9da404e7b606d2
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Wed Dec 26 23:12:55 2007 +0100

    handle changes of CVT in FontDocument class

diff --git a/nongui/cvtmodel.cxx b/nongui/cvtmodel.cxx
index a67902d..9365333 100644
--- a/nongui/cvtmodel.cxx
+++ b/nongui/cvtmodel.cxx
@@ -21,6 +21,12 @@ CVTModel::CVTModel(FontDocument *doc, QObject *parent) : QAbstractTableModel(par
 	m_doc(doc)
 {
 	Q_ASSERT(doc);
+
+	connect(m_doc, SIGNAL(cvtEntryChanged(int)), this, SLOT(cvtEntryChanged(int)));
+	connect(m_doc, SIGNAL(cvtEntriesAboutToBeRemoved(int, int)), this, SLOT(cvtEntriesAboutToBeRemoved(int, int)));
+	connect(m_doc, SIGNAL(cvtEntriesRemoved(int, int)), this, SLOT(cvtEntriesRemoved(int, int)));
+	connect(m_doc, SIGNAL(cvtEntriesAboutToBeAdded(int, int)), this, SLOT(cvtEntriesAboutToBeAdded(int, int)));
+	connect(m_doc, SIGNAL(cvtEntriesAdded(int, int)), this, SLOT(cvtEntriesAdded(int, int)));
 }
 
 int CVTModel::columnCount(const QModelIndex &parent) const
@@ -85,8 +91,6 @@ bool CVTModel::setData(const QModelIndex &index, const QVariant &value, int role
 
 	Q_ASSERT(index.row() >= 0 && index.row() < m_doc->cvt().size());
 
-	bool ret = false;
-
 	if (role == Qt::EditRole) {
 		CVTEntry newEntry = m_doc->cvt().at(index.row());
 
@@ -95,27 +99,22 @@ bool CVTModel::setData(const QModelIndex &index, const QVariant &value, int role
 			if (!value.canConvert<int>())
 				return false;
 			newEntry.setValue(value.toInt());
-			ret = m_doc->changeCvtEntry(index.row(), newEntry);
-			break;
+			return m_doc->changeCvtEntry(index.row(), newEntry);
 		case VariableColumn:
 			if (!value.canConvert<QString>())
 				return false;
 			newEntry.setVariableName(value.toString());
-			ret = m_doc->changeCvtEntry(index.row(), newEntry);
-			break;
+			return m_doc->changeCvtEntry(index.row(), newEntry);
 		case CommentColumn:
 			if (!value.canConvert<QString>())
 				return false;
 			newEntry.setComment(value.toString());
-			ret =  m_doc->changeCvtEntry(index.row(), newEntry);
-			break;
+			return m_doc->changeCvtEntry(index.row(), newEntry);
 		default:
 			break;
 		}
-		if (ret)
-			emit dataChanged(index, index);
 	}
-	return ret;
+	return false;
 }
 
 Qt::ItemFlags CVTModel::flags(const QModelIndex &index) const
@@ -131,14 +130,7 @@ bool CVTModel::removeRows(int row, int count, const QModelIndex &parent)
 		return false;
 	Q_ASSERT(count > 0 && row >= 0);
 
-	if (row + count > m_doc->cvt().size())
-		return false;
-
-	beginRemoveRows(parent, row, row + count - 1);
-	m_doc->removeCvtEntries(row, count);
-	endRemoveRows();
-
-	return false;
+	return m_doc->removeCvtEntries(row, count);
 }
 
 bool CVTModel::insertRows(int row, int count, const QModelIndex &parent)
@@ -146,13 +138,37 @@ bool CVTModel::insertRows(int row, int count, const QModelIndex &parent)
 	if (parent.isValid())
 		return false;
 	Q_ASSERT(count > 0 && row >= 0);
-	
-	if (row > m_doc->cvt().size())
-		return false;
 
-	beginInsertRows(parent, row, row + count - 1);
-	m_doc->insertCvtEntries(row, count);
-	endInsertRows();
+	return m_doc->insertCvtEntries(row, count);
+}
 
-	return false;
+void CVTModel::cvtEntryChanged(int number)
+{
+	QModelIndex start = createIndex(number, ValueColumn);
+	QModelIndex end = createIndex(number, CommentColumn);
+	emit dataChanged(start, end);
+}
+
+void CVTModel::cvtEntriesAboutToBeRemoved(int start, int end)
+{
+	beginRemoveRows(QModelIndex(), start, end);
+}
+
+void CVTModel::cvtEntriesRemoved(int start, int end)
+{
+	Q_UNUSED(start);
+	Q_UNUSED(end);
+	endRemoveRows();
+}
+
+void CVTModel::cvtEntriesAboutToBeAdded(int start, int end)
+{
+	beginInsertRows(QModelIndex(), start, end);
+}
+
+void CVTModel::cvtEntriesAdded(int start, int end)
+{
+	Q_UNUSED(start);
+	Q_UNUSED(end);
+	endInsertRows();
 }
diff --git a/nongui/cvtmodel.h b/nongui/cvtmodel.h
index dc7493f..c5a5fc9 100644
--- a/nongui/cvtmodel.h
+++ b/nongui/cvtmodel.h
@@ -33,6 +33,12 @@ public:
 	Qt::ItemFlags flags(const QModelIndex &index) const;
 	bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex());
 	bool insertRows(int row, int count, const QModelIndex &parent = QModelIndex());
+private slots:
+	void cvtEntryChanged(int number);
+	void cvtEntriesAboutToBeRemoved(int start, int end);
+	void cvtEntriesRemoved(int start, int end);
+	void cvtEntriesAboutToBeAdded(int start, int end);
+	void cvtEntriesAdded(int start, int end);
 private:
 	FontDocument *m_doc;
 };
diff --git a/nongui/fontdocument.cxx b/nongui/fontdocument.cxx
index 1ea0251..93f5e34 100644
--- a/nongui/fontdocument.cxx
+++ b/nongui/fontdocument.cxx
@@ -108,7 +108,11 @@ QString FontDocument::fpgm() const
  */
 void FontDocument::addCvtEntry(qint16 value, QString variableName, QString comment)
 {
+	int idx = m_cvt.size();
+	emit cvtEntriesAboutToBeAdded(idx, idx);
 	m_cvt << CVTEntry(value, variableName, comment);
+	emit cvtEntriesAdded(idx, idx);
+	setChanged();
 }
 
 /** returns control value table.
@@ -373,22 +377,31 @@ bool FontDocument::changeCvtEntry(int index, const CVTEntry &newEntry)
 	if (newEntry == m_cvt.at(index))
 		return true;
 	m_cvt[index] = newEntry;
+	emit cvtEntryChanged(index);
 	setChanged();
 	return true;
 }
 
-void FontDocument::removeCvtEntries(int first, int count)
+bool FontDocument::removeCvtEntries(int first, int count)
 {
-	Q_ASSERT(first >= 0 && first + count <= m_cvt.size());
+	if (first < 0 || first + count > m_cvt.size())
+		return false;
+	emit cvtEntriesAboutToBeRemoved(first, first + count - 1);
 	m_cvt.remove(first, count);
+	emit cvtEntriesRemoved(first, first + count - 1);
 	setChanged();
+	return true;
 }
 
-void FontDocument::insertCvtEntries(int first, int count)
+bool FontDocument::insertCvtEntries(int first, int count)
 {
-	Q_ASSERT(first >= 0 && first <= m_cvt.size());
+	if (first < 0 || first > m_cvt.size())
+		return false;
+	emit cvtEntriesAboutToBeAdded(first, first + count - 1);
 	m_cvt.insert(first, count, CVTEntry());
+	emit cvtEntriesAdded(first, first + count - 1);
 	setChanged();
+	return true;
 }
 
 unsigned FontDocument::zonesCount() const
diff --git a/nongui/fontdocument.h b/nongui/fontdocument.h
index 6eb8924..09124cb 100644
--- a/nongui/fontdocument.h
+++ b/nongui/fontdocument.h
@@ -97,8 +97,8 @@ public:
 	bool changed() const;
 
 	bool changeCvtEntry(int index, const CVTEntry &newEntry);
-	void removeCvtEntries(int first, int count);
-	void insertCvtEntries(int first, int count);
+	bool removeCvtEntries(int first, int count);
+	bool insertCvtEntries(int first, int count);
 
 	// maxp table related functions
 	unsigned zonesCount() const;
@@ -157,6 +157,12 @@ signals:
 	void glyphsRemoved(int start, int end);
 	void glyphsAboutToBeAdded(int start, int end);
 	void glyphsAdded(int start, int end);
+
+	void cvtEntryChanged(int number);
+	void cvtEntriesAboutToBeRemoved(int start, int end);
+	void cvtEntriesRemoved(int start, int end);
+	void cvtEntriesAboutToBeAdded(int start, int end);
+	void cvtEntriesAdded(int start, int end);
 private:
 	class FontFace {
 	public:

commit 51338b46c0e64a7cf7dc6d856be6c0c1da29aa68
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Wed Dec 26 23:12:09 2007 +0100

    do not use GlyphModel in GlyphCell class

diff --git a/gui/glyphcell.cxx b/gui/glyphcell.cxx
index 2ea017a..571eb17 100644
--- a/gui/glyphcell.cxx
+++ b/gui/glyphcell.cxx
@@ -25,14 +25,11 @@
 #include "glyphgraphics.h"
 #include "glyph.h"
 #include <QIcon>
-#include "glyphsmodel.h"
 #include "fontdocument.h"
 
-GlyphCell::GlyphCell(GlyphsModel *model, const QModelIndex &index) : QGraphicsView(), m_model(model)
+GlyphCell::GlyphCell(Glyph *glyph) : QGraphicsView(), m_glyph(glyph)
 {
-	Glyph *glyph = qobject_cast<Glyph *>(index.data(GlyphsModel::GlyphRole).value<QObject *>());
-	Q_ASSERT(glyph);
-	glyphIndex = index;
+	Q_ASSERT(m_glyph);
 
 	setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
 	setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
@@ -44,7 +41,7 @@ GlyphCell::GlyphCell(GlyphsModel *model, const QModelIndex &index) : QGraphicsVi
 	setScene(scene);
 	setTransformationAnchor(AnchorUnderMouse);
 
-	gg = new GlyphGraphics(this, glyph);
+	gg = new GlyphGraphics(this, m_glyph);
 	fitGlyph();
 }
 
@@ -62,7 +59,7 @@ void GlyphCell::wheelEvent(QWheelEvent *event)
 void GlyphCell::fitGlyph()
 {
 	QRectF rect = scene()->itemsBoundingRect();
-	FontDocument *doc = qobject_cast<FontDocument *>(glyphIndex.data(GlyphsModel::DocumentRole).value<QObject *>());
+	FontDocument *doc = m_glyph->document();
 	Q_ASSERT(doc);
 	if (rect.top() > -doc->ascent() - 50)
 		rect.setTop(-doc->ascent() - 50);
@@ -80,11 +77,9 @@ void GlyphCell::drawForeground(QPainter *painter, const QRectF &rect)
 	painter->drawLine(QLineF(0, rect.bottom(), 0, rect.top()));
 	painter->drawLine(QLineF(rect.left(), 0, rect.right(), 0));
 
-	FontDocument *doc = qobject_cast<FontDocument *>(glyphIndex.data(GlyphsModel::DocumentRole).value<QObject *>());
-	Glyph *g = qobject_cast<Glyph *>(glyphIndex.data(GlyphsModel::GlyphRole).value<QObject *>());
+	FontDocument *doc = m_glyph->document();
 	// TODO those values should be cached and updated by signals
 	Q_ASSERT(doc);
-	Q_ASSERT(g);
 
 	painter->setPen(Qt::lightGray);
 
@@ -95,7 +90,7 @@ void GlyphCell::drawForeground(QPainter *painter, const QRectF &rect)
 	if (doc->descent() != 0) {
 		painter->drawLine(QLineF(rect.left(), doc->descent(), rect.right(), doc->descent()));
 	}
-	if (g->hasHorizAdvX()) {
-		painter->drawLine(QLineF(g->horizAdvX(), rect.bottom(), g->horizAdvX(), rect.top()));
+	if (m_glyph->hasHorizAdvX()) {
+		painter->drawLine(QLineF(m_glyph->horizAdvX(), rect.bottom(), m_glyph->horizAdvX(), rect.top()));
 	}
 }
diff --git a/gui/glyphcell.h b/gui/glyphcell.h
index f92af5b..32ce107 100644
--- a/gui/glyphcell.h
+++ b/gui/glyphcell.h
@@ -17,18 +17,15 @@
 #ifndef TTGLYPHCELL_H
 #define TTGLYPHCELL_H
 #include <QGraphicsView>
-#include <QPersistentModelIndex>
-#include "glyphgraphics.h"
 
 class GlyphGraphics;
-class QModelIndex;
-class GlyphsModel;
+class Glyph;
 
 class GlyphCell : public QGraphicsView
 {
 	Q_OBJECT
 public:
-	GlyphCell(GlyphsModel *model, const QModelIndex &index);
+	GlyphCell(Glyph *glyph);
 	void wheelEvent(QWheelEvent *event);
 public slots:
 	void fitGlyph();
@@ -36,8 +33,7 @@ protected:
 	void drawForeground(QPainter *painter, const QRectF &rect);
 private:
 	GlyphGraphics *gg;
-	QPersistentModelIndex glyphIndex;
-	GlyphsModel *m_model;
+	Glyph *m_glyph;
 };
 
 #endif
diff --git a/gui/glypheditwidget.cxx b/gui/glypheditwidget.cxx
index c5f0062..651365e 100644
--- a/gui/glypheditwidget.cxx
+++ b/gui/glypheditwidget.cxx
@@ -42,7 +42,7 @@ GlyphEditWidget::GlyphEditWidget(QWidget *parent, GlyphsModel *model, const QMod
 	m_glyph = qobject_cast<Glyph *>(index.data(GlyphsModel::GlyphRole).value<QObject *>());
 	Q_ASSERT(m_glyph);
 
-	cell = new GlyphCell(model, index);
+	cell = new GlyphCell(m_glyph);
 	setCentralWidget(cell);
 
 	setWindowIcon(QIcon(new GlyphIconEngine(index)));

commit 2ce87079a32be88c7cdd9339ac024efe5d49bd97
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Wed Dec 26 22:19:34 2007 +0100

    do not store model and model index in GlyphEditWidget
    use FontDocument and Glyph instead

diff --git a/gui/glypheditwidget.cxx b/gui/glypheditwidget.cxx
index cc6cae8..c5f0062 100644
--- a/gui/glypheditwidget.cxx
+++ b/gui/glypheditwidget.cxx
@@ -23,7 +23,6 @@
 #include <QGridLayout>
 #include <QToolButton>
 #include <QApplication>
-#include <QStyle>
 #include "fontdocument.h"
 #include "glyphiconengine.h"
 #include <QModelIndex>
@@ -36,18 +35,14 @@ GlyphEditWidget::GlyphEditWidget(QWidget *parent, GlyphsModel *model, const QMod
 	// Qt does not like this on non-top-level windows
 	setAttribute(Qt::WA_QuitOnClose, false);
 
-	valid = false;
-
-	if (!index.isValid()) // FIXME maybe assert?
-		return;
+	Q_ASSERT(index.isValid());
 
 	Q_ASSERT(model);
-	m_model = model;
-	m_index = index;
-	Q_ASSERT(m_index.isValid());
-
+	// FIXME why it is so strange?
+	m_glyph = qobject_cast<Glyph *>(index.data(GlyphsModel::GlyphRole).value<QObject *>());
+	Q_ASSERT(m_glyph);
 
-	cell = new GlyphCell(model, index); // TODO m_index?
+	cell = new GlyphCell(model, index);
 	setCentralWidget(cell);
 
 	setWindowIcon(QIcon(new GlyphIconEngine(index)));
@@ -56,11 +51,15 @@ GlyphEditWidget::GlyphEditWidget(QWidget *parent, GlyphsModel *model, const QMod
 	createMenus();
 	createDockWindows();
 
-	connect(m_model, SIGNAL(rowsAboutToBeRemoved(const QModelIndex&, int, int)),
-			this, SLOT(modelRowsAboutToBeRemoved(const QModelIndex&, int, int)));
-	connect(m_model, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),
-			this, SLOT(modelDataChanged(const QModelIndex&, const QModelIndex&)));
-	valid = true;
+	FontDocument *doc = m_glyph->document();
+	Q_ASSERT(doc);
+
+	connect(doc, SIGNAL(destroyed()), this, SLOT(close()));
+	connect(doc, SIGNAL(glyphsAboutToBeRemoved(int, int)),
+			this, SLOT(glyphsAboutToBeRemoved(int, int)));
+	connect(doc, SIGNAL(fontNameChanged()), this, SLOT(updateWindowTitle()));
+	connect(m_glyph, SIGNAL(glyphNameChanged(const QString &, const QString &)),
+			this, SLOT(updateWindowTitle()));
 	updateWindowTitle();
 }
 
@@ -105,39 +104,25 @@ void GlyphEditWidget::createDockWindows()
 	viewMenu->addAction(dock->toggleViewAction());
 }
 
-void GlyphEditWidget::modelRowsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
+void GlyphEditWidget::glyphsAboutToBeRemoved(int start, int end)
 {
-	if (parent.isValid())
-		return;
+	FontDocument *doc = m_glyph->document();
+	Q_ASSERT(doc);
 
-	int row = m_index.row();
+	int idx = doc->glyphIndex(m_glyph);
+	Q_ASSERT(idx != -1);
 
-	if (row >= start && row <= end)
+	if (idx >= start && idx <= end)
 		close();
 }
 
-void GlyphEditWidget::modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
-{
-	Q_ASSERT(m_index.isValid());
-
-	if (m_index.parent() != topLeft.parent())
-		return;
-	if (m_index.row() < topLeft.row() || m_index.row() > bottomRight.row())
-		return;
-	if (GlyphsModel::NameColumn < topLeft.column() || GlyphsModel::NameColumn > bottomRight.column())
-		return;
-	updateWindowTitle();
-}
-
 void GlyphEditWidget::updateWindowTitle()
 {
-	FontDocument *doc = qobject_cast<FontDocument *>(m_index.data(GlyphsModel::DocumentRole).value<QObject *>());
+	FontDocument *doc = m_glyph->document();
 	Q_ASSERT(doc);
 
-	QString glyphName = m_index.data().toString();
-
 	if (!doc->fontName().isEmpty())
-		setWindowTitle(QString("%1 in %2").arg(glyphName).arg(doc->fontName()));
+		setWindowTitle(QString("%1 in %2").arg(m_glyph->glyphName()).arg(doc->fontName()));
 	else
-		setWindowTitle(glyphName);
+		setWindowTitle(m_glyph->glyphName());
 }
diff --git a/gui/glypheditwidget.h b/gui/glypheditwidget.h
index 2bd28da..63a3ff0 100644
--- a/gui/glypheditwidget.h
+++ b/gui/glypheditwidget.h
@@ -17,7 +17,6 @@
 #ifndef GLYPHEDITWIDGET_H
 #define GLYPHEDITWIDGET_H
 #include <QMainWindow>
-#include <QPersistentModelIndex>
 
 class GlyphCell;
 class Glyph;
@@ -29,15 +28,13 @@ class GlyphEditWidget : public QMainWindow
 	Q_OBJECT
 public:
 	GlyphEditWidget(QWidget *parent, GlyphsModel *model, const QModelIndex &index);
-	bool isValid() const {return valid;}
-public slots:
-	void modelRowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
-	void modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
+private slots:
+	void updateWindowTitle();
+	void glyphsAboutToBeRemoved(int start, int end);
 private:
 	void createActions();
 	void createMenus();
 	void createDockWindows();
-	void updateWindowTitle();
 
 	QAction *closeAction;
 	QAction *fitGlyphAction;
@@ -45,10 +42,8 @@ private:
 	QMenu *viewMenu;
 
 	GlyphCell *cell;
-	bool valid;
 
-	QAbstractItemModel *m_model;
-	QPersistentModelIndex m_index;
+	Glyph *m_glyph;
 };
 
 #endif
diff --git a/gui/mainwindow.cxx b/gui/mainwindow.cxx
index ea466f1..661ee72 100644
--- a/gui/mainwindow.cxx
+++ b/gui/mainwindow.cxx
@@ -386,16 +386,13 @@ void MainWindow::about()
 }
 
 void MainWindow::editGlyph(const QModelIndex &index)
-{	
+{
 	Q_ASSERT(model);
 
 	QAbstractProxyModel *proxy = qobject_cast<QAbstractProxyModel *>(glyphsView->model());
 	if (proxy) {
 		GlyphEditWidget *editor = new GlyphEditWidget(this, qobject_cast<GlyphsModel *>(proxy->sourceModel()), proxy->mapToSource(index));
-		if (editor->isValid())
-			editor->show();
-		else
-			delete editor;
+		editor->show();
 	}
 }
 

commit 09e26d0b66a8675c2997e24ef2e2720dd3e90dc5
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Wed Dec 26 21:56:47 2007 +0100

    add FontDocument::glyphIndex()

diff --git a/nongui/fontdocument.cxx b/nongui/fontdocument.cxx
index 6d3cd4d..1ea0251 100644
--- a/nongui/fontdocument.cxx
+++ b/nongui/fontdocument.cxx
@@ -501,3 +501,8 @@ void FontDocument::glyphOutlineChanged()
 	emit glyphChanged(idx);
 	setChanged();
 }
+
+int FontDocument::glyphIndex(const Glyph *glyph) const
+{
+	return m_glyphs.indexOf(const_cast<Glyph *>(glyph)); // FIXME bug?
+}
diff --git a/nongui/fontdocument.h b/nongui/fontdocument.h
index f23e3e2..6eb8924 100644
--- a/nongui/fontdocument.h
+++ b/nongui/fontdocument.h
@@ -122,6 +122,7 @@ public slots:
 	bool addGlyph(Glyph *glyph);
 	bool hasGlyph(const QString &name) const;
 	Glyph *getGlyph(const QString &name) const;
+	int glyphIndex(const Glyph *glyph) const;
 
 	bool removeGlyphs(int first, int count);
 

commit f7e1e0bee38e0fca3440b98c4b725035f42ba971
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Wed Dec 26 21:45:39 2007 +0100

    add a TODO item

diff --git a/gui/unicodeproxymodel.h b/gui/unicodeproxymodel.h
index a0e66e7..47a7970 100644
--- a/gui/unicodeproxymodel.h
+++ b/gui/unicodeproxymodel.h
@@ -30,6 +30,7 @@ public slots:
 	void sourceLayoutChanged();
 	void sourceRowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
 	void sourceRowsRemoved(const QModelIndex &parent, int start, int end);
+	// TODO handle rows insertion
 private:
 	QHash<int, int> toSourceMap;
 	QHash<int, int> fromSourceMap;

commit a713b791727b37df8a0d1aaef0113619b9144c00
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Wed Dec 26 21:41:22 2007 +0100

    handle glyphs{AboutToBe,}Added signals from FontDocument in GlyphsModel

diff --git a/gui/glyphsmodel.cxx b/gui/glyphsmodel.cxx
index d5c0cec..b78b9d5 100644
--- a/gui/glyphsmodel.cxx
+++ b/gui/glyphsmodel.cxx
@@ -209,6 +209,8 @@ void GlyphsModel::setDocument(FontDocument *d)
 	connect(doc, SIGNAL(glyphChanged(int)), this, SLOT(glyphChanged(int)));
 	connect(doc, SIGNAL(glyphsAboutToBeRemoved(int, int)), this, SLOT(glyphsAboutToBeRemoved(int, int)));
 	connect(doc, SIGNAL(glyphsRemoved(int, int)), this, SLOT(glyphsRemoved(int, int)));
+	connect(doc, SIGNAL(glyphsAboutToBeAdded(int, int)), this, SLOT(glyphsAboutToBeAdded(int, int)));
+	connect(doc, SIGNAL(glyphsAdded(int, int)), this, SLOT(glyphsAdded(int, int)));
 }
 
 // XXX does this really belong here?
@@ -299,3 +301,16 @@ void GlyphsModel::glyphsRemoved(int start, int end)
 
 	endRemoveRows();
 }
+
+void GlyphsModel::glyphsAboutToBeAdded(int start, int end)
+{
+	beginInsertRows(QModelIndex(), start, end);
+}
+
+void GlyphsModel::glyphsAdded(int start, int end)
+{
+	Q_UNUSED(start);
+	Q_UNUSED(end);
+
+	endInsertRows();
+}
diff --git a/gui/glyphsmodel.h b/gui/glyphsmodel.h
index a6097c3..1109540 100644
--- a/gui/glyphsmodel.h
+++ b/gui/glyphsmodel.h
@@ -52,6 +52,8 @@ private slots:
 
 	void glyphsAboutToBeRemoved(int start, int end);
 	void glyphsRemoved(int start, int end);
+	void glyphsAboutToBeAdded(int star, int end);
+	void glyphsAdded(int start, int end);
 private:
 	static void drawGlyph(PathList *paths, const Glyph *glyph);
 	static void drawContours(PathList *paths, const Glyph *glyph, int order, QPoint off);

commit 87194a825e154dd5c930e444003ca0994724ebf6
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Wed Dec 26 21:34:36 2007 +0100

    emit FontDocument::glyphs{AboutToBe,}Added signals in FontDocument::addGlyph()

diff --git a/nongui/fontdocument.cxx b/nongui/fontdocument.cxx
index 39450c7..6d3cd4d 100644
--- a/nongui/fontdocument.cxx
+++ b/nongui/fontdocument.cxx
@@ -157,6 +157,9 @@ bool FontDocument::addGlyph(Glyph *glyph)
 	if (unicode != -1 && hasUnicodeGlyph(unicode))
 		return false;
 
+	int newPos = m_glyphs.size();
+
+	emit glyphsAboutToBeAdded(newPos, newPos);
 	m_glyphs << glyph;
 	nameHash[name] = glyph;
 	if (glyph->unicode() != -1)
@@ -168,6 +171,7 @@ bool FontDocument::addGlyph(Glyph *glyph)
 			this, SLOT(glyphRenamed(const QString&, const QString&)));
 	connect(glyph, SIGNAL(unicodeChanged(int, int)),
 			this, SLOT(unicodeValueChanged(int, int)));
+	emit glyphsAdded(newPos, newPos);
 
 	return true;
 }
diff --git a/nongui/fontdocument.h b/nongui/fontdocument.h
index 43689f3..f23e3e2 100644
--- a/nongui/fontdocument.h
+++ b/nongui/fontdocument.h
@@ -154,6 +154,8 @@ signals:
 
 	void glyphsAboutToBeRemoved(int start, int end);
 	void glyphsRemoved(int start, int end);
+	void glyphsAboutToBeAdded(int start, int end);
+	void glyphsAdded(int start, int end);
 private:
 	class FontFace {
 	public:

commit 04f03d6a31c2f243b6c24ff56cd0a95d19ac5909
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Wed Dec 26 21:26:11 2007 +0100

    do not segfault on glyphs removal when edit widget is open

diff --git a/gui/glypheditwidget.cxx b/gui/glypheditwidget.cxx
index 2a47ee9..cc6cae8 100644
--- a/gui/glypheditwidget.cxx
+++ b/gui/glypheditwidget.cxx
@@ -56,8 +56,8 @@ GlyphEditWidget::GlyphEditWidget(QWidget *parent, GlyphsModel *model, const QMod
 	createMenus();
 	createDockWindows();
 
-	connect(m_model, SIGNAL(rowsRemoved(const QModelIndex&, int, int)),
-			this, SLOT(modelRowsRemoved(const QModelIndex&, int, int)));
+	connect(m_model, SIGNAL(rowsAboutToBeRemoved(const QModelIndex&, int, int)),
+			this, SLOT(modelRowsAboutToBeRemoved(const QModelIndex&, int, int)));
 	connect(m_model, SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)),
 			this, SLOT(modelDataChanged(const QModelIndex&, const QModelIndex&)));
 	valid = true;
@@ -105,13 +105,14 @@ void GlyphEditWidget::createDockWindows()
 	viewMenu->addAction(dock->toggleViewAction());
 }
 
-void GlyphEditWidget::modelRowsRemoved(const QModelIndex &parent, int start, int end)
+void GlyphEditWidget::modelRowsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
 {
-	Q_UNUSED(parent);
-	Q_UNUSED(start);
-	Q_UNUSED(end);
+	if (parent.isValid())
+		return;
+
+	int row = m_index.row();
 
-	if (!m_index.isValid())
+	if (row >= start && row <= end)
 		close();
 }
 
diff --git a/gui/glypheditwidget.h b/gui/glypheditwidget.h
index 7310aad..2bd28da 100644
--- a/gui/glypheditwidget.h
+++ b/gui/glypheditwidget.h
@@ -31,7 +31,7 @@ public:
 	GlyphEditWidget(QWidget *parent, GlyphsModel *model, const QModelIndex &index);
 	bool isValid() const {return valid;}
 public slots:
-	void modelRowsRemoved(const QModelIndex &parent, int start, int end);
+	void modelRowsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
 	void modelDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
 private:
 	void createActions();

commit 7a313ea210de62e0c490ec17ee002a771c10d955
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Wed Dec 26 21:22:53 2007 +0100

    move glyphs removal to FontDocument class

diff --git a/gui/glyphsmodel.cxx b/gui/glyphsmodel.cxx
index 6649a50..d5c0cec 100644
--- a/gui/glyphsmodel.cxx
+++ b/gui/glyphsmodel.cxx
@@ -207,6 +207,8 @@ void GlyphsModel::setDocument(FontDocument *d)
 	endInsertRows();
 
 	connect(doc, SIGNAL(glyphChanged(int)), this, SLOT(glyphChanged(int)));
+	connect(doc, SIGNAL(glyphsAboutToBeRemoved(int, int)), this, SLOT(glyphsAboutToBeRemoved(int, int)));
+	connect(doc, SIGNAL(glyphsRemoved(int, int)), this, SLOT(glyphsRemoved(int, int)));
 }
 
 // XXX does this really belong here?
@@ -276,15 +278,7 @@ bool GlyphsModel::removeRows(int row, int count, const QModelIndex &index)
 	if (index.isValid())
 		return false;
 
-	if (row + count > doc->glyphs().size())
-		return false;
-
-
-	beginRemoveRows(index, row, row + count - 1);
-	doc->removeGlyphs(row, count);
-	endRemoveRows();
-
-	return true;
+	return doc->removeGlyphs(row, count);
 }
 
 void GlyphsModel::glyphChanged(int glyphNo)
@@ -292,3 +286,16 @@ void GlyphsModel::glyphChanged(int glyphNo)
 	QModelIndex idx = createIndex(glyphNo, GlyphColumn);
 	emit dataChanged(idx, idx);
 }
+
+void GlyphsModel::glyphsAboutToBeRemoved(int start, int end)
+{
+	beginRemoveRows(QModelIndex(), start, end);
+}
+
+void GlyphsModel::glyphsRemoved(int start, int end)
+{
+	Q_UNUSED(start);
+	Q_UNUSED(end);
+
+	endRemoveRows();
+}
diff --git a/gui/glyphsmodel.h b/gui/glyphsmodel.h
index 9f77c62..a6097c3 100644
--- a/gui/glyphsmodel.h
+++ b/gui/glyphsmodel.h
@@ -47,8 +47,11 @@ public:
 	int columnCount(const QModelIndex &parent) const;
 	void setDocument(FontDocument *d);
 	bool removeRows(int row, int count, const QModelIndex &index);
-public slots:
+private slots:
 	void glyphChanged(int glyphNo);
+
+	void glyphsAboutToBeRemoved(int start, int end);
+	void glyphsRemoved(int start, int end);
 private:
 	static void drawGlyph(PathList *paths, const Glyph *glyph);
 	static void drawContours(PathList *paths, const Glyph *glyph, int order, QPoint off);
diff --git a/nongui/fontdocument.cxx b/nongui/fontdocument.cxx
index 918cb94..39450c7 100644
--- a/nongui/fontdocument.cxx
+++ b/nongui/fontdocument.cxx
@@ -342,20 +342,26 @@ void FontDocument::unicodeValueChanged(int oldUnicode, int newUnicode)
 	setChanged();
 }
 
-void FontDocument::removeGlyphs(int first, int count)
-{
-	bool changed = false;
-
-	for (int i = 0; i < count; i++) {
-		Glyph *g = m_glyphs.at(first);
-		unicodeHash.remove(g->unicode());
-		nameHash.remove(g->glyphName());
-		m_glyphs.removeAt(first);
-		g->deleteLater();
-		changed = true;
-	}
-	if (changed)
+bool FontDocument::removeGlyphs(int first, int count)
+{
+	if (count > 0) {
+		if (first >= m_glyphs.size())
+			return false;
+		if (first + count > m_glyphs.size())
+			return false;
+
+		emit glyphsAboutToBeRemoved(first, first + count - 1);
+		for (int i = 0; i < count; i++) {
+			Glyph *g = m_glyphs.at(first);
+			unicodeHash.remove(g->unicode());
+			nameHash.remove(g->glyphName());
+			m_glyphs.removeAt(first);
+			g->deleteLater();
+		}
+		emit glyphsRemoved(first, first + count - 1);
 		setChanged();
+	}
+	return true;
 }
 
 bool FontDocument::changeCvtEntry(int index, const CVTEntry &newEntry)
@@ -481,7 +487,7 @@ bool FontDocument::setMaxStackDepth(unsigned depth)
 void FontDocument::glyphOutlineChanged()
 {
 	Glyph *g = qobject_cast<Glyph *>(sender());
-	
+
 	if (!g)
 		return;
 
diff --git a/nongui/fontdocument.h b/nongui/fontdocument.h
index bf6be5b..43689f3 100644
--- a/nongui/fontdocument.h
+++ b/nongui/fontdocument.h
@@ -123,7 +123,7 @@ public slots:
 	bool hasGlyph(const QString &name) const;
 	Glyph *getGlyph(const QString &name) const;
 
-	void removeGlyphs(int first, int count);
+	bool removeGlyphs(int first, int count);
 
 	bool hasUnicodeGlyph(int unicode) const;
 protected slots:
@@ -151,6 +151,9 @@ signals:
 	void maxStackDepthChanged();
 
 	void glyphChanged(int index);
+
+	void glyphsAboutToBeRemoved(int start, int end);
+	void glyphsRemoved(int start, int end);
 private:
 	class FontFace {
 	public:

commit 91447e7df93c430c7d336657a8af53bf6b430a67
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Wed Dec 26 21:04:09 2007 +0100

    remove some useless debug code

diff --git a/gui/glyphsmodel.cxx b/gui/glyphsmodel.cxx
index bb8b6e3..6649a50 100644
--- a/gui/glyphsmodel.cxx
+++ b/gui/glyphsmodel.cxx
@@ -280,16 +280,9 @@ bool GlyphsModel::removeRows(int row, int count, const QModelIndex &index)
 		return false;
 
 
-	QModelIndexList indices = persistentIndexList();
-	qDebug() << indices;
 	beginRemoveRows(index, row, row + count - 1);
-	//FIXME persistent indices
-	indices = persistentIndexList();
-	qDebug() << indices;
 	doc->removeGlyphs(row, count);
 	endRemoveRows();
-	indices = persistentIndexList();
-	qDebug() << indices;
 
 	return true;
 }

commit 5538b408adfbf53e0df435e3573bfc5b2e2050f3
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Wed Dec 26 02:55:10 2007 +0100

    use QObject::deleteLater() for destroying glyphs, it should be safer

diff --git a/nongui/fontdocument.cxx b/nongui/fontdocument.cxx
index 5c7a3c5..918cb94 100644
--- a/nongui/fontdocument.cxx
+++ b/nongui/fontdocument.cxx
@@ -347,11 +347,11 @@ void FontDocument::removeGlyphs(int first, int count)
 	bool changed = false;
 
 	for (int i = 0; i < count; i++) {
-		const Glyph *g = m_glyphs.at(first);
+		Glyph *g = m_glyphs.at(first);
 		unicodeHash.remove(g->unicode());
 		nameHash.remove(g->glyphName());
 		m_glyphs.removeAt(first);
-		delete g;
+		g->deleteLater();
 		changed = true;
 	}
 	if (changed)

commit b187d6a2f38bbf97a9cd9cc33eb372b29fb120db
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Wed Dec 26 02:39:17 2007 +0100

    make ControlPoint a QObject and let it manage points movement in GlyphContour

diff --git a/gui/controlpoint.cxx b/gui/controlpoint.cxx
index a7cbe97..294ace2 100644
--- a/gui/controlpoint.cxx
+++ b/gui/controlpoint.cxx
@@ -19,12 +19,14 @@
 #include "glyphcontour.h"
 
 ControlPoint::ControlPoint(GlyphContour *contour, int pointNumber, QGraphicsItem *parent) :
-	QGraphicsItem(parent), m_contour(contour), m_pointNumber(pointNumber)
+	QObject(), QGraphicsItem(parent), m_contour(contour), m_pointNumber(pointNumber)
 {
 	setFlag(ItemIsMovable);
 	setFlag(ItemIsSelectable);
 	setFlag(ItemIgnoresTransformations);
 	setZValue(1);
+
+	connect(m_contour, SIGNAL(pointChanged(int)), this, SLOT(glyphPointChanged(int)));
 }
 
 QRectF ControlPoint::boundingRect() const
@@ -64,3 +66,14 @@ QVariant ControlPoint::itemChange(GraphicsItemChange change, const QVariant &val
 	}
 	return QGraphicsItem::itemChange(change, value);
 }
+
+void ControlPoint::glyphPointChanged(int number)
+{
+	if (number == m_pointNumber) {
+		GlyphPoint pt = m_contour->points().at(number);
+		QPointF newPos(pt.x(), -pt.y());
+		if (newPos != pos()) {
+			setPos(newPos);
+		}
+	}
+}
diff --git a/gui/controlpoint.h b/gui/controlpoint.h
index 1ed2e35..b95dd4c 100644
--- a/gui/controlpoint.h
+++ b/gui/controlpoint.h
@@ -17,10 +17,12 @@
 #ifndef CONTROLPOINT_H
 #define CONTROLPOINT_H
 #include <QGraphicsItem>
+#include <QObject>
 
 class GlyphContour;
 
-class ControlPoint: public QGraphicsItem {
+class ControlPoint: public QObject, public QGraphicsItem {
+	Q_OBJECT
 public:
 	ControlPoint(GlyphContour *contour, int pointNumber, QGraphicsItem *parent = 0);
 	enum {Type = UserType + 1};
@@ -36,6 +38,8 @@ protected:
 private:
 	GlyphContour *m_contour;
 	int m_pointNumber;
+private slots:
+	void glyphPointChanged(int number);
 };
 
 #endif
diff --git a/gui/glyphgraphics.cxx b/gui/glyphgraphics.cxx
index c5c3a33..f928e8e 100644
--- a/gui/glyphgraphics.cxx
+++ b/gui/glyphgraphics.cxx
@@ -65,8 +65,6 @@ GlyphGraphics::GlyphGraphics(GlyphCell *parent, Glyph *glyph) :
 	}
 	p->scene()->addItem(item);
 	connect(m_glyph, SIGNAL(outlineChanged()), this, SLOT(glyphOutlineChanged()));
-	connect(m_glyph, SIGNAL(pointChanged(int, int)),
-			this, SLOT(glyphPointMoved(int, int)));
 }
 
 GlyphGraphics::GlyphGraphics(GlyphGraphics *parent, Glyph *glyph, const QPointF &pos) :
@@ -145,26 +143,3 @@ void GlyphGraphics::glyphOutlineChanged()
 {
 	item->update();
 }
-
-void GlyphGraphics::glyphPointMoved(int component, int pointNo)
-{
-	ControlPoint *pt = 0;
-
-	GlyphContentBase *item = m_glyph->content().at(component);
-
-	for (int i = 0; i < points.size(); i++) {
-		if (points.at(i)->contour() == item && points.at(i)->pointNumber() == pointNo) {
-			pt = points.at(i);
-			break;
-		}
-	}
-	Q_ASSERT(pt);
-	const GlyphContour *contour = qobject_cast<const GlyphContour *>(m_glyph->content().at(component));
-	Q_ASSERT(contour);
-
-	GlyphPoint point = contour->points().at(pointNo);
-	QPointF realPos(point.x(), -point.y());
-	if (pt->pos() != realPos) {
-		pt->setPos(realPos);
-	}
-}
diff --git a/gui/glyphgraphics.h b/gui/glyphgraphics.h
index 44b21b7..89767e6 100644
--- a/gui/glyphgraphics.h
+++ b/gui/glyphgraphics.h
@@ -37,7 +37,6 @@ public:
 	//~GlyphGraphics();
 public slots:
 	void glyphOutlineChanged();
-	void glyphPointMoved(int component, int pointNo);
 private:
 	GlyphGraphics(GlyphGraphics *parent, Glyph *glyph, const QPointF &pos);
 	GlyphCell *p;
diff --git a/gui/gui.rules b/gui/gui.rules
index c56ef8d..b57b6c7 100644
--- a/gui/gui.rules
+++ b/gui/gui.rules
@@ -38,7 +38,8 @@ nodist_libfonduegui_a_SOURCES =			\
 	gui/cvteditor.moc.cxx			\
 	gui/maxpeditor.moc.cxx			\
 	gui/glyphgraphics.moc.cxx		\
-	gui/documentinfoeditor.moc.cxx
+	gui/documentinfoeditor.moc.cxx		\
+	gui/controlpoint.moc.cxx
 
 gui/instnames.tbl.cxx: data/instructions.xml
 gui/instnames.tbl.cxx: DATAFILE=$(srcdir)/data/instructions.xml
diff --git a/nongui/glyph.cxx b/nongui/glyph.cxx
index 6b3f044..26ca11e 100644
--- a/nongui/glyph.cxx
+++ b/nongui/glyph.cxx
@@ -26,7 +26,6 @@ Glyph::Glyph(const QString &name) :
 	QObject(), m_glyphName(name), horiz_adv_x(0), horiz_adv_x_set(false), m_unicode(-1), m_changed(false)
 {
 	setObjectName(name);
-	connect(this, SIGNAL(pointChanged(int, int)), this, SIGNAL(outlineChanged()));
 }
 
 FontDocument *Glyph::document() const
@@ -51,7 +50,7 @@ void Glyph::appendContent(GlyphContentBase *item)
 		GlyphContour *contour = qobject_cast<GlyphContour *>(item);
 		Q_ASSERT(contour);
 
-		connect(contour, SIGNAL(pointChanged(int)), this, SLOT(contourPointChanged(int)));
+		connect(contour, SIGNAL(pointChanged(int)), this, SLOT(contourPointChanged()));
 	}
 }
 
@@ -322,12 +321,9 @@ void Glyph::countParts(unsigned &nContours, unsigned &nRefs) const
 	}
 }
 
-void Glyph::contourPointChanged(int number)
+void Glyph::contourPointChanged()
 {
-	GlyphContentBase *obj = qobject_cast<GlyphContentBase *>(sender());
-	Q_ASSERT(obj);
+	setChanged();
 
-	int idx = m_content.indexOf(obj);
-	Q_ASSERT(idx != -1);
-	emit pointChanged(idx, number);
+	emit outlineChanged();
 }
diff --git a/nongui/glyph.h b/nongui/glyph.h
index 3f70d60..860e3a6 100644
--- a/nongui/glyph.h
+++ b/nongui/glyph.h
@@ -76,10 +76,9 @@ signals:
 	void glyphNameChanged(const QString &oldName, const QString &newName);
 	void unicodeChanged(int oldUnicode, int newUnicode);
 
-	void pointChanged(int component, int pointNo);
 	void outlineChanged();
 private slots:
-	void contourPointChanged(int number);
+	void contourPointChanged();
 private:
 	QString m_glyphName;
 	qreal horiz_adv_x;

commit 6080d7b19b89e94f49cb6366b592cd7f5aa38861
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Wed Dec 26 02:19:51 2007 +0100

    add GlyphPoint::pos()

diff --git a/nongui/glyphpoint.h b/nongui/glyphpoint.h
index 1a9ba9d..92dbbf6 100644
--- a/nongui/glyphpoint.h
+++ b/nongui/glyphpoint.h
@@ -26,6 +26,8 @@ public:
 	GlyphPoint(const QPointF &point, bool on = true) : QPointF(point), m_on(on) {}
 	GlyphPoint(const GlyphPoint &point) : QPointF(point), m_on(point.m_on) {}
 	GlyphPoint(qreal x, qreal y, bool on = true) : QPointF(x, y), m_on(on) {}
+
+	QPointF pos() const {return (QPointF)*this;}
 	bool on() const {return m_on;}
 	void setOn(bool on = true) {m_on = on;}
 private:
@@ -34,7 +36,7 @@ private:
 
 inline bool operator==(const GlyphPoint &p1, const GlyphPoint &p2)
 {
-	return ((QPointF)p1 == (QPointF)p2) && (p1.on() == p2.on());
+	return (p1.pos() == p2.pos()) && (p1.on() == p2.on());
 }
 
 Q_DECLARE_TYPEINFO(GlyphPoint, Q_MOVABLE_TYPE);

commit ac7c4f15d9e10fff4a13348e7fd895ecc095b2c3
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Wed Dec 26 01:34:04 2007 +0100

    simplify meta types registration

diff --git a/qscript/constructors.cxx b/qscript/constructors.cxx
index f44795f..b896da0 100644
--- a/qscript/constructors.cxx
+++ b/qscript/constructors.cxx
@@ -82,26 +82,17 @@ static void cvtEntryFromScriptValue(const QScriptValue &obj, CVTEntry &ent)
 		ent.setComment(QString());
 }
 
-static QScriptValue glyphToScriptValue(QScriptEngine *engine, Glyph * const &glyph)
+template <class T>
+static QScriptValue qObjectToScriptValue(QScriptEngine *engine, const T &qobj)
 {
-	QScriptValue obj = engine->newQObject(glyph, QScriptEngine::AutoOwnership);
+	QScriptValue obj = engine->newQObject(qobj, QScriptEngine::AutoOwnership);
 	return obj;
 }
 
-static void glyphFromScriptValue(const QScriptValue &obj, Glyph *&glyph)
+template <class T>
+static void qObjectFromScriptValue(const QScriptValue &obj, T &qobj)
 {
-	glyph = qobject_cast<Glyph *>(qscriptvalue_cast<QObject *>(obj));
-}
-
-static QScriptValue glyphContentToScriptValue(QScriptEngine *engine, GlyphContentBase *const &item)
-{
-	QScriptValue obj = engine->newQObject(item, QScriptEngine::AutoOwnership);
-	return obj;
-}
-
-static void glyphContentFromScriptValue(const QScriptValue &obj, GlyphContentBase *&item)
-{
-	item = qobject_cast<GlyphContentBase *>(qscriptvalue_cast<QObject *>(obj));
+	qobj = qobject_cast<T>(qscriptvalue_cast<QObject *>(obj));
 }
 
 static QScriptValue pointToScriptValue(QScriptEngine *engine, const QPointF &point)
@@ -141,11 +132,11 @@ void initScripting(QScriptEngine *engine)
 	global.setProperty("saveFont", engine->newFunction(saveFont, 2));
 	global.setProperty("exportFontToTTF", engine->newFunction(exportFontToTTF, 2));
 
-	qScriptRegisterMetaType<Glyph *>(engine, glyphToScriptValue, glyphFromScriptValue);
+	qScriptRegisterMetaType<Glyph *>(engine, qObjectToScriptValue, qObjectFromScriptValue);
 	qScriptRegisterSequenceMetaType<QList<Glyph *> >(engine);
 	qScriptRegisterMetaType<CVTEntry>(engine, cvtEntryToScriptValue, cvtEntryFromScriptValue);
 	qScriptRegisterSequenceMetaType<QVector<CVTEntry> >(engine);
-	qScriptRegisterMetaType<GlyphContentBase *>(engine, glyphContentToScriptValue, glyphContentFromScriptValue);
+	qScriptRegisterMetaType<GlyphContentBase *>(engine, qObjectToScriptValue, qObjectFromScriptValue);
 	qScriptRegisterSequenceMetaType<GlyphContentList>(engine);
 	qScriptRegisterMetaType<QPointF>(engine, pointToScriptValue, pointFromScriptValue);
 }

commit 849ffa9198367d35809c9843050945cd1410987c
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Wed Dec 26 00:37:27 2007 +0100

    cleanup glyph gui classes

diff --git a/gui/controlpoint.cxx b/gui/controlpoint.cxx
index 613879f..a7cbe97 100644
--- a/gui/controlpoint.cxx
+++ b/gui/controlpoint.cxx
@@ -16,13 +16,10 @@
  */
 #include "controlpoint.h"
 #include <QPainter>
-#include <QVariant>
-#include "glyphgraphics.h"
-#include "glyphcell.h"
-#include <QDebug>
+#include "glyphcontour.h"
 
-ControlPoint::ControlPoint(GlyphGraphics *gfx, const GlyphGraphics::PointIndex &idx, QGraphicsItem *parent) :
-	QGraphicsItem(parent), m_gfx(gfx), m_idx(idx)
+ControlPoint::ControlPoint(GlyphContour *contour, int pointNumber, QGraphicsItem *parent) :
+	QGraphicsItem(parent), m_contour(contour), m_pointNumber(pointNumber)
 {
 	setFlag(ItemIsMovable);
 	setFlag(ItemIsSelectable);
@@ -59,8 +56,11 @@ void ControlPoint::paint(QPainter *painter, const QStyleOptionGraphicsItem *opti
 QVariant ControlPoint::itemChange(GraphicsItemChange change, const QVariant &value)
 {
 	if (change == ItemPositionHasChanged) {
+		GlyphPoint point = m_contour->points().at(m_pointNumber);
 		QPointF newpoint = value.toPointF();
-		m_gfx->changePoint(m_idx, newpoint);
+		point.setX(newpoint.x());
+		point.setY(-newpoint.y());
+		m_contour->changePoint(m_pointNumber, point);
 	}
 	return QGraphicsItem::itemChange(change, value);
 }
diff --git a/gui/controlpoint.h b/gui/controlpoint.h
index e30a7ef..1ed2e35 100644
--- a/gui/controlpoint.h
+++ b/gui/controlpoint.h
@@ -17,24 +17,25 @@
 #ifndef CONTROLPOINT_H
 #define CONTROLPOINT_H
 #include <QGraphicsItem>
-#include "glyphgraphics.h"
 
-class GlyphPoint;
+class GlyphContour;
 
 class ControlPoint: public QGraphicsItem {
 public:
-	ControlPoint(GlyphGraphics *gfx, const GlyphGraphics::PointIndex &idx, QGraphicsItem *parent);
+	ControlPoint(GlyphContour *contour, int pointNumber, QGraphicsItem *parent = 0);
 	enum {Type = UserType + 1};
 	int type() const {return Type;}
 	QRectF boundingRect() const;
 	QPainterPath shape() const;
 	void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
-	GlyphGraphics::PointIndex idx() const {return m_idx;}
+
+	const GlyphContour *contour() const {return m_contour;}
+	int pointNumber() const {return m_pointNumber;}
 protected:
 	QVariant itemChange(GraphicsItemChange change, const QVariant &value);
 private:
-	GlyphGraphics *m_gfx;
-	GlyphGraphics::PointIndex m_idx;
+	GlyphContour *m_contour;
+	int m_pointNumber;
 };
 
 #endif
diff --git a/gui/glyphgraphics.cxx b/gui/glyphgraphics.cxx
index d9ba5ed..c5c3a33 100644
--- a/gui/glyphgraphics.cxx
+++ b/gui/glyphgraphics.cxx
@@ -36,14 +36,14 @@ GlyphGraphics::GlyphGraphics(GlyphCell *parent, Glyph *glyph) :
 	item = new GlyphItemOutline(this);
 
 	for (int i = 0; i < m_glyph->content().size(); i++) {
-		const GlyphContentBase *v = m_glyph->content().at(i);
+		GlyphContentBase *v = m_glyph->content().at(i);
 		if (v->type() == GlyphContentBase::Contour) {
-			const GlyphContour *c = qobject_cast<const GlyphContour *>(v);
+			GlyphContour *c = qobject_cast<GlyphContour *>(v);
 			Q_ASSERT(c);
 
 			for (int j = 0; j < c->points().size(); j++) {
 				const GlyphPoint pt = c->points().at(j);
-				ControlPoint *cp = new ControlPoint(this, PointIndex(i, j), item);
+				ControlPoint *cp = new ControlPoint(c, j, item);
 				points.append(cp);
 				cp->setPos(pt.x(), -pt.y());
 			}
@@ -150,8 +150,10 @@ void GlyphGraphics::glyphPointMoved(int component, int pointNo)
 {
 	ControlPoint *pt = 0;
 
+	GlyphContentBase *item = m_glyph->content().at(component);
+
 	for (int i = 0; i < points.size(); i++) {
-		if (points.at(i)->idx().element == component && points.at(i)->idx().num == pointNo) {
+		if (points.at(i)->contour() == item && points.at(i)->pointNumber() == pointNo) {
 			pt = points.at(i);
 			break;
 		}
@@ -166,16 +168,3 @@ void GlyphGraphics::glyphPointMoved(int component, int pointNo)
 		pt->setPos(realPos);
 	}
 }
-
-void GlyphGraphics::changePoint(const GlyphGraphics::PointIndex &idx, const QPointF &newPoint)
-{
-	QPointF newCoord(newPoint.x(), -newPoint.y());
-
-	GlyphContour *contour = qobject_cast<GlyphContour *>(m_glyph->content()[idx.element]);
-	Q_ASSERT(contour);
-
-	GlyphPoint point = contour->points().at(idx.num);
-	point.setX(newPoint.x());
-	point.setY(-newPoint.y());
-	contour->changePoint(idx.num, point);
-}
diff --git a/gui/glyphgraphics.h b/gui/glyphgraphics.h
index ae43ea1..44b21b7 100644
--- a/gui/glyphgraphics.h
+++ b/gui/glyphgraphics.h
@@ -32,17 +32,9 @@ class GlyphGraphics: public QObject {
 	Q_OBJECT
 	friend class GlyphItemBase;
 public:
-	struct PointIndex {
-		PointIndex(int e, int n) : element(e), num(n) {}
-		int element;
-		int num;
-	};
-
 	GlyphGraphics(GlyphCell *parent, Glyph *glyph);
 	// FIXME destructor may be needed
 	//~GlyphGraphics();
-
-	void changePoint(const GlyphGraphics::PointIndex &idx, const QPointF &newPoint);
 public slots:
 	void glyphOutlineChanged();
 	void glyphPointMoved(int component, int pointNo);

commit e62dc1dd6a4910b24bbf7d5749cf3119bd5649ab
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Tue Dec 25 21:55:17 2007 +0100

    handle points movement in class GlyphContour, not in Glyph

diff --git a/gui/glyphgraphics.cxx b/gui/glyphgraphics.cxx
index 03ed8cd..d9ba5ed 100644
--- a/gui/glyphgraphics.cxx
+++ b/gui/glyphgraphics.cxx
@@ -65,8 +65,8 @@ GlyphGraphics::GlyphGraphics(GlyphCell *parent, Glyph *glyph) :
 	}
 	p->scene()->addItem(item);
 	connect(m_glyph, SIGNAL(outlineChanged()), this, SLOT(glyphOutlineChanged()));
-	connect(m_glyph, SIGNAL(pointMoved(int, int, QPointF)),
-			this, SLOT(glyphPointMoved(int, int, QPointF)));
+	connect(m_glyph, SIGNAL(pointChanged(int, int)),
+			this, SLOT(glyphPointMoved(int, int)));
 }
 
 GlyphGraphics::GlyphGraphics(GlyphGraphics *parent, Glyph *glyph, const QPointF &pos) :
@@ -146,7 +146,7 @@ void GlyphGraphics::glyphOutlineChanged()
 	item->update();
 }
 
-void GlyphGraphics::glyphPointMoved(int component, int pointNo, const QPointF &newPos)
+void GlyphGraphics::glyphPointMoved(int component, int pointNo)
 {
 	ControlPoint *pt = 0;
 
@@ -157,7 +157,11 @@ void GlyphGraphics::glyphPointMoved(int component, int pointNo, const QPointF &n
 		}
 	}
 	Q_ASSERT(pt);
-	QPointF realPos(newPos.x(), -newPos.y());
+	const GlyphContour *contour = qobject_cast<const GlyphContour *>(m_glyph->content().at(component));
+	Q_ASSERT(contour);
+
+	GlyphPoint point = contour->points().at(pointNo);
+	QPointF realPos(point.x(), -point.y());
 	if (pt->pos() != realPos) {
 		pt->setPos(realPos);
 	}
@@ -166,5 +170,12 @@ void GlyphGraphics::glyphPointMoved(int component, int pointNo, const QPointF &n
 void GlyphGraphics::changePoint(const GlyphGraphics::PointIndex &idx, const QPointF &newPoint)
 {
 	QPointF newCoord(newPoint.x(), -newPoint.y());
-	m_glyph->movePoint(idx.element, idx.num, newCoord);
+
+	GlyphContour *contour = qobject_cast<GlyphContour *>(m_glyph->content()[idx.element]);
+	Q_ASSERT(contour);
+
+	GlyphPoint point = contour->points().at(idx.num);
+	point.setX(newPoint.x());
+	point.setY(-newPoint.y());
+	contour->changePoint(idx.num, point);
 }
diff --git a/gui/glyphgraphics.h b/gui/glyphgraphics.h
index ca95258..ae43ea1 100644
--- a/gui/glyphgraphics.h
+++ b/gui/glyphgraphics.h
@@ -45,7 +45,7 @@ public:
 	void changePoint(const GlyphGraphics::PointIndex &idx, const QPointF &newPoint);
 public slots:
 	void glyphOutlineChanged();
-	void glyphPointMoved(int component, int pointNo, const QPointF &newPos);
+	void glyphPointMoved(int component, int pointNo);
 private:
 	GlyphGraphics(GlyphGraphics *parent, Glyph *glyph, const QPointF &pos);
 	GlyphCell *p;
diff --git a/nongui/glyph.cxx b/nongui/glyph.cxx
index 35f5490..6b3f044 100644
--- a/nongui/glyph.cxx
+++ b/nongui/glyph.cxx
@@ -26,6 +26,7 @@ Glyph::Glyph(const QString &name) :
 	QObject(), m_glyphName(name), horiz_adv_x(0), horiz_adv_x_set(false), m_unicode(-1), m_changed(false)
 {
 	setObjectName(name);
+	connect(this, SIGNAL(pointChanged(int, int)), this, SIGNAL(outlineChanged()));
 }
 
 FontDocument *Glyph::document() const
@@ -45,6 +46,13 @@ void Glyph::appendContent(GlyphContentBase *item)
 
 	item->setParent(this);
 	m_content << item;
+
+	if (item->type() == GlyphContentBase::Contour) {
+		GlyphContour *contour = qobject_cast<GlyphContour *>(item);
+		Q_ASSERT(contour);
+
+		connect(contour, SIGNAL(pointChanged(int)), this, SLOT(contourPointChanged(int)));
+	}
 }
 
 template <typename T>
@@ -314,20 +322,12 @@ void Glyph::countParts(unsigned &nContours, unsigned &nRefs) const
 	}
 }
 
-void Glyph::movePoint(int component, int pointNo, const QPointF &newPos)
+void Glyph::contourPointChanged(int number)
 {
-	Q_ASSERT(component < content().size());
-	GlyphContour *contour = qobject_cast<GlyphContour *>(content().at(component));
-	Q_ASSERT(contour);
-	Q_ASSERT(pointNo < contour->points().size());
-
-	GlyphPoint pt = contour->points().at(pointNo);
-	if (pt.x() != newPos.x() || pt.y() != newPos.y()) {
-		pt.setX(newPos.x());
-		pt.setY(newPos.y());
-		contour->changePoint(pointNo, pt);
-
-		emit pointMoved(component, pointNo, newPos);
-		emit outlineChanged();
-	}
+	GlyphContentBase *obj = qobject_cast<GlyphContentBase *>(sender());
+	Q_ASSERT(obj);
+
+	int idx = m_content.indexOf(obj);
+	Q_ASSERT(idx != -1);
+	emit pointChanged(idx, number);
 }
diff --git a/nongui/glyph.h b/nongui/glyph.h
index 822e5a2..3f70d60 100644
--- a/nongui/glyph.h
+++ b/nongui/glyph.h
@@ -71,15 +71,15 @@ public:
 
 	bool computeMetrics(qreal &xMin, qreal &xMax, qreal &yMin, qreal &yMax) const;
 	void countParts(unsigned &nContours, unsigned &nRefs) const;
-
-	void movePoint(int component, int pointNo, const QPointF &newPos);
 signals:
 	void glyphChanged();
 	void glyphNameChanged(const QString &oldName, const QString &newName);
 	void unicodeChanged(int oldUnicode, int newUnicode);
 
-	void pointMoved(int component, int pointNo, const QPointF &newPos);
+	void pointChanged(int component, int pointNo);
 	void outlineChanged();
+private slots:
+	void contourPointChanged(int number);
 private:
 	QString m_glyphName;
 	qreal horiz_adv_x;
diff --git a/nongui/glyphcontour.cxx b/nongui/glyphcontour.cxx
index 814452a..18bb55c 100644
--- a/nongui/glyphcontour.cxx
+++ b/nongui/glyphcontour.cxx
@@ -36,8 +36,13 @@ void GlyphContour::appendPoint(const GlyphPoint &point)
 	m_points << point;
 }
 
-void GlyphContour::changePoint(int which, const GlyphPoint &newPoint)
+void GlyphContour::changePoint(int number, const GlyphPoint &newPoint)
 {
-	Q_ASSERT(which < m_points.size()); // XXX scriptable!
-	m_points[which] = newPoint;
+	Q_ASSERT(number < m_points.size()); // XXX scriptable!
+	Q_ASSERT(number >= 0);
+
+	if (m_points.at(number) != newPoint) {
+		m_points[number] = newPoint;
+		emit pointChanged(number);
+	}
 }
diff --git a/nongui/glyphcontour.h b/nongui/glyphcontour.h
index b708d19..c6fea1f 100644
--- a/nongui/glyphcontour.h
+++ b/nongui/glyphcontour.h
@@ -33,7 +33,9 @@ public:
 	GlyphPointList points() const {return m_points;}
 
 	Q_INVOKABLE void appendPoint(const GlyphPoint &point);
-	Q_INVOKABLE void changePoint(int which, const GlyphPoint &newPoint);
+	Q_INVOKABLE void changePoint(int number, const GlyphPoint &newPoint);
+signals:
+	void pointChanged(int number);
 private:
 	bool m_open;
 	GlyphPointList m_points;

commit eada3b6d7cf472251ffcea55a8d75e57b8a128a3
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Tue Dec 25 21:31:30 2007 +0100

    add operator == for GlyphPoints

diff --git a/nongui/glyphpoint.h b/nongui/glyphpoint.h
index a849b67..1a9ba9d 100644
--- a/nongui/glyphpoint.h
+++ b/nongui/glyphpoint.h
@@ -32,6 +32,11 @@ private:
 	bool m_on;
 };
 
+inline bool operator==(const GlyphPoint &p1, const GlyphPoint &p2)
+{
+	return ((QPointF)p1 == (QPointF)p2) && (p1.on() == p2.on());
+}
+
 Q_DECLARE_TYPEINFO(GlyphPoint, Q_MOVABLE_TYPE);
 
 typedef QList<GlyphPoint> GlyphPointList;

-- 
Fondue Font Editor



More information about the fondue-commits mailing list