• QSDiffRunner
  • QSDiffRunner Class

    Header: #include <QSDiffRunner>

    Public Functions

    QSDiffRunner()
    QSPatchSet compare(const QVariantList & from, const QVariantList & to)
    QString keyField() const
    bool patch(QSPatchable * patchable, const QSPatchSet & patches) const
    void setKeyField(const QString & keyField)

    Detailed Description

    QSDiffRunner compares two QVariantList to produce a patch for transforming one of the list to another list with minimum no. of steps. The result can be applied on a QSListModel via QSPatchable interface. QSDiffRunner use an average O(n) algorithm and therefore it should be fast enough for regular UI application.

    Member Function Documentation

    QSDiffRunner::QSDiffRunner()

    QSPatchSet QSDiffRunner::compare(const QVariantList & from, const QVariantList & to)

    Call this function to compare two list, then return a list of patches required to transform from a list to other with the minimum number of steps. It uses an algorithm with average O(n) runtime.

    You should set the key field before calling this function.

    See also setKeyField.

    QString QSDiffRunner::keyField() const

    See also setKeyField().

    bool QSDiffRunner::patch(QSPatchable * patchable, const QSPatchSet & patches) const

    Call this function to patch a list model that implemented the QSPatchable interface. You should use the result generated by QSDiffRunner::compare().

    void QSDiffRunner::setKeyField(const QString & keyField)

    Call this function to set the key field before using compare(). If it is not set, it won't be able to identify insert, remove and move changes.

    See also keyField().