SVN commit 1317187 by pino: SigModel: cache the signatures should be faster than updating the whole dom tree of each signature for each change (like every keypress (!)) M +5 -2 sigmodel.cpp M +2 -0 sigmodel.h --- trunk/extragear/pim/ksig/sigmodel.cpp #1317186:1317187 @@ -40,9 +40,9 @@ switch(role) { case Qt::DisplayRole: - return signatureString(m_signatures.at(index.row())).simplified(); + return m_cachedSignatures.at(index.row()).simplified(); case SignatureRole: - return signatureString(m_signatures.at(index.row())); + return m_cachedSignatures.at(index.row()); } return QVariant(); } @@ -130,6 +130,9 @@ } m_signatures = m_doc.elementsByTagName("signature"); + m_cachedSignatures.resize(m_signatures.count()); + for(int i = 0; i < m_signatures.count(); ++i) + m_cachedSignatures[i] = signatureString(m_signatures.at(i)); } // if the document could not be opened or setData failed, create the document framework else { --- trunk/extragear/pim/ksig/sigmodel.h #1317186:1317187 @@ -13,6 +13,7 @@ #include #include #include +#include class SigModel : public QAbstractItemModel { @@ -41,6 +42,7 @@ QDomDocument m_doc; QDomElement m_rootElement; QDomNodeList m_signatures; + QVector m_cachedSignatures; mutable QString m_emptySigString; };