[fondue-commits] [SCM] Fondue Font Editor branch, master, updated. 773c6b376fa8f2b9857af9c49bc3821e3bb0a949

Eugeniy Meshcheryakov eugen at debian.org
Mon Aug 27 11:24:00 UTC 2007


The branch, master has been updated
       via  773c6b376fa8f2b9857af9c49bc3821e3bb0a949 (commit)
      from  8d2fbec30263ec381373ef78d38b0fb8a9a85449 (commit)


- Shortlog ------------------------------------------------------------
773c6b3 handle layout{AboutToBe,}Changed signals from source

Summary of changes:
 gui/unicodeproxymodel.cxx |   49 +++++++++++++++++++++++++++++++++++++++++---
 gui/unicodeproxymodel.h   |    4 +++
 2 files changed, 49 insertions(+), 4 deletions(-)
-----------------------------------------------------------------------
Details of changes:

commit 773c6b376fa8f2b9857af9c49bc3821e3bb0a949
Author: Eugeniy Meshcheryakov <eugen at debian.org>
Date:   Mon Aug 27 13:23:48 2007 +0200

    handle layout{AboutToBe,}Changed signals from source
    emit missing layout{AboutToBe,}Changed in sourceDataChanged() handler, updating unicode value bacame slow again :/

diff --git a/gui/unicodeproxymodel.cxx b/gui/unicodeproxymodel.cxx
index 44b1738..fa758c2 100644
--- a/gui/unicodeproxymodel.cxx
+++ b/gui/unicodeproxymodel.cxx
@@ -34,16 +34,24 @@ QModelIndex UnicodeProxyModel::mapToSource(const QModelIndex &proxyIndex) const
 void UnicodeProxyModel::setSourceModel(QAbstractItemModel *sourceModel)
 {
 	if (this->sourceModel()) {
-		disconnect(this->sourceModel(), SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)),
-				this, SLOT(sourceDataChanged(const QModelIndex &, const QModelIndex &)));
+		disconnect(this->sourceModel(), SIGNAL(dataChanged(QModelIndex, QModelIndex)),
+				this, SLOT(sourceDataChanged(QModelIndex, QModelIndex)));
+		disconnect(this->sourceModel(), SIGNAL(layoutAboutToBeChanged()),
+				this, SLOT(sourceLayoutAboutToBeChanged()));
+		disconnect(this->sourceModel(), SIGNAL(layoutChanged()),
+				this, SLOT(sourceLayoutChanged));
 	}
 	QAbstractProxyModel::setSourceModel(sourceModel);
 
 	createMapping();
 
 	if (sourceModel) {
-		connect(sourceModel, SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)),
-				this, SLOT(sourceDataChanged(const QModelIndex &, const QModelIndex &)));
+		connect(sourceModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)),
+				this, SLOT(sourceDataChanged(QModelIndex, QModelIndex)));
+		connect(sourceModel, SIGNAL(layoutAboutToBeChanged()),
+				this, SLOT(sourceLayoutAboutToBeChanged()));
+		connect(sourceModel, SIGNAL(layoutChanged()),
+				this, SLOT(sourceLayoutChanged()));
 	}
 }
 
@@ -180,6 +188,7 @@ void UnicodeProxyModel::sourceDataChanged(const QModelIndex &topLeft, const QMod
 	if (reorder) {
 		QModelIndexList oldIndices = persistentIndexList();
 		if (!oldIndices.isEmpty()) {
+			emit layoutAboutToBeChanged();
 			QModelIndexList sourceIndices;
 			foreach (const QModelIndex &idx, oldIndices)
 				sourceIndices << mapToSource(idx);
@@ -188,6 +197,7 @@ void UnicodeProxyModel::sourceDataChanged(const QModelIndex &topLeft, const QMod
 			foreach (const QModelIndex &idx, sourceIndices)
 				newIndices << mapFromSource(idx);
 			changePersistentIndexList(oldIndices, newIndices);
+			emit layoutChanged();
 		}
 	}
 }
@@ -203,3 +213,34 @@ bool UnicodeProxyModel::setData(const QModelIndex &index, const QVariant &value,
 		return sourceModel()->setData(sourceIndex, value, role);
 	return false;
 }
+
+void UnicodeProxyModel::sourceLayoutAboutToBeChanged()
+{
+	savedIndices.clear();
+	QModelIndexList oldIndices = persistentIndexList();
+	if (oldIndices.isEmpty())
+		return;
+
+	emit layoutAboutToBeChanged();
+
+	foreach (const QModelIndex &idx, oldIndices)
+		savedIndices << mapToSource(idx);
+}
+
+void UnicodeProxyModel::sourceLayoutChanged()
+{
+	if (savedIndices.isEmpty())
+		return;
+
+	QModelIndexList oldIndices = persistentIndexList();
+	
+	createMapping();
+
+	QModelIndexList newIndices;
+	foreach (const QPersistentModelIndex &idx, savedIndices)
+		newIndices << mapFromSource(idx);
+
+	changePersistentIndexList(oldIndices, newIndices);
+
+	emit layoutChanged();
+}
diff --git a/gui/unicodeproxymodel.h b/gui/unicodeproxymodel.h
index bcec115..6e4999b 100644
--- a/gui/unicodeproxymodel.h
+++ b/gui/unicodeproxymodel.h
@@ -24,11 +24,15 @@ public:
 	Qt::ItemFlags flags(const QModelIndex &index) const;
 public slots:
 	void sourceDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
+	void sourceLayoutAboutToBeChanged();
+	void sourceLayoutChanged();
 private:
 	QHash<int, int> toSourceMap;
 	QHash<int, int> fromSourceMap;
 	int unencodedGlyphs;
 
+	QList<QPersistentModelIndex> savedIndices;
+
 	void createMapping();
 };
 

-- 
Fondue Font Editor



More information about the fondue-commits mailing list